Hi, I have created a patch for fpm module,which provides CLI in zebra for configuring remote fpm server ip and port of remote fpm server.This helps us to update the FIB updates to remote fpm module. please review and let me know your comments.
Thanks and Regards Udaya, ---------- Forwarded message ---------- From: Udaya Shankara KS <shankara.k....@gmail.com> Date: Tue, Jan 19, 2016 at 5:23 PM Subject: [PATCH] zebra: Enable fpm module to connect to remote fpm server To: quagga-dev@lists.quagga.net Hi, On enabling fpm module (--enable-fpm) in quagga. It aims to provide cross platform mechanism to support scenarios where the router has a forwarding path that is distinct from the kernel, commonly a hardware-based fast path (fpm). In Current scenario hardware based fast path is always in local machine. Hence fpm will always tries to connect to* localhost *on* port 2620 *on enabling fpm module (--enable-fpm) and this is non-configurable. This component will be very useful if this support is extended to connect to remote fpm component. *We have a SDN (Software Defined Networking) Scenario, Where forwarding intelligence will be programmed by the central SDN controller*. In that case quagga can be able to *connect to remote SDN controller *to update the FIB information to SDN's fpm module. I have attached the patch for proposed change and testing details for the same. It provides the CLI in zebra for configuring the remote fpm ip and port for FIB update and fpm can even make connection to remote host. Please review and let me know your comments. Thanks & Regards, Udaya,
CORD-JIRA-411-FPM-IP-Port-Enhancement.doc
Description: MS-Word document
From 1fe1fa3f92a07d2527ebf9ce3fee94e90f1e70ed Mon Sep 17 00:00:00 2001 From: Udaya Shankara KS <shankara.k....@gmail.com> Date: Tue, 19 Jan 2016 17:10:09 +0530 Subject: [PATCH] zebra: Enable fpm module to connect to remote fpm server FPM aims to provide cross platform mechanism to support the scenario where the router has forwarding path distinct fromt the kernel.Commonly Hardware based fast path.Hence it is non-configurable paramter.This limits us to use funcationality to update FIB information to remote hosts, like SDN controller. This implementation provides the CLI to configure remote hosts and port information of remote fpm controller.Otherwise default fpm server will be localhost and default fpm port will be well know port 2620. * zebra_fpm.c: added fpm_server paramter to zfpm_global_t handler. Implemented CLI for configuring the fpm server and no fpm command to revert back to default configuration. * zserv.c: Install zebra node to write fpm configuration info on console/config file. --- fpm/fpm.h | 14 +++++++++ zebra/zebra_fpm.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++- zebra/zserv.c | 21 ++++++++++++++ 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/fpm/fpm.h b/fpm/fpm.h index 96f05f486573ff905f1afa9a2c1dbe2632691938..9a1dbf2b0db257cd2486dc8085fe2667e9da7e69 100644 --- a/fpm/fpm.h +++ b/fpm/fpm.h @@ -87,6 +87,14 @@ * table(s) when it reconnects. */ +/* + * Local host as a default server for fpm connection + */ +#define FPM_DEFAULT_IP (htonl (INADDR_LOOPBACK)) + +/* + * default port for fpm connections + */ #define FPM_DEFAULT_PORT 2620 /* @@ -270,4 +278,10 @@ fpm_msg_ok (const fpm_msg_hdr_t *hdr, size_t len) return 1; } +// tcp maximum range +#define TCP_MAX_PORT 65535 + +// tcp minimum range +#define TCP_MIN_PORT 1 + #endif /* _FPM_H */ diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 292dbb6389d76cbb6ecdf90140768c2e602bc5f2..7cafd1848c43e8292657d24f6553dbc55d31b536 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -153,6 +153,7 @@ typedef struct zfpm_glob_t_ zfpm_state_t state; + in_addr_t fpm_server; /* * Port on which the FPM is running. */ @@ -1126,7 +1127,10 @@ zfpm_connect_cb (struct thread *t) #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN serv.sin_len = sizeof (struct sockaddr_in); #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ - serv.sin_addr.s_addr = htonl (INADDR_LOOPBACK); + if (!zfpm_g->fpm_server) + serv.sin_addr.s_addr = htonl (INADDR_LOOPBACK); + else + serv.sin_addr.s_addr = (zfpm_g->fpm_server); /* * Connect to the FPM. @@ -1517,6 +1521,76 @@ DEFUN (clear_zebra_fpm_stats, return CMD_SUCCESS; } +/* + * update fpm connection information + */ +DEFUN ( fpm_remote_ip, + fpm_remote_ip_cmd, + "fpm connection ip A.B.C.D port <1-65535>", + "fpm connection remote ip and port\n" + "Remote fpm server ip A.B.C.D\n" + "Enter ip ") +{ + + in_addr_t fpm_server; + uint32_t port_no; + + fpm_server = inet_addr (argv[0]); + if (fpm_server == INADDR_NONE) + return CMD_ERR_INCOMPLETE; + + port_no = atoi (argv[1]); + if (port_no < TCP_MIN_PORT || port_no > TCP_MAX_PORT) + return CMD_ERR_INCOMPLETE; + + zfpm_g->fpm_server = fpm_server; + zfpm_g->fpm_port = port_no; + + + return CMD_SUCCESS; +} + +DEFUN ( no_fpm_remote_ip, + no_fpm_remote_ip_cmd, + "no fpm connection ip A.B.C.D port <1-65535>", + "fpm connection remote ip and port\n" + "Connection\n" + "Remote fpm server ip A.B.C.D\n" + "Enter ip ") +{ + if (zfpm_g->fpm_server != inet_addr (argv[0]) || + zfpm_g->fpm_port != atoi (argv[1])) + return CMD_ERR_NO_MATCH; + + zfpm_g->fpm_server = FPM_DEFAULT_IP; + zfpm_g->fpm_port = FPM_DEFAULT_PORT; + + return CMD_SUCCESS; +} + + +/** + * fpm_remote_srv_write + * + * Module to write remote fpm connection + * + * Returns ZERO on success. + */ + +int fpm_remote_srv_write (struct vty *vty ) +{ + struct in_addr in; + + in.s_addr = zfpm_g->fpm_server; + + if (zfpm_g->fpm_server != FPM_DEFAULT_IP || + zfpm_g->fpm_port != FPM_DEFAULT_PORT) + vty_out (vty,"fpm connection ip %s port %d%s", inet_ntoa (in),zfpm_g->fpm_port,VTY_NEWLINE); + + return 0; +} + + /** * zfpm_init * @@ -1560,11 +1634,16 @@ zfpm_init (struct thread_master *master, int enable, uint16_t port) install_element (ENABLE_NODE, &show_zebra_fpm_stats_cmd); install_element (ENABLE_NODE, &clear_zebra_fpm_stats_cmd); + install_element (CONFIG_NODE, &fpm_remote_ip_cmd); + install_element (CONFIG_NODE, &no_fpm_remote_ip_cmd); if (!enable) { return 1; } + if (!zfpm_g->fpm_server) + zfpm_g->fpm_server = FPM_DEFAULT_IP; + if (!port) port = FPM_DEFAULT_PORT; diff --git a/zebra/zserv.c b/zebra/zserv.c index 7a75ed420a825201d46b27e15f9a2967570452b8..346c83e16f2735f6b60b9cb5937f05ab6d536670 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -1926,6 +1926,24 @@ static struct cmd_node forwarding_node = 1 }; +#ifdef HAVE_FPM +/* function to write the fpm config info */ +static int +config_write_fpm (struct vty *vty) +{ + return + fpm_remote_srv_write (vty); +} + +/* Zebra node */ +static struct cmd_node zebra_node = +{ + ZEBRA_NODE, + "", + 1 +}; +#endif + /* Initialisation of zebra and installation of commands. */ void @@ -1937,6 +1955,9 @@ zebra_init (void) /* Install configuration write function. */ install_node (&table_node, config_write_table); install_node (&forwarding_node, config_write_forwarding); +#ifdef HAVE_FPM + install_node (&zebra_node, config_write_fpm); +#endif install_element (VIEW_NODE, &show_ip_forwarding_cmd); install_element (ENABLE_NODE, &show_ip_forwarding_cmd); -- 1.7.9.5
_______________________________________________ Quagga-dev mailing list Quagga-dev@lists.quagga.net https://lists.quagga.net/mailman/listinfo/quagga-dev