3 @@ -397,7 +397,7 @@ dnl -------------------------
4 AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \
5 sys/types.h linux/version.h netdb.h asm/types.h \
6 sys/param.h limits.h signal.h libutil.h \
7 - sys/socket.h netinet/in.h time.h sys/time.h])
8 + sys/socket.h netinet/in.h time.h sys/time.h linux/ip_mp_alg.h])
10 dnl Utility macro to avoid retyping includes all the time
11 m4_define([QUAGGA_INCLUDES],
12 @@ -779,6 +779,17 @@ AC_SUBST(RT_METHOD)
13 AC_SUBST(KERNEL_METHOD)
14 AC_SUBST(OTHER_METHOD)
17 +dnl Check for RTA_MP_ALGO in linux/rtnetlink.h
19 +AC_MSG_CHECKING(for support of multipath alg. in netlink)
20 + if grep RTA_MP_ALGO linux/rtnetlink.h >/dev/null 2>&1; then
21 + AC_DEFINE(HAVE_LINUX_IP_MP_ALG_H,,RTA_MP exist in rtnetlink)
27 dnl --------------------------
28 dnl Determine IS-IS I/O method
29 dnl --------------------------
32 @@ -101,6 +101,7 @@ enum node_type
33 DUMP_NODE, /* Packet dump node. */
34 FORWARDING_NODE, /* IP forwarding node. */
35 PROTOCOL_NODE, /* protocol filtering node */
36 + MULTIPATH_NODE, /* Multipath policy node */
37 VTY_NODE, /* Vty node. */
40 @@ -272,6 +273,7 @@ struct desc
41 /* Common descriptions. */
42 #define SHOW_STR "Show running system information\n"
43 #define IP_STR "IP information\n"
44 +#define MULTIPATH_STR "Configure multipath policy\n"
45 #define IPV6_STR "IPv6 information\n"
46 #define NO_STR "Negate a command or set its defaults\n"
47 #define REDIST_STR "Redistribute information from another routing protocol\n"
50 @@ -176,6 +176,10 @@ typedef int socklen_t;
51 #define RT_TABLE_MAIN 0
52 #endif /* HAVE_NETLINK */
54 +#ifdef HAVE_LINUX_IP_MP_ALG_H
55 +#include <linux/ip_mp_alg.h>
56 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
60 #endif /* HAVE_NETDB_H */
64 struct zebra_t zebrad =
66 .rtm_table_default = 0,
72 +++ b/zebra/multipath.h
75 + * multipath policy names.
77 + * This file is part of Quagga routing suite.
79 + * Quagga is free software; you can redistribute it and/or modify it
80 + * under the terms of the GNU General Public License as published by the
81 + * Free Software Foundation; either version 2, or (at your option) any
84 + * Quagga is distributed in the hope that it will be useful, but
85 + * WITHOUT ANY WARRANTY; without even the implied warranty of
86 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87 + * General Public License for more details.
89 + * You should have received a copy of the GNU General Public License
90 + * along with GNU Zebra; see the file COPYING. If not, write to the Free
91 + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
95 +#ifndef ZEBRA_MULTIPATH_H
96 +#define ZEBRA_MULTIPATH_H
99 +#ifdef HAVE_LINUX_IP_MP_ALG_H
101 +static char *mp_alg_names[IP_MP_ALG_MAX+1] = {
102 + [IP_MP_ALG_NONE] = "none",
103 + [IP_MP_ALG_RR] = "rr",
104 + [IP_MP_ALG_DRR] = "drr",
105 + [IP_MP_ALG_RANDOM] = "random",
106 + [IP_MP_ALG_WRANDOM] = "wrandom"
111 --- a/zebra/rt_netlink.c
112 +++ b/zebra/rt_netlink.c
117 +#include "multipath.h"
118 #include "zebra/zserv.h"
119 #include "zebra/rt.h"
120 #include "zebra/redistribute.h"
121 @@ -1694,6 +1695,16 @@ netlink_route_multipath (int cmd, struct
123 addattr_l (&req.n, sizeof req, RTA_PREFSRC, &src->ipv4, bytelen);
125 +#ifdef HAVE_LINUX_IP_MP_ALG_H
126 + if (zebrad.mpath != IP_MP_ALG_NONE)
128 + if (IS_ZEBRA_DEBUG_KERNEL)
129 + zlog_debug("netlink_route_multipath() (multihop): "
130 + "multipath policy : %s",mp_alg_names[zebrad.mpath]);
132 + addattr_l (&req.n, 1024, RTA_MP_ALGO, &zebrad.mpath, sizeof(zebrad.mpath));
135 if (rta->rta_len > RTA_LENGTH (0))
136 addattr_l (&req.n, 1024, RTA_MULTIPATH, RTA_DATA (rta),
144 +#include "multipath.h"
146 #include "zebra/zserv.h"
147 #include "zebra/router-id.h"
148 @@ -1120,6 +1121,9 @@ zebra_client_create (int sock)
149 /* Set table number. */
150 client->rtm_table = zebrad.rtm_table_default;
152 + /* Set multipath policy */
153 + client->mpath = zebrad.mpath;
155 /* Add this client to linked list. */
156 listnode_add (zebrad.client_list, client);
158 @@ -1697,6 +1701,91 @@ static struct cmd_node forwarding_node =
162 +#ifdef HAVE_LINUX_IP_MP_ALG_H
163 +DEFUN (multipath_rr,
167 + "Round Robin multipath policy")
169 + zebrad.mpath=IP_MP_ALG_RR;
170 + return CMD_SUCCESS;
173 +DEFUN (multipath_drr,
177 + "Device round robin multipath policy")
179 + zebrad.mpath=IP_MP_ALG_DRR;
180 + return CMD_SUCCESS;
183 +DEFUN (multipath_random,
184 + multipath_random_cmd,
185 + "multipath random",
187 + "Random multipath policy")
189 + zebrad.mpath=IP_MP_ALG_RANDOM;
190 + return CMD_SUCCESS;
193 +DEFUN (multipath_wrandom,
194 + multipath_wrandom_cmd,
195 + "multipath wrandom",
197 + "Weighted random multipath policy")
199 + zebrad.mpath=IP_MP_ALG_WRANDOM;
200 + return CMD_SUCCESS;
203 +DEFUN (no_multipath,
208 + "Remove multipath policy")
210 + zebrad.mpath=IP_MP_ALG_NONE;
211 + return CMD_SUCCESS;
214 +DEFUN (show_multipath,
215 + show_multipath_cmd,
218 + "Show multipath policy")
220 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
222 + return CMD_SUCCESS;
225 +/* multipath policy configuration write function. */
227 +config_write_multipath (struct vty *vty)
232 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
237 +/* table node for multipath policy. */
238 +struct cmd_node multipath_node =
245 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
247 /* Initialisation of zebra and installation of commands. */
250 @@ -1708,6 +1797,10 @@ zebra_init (void)
251 install_node (&table_node, config_write_table);
252 install_node (&forwarding_node, config_write_forwarding);
254 +#ifdef HAVE_LINUX_IP_MP_ALG_H
255 + install_node (&multipath_node, config_write_multipath);
258 install_element (VIEW_NODE, &show_ip_forwarding_cmd);
259 install_element (ENABLE_NODE, &show_ip_forwarding_cmd);
260 install_element (CONFIG_NODE, &ip_forwarding_cmd);
261 @@ -1718,6 +1811,14 @@ zebra_init (void)
262 install_element (VIEW_NODE, &show_table_cmd);
263 install_element (ENABLE_NODE, &show_table_cmd);
264 install_element (CONFIG_NODE, &config_table_cmd);
265 +#ifdef HAVE_LINUX_IP_MP_ALG_H
266 + install_element (CONFIG_NODE, &multipath_rr_cmd);
267 + install_element (CONFIG_NODE, &multipath_drr_cmd);
268 + install_element (CONFIG_NODE, &multipath_random_cmd);
269 + install_element (CONFIG_NODE, &multipath_wrandom_cmd);
270 + install_element (CONFIG_NODE, &no_multipath_cmd);
271 + install_element (ENABLE_NODE, &show_multipath_cmd);
272 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
273 #endif /* HAVE_NETLINK */
278 @@ -55,6 +55,9 @@ struct zserv
279 /* default routing table this client munges */
282 + /* multipath policy */
285 /* This client's redistribute flag. */
286 u_char redist[ZEBRA_ROUTE_MAX];
288 @@ -78,6 +81,9 @@ struct zebra_t
290 int rtm_table_default;
292 + /* multipath policy */
296 struct work_queue *ribq;
297 struct meta_queue *mq;