[packages] quagga-unstable: Update to v0.99.14 and refresh patches
[openwrt/svn-archive/archive.git] / net / quagga-unstable / patches / 100-quagga_multipath_caching_policy.patch
1 --- a/configure.ac
2 +++ b/configure.ac
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])
9
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)
15
16 +dnl ----------
17 +dnl Check for RTA_MP_ALGO in linux/rtnetlink.h
18 +dnl ----------
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_RT_MP_ALGO,,RTA_MP exist in rtnetlink)
22 + AC_MSG_RESULT(yes)
23 + else
24 + AC_MSG_RESULT(no)
25 + fi
26 +
27 dnl --------------------------
28 dnl Determine IS-IS I/O method
29 dnl --------------------------
30 --- a/lib/command.h
31 +++ b/lib/command.h
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. */
38 };
39
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"
48 --- a/lib/zebra.h
49 +++ b/lib/zebra.h
50 @@ -176,6 +176,10 @@ typedef int socklen_t;
51 #define RT_TABLE_MAIN 0
52 #endif /* HAVE_NETLINK */
53
54 +#ifdef HAVE_LINUX_IP_MP_ALG_H
55 +#include <linux/ip_mp_alg.h>
56 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
57 +
58 #ifdef HAVE_NETDB_H
59 #include <netdb.h>
60 #endif /* HAVE_NETDB_H */
61 --- a/zebra/main.c
62 +++ b/zebra/main.c
63 @@ -44,6 +44,7 @@
64 struct zebra_t zebrad =
65 {
66 .rtm_table_default = 0,
67 + .mpath = 0,
68 };
69
70 /* process id. */
71 --- /dev/null
72 +++ b/zebra/multipath.h
73 @@ -0,0 +1,37 @@
74 +/*
75 + * multipath policy names.
76 + *
77 + * This file is part of Quagga routing suite.
78 + *
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
82 + * later version.
83 + *
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.
88 + *
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
92 + * 02111-1307, USA.
93 + */
94 +
95 +#ifndef ZEBRA_MULTIPATH_H
96 +#define ZEBRA_MULTIPATH_H
97 +#include <zebra.h>
98 +
99 +#ifdef HAVE_LINUX_IP_MP_ALG_H
100 +
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"
107 + };
108 +#endif
109 +#endif
110 +
111 --- a/zebra/rt_netlink.c
112 +++ b/zebra/rt_netlink.c
113 @@ -36,6 +36,7 @@
114 #include "thread.h"
115 #include "privs.h"
116
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
122 if (src)
123 addattr_l (&req.n, sizeof req, RTA_PREFSRC, &src->ipv4, bytelen);
124
125 +#ifdef HAVE_RT_MP_ALGO
126 + if (zebrad.mpath != IP_MP_ALG_NONE)
127 + {
128 + if (IS_ZEBRA_DEBUG_KERNEL)
129 + zlog_debug("netlink_route_multipath() (multihop): "
130 + "multipath policy : %s",mp_alg_names[zebrad.mpath]);
131 +
132 + addattr_l (&req.n, 1024, RTA_MP_ALGO, &zebrad.mpath, sizeof(zebrad.mpath));
133 + }
134 +#endif
135 if (rta->rta_len > RTA_LENGTH (0))
136 addattr_l (&req.n, 1024, RTA_MULTIPATH, RTA_DATA (rta),
137 RTA_PAYLOAD (rta));
138 --- a/zebra/zserv.c
139 +++ b/zebra/zserv.c
140 @@ -36,6 +36,7 @@
141 #include "privs.h"
142 #include "network.h"
143 #include "buffer.h"
144 +#include "multipath.h"
145
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;
151
152 + /* Set multipath policy */
153 + client->mpath = zebrad.mpath;
154 +
155 /* Add this client to linked list. */
156 listnode_add (zebrad.client_list, client);
157
158 @@ -1697,6 +1701,91 @@ static struct cmd_node forwarding_node =
159 };
160
161 \f
162 +#ifdef HAVE_RT_MP_ALGO
163 +DEFUN (multipath_rr,
164 + multipath_rr_cmd,
165 + "multipath rr",
166 + MULTIPATH_STR
167 + "Round Robin multipath policy")
168 +{
169 + zebrad.mpath=IP_MP_ALG_RR;
170 + return CMD_SUCCESS;
171 +}
172 +
173 +DEFUN (multipath_drr,
174 + multipath_drr_cmd,
175 + "multipath drr",
176 + MULTIPATH_STR
177 + "Device round robin multipath policy")
178 +{
179 + zebrad.mpath=IP_MP_ALG_DRR;
180 + return CMD_SUCCESS;
181 +}
182 +
183 +DEFUN (multipath_random,
184 + multipath_random_cmd,
185 + "multipath random",
186 + MULTIPATH_STR
187 + "Random multipath policy")
188 +{
189 + zebrad.mpath=IP_MP_ALG_RANDOM;
190 + return CMD_SUCCESS;
191 +}
192 +
193 +DEFUN (multipath_wrandom,
194 + multipath_wrandom_cmd,
195 + "multipath wrandom",
196 + MULTIPATH_STR
197 + "Weighted random multipath policy")
198 +{
199 + zebrad.mpath=IP_MP_ALG_WRANDOM;
200 + return CMD_SUCCESS;
201 +}
202 +
203 +DEFUN (no_multipath,
204 + no_multipath_cmd,
205 + "no multipath",
206 + NO_STR
207 + MULTIPATH_STR
208 + "Remove multipath policy")
209 +{
210 + zebrad.mpath=IP_MP_ALG_NONE;
211 + return CMD_SUCCESS;
212 +}
213 +
214 +DEFUN (show_multipath,
215 + show_multipath_cmd,
216 + "show multipath",
217 + SHOW_STR
218 + "Show multipath policy")
219 +{
220 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
221 + VTY_NEWLINE);
222 + return CMD_SUCCESS;
223 +}
224 +
225 +/* multipath policy configuration write function. */
226 +static int
227 +config_write_multipath (struct vty *vty)
228 +{
229 +
230 +
231 + if (zebrad.mpath)
232 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
233 + VTY_NEWLINE);
234 + return 0;
235 +}
236 +
237 +/* table node for multipath policy. */
238 +struct cmd_node multipath_node =
239 +{
240 + MULTIPATH_NODE,
241 + "",
242 + 1
243 +};
244 +
245 +#endif /* HAVE_RT_MP_ALGO */
246 +
247 /* Initialisation of zebra and installation of commands. */
248 void
249 zebra_init (void)
250 @@ -1715,6 +1804,10 @@ zebra_init (void)
251 install_node (&table_node, config_write_table);
252 install_node (&forwarding_node, config_write_forwarding);
253
254 +#ifdef HAVE_RT_MP_ALGO
255 + install_node (&multipath_node, config_write_multipath);
256 +#endif
257 +
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 @@ -1725,6 +1818,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_RT_MP_ALGO
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_RT_MP_ALGO */
273 #endif /* HAVE_NETLINK */
274
275 #ifdef HAVE_IPV6
276 --- a/zebra/zserv.h
277 +++ b/zebra/zserv.h
278 @@ -55,6 +55,9 @@ struct zserv
279 /* default routing table this client munges */
280 int rtm_table;
281
282 + /* multipath policy */
283 + u_int32_t mpath;
284 +
285 /* This client's redistribute flag. */
286 u_char redist[ZEBRA_ROUTE_MAX];
287
288 @@ -78,6 +81,9 @@ struct zebra_t
289 /* default table */
290 int rtm_table_default;
291
292 + /* multipath policy */
293 + u_int32_t mpath;
294 +
295 /* rib work queue */
296 struct work_queue *ribq;
297 struct meta_queue *mq;