[8.09] [packages] rtorrent: add upstream patch for gcc-3.4.6 ICE (closes: #4926)
[openwrt/svn-archive/archive.git] / net / quagga-unstable / patches / 100-quagga_multipath_caching_policy.patch
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
4 @@ -385,7 +385,7 @@
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])
10
11 dnl Utility macro to avoid retyping includes all the time
12 m4_define([QUAGGA_INCLUDES],
13 @@ -755,6 +755,17 @@
14 AC_SUBST(KERNEL_METHOD)
15 AC_SUBST(OTHER_METHOD)
16
17 +dnl ----------
18 +dnl Check for RTA_MP_ALGO in linux/rtnetlink.h
19 +dnl ----------
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)
23 + AC_MSG_RESULT(yes)
24 + else
25 + AC_MSG_RESULT(no)
26 + fi
27 +
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
34 @@ -101,6 +101,7 @@
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. */
40 };
41
42 @@ -272,6 +273,7 @@
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
53 @@ -168,6 +168,10 @@
54 #define RT_TABLE_MAIN 0
55 #endif /* HAVE_NETLINK */
56
57 +#ifdef HAVE_LINUX_IP_MP_ALG_H
58 +#include <linux/ip_mp_alg.h>
59 +#endif /* HAVE_LINUX_IP_MP_ALG_H */
60 +
61 #ifdef HAVE_NETDB_H
62 #include <netdb.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
67 @@ -44,6 +44,7 @@
68 struct zebra_t zebrad =
69 {
70 .rtm_table_default = 0,
71 + .mpath = 0,
72 };
73
74 /* process id. */
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
78 @@ -0,0 +1,37 @@
79 +/*
80 + * multipath policy names.
81 + *
82 + * This file is part of Quagga routing suite.
83 + *
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
87 + * later version.
88 + *
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.
93 + *
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
97 + * 02111-1307, USA.
98 + */
99 +
100 +#ifndef ZEBRA_MULTIPATH_H
101 +#define ZEBRA_MULTIPATH_H
102 +#include <zebra.h>
103 +
104 +#ifdef HAVE_LINUX_IP_MP_ALG_H
105 +
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"
112 + };
113 +#endif
114 +#endif
115 +
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
119 @@ -36,6 +36,7 @@
120 #include "thread.h"
121 #include "privs.h"
122
123 +#include "multipath.h"
124 #include "zebra/zserv.h"
125 #include "zebra/rt.h"
126 #include "zebra/redistribute.h"
127 @@ -1694,6 +1695,16 @@
128 if (src)
129 addattr_l (&req.n, sizeof req, RTA_PREFSRC, &src->ipv4, bytelen);
130
131 +#ifdef HAVE_RT_MP_ALGO
132 + if (zebrad.mpath != IP_MP_ALG_NONE)
133 + {
134 + if (IS_ZEBRA_DEBUG_KERNEL)
135 + zlog_debug("netlink_route_multipath() (multihop): "
136 + "multipath policy : %s",mp_alg_names[zebrad.mpath]);
137 +
138 + addattr_l (&req.n, 1024, RTA_MP_ALGO, &zebrad.mpath, sizeof(zebrad.mpath));
139 + }
140 +#endif
141 if (rta->rta_len > RTA_LENGTH (0))
142 addattr_l (&req.n, 1024, RTA_MULTIPATH, RTA_DATA (rta),
143 RTA_PAYLOAD (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
147 @@ -36,6 +36,7 @@
148 #include "privs.h"
149 #include "network.h"
150 #include "buffer.h"
151 +#include "multipath.h"
152
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;
158
159 + /* Set multipath policy */
160 + client->mpath = zebrad.mpath;
161 +
162 /* Add this client to linked list. */
163 listnode_add (zebrad.client_list, client);
164
165 @@ -1697,6 +1701,91 @@
166 };
167
168 \f
169 +#ifdef HAVE_RT_MP_ALGO
170 +DEFUN (multipath_rr,
171 + multipath_rr_cmd,
172 + "multipath rr",
173 + MULTIPATH_STR
174 + "Round Robin multipath policy")
175 +{
176 + zebrad.mpath=IP_MP_ALG_RR;
177 + return CMD_SUCCESS;
178 +}
179 +
180 +DEFUN (multipath_drr,
181 + multipath_drr_cmd,
182 + "multipath drr",
183 + MULTIPATH_STR
184 + "Device round robin multipath policy")
185 +{
186 + zebrad.mpath=IP_MP_ALG_DRR;
187 + return CMD_SUCCESS;
188 +}
189 +
190 +DEFUN (multipath_random,
191 + multipath_random_cmd,
192 + "multipath random",
193 + MULTIPATH_STR
194 + "Random multipath policy")
195 +{
196 + zebrad.mpath=IP_MP_ALG_RANDOM;
197 + return CMD_SUCCESS;
198 +}
199 +
200 +DEFUN (multipath_wrandom,
201 + multipath_wrandom_cmd,
202 + "multipath wrandom",
203 + MULTIPATH_STR
204 + "Weighted random multipath policy")
205 +{
206 + zebrad.mpath=IP_MP_ALG_WRANDOM;
207 + return CMD_SUCCESS;
208 +}
209 +
210 +DEFUN (no_multipath,
211 + no_multipath_cmd,
212 + "no multipath",
213 + NO_STR
214 + MULTIPATH_STR
215 + "Remove multipath policy")
216 +{
217 + zebrad.mpath=IP_MP_ALG_NONE;
218 + return CMD_SUCCESS;
219 +}
220 +
221 +DEFUN (show_multipath,
222 + show_multipath_cmd,
223 + "show multipath",
224 + SHOW_STR
225 + "Show multipath policy")
226 +{
227 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
228 + VTY_NEWLINE);
229 + return CMD_SUCCESS;
230 +}
231 +
232 +/* multipath policy configuration write function. */
233 +static int
234 +config_write_multipath (struct vty *vty)
235 +{
236 +
237 +
238 + if (zebrad.mpath)
239 + vty_out (vty, "multipath %s%s", mp_alg_names[zebrad.mpath],
240 + VTY_NEWLINE);
241 + return 0;
242 +}
243 +
244 +/* table node for multipath policy. */
245 +struct cmd_node multipath_node =
246 +{
247 + MULTIPATH_NODE,
248 + "",
249 + 1
250 +};
251 +
252 +#endif /* HAVE_RT_MP_ALGO */
253 +
254 /* Initialisation of zebra and installation of commands. */
255 void
256 zebra_init (void)
257 @@ -1715,6 +1804,10 @@
258 install_node (&table_node, config_write_table);
259 install_node (&forwarding_node, config_write_forwarding);
260
261 +#ifdef HAVE_RT_MP_ALGO
262 + install_node (&multipath_node, config_write_multipath);
263 +#endif
264 +
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 */
281
282 #ifdef HAVE_IPV6
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
286 @@ -55,6 +55,9 @@
287 /* default routing table this client munges */
288 int rtm_table;
289
290 + /* multipath policy */
291 + u_int32_t mpath;
292 +
293 /* This client's redistribute flag. */
294 u_char redist[ZEBRA_ROUTE_MAX];
295
296 @@ -78,6 +81,9 @@
297 /* default table */
298 int rtm_table_default;
299
300 + /* multipath policy */
301 + u_int32_t mpath;
302 +
303 /* rib work queue */
304 struct work_queue *ribq;
305 struct meta_queue *mq;