[quagga-dev 4421] Re: multipath policy support for quagga

Piotr Chytla pch at packetconsulting.pl
Sun Oct 1 21:57:14 BST 2006


On Tue, Sep 19, 2006 at 12:13:30AM +0200, Piotr Chytla wrote:
[..]

Hi 

I'm sending again my multipath support patch , now is against cvs HEAD
    
     - Changelogs are updated, (lib/Changelog , zebra/Changelog , /Changelog)
     - some minor fixes in indention

In patch one file - zebra/multipath.h is missing becouse I don't have
write access to cvs repository to do cvs add . I've sent it separately.

Comments welcome :)

/pch

-- 
Dyslexia bug unpatched since 1977 ...
exploit has been leaked to the underground.
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /var/cvsroot/quagga/ChangeLog,v
retrieving revision 1.148
diff -u -p -w -b -r1.148 ChangeLog
--- ChangeLog	27 Aug 2006 22:06:12 -0000	1.148
+++ ChangeLog	1 Oct 2006 20:23:07 -0000
@@ -1,3 +1,10 @@
+2006-09-28 Piotr Chytła <pch at packetconsulting.pl>
+
+       * configure.ac  - Added check for RTA_MP_ALGO in
+       			rtnetlink.h , and linux/ip_mp_alg.h
+			(We need this for check if kernel have support for 
+			 multipath)
+
 2006-08-27 Paul Jakma <paul.jakma at sun.com>
 
 	* configure.ac: Bump to 0.99.5
Index: configure.ac
===================================================================
RCS file: /var/cvsroot/quagga/configure.ac,v
retrieving revision 1.123
diff -u -p -w -b -r1.123 configure.ac
--- configure.ac	27 Aug 2006 22:06:12 -0000	1.123
+++ configure.ac	1 Oct 2006 20:23:08 -0000
@@ -367,7 +367,7 @@ AC_CHECK_HEADERS([string.h stropts.h sys
 
 AC_CHECK_HEADERS([sys/socket.h netinet/in_systm.h netinet/in.h \
 		 net/if_dl.h net/netopt.h inet/nd.h net/route.h \
-		 net/if.h net/if_var.h netinet/in_var.h])
+		 net/if.h net/if_var.h netinet/in_var.h linux/ip_mp_alg.h])
 
 dnl V6 headers are checked below, after we check for v6
 
@@ -610,6 +610,17 @@ fi
 AC_SUBST(RT_METHOD)
 AC_SUBST(KERNEL_METHOD)
 AC_SUBST(OTHER_METHOD)
+
+dnl ----------
+dnl Check for RTA_MP_ALGO in /usr/include/linux/rtnetlink.h
+dnl ----------
+AC_MSG_CHECKING(for support of multipath alg. in netlink)
+  if grep RTA_MP_ALGO /usr/include/linux/rtnetlink.h >/dev/null 2>&1; then
+    AC_DEFINE(HAVE_RT_MP_ALGO,,RTA_MP exist in rtnetlink)
+    AC_MSG_RESULT(yes)
+   else 
+    AC_MSG_RESULT(no)
+  fi
 
 dnl ------------------------------------
 dnl check for broken CMSG_FIRSTHDR macro
Index: lib/ChangeLog
===================================================================
RCS file: /var/cvsroot/quagga/lib/ChangeLog,v
retrieving revision 1.273
diff -u -p -w -b -r1.273 ChangeLog
--- lib/ChangeLog	26 Sep 2006 15:30:43 -0000	1.273
+++ lib/ChangeLog	1 Oct 2006 20:23:25 -0000
@@ -1,3 +1,6 @@
+2006-09-28 Piotr Chytła <pch at packetconsulting.pl>
+	* command.h/zebra.h - Added MULTIPATH_NODE/STR .
+
 2006-09-26 Pierre-Yves Ritschard <pierre-yves at spootnik.org>
 
 	* smux.c: (smux_open,smux_trap,smux_register) Fix various
Index: lib/command.h
===================================================================
RCS file: /var/cvsroot/quagga/lib/command.h,v
retrieving revision 1.24
diff -u -p -w -b -r1.24 command.h
--- lib/command.h	27 Jun 2006 07:52:03 -0000	1.24
+++ lib/command.h	1 Oct 2006 20:23:26 -0000
@@ -99,6 +99,7 @@ enum node_type 
   SMUX_NODE,			/* SNMP configuration node. */
   DUMP_NODE,			/* Packet dump node. */
   FORWARDING_NODE,		/* IP forwarding node. */
+  MULTIPATH_NODE,		/* Multipath policy node */
   VTY_NODE			/* Vty node. */
 };
 
@@ -270,6 +271,7 @@ struct desc
 /* Common descriptions. */
 #define SHOW_STR "Show running system information\n"
 #define IP_STR "IP information\n"
+#define MULTIPATH_STR "Configure multipath policy\n"
 #define IPV6_STR "IPv6 information\n"
 #define NO_STR "Negate a command or set its defaults\n"
 #define REDIST_STR "Redistribute information from another routing protocol\n"
