1 diff -urN quagga-0.99.11/configure.ac quagga-0.99.11.new/configure.ac
2 --- quagga-0.99.11/configure.ac 2008-10-02 10:31:09.000000000 +0200
3 +++ quagga-0.99.11.new/configure.ac 2008-11-22 20:58:12.000000000 +0100
5 AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \
6 sys/types.h linux/version.h netdb.h asm/types.h \
7 sys/param.h limits.h signal.h libutil.h \
8 - sys/socket.h netinet/in.h])
9 + sys/socket.h netinet/in.h linux/ip_mp_alg.h])
11 dnl Utility macro to avoid retyping includes all the time
12 m4_define([QUAGGA_INCLUDES],
14 AC_SUBST(KERNEL_METHOD)
15 AC_SUBST(OTHER_METHOD)
18 +dnl Check for RTA_MP_ALGO in linux/rtnetlink.h
20 +AC_MSG_CHECKING(for support of multipath alg. in netlink)
21 + if grep RTA_MP_ALGO linux/rtnetlink.h >/dev/null 2>&1; then
22 + AC_DEFINE(HAVE_RT_MP_ALGO,,RTA_MP exist in rtnetlink)
28 dnl --------------------------
29 dnl Determine IS-IS I/O method
30 dnl --------------------------
31 diff -urN quagga-0.99.11/lib/command.h quagga-0.99.11.new/lib/command.h
32 --- quagga-0.99.11/lib/command.h 2008-09-09 22:18:57.000000000 +0200
33 +++ quagga-0.99.11.new/lib/command.h 2008-11-22 20:48:07.000000000 +0100
35 DUMP_NODE, /* Packet dump node. */
36 FORWARDING_NODE, /* IP forwarding node. */
37 PROTOCOL_NODE, /* protocol filtering node */
38 + MULTIPATH_NODE, /* Multipath policy node */
39 VTY_NODE, /* Vty node. */
43 /* Common descriptions. */
44 #define SHOW_STR "Show running system information\n"
45 #define IP_STR "IP information\n"
46 +#define MULTIPATH_STR "Configure multipath policy\n"
47 #define IPV6_STR "IPv6 information\n"
48 #define NO_STR "Negate a command or set its defaults\n"
49 #define REDIST_STR "Redistribute information from another routing protocol\n"
50 diff -urN quagga-0.99.11/lib/zebra.h quagga-0.99.11.new/lib/zebra.h
51 --- quagga-0.99.11/lib/zebra.h 2008-09-24 17:22:51.000000000 +0200
52 +++ quagga-0.99.11.new/lib/zebra.h 2008-11-22 20:48:44.000000000 +0100
54 #define RT_TABLE_MAIN 0
55 #endif /* HAVE_NETLINK */
57 +#ifdef HAVE_LINUX_IP_MP_ALG_H
58 +#include <linux/ip_mp_alg.h>
59 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
63 #endif /* HAVE_NETDB_H */
64 diff -urN quagga-0.99.11/zebra/main.c quagga-0.99.11.new/zebra/main.c
65 --- quagga-0.99.11/zebra/main.c 2008-09-05 16:27:26.000000000 +0200
66 +++ quagga-0.99.11.new/zebra/main.c 2008-11-22 20:48:44.000000000 +0100
68 struct zebra_t zebrad =
70 .rtm_table_default = 0,
75 diff -urN quagga-0.99.11/zebra/multipath.h quagga-0.99.11.new/zebra/multipath.h
76 --- quagga-0.99.11/zebra/multipath.h 1970-01-01 01:00:00.000000000 +0100
77 +++ quagga-0.99.11.new/zebra/multipath.h 2008-11-22 20:48:44.000000000 +0100
80 + * multipath policy names.
82 + * This file is part of Quagga routing suite.
84 + * Quagga is free software; you can redistribute it and/or modify it
85 + * under the terms of the GNU General Public License as published by the
86 + * Free Software Foundation; either version 2, or (at your option) any
89 + * Quagga is distributed in the hope that it will be useful, but
90 + * WITHOUT ANY WARRANTY; without even the implied warranty of
91 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
92 + * General Public License for more details.
94 + * You should have received a copy of the GNU General Public License
95 + * along with GNU Zebra; see the file COPYING. If not, write to the Free
96 + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
100 +#ifndef ZEBRA_MULTIPATH_H
101 +#define ZEBRA_MULTIPATH_H
104 +#ifdef HAVE_LINUX_IP_MP_ALG_H
106 +static char *mp_alg_names[IP_MP_ALG_MAX+1] = {
107 + [IP_MP_ALG_NONE] = "none",
108 + [IP_MP_ALG_RR] = "rr",
109 + [IP_MP_ALG_DRR] = "drr",
110 + [IP_MP_ALG_RANDOM] = "random",
111 + [IP_MP_ALG_WRANDOM] = "wrandom"
116 diff -urN quagga-0.99.11/zebra/rt_netlink.c quagga-0.99.11.new/zebra/rt_netlink.c
117 --- quagga-0.99.11/zebra/rt_netlink.c 2008-09-05 16:27:26.000000000 +0200
118 +++ quagga-0.99.11.new/zebra/rt_netlink.c 2008-11-22 20:48:44.000000000 +0100
123 +#include "multipath.h"
124 #include "zebra/zserv.h"
125 #include "zebra/rt.h"
126 #include "zebra/redistribute.h"
127 @@ -1694,6 +1695,16 @@
129 addattr_l (&req.n, sizeof req, RTA_PREFSRC, &src->ipv4, bytelen);
131 +#ifdef HAVE_RT_MP_ALGO
132 + if (zebrad.mpath != IP_MP_ALG_NONE)
134 + if (IS_ZEBRA_DEBUG_KERNEL)
135 + zlog_debug("netlink_route_multipath() (multihop): "
136 + "multipath policy : %s",mp_alg_names[zebrad.mpath]);
138 + addattr_l (&req.n, 1024, RTA_MP_ALGO, &zebrad.mpath, sizeof(zebrad.mpath));
141 if (rta->rta_len > RTA_LENGTH (0))
142 addattr_l (&req.n, 1024, RTA_MULTIPATH, RTA_DATA (rta),
144 diff -urN quagga-0.99.11/zebra/zserv.c quagga-0.99.11.new/zebra/zserv.c
145 --- quagga-0.99.11/zebra/zserv.c 2008-09-24 17:22:51.000000000 +0200
146 +++ quagga-0.99.11.new/zebra/zserv.c 2008-11-22 20:48:44.000000000 +0100
151 +#include "multipath.h"
153 #include "zebra/zserv.h"
154 #include "zebra/router-id.h"
155 @@ -1120,6 +1121,9 @@
156 /* Set table number. */
157 client->rtm_table = zebrad.rtm_table_default;
159 + /* Set multipath policy */
160 + client->mpath = zebrad.mpath;
162 /* Add this client to linked list. */
163 listnode_add (zebrad.client_list, client);
165 @@ -1697,6 +1701,91 @@
169 +#ifdef HAVE_RT_MP_ALGO
170 +DEFUN (multipath_rr,
174 + "Round Robin multipath policy")
176 + zebrad.mpath=IP_MP_ALG_RR;
177 + return CMD_SUCCESS;
180 +DEFUN (multipath_drr,
184 + "Device round robin multipath policy")
186 + zebrad.mpath=IP_MP_ALG_DRR;
187 + return CMD_SUCCESS;
190 +DEFUN (multipath_random,
191 + multipath_random_cmd,
192 + "multipath random",
194 + "Random multipath policy")
196 + zebrad.mpath=IP_MP_ALG_RANDOM;
197 + return CMD_SUCCESS;
200 +DEFUN (multipath_wrandom,
201 + multipath_wrandom_cmd,
202 + "multipath wrandom",
204 + "Weighted random multipath policy")
206 + zebrad.mpath=IP_MP_ALG_WRANDOM;
207 + return CMD_SUCCESS;
210 +DEFUN (no_multipath,
215 + "Remove multipath policy")
217 + zebrad.mpath=IP_MP_ALG_NONE;
218 + return CMD_SUCCESS;
221 +DEFUN (show_multipath,
222 + show_multipath_cmd,
225 + "Show multipath policy")
227 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
229 + return CMD_SUCCESS;
232 +/* multipath policy configuration write function. */
234 +config_write_multipath (struct vty *vty)
239 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
244 +/* table node for multipath policy. */
245 +struct cmd_node multipath_node =
252 +#endif /* HAVE_RT_MP_ALGO */
254 /* Initialisation of zebra and installation of commands. */
257 @@ -1715,6 +1804,10 @@
258 install_node (&table_node, config_write_table);
259 install_node (&forwarding_node, config_write_forwarding);
261 +#ifdef HAVE_RT_MP_ALGO
262 + install_node (&multipath_node, config_write_multipath);
265 install_element (VIEW_NODE, &show_ip_forwarding_cmd);
266 install_element (ENABLE_NODE, &show_ip_forwarding_cmd);
267 install_element (CONFIG_NODE, &ip_forwarding_cmd);
268 @@ -1725,6 +1818,14 @@
269 install_element (VIEW_NODE, &show_table_cmd);
270 install_element (ENABLE_NODE, &show_table_cmd);
271 install_element (CONFIG_NODE, &config_table_cmd);
272 +#ifdef HAVE_RT_MP_ALGO
273 + install_element (CONFIG_NODE, &multipath_rr_cmd);
274 + install_element (CONFIG_NODE, &multipath_drr_cmd);
275 + install_element (CONFIG_NODE, &multipath_random_cmd);
276 + install_element (CONFIG_NODE, &multipath_wrandom_cmd);
277 + install_element (CONFIG_NODE, &no_multipath_cmd);
278 + install_element (ENABLE_NODE, &show_multipath_cmd);
279 +#endif /* HAVE_RT_MP_ALGO */
280 #endif /* HAVE_NETLINK */
283 diff -urN quagga-0.99.11/zebra/zserv.h quagga-0.99.11.new/zebra/zserv.h
284 --- quagga-0.99.11/zebra/zserv.h 2008-09-24 17:22:51.000000000 +0200
285 +++ quagga-0.99.11.new/zebra/zserv.h 2008-11-22 20:48:44.000000000 +0100
287 /* default routing table this client munges */
290 + /* multipath policy */
293 /* This client's redistribute flag. */
294 u_char redist[ZEBRA_ROUTE_MAX];
298 int rtm_table_default;
300 + /* multipath policy */
304 struct work_queue *ribq;
305 struct meta_queue *mq;