iproute/iprule: support toolchains without RTA_TABLE routing attribute
iproute.c: In function 'print_route':
iproute.c:85:9: error: 'RTA_TABLE' undeclared (first use in this function)
iproute.c:85:9: note: each undeclared identifier is reported only once for each function it appears in
iproute.c: In function 'iproute_modify':
iproute.c:467:36: error: 'RTA_TABLE' undeclared (first use in this function)
Fix it by partially #ifdef'ing the code added in b42107f215
Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
d3a7e88008
commit
ecce3a1999
@ -14,6 +14,11 @@
|
|||||||
#include "rt_names.h"
|
#include "rt_names.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <linux/version.h>
|
||||||
|
/* RTA_TABLE is not a define, can't test with ifdef. */
|
||||||
|
/* As a proxy, test which kernels toolchain expects: */
|
||||||
|
#define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
|
||||||
|
|
||||||
#ifndef RTAX_RTTVAR
|
#ifndef RTAX_RTTVAR
|
||||||
#define RTAX_RTTVAR RTAX_HOPS
|
#define RTAX_RTTVAR RTAX_HOPS
|
||||||
#endif
|
#endif
|
||||||
@ -81,9 +86,11 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
|
|||||||
memset(tb, 0, sizeof(tb));
|
memset(tb, 0, sizeof(tb));
|
||||||
parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);
|
parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);
|
||||||
|
|
||||||
|
#if HAVE_RTA_TABLE
|
||||||
if (tb[RTA_TABLE])
|
if (tb[RTA_TABLE])
|
||||||
tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]);
|
tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
tid = r->rtm_table;
|
tid = r->rtm_table;
|
||||||
|
|
||||||
if (r->rtm_family == AF_INET6)
|
if (r->rtm_family == AF_INET6)
|
||||||
@ -459,12 +466,13 @@ IF_FEATURE_IP_RULE(ARG_table,)
|
|||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rttable_a2n(&tid, *argv))
|
if (rtnl_rttable_a2n(&tid, *argv))
|
||||||
invarg_1_to_2(*argv, keyword_table);
|
invarg_1_to_2(*argv, keyword_table);
|
||||||
if (tid < 256)
|
#if HAVE_RTA_TABLE
|
||||||
req.r.rtm_table = tid;
|
if (tid > 255) {
|
||||||
else {
|
|
||||||
req.r.rtm_table = RT_TABLE_UNSPEC;
|
req.r.rtm_table = RT_TABLE_UNSPEC;
|
||||||
addattr32(&req.n, sizeof(req), RTA_TABLE, tid);
|
addattr32(&req.n, sizeof(req), RTA_TABLE, tid);
|
||||||
}
|
} else
|
||||||
|
#endif
|
||||||
|
req.r.rtm_table = tid;
|
||||||
#endif
|
#endif
|
||||||
} else if (arg == ARG_dev || arg == ARG_oif) {
|
} else if (arg == ARG_dev || arg == ARG_oif) {
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
#include "rt_names.h"
|
#include "rt_names.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <linux/version.h>
|
||||||
|
/* RTA_TABLE is not a define, can't test with ifdef. */
|
||||||
|
/* As a proxy, test which kernels toolchain expects: */
|
||||||
|
#define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
|
||||||
|
|
||||||
/* If you add stuff here, update iprule_full_usage */
|
/* If you add stuff here, update iprule_full_usage */
|
||||||
static const char keywords[] ALIGN1 =
|
static const char keywords[] ALIGN1 =
|
||||||
"from\0""to\0""preference\0""order\0""priority\0"
|
"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,
|
|||||||
printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF]));
|
printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_RTA_TABLE
|
||||||
if (tb[RTA_TABLE])
|
if (tb[RTA_TABLE])
|
||||||
printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE])));
|
printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE])));
|
||||||
else if (r->rtm_table)
|
else
|
||||||
|
#endif
|
||||||
|
if (r->rtm_table)
|
||||||
printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table));
|
printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table));
|
||||||
|
|
||||||
if (tb[FRA_SUPPRESS_PREFIXLEN]) {
|
if (tb[FRA_SUPPRESS_PREFIXLEN]) {
|
||||||
@ -266,12 +274,15 @@ static int iprule_modify(int cmd, char **argv)
|
|||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (rtnl_rttable_a2n(&tid, *argv))
|
if (rtnl_rttable_a2n(&tid, *argv))
|
||||||
invarg_1_to_2(*argv, "table ID");
|
invarg_1_to_2(*argv, "table ID");
|
||||||
if (tid < 256)
|
|
||||||
req.r.rtm_table = tid;
|
#if HAVE_RTA_TABLE
|
||||||
else {
|
if (tid > 255) {
|
||||||
req.r.rtm_table = RT_TABLE_UNSPEC;
|
req.r.rtm_table = RT_TABLE_UNSPEC;
|
||||||
addattr32(&req.n, sizeof(req), RTA_TABLE, tid);
|
addattr32(&req.n, sizeof(req), RTA_TABLE, tid);
|
||||||
}
|
} else
|
||||||
|
#endif
|
||||||
|
req.r.rtm_table = tid;
|
||||||
|
|
||||||
table_ok = 1;
|
table_ok = 1;
|
||||||
} else if (key == ARG_suppress_prefixlength) {
|
} else if (key == ARG_suppress_prefixlength) {
|
||||||
int prefix_length;
|
int prefix_length;
|
||||||
|
Loading…
Reference in New Issue
Block a user