aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/iproute.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/libiproute/iproute.c')
-rw-r--r--networking/libiproute/iproute.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 6a41b8331..95dafe183 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -9,12 +9,16 @@
9 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses 9 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
10 * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized 10 * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized
11 */ 11 */
12
13#include "ip_common.h" /* #include "libbb.h" is inside */ 12#include "ip_common.h" /* #include "libbb.h" is inside */
14#include "common_bufsiz.h" 13#include "common_bufsiz.h"
15#include "rt_names.h" 14#include "rt_names.h"
16#include "utils.h" 15#include "utils.h"
17 16
17#include <linux/version.h>
18/* RTA_TABLE is not a define, can't test with ifdef. */
19/* As a proxy, test which kernels toolchain expects: */
20#define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
21
18#ifndef RTAX_RTTVAR 22#ifndef RTAX_RTTVAR
19#define RTAX_RTTVAR RTAX_HOPS 23#define RTAX_RTTVAR RTAX_HOPS
20#endif 24#endif
@@ -82,9 +86,11 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
82 memset(tb, 0, sizeof(tb)); 86 memset(tb, 0, sizeof(tb));
83 parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); 87 parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);
84 88
89#if HAVE_RTA_TABLE
85 if (tb[RTA_TABLE]) 90 if (tb[RTA_TABLE])
86 tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); 91 tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]);
87 else 92 else
93#endif
88 tid = r->rtm_table; 94 tid = r->rtm_table;
89 95
90 if (r->rtm_family == AF_INET6) 96 if (r->rtm_family == AF_INET6)
@@ -460,12 +466,13 @@ IF_FEATURE_IP_RULE(ARG_table,)
460 NEXT_ARG(); 466 NEXT_ARG();
461 if (rtnl_rttable_a2n(&tid, *argv)) 467 if (rtnl_rttable_a2n(&tid, *argv))
462 invarg_1_to_2(*argv, keyword_table); 468 invarg_1_to_2(*argv, keyword_table);
463 if (tid < 256) 469#if HAVE_RTA_TABLE
464 req.r.rtm_table = tid; 470 if (tid > 255) {
465 else {
466 req.r.rtm_table = RT_TABLE_UNSPEC; 471 req.r.rtm_table = RT_TABLE_UNSPEC;
467 addattr32(&req.n, sizeof(req), RTA_TABLE, tid); 472 addattr32(&req.n, sizeof(req), RTA_TABLE, tid);
468 } 473 } else
474#endif
475 req.r.rtm_table = tid;
469#endif 476#endif
470 } else if (arg == ARG_dev || arg == ARG_oif) { 477 } else if (arg == ARG_dev || arg == ARG_oif) {
471 NEXT_ARG(); 478 NEXT_ARG();