Index: lib/zebra.h
===================================================================
RCS file: /var/cvsroot/quagga/lib/zebra.h,v
retrieving revision 1.42
diff -u -p -w -b -r1.42 zebra.h
--- lib/zebra.h	28 May 2006 08:08:24 -0000	1.42
+++ lib/zebra.h	1 Oct 2006 20:23:28 -0000
@@ -167,6 +167,10 @@ typedef int socklen_t;
 #define RT_TABLE_MAIN		0
 #endif /* HAVE_NETLINK */
 
+#ifdef HAVE_LINUX_IP_MP_ALG_H
+#include <linux/ip_mp_alg.h>
+#endif /* HAVE_LINUX_IP_MP_ALG_H */
+
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif /* HAVE_NETDB_H */
Index: zebra/ChangeLog
===================================================================
RCS file: /var/cvsroot/quagga/zebra/ChangeLog,v
retrieving revision 1.143
diff -u -p -w -b -r1.143 ChangeLog
--- zebra/ChangeLog	13 Sep 2006 12:13:08 -0000	1.143
+++ zebra/ChangeLog	1 Oct 2006 20:23:36 -0000
@@ -1,3 +1,16 @@
+2006-09-28 Piotr Chytła <pch at packetconsulting.pl>
+
+	* rt_netlink.c - When multipath policy is specified in configure mode 
+	  zebra insertes all multipath routes with selected multipath policy
+	  algorithm (netlink RTA_MP_ALGO option)
+	  multipath.h - multipath policy names (struct mp_alg_names riped from
+	  iproute2-2.6.16-060323/ip/iproute.c)
+	  zserv.h - added mpath variable to struct zserv/zebra_t,
+	  zserv.c - added comands multipath rr/drr/random/wrandom to configure
+	  mode, show multipath to enable mode. All options are available only 
+	  on linux with kernel with proper support of multipath policy
+	  (>=2.6.12)
+	  
 2006-09-13 Tom Everett <tom at khubla.com>
 
 	* kernel_socket.c (rtm_type_str): ifdef RTM_OLD{ADD,DEL} to
Index: zebra/main.c
===================================================================
RCS file: /var/cvsroot/quagga/zebra/main.c,v
retrieving revision 1.24
diff -u -p -w -b -r1.24 main.c
--- zebra/main.c	19 Jan 2006 20:16:56 -0000	1.24
+++ zebra/main.c	1 Oct 2006 20:23:37 -0000
@@ -43,6 +43,7 @@
 struct zebra_t zebrad =
 {
   .rtm_table_default = 0,
+  .mpath = 0,
 };
 
 /* process id. */
Index: zebra/rt_netlink.c
===================================================================
RCS file: /var/cvsroot/quagga/zebra/rt_netlink.c,v
retrieving revision 1.43
diff -u -p -w -b -r1.43 rt_netlink.c
--- zebra/rt_netlink.c	2 Jul 2006 16:38:54 -0000	1.43
+++ zebra/rt_netlink.c	1 Oct 2006 20:23:41 -0000
@@ -36,6 +36,7 @@
 #include "thread.h"
 #include "privs.h"
 
+#include "multipath.h"
 #include "zebra/zserv.h"
 #include "zebra/rt.h"
 #include "zebra/redistribute.h"
@@ -1759,6 +1760,16 @@ netlink_route_multipath (int cmd, struct
             }
         }
 
+#ifdef HAVE_RT_MP_ALGO
+       if (zebrad.mpath != IP_MP_ALG_NONE)
+       {
+             if (IS_ZEBRA_DEBUG_KERNEL)
+                        zlog_debug("netlink_route_multipath() (multihop): "
+	                           "multipath policy : %s",mp_alg_names[zebrad.mpath]);
+
+            addattr_l (&req.n, 1024, RTA_MP_ALGO, &zebrad.mpath, sizeof(zebrad.mpath));
+       }
+#endif 
       if (rta->rta_len > RTA_LENGTH (0))
         addattr_l (&req.n, 1024, RTA_MULTIPATH, RTA_DATA (rta),
                    RTA_PAYLOAD (rta));
Index: zebra/zserv.c
===================================================================
RCS file: /var/cvsroot/quagga/zebra/zserv.c,v
retrieving revision 1.40
diff -u -p -w -b -r1.40 zserv.c
--- zebra/zserv.c	27 Jul 2006 16:11:02 -0000	1.40
+++ zebra/zserv.c	1 Oct 2006 20:23:45 -0000
@@ -36,6 +36,7 @@
 #include "privs.h"
 #include "network.h"
 #include "buffer.h"
+#include "multipath.h"
 
 #include "zebra/zserv.h"
 #include "zebra/router-id.h"
@@ -1120,6 +1121,9 @@ zebra_client_create (int sock)
   /* Set table number. */
   client->rtm_table = zebrad.rtm_table_default;
 
+  /* Set multipath policy */
+  client->mpath = zebrad.mpath;
+
   /* Add this client to linked list. */
   listnode_add (zebrad.client_list, client);
   
