#include <sync/common.h>
#include <jnx/ssd_ipc.h>
#include <jnx/ssd_ipc_msg.h>
#include <limits.h>
#include "ped_ssd.h"
Go to the source code of this file.
Data Structures | |
struct | ssd_request_t |
Defines | |
#define | RT_TBL_NAME "inet.0" |
routing table we wish to add routes to | |
#define | REQUESTS_BUFFER_SIZE 64 |
#define | UNCONFIRMED_CONTEXT REQUESTS_BUFFER_SIZE |
#define | MAX_UNCONFIRMED_CONTEXT UINT_MAX |
#define | RETRY_CONNECT 60 |
Functions | |
static int | ssd_client_connection (int fd) |
static void | ssd_client_connection_close (int fd, int cause) |
static void | ssd_client_msg (int fd, struct ssd_ipc_msg *cmsg) |
static void | connect_ssd (evContext ctx __unused, void *uap __unused, struct timespec due __unused, struct timespec inter __unused) |
static int | ssd_client_ifa_handler (kcom_ifa_t *msg, void *user_info) |
void | ped_ssd_init (void) |
void | ped_ssd_shutdown (void) |
boolean | get_ssd_ready (void) |
boolean | get_ssd_idle (void) |
boolean | ssd_client_add_route_request (policy_route_msg_t *route, ssd_reply_notification_handler func, void *user_data) |
boolean | ssd_client_del_route_request (policy_route_msg_t *route, ssd_reply_notification_handler func, void *user_data) |
void | clean_routes (void) |
Variables | |
static boolean | ssd_ready = FALSE |
The state of connection. | |
static int | ssd_server_fd = -1 |
socket to SSD | |
static int | client_id = 0 |
client id with SSD | |
static uint32_t | rt_tbl_id = 0 |
routing instance to which we add routes | |
static evTimerID | timer_id |
timer ID for retrying connection to SSD | |
static struct ssd_ipc_ft | ssd_client_ft |
the function table for SSD callbacks | |
evContext | ped_ctx |
Event context for ped. | |
static ssd_request_t | ssd_requests [REQUESTS_BUFFER_SIZE] |
buffer of requests | |
static uint32_t | next_buffer = 0 |
index of next buffer to use up for a request | |
static uint32_t | next_unconfirmed = UNCONFIRMED_CONTEXT |
number of requests outstanding in buffer | |
static int | outstanding_requests = 0 |
number of requests outstanding in buffer |
Functions for connecting to SSD and adding or deleting route.
Definition in file ped_ssd.c.
#define MAX_UNCONFIRMED_CONTEXT UINT_MAX |
Max value for next_unconfirmed where upon we reset it to UNCONFIRMED_CONTEXT
Definition at line 57 of file ped_ssd.c.
Referenced by clean_routes(), and ssd_client_del_route_request().
#define REQUESTS_BUFFER_SIZE 64 |
Number of requests we accept without responses back from SSD
Definition at line 46 of file ped_ssd.c.
Referenced by ped_ssd_init(), ssd_client_add_route_request(), ssd_client_del_route_request(), and ssd_client_msg().
#define RETRY_CONNECT 60 |
#define UNCONFIRMED_CONTEXT REQUESTS_BUFFER_SIZE |
The client context to give to libssd when a request is to be unconfirmed (which only applies to deletes herein)
Definition at line 52 of file ped_ssd.c.
Referenced by ped_ssd_init(), and ssd_client_del_route_request().
void clean_routes | ( | void | ) |
Clean up all routes created and shutdown this module
Definition at line 790 of file ped_ssd.c.
References MAX_UNCONFIRMED_CONTEXT, ssd_ready, and ssd_server_fd.
static void connect_ssd | ( | evContext ctx | __unused, | |
void *uap | __unused, | |||
struct timespec due | __unused, | |||
struct timespec inter | __unused | |||
) | [static] |
Setup the connection to SSD. This also sets the function table of callbacks to use between ped and libssd. We periodically call this until the connection setup is successful.
[in] | ctx | The event context for this application |
[in] | uap | The user data for this callback |
[in] | due | The absolute time when the event is due (now) |
[in] | inter | The period; when this will next be called |
Definition at line 128 of file ped_ssd.c.
References ped_ctx, ssd_client_ft, ssd_server_fd, and timer_id.
Referenced by ped_ssd_init(), service_route_init(), and ssd_client_connection_close().
boolean get_ssd_idle | ( | void | ) |
Are there any outstanding requests to SSD for which we soon expect replies
Definition at line 568 of file ped_ssd.c.
References outstanding_requests.
Referenced by policy_table_clean(), and psd_ipc_read().
boolean get_ssd_ready | ( | void | ) |
Check the state of SSD connection.
Definition at line 554 of file ped_ssd.c.
References ssd_ready.
Referenced by policy_table_clean(), and psd_ipc_read().
void ped_ssd_init | ( | void | ) |
Initialize client
Definition at line 502 of file ped_ssd.c.
References client_id, connect_ssd(), next_buffer, next_unconfirmed, outstanding_requests, ped_ctx, REQUESTS_BUFFER_SIZE, RETRY_CONNECT, rt_tbl_id, ssd_requests, ssd_server_fd, timer_id, UNCONFIRMED_CONTEXT, and ssd_request_t::user_data.
Referenced by ped_init().
void ped_ssd_shutdown | ( | void | ) |
boolean ssd_client_add_route_request | ( | policy_route_msg_t * | route, | |
ssd_reply_notification_handler | func, | |||
void * | user_data | |||
) |
Send message to SSD to add a route.
[in] | route | Pointer to route data. |
[in] | func | function to callback when result is available |
[in] | user_data | user data to echo in callback |
Definition at line 591 of file ped_ssd.c.
References policy_route_msg_s::af, policy_route_msg_s::ifname, next_buffer, outstanding_requests, ssd_request_t::reply_handler, REQUESTS_BUFFER_SIZE, ssd_client_ifa_handler(), ssd_ready, ssd_requests, and ssd_request_t::user_data.
Referenced by add_route().
static int ssd_client_connection | ( | int | fd | ) | [static] |
static void ssd_client_connection_close | ( | int fd | __unused, | |
int cause | __unused | |||
) | [static] |
The callback function to handle the connection close from SSD
[in] | fd | SSD server socket |
[in] | cause | The cause of the connection close |
Definition at line 191 of file ped_ssd.c.
References connect_ssd(), ped_ctx, RETRY_CONNECT, ssd_ready, ssd_server_fd, and timer_id.
boolean ssd_client_del_route_request | ( | policy_route_msg_t * | route, | |
ssd_reply_notification_handler | func, | |||
void * | user_data | |||
) |
Send message to SSD to delete a route. This should be done with confirmation (func should handle the result). However, if our SSD confirmation-of-request buffers run out, then we return FALSE. In case of this, the caller can try calling the function again with func and user_data both NULL, but beware that no confirmation of the result will be provided, and the function will return TRUE unless libssd fails to accept it.
[in] | route | Pointer to route data. |
[in] | func | function to callback when result is available. NULL if trying to delete without confirmation (caller will never know result if SSD accepts the reqest) |
[in] | user_data | user data to echo in callback |
Definition at line 700 of file ped_ssd.c.
References MAX_UNCONFIRMED_CONTEXT, next_buffer, next_unconfirmed, outstanding_requests, ssd_request_t::reply_handler, REQUESTS_BUFFER_SIZE, policy_route_msg_s::route_addr, policy_route_msg_s::route_addr_prefix, rt_tbl_id, ssd_ready, ssd_requests, ssd_server_fd, UNCONFIRMED_CONTEXT, and ssd_request_t::user_data.
Referenced by remove_route(), and ssd_request_status().
static int ssd_client_ifa_handler | ( | kcom_ifa_t * | msg, | |
void * | user_info | |||
) | [static] |
A callback/handler passed into junos_kcom_ifa_get_all from ssd_client_add_route_request
[in] | msg | message with ifa info |
[in] | user_info | user data passed to junos_kcom_ifa_get_all |
Definition at line 411 of file ped_ssd.c.
References policy_route_msg_s::metrics, next_buffer, policy_route_msg_s::nh_addr, policy_route_msg_s::nh_type, policy_route_msg_s::preferences, policy_route_msg_s::route_addr, policy_route_msg_s::route_addr_prefix, rt_tbl_id, and ssd_server_fd.
Referenced by ssd_client_add_route_request().
static void ssd_client_msg | ( | int | fd, | |
struct ssd_ipc_msg * | cmsg | |||
) | [static] |
The callback function to handle getting messages from SSD
[in] | fd | SSD server fd. |
[in] | cmsg | The pointer to the message from SSD. |
Definition at line 230 of file ped_ssd.c.
References ADD_FAILED, ADD_SUCCESS, client_id, DELETE_FAILED, DELETE_SUCCESS, outstanding_requests, ssd_request_t::reply_handler, REQUESTS_BUFFER_SIZE, rt_tbl_id, RT_TBL_NAME, ssd_ready, ssd_requests, and ssd_request_t::user_data.
struct ssd_ipc_ft ssd_client_ft [static] |
Initial value:
the function table for SSD callbacks