Commit bd4bcdad authored by Patrick McHardy's avatar Patrick McHardy Committed by Stephen Hemminger

Preparation for 32 bit table IDs

[IPROUTE]: Preparation for 32 bit table IDs

The route table filter uses an integer for the table number and the value
-1 to represent cloned routes. For 32 bit table IDs it needs to become an
unsigned, so this won't work anymore. Introduce a new filter flag "cloned"
and use instead of filter.tb = -1.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
parent e0b29fe7
...@@ -89,6 +89,7 @@ static void usage(void) ...@@ -89,6 +89,7 @@ static void usage(void)
static struct static struct
{ {
int tb; int tb;
int cloned;
int flushed; int flushed;
char *flushb; char *flushb;
int flushp; int flushp;
...@@ -168,11 +169,11 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -168,11 +169,11 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
ip6_multiple_tables = 1; ip6_multiple_tables = 1;
if (r->rtm_family == AF_INET6 && !ip6_multiple_tables) { if (r->rtm_family == AF_INET6 && !ip6_multiple_tables) {
if (filter.tb) { if (filter.cloned) {
if (filter.tb < 0) {
if (!(r->rtm_flags&RTM_F_CLONED)) if (!(r->rtm_flags&RTM_F_CLONED))
return 0; return 0;
} else { }
if (filter.tb) {
if (r->rtm_flags&RTM_F_CLONED) if (r->rtm_flags&RTM_F_CLONED)
return 0; return 0;
if (filter.tb == RT_TABLE_LOCAL) { if (filter.tb == RT_TABLE_LOCAL) {
...@@ -185,7 +186,6 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ...@@ -185,7 +186,6 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
return 0; return 0;
} }
} }
}
} else { } else {
if (filter.tb > 0 && filter.tb != r->rtm_table) if (filter.tb > 0 && filter.tb != r->rtm_table)
return 0; return 0;
...@@ -1045,19 +1045,19 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) ...@@ -1045,19 +1045,19 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
NEXT_ARG(); NEXT_ARG();
if (rtnl_rttable_a2n(&tid, *argv)) { if (rtnl_rttable_a2n(&tid, *argv)) {
if (strcmp(*argv, "all") == 0) { if (strcmp(*argv, "all") == 0) {
tid = 0; filter.tb = 0;
} else if (strcmp(*argv, "cache") == 0) { } else if (strcmp(*argv, "cache") == 0) {
tid = -1; filter.cloned = 1;
} else if (strcmp(*argv, "help") == 0) { } else if (strcmp(*argv, "help") == 0) {
usage(); usage();
} else { } else {
invarg("table id value is invalid\n", *argv); invarg("table id value is invalid\n", *argv);
} }
} } else
filter.tb = tid; filter.tb = tid;
} else if (matches(*argv, "cached") == 0 || } else if (matches(*argv, "cached") == 0 ||
matches(*argv, "cloned") == 0) { matches(*argv, "cloned") == 0) {
filter.tb = -1; filter.cloned = 1;
} else if (strcmp(*argv, "tos") == 0 || } else if (strcmp(*argv, "tos") == 0 ||
matches(*argv, "dsfield") == 0) { matches(*argv, "dsfield") == 0) {
__u32 tos; __u32 tos;
...@@ -1189,7 +1189,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) ...@@ -1189,7 +1189,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
char flushb[4096-512]; char flushb[4096-512];
time_t start = time(0); time_t start = time(0);
if (filter.tb == -1) { if (filter.cloned) {
if (do_ipv6 != AF_INET6) { if (do_ipv6 != AF_INET6) {
iproute_flush_cache(); iproute_flush_cache();
if (show_stats) if (show_stats)
...@@ -1215,7 +1215,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) ...@@ -1215,7 +1215,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
} }
if (filter.flushed == 0) { if (filter.flushed == 0) {
if (round == 0) { if (round == 0) {
if (filter.tb != -1 || do_ipv6 == AF_INET6) if (!filter.cloned || do_ipv6 == AF_INET6)
fprintf(stderr, "Nothing to flush.\n"); fprintf(stderr, "Nothing to flush.\n");
} else if (show_stats) } else if (show_stats)
printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":""); printf("*** Flush is complete after %d round%s ***\n", round, round>1?"s":"");
...@@ -1239,7 +1239,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) ...@@ -1239,7 +1239,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
} }
} }
if (filter.tb != -1) { if (!filter.cloned) {
if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) { if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
perror("Cannot send dump request"); perror("Cannot send dump request");
exit(1); exit(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment