]> git.puffer.fish Git - matthieu/frr.git/commitdiff
mpls: add null driver
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 12 Sep 2016 12:02:39 +0000 (09:02 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 23 Sep 2016 13:31:13 +0000 (09:31 -0400)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
configure.ac
zebra/Makefile.am
zebra/kernel_null.c
zebra/rt_netlink.c
zebra/rt_netlink.h
zebra/zebra_mpls_netlink.c [new file with mode: 0644]
zebra/zebra_mpls_null.c

index eb1f1de6c1852f10442c3b860ff77ea1fa999496..e15f384c218bbcc6fc7385b886da31b5bd777f4b 100755 (executable)
@@ -309,6 +309,8 @@ AC_ARG_ENABLE(systemd,
   AS_HELP_STRING([--enable-systemd], [enable Systemd support]))
 AC_ARG_ENABLE(poll,
   AS_HELP_STRING([--enable-poll], [enable usage of Poll instead of select]))
+AC_ARG_ENABLE(mpls,
+  AS_HELP_STRING([--enable-mpls], [enable MPLS support - requires compatible kernel]))
 AC_ARG_ENABLE(werror,
   AS_HELP_STRING([--enable-werror], [enable -Werror (recommended for developers only)]))
 AC_ARG_ENABLE(cumulus,
@@ -360,6 +362,29 @@ if test "${enable_poll}" = "yes" ; then
   AC_DEFINE(HAVE_POLL,,Compile systemd support in)
 fi
 
+dnl ----------
+dnl MPLS check
+dnl ----------
+MPLS_METHOD=""
+AC_MSG_CHECKING(whether this OS has MPLS stack)
+if test "x${enable_mpls}" = "xyes"; then
+  case "$host" in
+    *-linux*)
+        AC_DEFINE(HAVE_MPLS,,Enable MPLS)
+        MPLS_METHOD="zebra_mpls_netlink.o"
+        AC_MSG_RESULT(Linux MPLS)
+    ;;
+    *)
+        AC_MSG_RESULT(Unsupported kernel)
+        MPLS_METHOD="zebra_mpls_null.o"
+    ;;
+  esac
+else
+  AC_MSG_RESULT(disabled)
+  MPLS_METHOD="zebra_mpls_null.o"
+fi
+AC_SUBST(MPLS_METHOD)
+
 if test "${enable_cumulus}" = "yes" ; then
   AC_DEFINE(HAVE_CUMULUS,,Compile Special Cumulus Code in)
 fi
index 10f7850c96028768b944e2ec1f2efefdf5791719..b08c37f55e52b667263f81edb9a07ea54aa328e6 100644 (file)
@@ -12,9 +12,10 @@ rt_method = @RT_METHOD@
 rtread_method = @RTREAD_METHOD@
 kernel_method = @KERNEL_METHOD@
 ioctl_method = @IOCTL_METHOD@
+mpls_method = @MPLS_METHOD@
 
 otherobj = $(ioctl_method) $(ipforward) $(if_method) \
-       $(rt_method) $(rtread_method) $(kernel_method)
+       $(rt_method) $(rtread_method) $(kernel_method) $(mpls_method)
 
 if HAVE_NETLINK
 othersrc = zebra_fpm_netlink.c
@@ -38,7 +39,7 @@ testzebra_SOURCES = test_main.c zebra_rib.c interface.c connected.c debug.c \
        zebra_vty.c zebra_ptm.c zebra_routemap.c zebra_ns.c zebra_vrf.c \
        kernel_null.c  redistribute_null.c ioctl_null.c misc_null.c zebra_rnh_null.c \
        zebra_ptm_null.c rtadv_null.c if_null.c zserv_null.c zebra_static.c \
-       zebra_memory.c zebra_mpls_null.c
+       zebra_memory.c zebra_mpls.c zebra_mpls_null.c
 
 noinst_HEADERS = \
        zebra_memory.h \
index 0802570e60f271667915bbcfd45b7b892c609ead..17b3c7bc8d421a1e25767f8648b897f48bc5ca7d 100644 (file)
@@ -30,7 +30,6 @@
 #include "zebra/connected.h"
 #include "zebra/rt_netlink.h"
 #include "zebra/rib.h"
-#include "zebra/zebra_mpls.h"
 
 int kernel_add_ipv4 (struct prefix *a, struct rib *b) { return 0; }
 int kernel_update_ipv4 (struct prefix *a, struct rib *b) { return 0; }
@@ -66,9 +65,3 @@ int kernel_neigh_update (int a, int b, uint32_t c, char *d, int e)
 void kernel_init (struct zebra_ns *zns) { return; }
 void kernel_terminate (struct zebra_ns *zns) { return; }
 void route_read (struct zebra_ns *zns) { return; }