@@ -1697,6 +1701,91 @@ struct cmd_node forwarding_node =
 };
 
 
+#ifdef HAVE_RT_MP_ALGO
+DEFUN (multipath_rr,
+       multipath_rr_cmd,
+       "multipath rr",
+       MULTIPATH_STR
+       "Round Robin multipath policy")
+{
+	  zebrad.mpath=IP_MP_ALG_RR;
+	  return CMD_SUCCESS;
+}
+
+DEFUN (multipath_drr,
+       multipath_drr_cmd,
+       "multipath drr",
+       MULTIPATH_STR
+       "Device round robin multipath policy")
+{
+	  zebrad.mpath=IP_MP_ALG_DRR;
+	  return CMD_SUCCESS;
+}
+
+DEFUN (multipath_random,
+       multipath_random_cmd,
+       "multipath random",
+       MULTIPATH_STR
+       "Random multipath policy")
+{
+	  zebrad.mpath=IP_MP_ALG_RANDOM;
+	  return CMD_SUCCESS;
+}
+
+DEFUN (multipath_wrandom,
+       multipath_wrandom_cmd,
+       "multipath wrandom",
+	MULTIPATH_STR
+       "Weighted random multipath policy")
+{
+         zebrad.mpath=IP_MP_ALG_WRANDOM;
+         return CMD_SUCCESS;
+}
+
+DEFUN (no_multipath,
+	no_multipath_cmd,
+	"no multipath",
+	NO_STR
+	MULTIPATH_STR
+	"Remove multipath policy")
+{
+	zebrad.mpath=IP_MP_ALG_NONE;
+	return CMD_SUCCESS;
+}
+
+DEFUN (show_multipath,
+	show_multipath_cmd,
+	"show multipath",
+	SHOW_STR
+	"Show multipath policy")
+{
+        vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
+		             VTY_NEWLINE);
+	return CMD_SUCCESS;
+}
+
+/* multipath policy configuration write function. */
+static int
+config_write_multipath (struct vty *vty)
+{
+
+
+  if (zebrad.mpath)
+    vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
+	     VTY_NEWLINE);
+  return 0;
+}
+
+/* table node for multipath policy. */
+struct cmd_node multipath_node =
+{
+	  MULTIPATH_NODE,
+	  "",                           
+	  1
+};
+
+#endif /* HAVE_RT_MP_ALGO */
+
 /* Initialisation of zebra and installation of commands. */
 void
 zebra_init (void)
@@ -1715,6 +1804,10 @@ zebra_init (void)
   install_node (&table_node, config_write_table);
   install_node (&forwarding_node, config_write_forwarding);
 
+#ifdef HAVE_RT_MP_ALGO
+  install_node (&multipath_node, config_write_multipath);
+#endif
+
   install_element (VIEW_NODE, &show_ip_forwarding_cmd);
   install_element (ENABLE_NODE, &show_ip_forwarding_cmd);
   install_element (CONFIG_NODE, &ip_forwarding_cmd);
@@ -1725,6 +1818,14 @@ zebra_init (void)
   install_element (VIEW_NODE, &show_table_cmd);
   install_element (ENABLE_NODE, &show_table_cmd);
   install_element (CONFIG_NODE, &config_table_cmd);
+#ifdef HAVE_RT_MP_ALGO
+  install_element (CONFIG_NODE, &multipath_rr_cmd);
+  install_element (CONFIG_NODE, &multipath_drr_cmd);
+  install_element (CONFIG_NODE, &multipath_random_cmd);
+  install_element (CONFIG_NODE, &multipath_wrandom_cmd);
+  install_element (CONFIG_NODE, &no_multipath_cmd);
+  install_element (ENABLE_NODE, &show_multipath_cmd);
+#endif /* HAVE_RT_MP_ALGO */
 #endif /* HAVE_NETLINK */
 
 #ifdef HAVE_IPV6
Index: zebra/zserv.h
===================================================================
RCS file: /var/cvsroot/quagga/zebra/zserv.h,v
retrieving revision 1.14
diff -u -p -w -b -r1.14 zserv.h
--- zebra/zserv.h	24 Nov 2005 15:15:17 -0000	1.14
+++ zebra/zserv.h	1 Oct 2006 20:23:45 -0000
@@ -55,6 +55,9 @@ struct zserv
   /* default routing table this client munges */
   int rtm_table;
 
+  /* multipath policy */
+  u_int32_t mpath;
+
   /* This client's redistribute flag. */
   u_char redist[ZEBRA_ROUTE_MAX];
 
@@ -77,6 +80,9 @@ struct zebra_t
 
   /* default table */
   int rtm_table_default;
+
+  /* multipath policy */
+  u_int32_t mpath;
 
   /* rib work queue */
   struct work_queue *ribq;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multipath.h
Type: text/x-chdr
Size: 1226 bytes
Desc: not available
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20061001/1b47e8b0/attachment-0001.bin>


More information about the Quagga-dev mailing list