#include <sync/common.h>
#include <jnx/ssd_ipc.h>
#include <jnx/ssd_ipc_msg.h>
#include "ped_service_route.h"
Go to the source code of this file.
Data Structures | |
struct | route_info_s |
struct | request_info_s |
Defines | |
#define | RT_TBL_NAME "inet.0" |
#define | PFD_RT_TBL_NAME "pfd_forwarding.inet.0" |
#define | RETRY_CONNECT 60 |
#define | DEFAULT_ROUTE_ADDRESS 0 |
Default route address. | |
#define | DEFAULT_ROUTE_MASK 0 |
Default route mask. | |
#define | FULL_ROUTE_MASK 32 |
Full route mask. | |
#define | SERVICE_ROUTE_PREF 10 |
Default route preference for service routes. | |
#define | INT_NAME_STR_SIZE 64 |
string size for interface names | |
Typedefs | |
typedef route_info_s | route_info_t |
typedef request_info_s | request_info_t |
Functions | |
static int | serv_rt_client_connection (int fd) |
static void | serv_rt_client_connection_close (int fd, int cause) |
static void | serv_rt_client_msg (int fd, struct ssd_ipc_msg *cmsg) |
static | TAILQ_HEAD (route_list_s, route_info_s) |
static | TAILQ_HEAD (request_buffer_s, request_info_s) |
static route_info_t * | get_route_by_ctx (uint32_t client_context) |
static status_t | get_ifl_index (char *interface_name, ifl_idx_t *ifl_index) |
static void | add_service_route_helper (route_info_t *route_info) |
static void | process_requests (void) |
void | service_route_init (evContext ctx) |
void | service_route_shutdown (void) |
void | pfd_ri_created (void) |
boolean | get_serviceroute_ready (void) |
void | add_pfd_service_route (char *interface_name) |
void | delete_pfd_service_route (char *interface_name) |
void | add_service_route (char *interface_name, in_addr_t address) |
void | delete_service_route (char *interface_name, in_addr_t address) |
void | clean_service_routes (void) |
Variables | |
static boolean | ssd_ready = FALSE |
The state of connection. | |
static int | ssd_server_fd |
socket to SSD | |
static int | client_id |
client id with SSD | |
static int | client_nexthop_id |
a counter to provide unique next-hop IDs | |
static uint32_t | client_ctx |
context echoed from SSD in callbacks | |
static uint32_t | rt_tbl_id |
routing instance to which we add routes | |
static uint32_t | pfd_rt_tbl_id |
PFD RI 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 |
Functions for connecting to SSD stricly for adding and deleting service routes and next hops.
Definition in file ped_service_route.c.
#define PFD_RT_TBL_NAME "pfd_forwarding.inet.0" |
The routing table we wish to add routes to in the pfd_forwarding RI
Definition at line 49 of file ped_service_route.c.
Referenced by pfd_ri_created(), and serv_rt_client_msg().
#define RETRY_CONNECT 60 |
Retry connecting to SSD every RETRY_CONNECT seconds until connection is made
Definition at line 54 of file ped_service_route.c.
Referenced by ped_ssd_init(), service_route_init(), and ssd_client_connection_close().
#define RT_TBL_NAME "inet.0" |
The routing table we wish to add routes to in the default routing instance
Definition at line 44 of file ped_service_route.c.
Referenced by serv_rt_client_msg(), and ssd_client_msg().
typedef struct request_info_s request_info_t |
Information we store when we must buffer request until ssd_ready=TRUE
typedef struct route_info_s route_info_t |
Information we store for each route
void add_pfd_service_route | ( | char * | interface_name | ) |
Adds a default service route in the pfd_forwarding routing instance
[in] | interface_name | The name of the interface in the pfd_forwarding routing instance that the PFD uses |
Definition at line 768 of file ped_service_route.c.
References route_info_s::address, route_info_s::client_ctx, client_nexthop_id, route_info_s::client_nh_id, DEFAULT_ROUTE_ADDRESS, DEFAULT_ROUTE_MASK, get_ifl_index(), route_info_s::ifl_index, INT_NAME_STR_SIZE, request_info_s::interface_name, route_info_s::mask, pfd_rt_tbl_id, request_info_s::req_action, route_info_s::rt_table_id, ssd_ready, and ssd_server_fd.
Referenced by ped_config_read(), and process_requests().
void add_service_route | ( | char * | interface_name, | |
in_addr_t | address | |||
) |
Adds a service route to the default routing instance given the address assuming a /32 mask
[in] | interface_name | The name of the interface (next-hop) in the route used by the PFD when NAT'ing to CPD |
[in] | address | The IP address used to create the service route with the /32 mask |
Definition at line 906 of file ped_service_route.c.
References request_info_s::address, route_info_s::address, route_info_s::client_ctx, client_nexthop_id, route_info_s::client_nh_id, FULL_ROUTE_MASK, get_ifl_index(), route_info_s::ifl_index, INT_NAME_STR_SIZE, request_info_s::interface_name, route_info_s::mask, request_info_s::req_action, route_info_s::rt_table_id, rt_tbl_id, ssd_ready, and ssd_server_fd.
Referenced by ped_config_read(), and process_requests().
static void add_service_route_helper | ( | route_info_t * | route_info | ) | [static] |
Add a service route given that the next-hop is already added
[in] | route_info | Information about the route and next-hop |
Definition at line 270 of file ped_service_route.c.
References route_info_s::address, route_info_s::client_ctx, route_info_s::ifl_index, route_info_s::mask, route_info_s::nh_index, route_info_s::rt_table_id, SERVICE_ROUTE_PREF, and ssd_server_fd.
Referenced by serv_rt_client_msg().
void clean_service_routes | ( | void | ) |
Clean up all service routes created
Definition at line 1048 of file ped_service_route.c.
References route_info_s::client_ctx, ssd_ready, and ssd_server_fd.
Referenced by ped_config_read().
void delete_pfd_service_route | ( | char * | interface_name | ) |
Deletes a default service route in the pfd_forwarding routing instance
[in] | interface_name | The name of the interface in the pfd_forwarding routing instance that the PFD uses |
Definition at line 833 of file ped_service_route.c.
References route_info_s::address, route_info_s::client_ctx, get_ifl_index(), route_info_s::ifl_index, INT_NAME_STR_SIZE, request_info_s::interface_name, route_info_s::mask, request_info_s::req_action, route_info_s::rt_table_id, ssd_ready, and ssd_server_fd.
Referenced by ped_config_read(), and process_requests().
void delete_service_route | ( | char * | interface_name, | |
in_addr_t | address | |||
) |
Deletes a service route to the default routing instance given the address assuming a /32 mask
[in] | interface_name | The name of the interface (next-hop) in the route |
[in] | address | The IP address used in the service route with the /32 mask |
Definition at line 975 of file ped_service_route.c.
References request_info_s::address, route_info_s::address, route_info_s::client_ctx, get_ifl_index(), route_info_s::ifl_index, INT_NAME_STR_SIZE, request_info_s::interface_name, route_info_s::mask, request_info_s::req_action, route_info_s::rt_table_id, ssd_ready, and ssd_server_fd.
Referenced by ped_config_read(), and process_requests().
static status_t get_ifl_index | ( | char * | interface_name, | |
ifl_idx_t * | ifl_index | |||
) | [static] |
Get the IFL index of an interface
[in] | interface_name | The IFL formatted interface name for which the IFL index is desired |
[out] | ifl_index | The IFL index structure that where the IFL index will be stored |
Definition at line 228 of file ped_service_route.c.
Referenced by add_pfd_service_route(), add_service_route(), delete_pfd_service_route(), and delete_service_route().
static route_info_t* get_route_by_ctx | ( | uint32_t | client_context | ) | [static] |
Get the route under manager by client context id
[in] | client_context | context used in lookup |
Definition at line 200 of file ped_service_route.c.
References route_info_s::client_ctx.
Referenced by serv_rt_client_msg().
boolean get_serviceroute_ready | ( | void | ) |
Check the state
Definition at line 754 of file ped_service_route.c.
References ssd_ready.
Referenced by ped_config_read().
void pfd_ri_created | ( | void | ) |
If the module is not ready it is liely because the PFD route table doesn't exist and we haven't been able to get its table ID. If another module knows that the RI has been created, then we try getting it again.
Definition at line 723 of file ped_service_route.c.
References client_id, PFD_RT_TBL_NAME, ssd_ready, and ssd_server_fd.
Referenced by ped_config_read().
static void process_requests | ( | void | ) | [static] |
Process all requests that have been buffered now that ssd_ready = TRUE
Definition at line 308 of file ped_service_route.c.
References add_pfd_service_route(), add_service_route(), request_info_s::address, delete_pfd_service_route(), delete_service_route(), request_info_s::interface_name, and request_info_s::req_action.
Referenced by serv_rt_client_msg().
static int serv_rt_client_connection | ( | int | fd | ) | [static] |
The callback function called after first connecting to SSD. We also ask SSD for a client ID.
Definition at line 338 of file ped_service_route.c.
static void serv_rt_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 367 of file ped_service_route.c.
References ssd_ready, and ssd_server_fd.
static void serv_rt_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 390 of file ped_service_route.c.
References add_service_route_helper(), route_info_s::client_ctx, client_id, route_info_s::client_nh_id, get_route_by_ctx(), route_info_s::nh_index, pfd_rt_tbl_id, PFD_RT_TBL_NAME, process_requests(), rt_tbl_id, RT_TBL_NAME, ssd_ready, and ssd_server_fd.
void service_route_init | ( | evContext | ctx | ) |
Initialize client
[in] | ctx | The event context for this application |
Definition at line 679 of file ped_service_route.c.
References route_info_s::client_ctx, client_id, client_nexthop_id, connect_ssd(), pfd_rt_tbl_id, RETRY_CONNECT, rt_tbl_id, ssd_server_fd, and timer_id.
Referenced by ped_init().
void service_route_shutdown | ( | void | ) |
static TAILQ_HEAD | ( | request_buffer_s | , | |
request_info_s | ||||
) | [static] |
List of request to buffer in case they're made before ssd_ready=TRUE
Definition at line 133 of file ped_service_route.c.
References route_info_s::rt_table_id, ssd_client_ft, ssd_server_fd, and timer_id.
static TAILQ_HEAD | ( | route_list_s | , | |
route_info_s | ||||
) | [static] |
List of route_info of service route under management
< Add a PFD service route
< Add a normal service route
< Delete a PFD service route
< Delete a normal service route
Definition at line 108 of file ped_service_route.c.
struct ssd_ipc_ft ssd_client_ft [static] |
Initial value:
the function table for SSD callbacks
Definition at line 85 of file ped_service_route.c.
Referenced by connect_ssd(), and TAILQ_HEAD().