diff options
-rw-r--r-- | networking/libiproute/iproute.c | 16 | ||||
-rw-r--r-- | networking/libiproute/iprule.c | 21 |
2 files changed, 28 insertions, 9 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index e8b26cb2f..95dafe183 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -14,6 +14,11 @@ | |||
14 | #include "rt_names.h" | 14 | #include "rt_names.h" |
15 | #include "utils.h" | 15 | #include "utils.h" |
16 | 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 | |||
17 | #ifndef RTAX_RTTVAR | 22 | #ifndef RTAX_RTTVAR |
18 | #define RTAX_RTTVAR RTAX_HOPS | 23 | #define RTAX_RTTVAR RTAX_HOPS |
19 | #endif | 24 | #endif |
@@ -81,9 +86,11 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, | |||
81 | memset(tb, 0, sizeof(tb)); | 86 | memset(tb, 0, sizeof(tb)); |
82 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); | 87 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); |
83 | 88 | ||
89 | #if HAVE_RTA_TABLE | ||
84 | if (tb[RTA_TABLE]) | 90 | if (tb[RTA_TABLE]) |
85 | tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); | 91 | tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); |
86 | else | 92 | else |
93 | #endif | ||
87 | tid = r->rtm_table; | 94 | tid = r->rtm_table; |
88 | 95 | ||
89 | if (r->rtm_family == AF_INET6) | 96 | if (r->rtm_family == AF_INET6) |
@@ -459,12 +466,13 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
459 | NEXT_ARG(); | 466 | NEXT_ARG(); |
460 | if (rtnl_rttable_a2n(&tid, *argv)) | 467 | if (rtnl_rttable_a2n(&tid, *argv)) |
461 | invarg_1_to_2(*argv, keyword_table); | 468 | invarg_1_to_2(*argv, keyword_table); |
462 | if (tid < 256) | 469 | #if HAVE_RTA_TABLE |
463 | req.r.rtm_table = tid; | 470 | if (tid > 255) { |
464 | else { | ||
465 | req.r.rtm_table = RT_TABLE_UNSPEC; | 471 | req.r.rtm_table = RT_TABLE_UNSPEC; |
466 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); | 472 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); |
467 | } | 473 | } else |
474 | #endif | ||
475 | req.r.rtm_table = tid; | ||
468 | #endif | 476 | #endif |
469 | } else if (arg == ARG_dev || arg == ARG_oif) { | 477 | } else if (arg == ARG_dev || arg == ARG_oif) { |
470 | NEXT_ARG(); | 478 | NEXT_ARG(); |
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 9938b4793..53b11e16c 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c | |||
@@ -24,6 +24,11 @@ | |||
24 | #include "rt_names.h" | 24 | #include "rt_names.h" |
25 | #include "utils.h" | 25 | #include "utils.h" |
26 | 26 | ||
27 | #include <linux/version.h> | ||
28 | /* RTA_TABLE is not a define, can't test with ifdef. */ | ||
29 | /* As a proxy, test which kernels toolchain expects: */ | ||
30 | #define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) | ||
31 | |||
27 | /* If you add stuff here, update iprule_full_usage */ | 32 | /* If you add stuff here, update iprule_full_usage */ |
28 | static const char keywords[] ALIGN1 = | 33 | static const char keywords[] ALIGN1 = |
29 | "from\0""to\0""preference\0""order\0""priority\0" | 34 | "from\0""to\0""preference\0""order\0""priority\0" |
@@ -120,9 +125,12 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
120 | printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); | 125 | printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); |
121 | } | 126 | } |
122 | 127 | ||
128 | #if HAVE_RTA_TABLE | ||
123 | if (tb[RTA_TABLE]) | 129 | if (tb[RTA_TABLE]) |
124 | printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); | 130 | printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); |
125 | else if (r->rtm_table) | 131 | else |
132 | #endif | ||
133 | if (r->rtm_table) | ||
126 | printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); | 134 | printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); |
127 | 135 | ||
128 | if (tb[FRA_SUPPRESS_PREFIXLEN]) { | 136 | if (tb[FRA_SUPPRESS_PREFIXLEN]) { |
@@ -266,12 +274,15 @@ static int iprule_modify(int cmd, char **argv) | |||
266 | NEXT_ARG(); | 274 | NEXT_ARG(); |
267 | if (rtnl_rttable_a2n(&tid, *argv)) | 275 | if (rtnl_rttable_a2n(&tid, *argv)) |
268 | invarg_1_to_2(*argv, "table ID"); | 276 | invarg_1_to_2(*argv, "table ID"); |
269 | if (tid < 256) | 277 | |
270 | req.r.rtm_table = tid; | 278 | #if HAVE_RTA_TABLE |
271 | else { | 279 | if (tid > 255) { |
272 | req.r.rtm_table = RT_TABLE_UNSPEC; | 280 | req.r.rtm_table = RT_TABLE_UNSPEC; |
273 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); | 281 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); |
274 | } | 282 | } else |
283 | #endif | ||
284 | req.r.rtm_table = tid; | ||
285 | |||
275 | table_ok = 1; | 286 | table_ok = 1; |
276 | } else if (key == ARG_suppress_prefixlength) { | 287 | } else if (key == ARG_suppress_prefixlength) { |
277 | int prefix_length; | 288 | int prefix_length; |