-
-int kernel_add_lsp (zebra_lsp_t *l) { return 0; }
-
-int kernel_del_lsp (zebra_lsp_t *l) { return 0; }
-
-int kernel_upd_lsp (zebra_lsp_t *l) { return 0; }
index 07d2923028ae9f9f38339656cd157f4b6ad3cbd8..95c8892979d14367e34792ea1f68bb7a02d518fb 100644 (file)
@@ -2805,7 +2805,7 @@ kernel_neigh_update (int add, int ifindex, uint32_t addr, char *lla, int llalen)
 /*
  * MPLS label forwarding table change via netlink interface.
  */
-static int
+int
 netlink_mpls_multipath (int cmd, zebra_lsp_t *lsp)
 {
   mpls_lse_t lse;
@@ -2977,7 +2977,7 @@ netlink_mpls_multipath (int cmd, zebra_lsp_t *lsp)
 /*
  * Handle failure in LSP install, clear flags for NHLFE.
  */
-static inline void
+void
 clear_nhlfe_installed (zebra_lsp_t *lsp)
 {
   zebra_nhlfe_t *nhlfe;
@@ -2994,80 +2994,6 @@ clear_nhlfe_installed (zebra_lsp_t *lsp)
     }
 }
 
-/*
- * Install Label Forwarding entry into the kernel.
- */
-int
-kernel_add_lsp (zebra_lsp_t *lsp)
-{
-  int ret;
-
-  if (!lsp || !lsp->best_nhlfe) // unexpected
-    return -1;
-
-  UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED);
-  ret = netlink_mpls_multipath (RTM_NEWROUTE, lsp);
-  if (!ret)
-    SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
-  else
-    clear_nhlfe_installed (lsp);
-
-  return ret;
-}
-
-/*
- * Update Label Forwarding entry in the kernel. This means that the Label
- * forwarding entry is already installed and needs an update - either a new
- * path is to be added, an installed path has changed (e.g., outgoing label)
- * or an installed path (but not all paths) has to be removed.
- * TODO: Performs a DEL followed by ADD now, need to change to REPLACE. Note
- * that REPLACE was originally implemented for IPv4 nexthops but removed as
- * it was not functioning when moving from swap to PHP as that was signaled
- * through the metric field (before kernel-MPLS). This shouldn't be an issue
- * any longer, so REPLACE can be reintroduced.
- */
-int
-kernel_upd_lsp (zebra_lsp_t *lsp)
-{
-  int ret;
-
-  if (!lsp || !lsp->best_nhlfe) // unexpected
-    return -1;
-
-  UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED);
-
-  /* First issue a DEL and clear the installed flag. */
-  netlink_mpls_multipath (RTM_DELROUTE, lsp);
-  UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
-
-  /* Then issue an ADD. */
-  ret = netlink_mpls_multipath (RTM_NEWROUTE, lsp);
-  if (!ret)
-    SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
-  else
-    clear_nhlfe_installed (lsp);
-
-  return ret;
-}
-
-/*
- * Delete Label Forwarding entry from the kernel.
- */
-int
-kernel_del_lsp (zebra_lsp_t *lsp)
-{
-  if (!lsp) // unexpected
-    return -1;
-
-  if (CHECK_FLAG (lsp->flags, LSP_FLAG_INSTALLED))
-    {
-      netlink_mpls_multipath (RTM_DELROUTE, lsp);
-      UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
-    }
-
-  return 0;
-}
-
 extern struct thread_master *master;
 
 /* Kernel route reflection. */
index 80d035e839df4001839b67f079e365c8b238e19a..7d8b2e704021164f976f2fd80b7b9308f0c3a8dd 100644 (file)
@@ -24,6 +24,8 @@
 
 #ifdef HAVE_NETLINK
 
+#include "zebra/zebra_mpls.h"
+
 #define NL_PKT_BUF_SIZE         8192
 #define NL_DEFAULT_ROUTE_METRIC 20
 
@@ -41,6 +43,11 @@ nl_msg_type_to_str (uint16_t msg_type);
 extern const char *
 nl_rtproto_to_str (u_char rtproto);
 
+extern void
+clear_nhlfe_installed (zebra_lsp_t *lsp);
+extern int
+netlink_mpls_multipath (int cmd, zebra_lsp_t *lsp);
+
 extern int interface_lookup_netlink (struct zebra_ns *zns);
 extern int netlink_route_read (struct zebra_ns *zns);
 
