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],
14 @@ -101,6 +101,7 @@ enum node_type
15 DUMP_NODE, /* Packet dump node. */
16 FORWARDING_NODE, /* IP forwarding node. */
17 PROTOCOL_NODE, /* protocol filtering node */
18 + MULTIPATH_NODE, /* Multipath policy node */
19 VTY_NODE, /* Vty node. */
22 @@ -272,6 +273,7 @@ struct desc
23 /* Common descriptions. */
24 #define SHOW_STR "Show running system information\n"
25 #define IP_STR "IP information\n"
26 +#define MULTIPATH_STR "Configure multipath policy\n"
27 #define IPV6_STR "IPv6 information\n"
28 #define NO_STR "Negate a command or set its defaults\n"
29 #define REDIST_STR "Redistribute information from another routing protocol\n"
32 @@ -176,6 +176,10 @@ typedef int socklen_t;
33 #define RT_TABLE_MAIN 0
34 #endif /* HAVE_NETLINK */
36 +#ifdef HAVE_LINUX_IP_MP_ALG_H
37 +#include <linux/ip_mp_alg.h>
38 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
42 #endif /* HAVE_NETDB_H */
46 struct zebra_t zebrad =
48 .rtm_table_default = 0,
54 +++ b/zebra/multipath.h
57 + * multipath policy names.
59 + * This file is part of Quagga routing suite.
61 + * Quagga is free software; you can redistribute it and/or modify it
62 + * under the terms of the GNU General Public License as published by the
63 + * Free Software Foundation; either version 2, or (at your option) any
66 + * Quagga is distributed in the hope that it will be useful, but
67 + * WITHOUT ANY WARRANTY; without even the implied warranty of
68 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
69 + * General Public License for more details.
71 + * You should have received a copy of the GNU General Public License
72 + * along with GNU Zebra; see the file COPYING. If not, write to the Free
73 + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
77 +#ifndef ZEBRA_MULTIPATH_H
78 +#define ZEBRA_MULTIPATH_H
81 +#ifdef HAVE_LINUX_IP_MP_ALG_H
83 +static char *mp_alg_names[IP_MP_ALG_MAX+1] = {
84 + [IP_MP_ALG_NONE] = "none",
85 + [IP_MP_ALG_RR] = "rr",
86 + [IP_MP_ALG_DRR] = "drr",
87 + [IP_MP_ALG_RANDOM] = "random",
88 + [IP_MP_ALG_WRANDOM] = "wrandom"
93 --- a/zebra/rt_netlink.c
94 +++ b/zebra/rt_netlink.c
99 +#include "multipath.h"
100 #include "zebra/zserv.h"
101 #include "zebra/rt.h"
102 #include "zebra/redistribute.h"
103 @@ -1694,6 +1695,16 @@ netlink_route_multipath (int cmd, struct
105 addattr_l (&req.n, sizeof req, RTA_PREFSRC, &src->ipv4, bytelen);
107 +#ifdef HAVE_LINUX_IP_MP_ALG_H
108 + if (zebrad.mpath != IP_MP_ALG_NONE)
110 + if (IS_ZEBRA_DEBUG_KERNEL)
111 + zlog_debug("netlink_route_multipath() (multihop): "
112 + "multipath policy : %s",mp_alg_names[zebrad.mpath]);
114 + addattr_l (&req.n, 1024, RTA_MP_ALGO, &zebrad.mpath, sizeof(zebrad.mpath));
117 if (rta->rta_len > RTA_LENGTH (0))
118 addattr_l (&req.n, 1024, RTA_MULTIPATH, RTA_DATA (rta),
126 +#include "multipath.h"
128 #include "zebra/zserv.h"
129 #include "zebra/router-id.h"
130 @@ -1120,6 +1121,9 @@ zebra_client_create (int sock)
131 /* Set table number. */
132 client->rtm_table = zebrad.rtm_table_default;
134 + /* Set multipath policy */
135 + client->mpath = zebrad.mpath;
137 /* Add this client to linked list. */
138 listnode_add (zebrad.client_list, client);
140 @@ -1697,6 +1701,91 @@ static struct cmd_node forwarding_node =
144 +#ifdef HAVE_LINUX_IP_MP_ALG_H
145 +DEFUN (multipath_rr,
149 + "Round Robin multipath policy")
151 + zebrad.mpath=IP_MP_ALG_RR;
152 + return CMD_SUCCESS;
155 +DEFUN (multipath_drr,
159 + "Device round robin multipath policy")
161 + zebrad.mpath=IP_MP_ALG_DRR;
162 + return CMD_SUCCESS;
165 +DEFUN (multipath_random,
166 + multipath_random_cmd,
167 + "multipath random",
169 + "Random multipath policy")
171 + zebrad.mpath=IP_MP_ALG_RANDOM;
172 + return CMD_SUCCESS;
175 +DEFUN (multipath_wrandom,
176 + multipath_wrandom_cmd,
177 + "multipath wrandom",
179 + "Weighted random multipath policy")
181 + zebrad.mpath=IP_MP_ALG_WRANDOM;
182 + return CMD_SUCCESS;
185 +DEFUN (no_multipath,
190 + "Remove multipath policy")
192 + zebrad.mpath=IP_MP_ALG_NONE;
193 + return CMD_SUCCESS;
196 +DEFUN (show_multipath,
197 + show_multipath_cmd,
200 + "Show multipath policy")
202 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
204 + return CMD_SUCCESS;
207 +/* multipath policy configuration write function. */
209 +config_write_multipath (struct vty *vty)
214 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
219 +/* table node for multipath policy. */
220 +struct cmd_node multipath_node =
227 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
229 /* Initialisation of zebra and installation of commands. */
232 @@ -1708,6 +1797,10 @@ zebra_init (void)
233 install_node (&table_node, config_write_table);
234 install_node (&forwarding_node, config_write_forwarding);
236 +#ifdef HAVE_LINUX_IP_MP_ALG_H
237 + install_node (&multipath_node, config_write_multipath);
240 install_element (VIEW_NODE, &show_ip_forwarding_cmd);
241 install_element (ENABLE_NODE, &show_ip_forwarding_cmd);
242 install_element (CONFIG_NODE, &ip_forwarding_cmd);
243 @@ -1718,6 +1811,14 @@ zebra_init (void)
244 install_element (VIEW_NODE, &show_table_cmd);
245 install_element (ENABLE_NODE, &show_table_cmd);
246 install_element (CONFIG_NODE, &config_table_cmd);
247 +#ifdef HAVE_LINUX_IP_MP_ALG_H
248 + install_element (CONFIG_NODE, &multipath_rr_cmd);
249 + install_element (CONFIG_NODE, &multipath_drr_cmd);
250 + install_element (CONFIG_NODE, &multipath_random_cmd);
251 + install_element (CONFIG_NODE, &multipath_wrandom_cmd);
252 + install_element (CONFIG_NODE, &no_multipath_cmd);
253 + install_element (ENABLE_NODE, &show_multipath_cmd);
254 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
255 #endif /* HAVE_NETLINK */
260 @@ -55,6 +55,9 @@ struct zserv
261 /* default routing table this client munges */
264 + /* multipath policy */
267 /* This client's redistribute flag. */
268 u_char redist[ZEBRA_ROUTE_MAX];
270 @@ -78,6 +81,9 @@ struct zebra_t
272 int rtm_table_default;
274 + /* multipath policy */
278 struct work_queue *ribq;
279 struct meta_queue *mq;