]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Enable fpm module to connect to remote fpm server
authorUdaya Shankara KS <shankara.k.s.u@gmail.com>
Thu, 11 Feb 2016 16:12:29 +0000 (21:42 +0530)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 23 Sep 2016 16:12:16 +0000 (12:12 -0400)
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.

Further documentation supplied:
-------------------------------

               ZEBRA : CLI CONFIGURATION FOR FPM MODULE
         ========================================================

1. INTRODUCTION
================================
   1.1 scope

     This memo discusses the configuration option for zebra to update
     FIB information to local and remote modules.
     This will also helps to address the issue associated with CORD project.
     https://jira.onosproject.org/browse/CORD-411

2. REFERENCE
================================
  Quagga version 99.24+ ( main branch committed on 29-sep-2015)

3. PROBLEM DESCRIPTION
================================

    Once FPM is enabled, Quagga periodically tries to initiate fpm
connection to localhost:2620.  These values are non configurable in
existing implementation.  There is no CLI available to configure
"host:port".  hence limits us to use it for hardware based fast path
modules only.

4. PROPOSED CHANGES
================================
Following changes are done to the quagga code
   a) Added new CLI to configure "host address : port".
      The CLI format
      <conf t>
           $ fpm connection ip <ipv4 address> port <tcp port num>

      and no fpm command to revert back to default
      <conf t>
           $ no fpm connection ip <ipv4 address> port <tcp port num>

   b) Allowed values are ipv4 address and tcp port range <1-65535>

   c) FPM initialization code has been enhanced to pick the "host
      address : port" values from zebra.conf.  if not found then
      default values as localhost:2620 will be used.  and updated the
      information on to config file on write config command

5. FILES MODIFIED
================================
  1) fpm/fpm.h :
     a) Added MACRO to represent network order loopback ip

  2) zebra/zebra_fpm.h :

     a) introduced fpm_server variable in zfpm_glob_t handler to hold
        the remote fpm server address

     b) Hooked 'fpm_remote_ip_cmd' and 'no_fpm_remote_ip_cmd' at CONFIG
        node to configure remote fpm detail and to revert back to
        default respectively

  3) zebra/zserv.c :
     a) Hooked 'config_write_fpm' callback function, at ZEBRA_NODE to
        display the fpm connection details on console on entering
        command

         $ show running_config
        and to write to configuration file on entering command
         $ write config

6. TESTING DETAILS
================================

   6.1. default behavior

          In default configuration FPM will attempt to connect to
          localhost:2620

   6.2. update fpm info
        a) Using CLI command user can configure fpm host:port details
           and can be able to write to config file(zebra.conf) using
           write config command.  this parameters has no
           dependency/impact on other parameters of config file

        b) show running-config/write config will display the fpm
           information if configured.  and will not display any
           information related to fpm for default configuration

        c) these configured information will be stored to config file.
           only on write config command.

   6.3 loading from config file
        a) zebra attempts to connect to fpm server if fpm parameter
           found in config file.else connects to default parameters.

        b) if fpm connection drops, fpm will periodically attempts to
           connect to remote server.

        c) if fpm connections already established. then newly
           configured fpm parameters will not disconnect the existing
           connection.  new connection to the different fpm server will
           happen only after existing connection closes by either of
           the end.

fix fpm prototype

fpm/fpm.h
zebra/zebra_fpm.c
zebra/zebra_fpm.h
zebra/zserv.c

index 96f05f486573ff905f1afa9a2c1dbe2632691938..9a1dbf2b0db257cd2486dc8085fe2667e9da7e69 100644 (file)
--- a/fpm/fpm.h
+++ b/fpm/fpm.h
  * 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 */
index 220fddaf67983c99b33e1496e92cb07a0870f3a9..34f0068514239c82da3115ae157df070f6cc4cbf 100644 (file)
@@ -156,6 +156,7 @@ typedef struct zfpm_glob_t_
 
   zfpm_state_t state;
 
+  in_addr_t   fpm_server;
   /*
    * Port on which the FPM is running.
    */
@@ -1129,7 +1130,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.
@@ -1520,6 +1524,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
  *
@@ -1563,11 +1637,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;
 
index 44dec028681c2bd3c9a0f8758fbd4191b64940c3..7fa71e40bca464ba79be95e36bf3672b6c81068d 100644 (file)
@@ -30,5 +30,6 @@
  */
 extern int zfpm_init (struct thread_master *master, int enable, uint16_t port);
 extern void zfpm_trigger_update (struct route_node *rn, const char *reason);
+extern int fpm_remote_srv_write (struct vty *vty);
 
 #endif /* _ZEBRA_FPM_H */
index 4cfeead887720594caa53d13e22fce53ff7c8813..27d10a171865b1bff4d044368a0f214460151063 100644 (file)
@@ -2576,6 +2576,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
@@ -2587,6 +2605,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);