diff --git a/zebra/zebra_mpls_netlink.c b/zebra/zebra_mpls_netlink.c
new file mode 100644 (file)
index 0000000..f5678ed
--- /dev/null
@@ -0,0 +1,78 @@
+#include <zebra.h>
+#include "zebra/rt.h"
+#include "zebra/rt_netlink.h"
+#include "zebra/zebra_mpls.h"
+
+/*
+ * Install Label Forwarding entry into the kernel.
+ */
+int
+kernel_add_lsp (zebra_lsp_t *lsp)
+{
+  int ret;
+
+  if (!lsp || !lsp->best_nhlfe) // unexpected
+    return -1;
+
+  UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED);
+  ret = netlink_mpls_multipath (RTM_NEWROUTE, lsp);
+  if (!ret)
+    SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
+  else
+    clear_nhlfe_installed (lsp);
+
+  return ret;
+}
+
+/*
+ * Update Label Forwarding entry in the kernel. This means that the Label
+ * forwarding entry is already installed and needs an update - either a new
+ * path is to be added, an installed path has changed (e.g., outgoing label)
+ * or an installed path (but not all paths) has to be removed.
+ * TODO: Performs a DEL followed by ADD now, need to change to REPLACE. Note
+ * that REPLACE was originally implemented for IPv4 nexthops but removed as
+ * it was not functioning when moving from swap to PHP as that was signaled
+ * through the metric field (before kernel-MPLS). This shouldn't be an issue
+ * any longer, so REPLACE can be reintroduced.
+ */
+int
+kernel_upd_lsp (zebra_lsp_t *lsp)
+{
+  int ret;
+
+  if (!lsp || !lsp->best_nhlfe) // unexpected
+    return -1;
+
+  UNSET_FLAG (lsp->flags, LSP_FLAG_CHANGED);
+
+  /* First issue a DEL and clear the installed flag. */
+  netlink_mpls_multipath (RTM_DELROUTE, lsp);
+  UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
+
+  /* Then issue an ADD. */
+  ret = netlink_mpls_multipath (RTM_NEWROUTE, lsp);
+  if (!ret)
+    SET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
+  else
+    clear_nhlfe_installed (lsp);
+
+  return ret;
+}
+
+/*
+ * Delete Label Forwarding entry from the kernel.
+ */
+int
+kernel_del_lsp (zebra_lsp_t *lsp)
+{
+  if (!lsp) // unexpected
+    return -1;
+
+  if (CHECK_FLAG (lsp->flags, LSP_FLAG_INSTALLED))
+    {
+      netlink_mpls_multipath (RTM_DELROUTE, lsp);
+      UNSET_FLAG (lsp->flags, LSP_FLAG_INSTALLED);
+    }
+
+  return 0;
+}
index 2953138dbc3e82bda4a21a43693619280506a639..9022fe30d27b3071504116da5d026315c9d80897 100644 (file)
@@ -1,81 +1,7 @@
 #include <zebra.h>
-#include "nexthop.h"
-#include "zebra/rib.h"
-#include "zebra/zserv.h"
+#include "zebra/rt.h"
 #include "zebra/zebra_mpls.h"
 
-int
-mpls_str2label (const char *label_str, u_int8_t *num_labels,
-                mpls_label_t *labels)
-{
-  return 0;
-}
-
-char *
-mpls_label2str (u_int8_t num_labels, mpls_label_t *labels,
-                char *buf, int len)
-{
-  return NULL;
-}
-
-int
-zebra_mpls_lsp_label_consistent (struct zebra_vrf *zvrf, mpls_label_t in_label,
-                     mpls_label_t out_label, enum nexthop_types_t gtype,
-                     union g_addr *gate, char *ifname, ifindex_t ifindex)
-{
-  return 1;
-}
-
-int
-zebra_mpls_static_lsp_add (struct zebra_vrf *zvrf, mpls_label_t in_label,
-                     mpls_label_t out_label, enum nexthop_types_t gtype,
-                     union g_addr *gate, char *ifname, ifindex_t ifindex)
-{
-  return 0;
-}
-
-int
-zebra_mpls_static_lsp_del (struct zebra_vrf *zvrf, mpls_label_t in_label,
-                           enum nexthop_types_t gtype, union g_addr *gate,
-                           char *ifname, ifindex_t ifindex)
-{
-  return 0;
-}
-
-void
-zebra_mpls_lsp_schedule (struct zebra_vrf *zvrf)
-{
-}
-
-void
-zebra_mpls_print_lsp (struct vty *vty, struct zebra_vrf *zvrf, mpls_label_t label,
-                      u_char use_json)
-{
-}
-
-void
-zebra_mpls_print_lsp_table (struct vty *vty, struct zebra_vrf *zvrf,
-                            u_char use_json)
-{
-}
-
-int
-zebra_mpls_write_lsp_config (struct vty *vty, struct zebra_vrf *zvrf)
-{
-  return 0;
-}
-
-void
-zebra_mpls_close_tables (struct zebra_vrf *zvrf)
-{
-}
-
-void
-zebra_mpls_init_tables (struct zebra_vrf *zvrf)
-{
-}
-
-void
-zebra_mpls_init (void)
-{
-}
+int kernel_add_lsp (zebra_lsp_t *lsp) { return 0; }
+int kernel_upd_lsp (zebra_lsp_t *lsp) { return 0; }
+int kernel_del_lsp (zebra_lsp_t *lsp) { return 0; }