aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-02-03 19:32:44 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-02-03 19:32:44 +0100
commit09020b1aa891afaee865caf5fa46fa4ddb42f264 (patch)
tree6db4146c3e5716877e664355ff897e00742904a4
parentb62d4d9d5700d4931faac500fca11f440dacd610 (diff)
downloadbusybox-w32-09020b1aa891afaee865caf5fa46fa4ddb42f264.tar.gz
busybox-w32-09020b1aa891afaee865caf5fa46fa4ddb42f264.tar.bz2
busybox-w32-09020b1aa891afaee865caf5fa46fa4ddb42f264.zip
route: improve -A inet6
Upstream route command shows non-up routes, it shows reject and nonexthop flags. And we had "ref" and "use" values mixed up... function old new delta flagvals 32 44 +12 flagchars 9 12 +3 INET_setroute 767 768 +1 INET6_setroute 495 496 +1 set_flags 43 39 -4 flags_ipvx 16 8 -8 route_main 632 623 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/3 up/down: 17/-21) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/route.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/networking/route.c b/networking/route.c
index 24cc2eb5a..d82b0132a 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -55,6 +55,7 @@
55#define RTF_WINDOW 0x0080 /* per route window clamping */ 55#define RTF_WINDOW 0x0080 /* per route window clamping */
56#define RTF_IRTT 0x0100 /* Initial round trip time */ 56#define RTF_IRTT 0x0100 /* Initial round trip time */
57#define RTF_REJECT 0x0200 /* Reject route */ 57#define RTF_REJECT 0x0200 /* Reject route */
58#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
58#endif 59#endif
59 60
60#if defined(SIOCADDRTOLD) || defined(RTF_IRTT) /* route */ 61#if defined(SIOCADDRTOLD) || defined(RTF_IRTT) /* route */
@@ -128,7 +129,7 @@ static const char tbl_ipvx[] ALIGN1 =
128 "\013\043reinstate" /* Since last, we can save a byte. */ 129 "\013\043reinstate" /* Since last, we can save a byte. */
129; 130;
130 131
131static const int flags_ipvx[] = { /* MUST match tbl_ipvx[] values above. */ 132static const uint16_t flags_ipvx[] = { /* MUST match tbl_ipvx[] values above. */
132#ifdef RTF_REJECT 133#ifdef RTF_REJECT
133 RTF_REJECT, 134 RTF_REJECT,
134#endif 135#endif
@@ -449,7 +450,11 @@ static NOINLINE void INET6_setroute(int action, char **args)
449} 450}
450#endif 451#endif
451 452
452static const unsigned flagvals[] = { /* Must agree with flagchars[]. */ 453static const
454IF_NOT_FEATURE_IPV6(uint16_t)
455IF_FEATURE_IPV6(unsigned)
456flagvals[] = { /* Must agree with flagchars[]. */
457 RTF_UP,
453 RTF_GATEWAY, 458 RTF_GATEWAY,
454 RTF_HOST, 459 RTF_HOST,
455 RTF_REINSTATE, 460 RTF_REINSTATE,
@@ -458,27 +463,25 @@ static const unsigned flagvals[] = { /* Must agree with flagchars[]. */
458#if ENABLE_FEATURE_IPV6 463#if ENABLE_FEATURE_IPV6
459 RTF_DEFAULT, 464 RTF_DEFAULT,
460 RTF_ADDRCONF, 465 RTF_ADDRCONF,
461 RTF_CACHE 466 RTF_CACHE,
467 RTF_REJECT,
468 RTF_NONEXTHOP, /* this one doesn't fit into 16 bits */
462#endif 469#endif
463}; 470};
464
465#define IPV4_MASK (RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
466#define IPV6_MASK (RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE)
467
468/* Must agree with flagvals[]. */ 471/* Must agree with flagvals[]. */
469static const char flagchars[] ALIGN1 = 472static const char flagchars[] ALIGN1 =
470 "GHRDM" 473 "UGHRDM"
471#if ENABLE_FEATURE_IPV6 474#if ENABLE_FEATURE_IPV6
472 "DAC" 475 "DAC!n"
473#endif 476#endif
474; 477;
478#define IPV4_MASK (RTF_UP|RTF_GATEWAY|RTF_HOST|RTF_REINSTATE|RTF_DYNAMIC|RTF_MODIFIED)
479#define IPV6_MASK (RTF_UP|RTF_GATEWAY|RTF_HOST|RTF_DEFAULT|RTF_ADDRCONF|RTF_CACHE|RTF_REJECT|RTF_NONEXTHOP)
475 480
476static void set_flags(char *flagstr, int flags) 481static void set_flags(char *flagstr, int flags)
477{ 482{
478 int i; 483 int i;
479 484
480 *flagstr++ = 'U';
481
482 for (i = 0; (*flagstr = flagchars[i]) != 0; i++) { 485 for (i = 0; (*flagstr = flagchars[i]) != 0; i++) {
483 if (flags & flagvals[i]) { 486 if (flags & flagvals[i]) {
484 ++flagstr; 487 ++flagstr;
@@ -574,7 +577,7 @@ static void INET6_displayroutes(void)
574 int r; 577 int r;
575 r = fscanf(fp, "%32s%x%*s%x%32s%x%x%x%x%s\n", 578 r = fscanf(fp, "%32s%x%*s%x%32s%x%x%x%x%s\n",
576 addr6x+14, &prefix_len, &slen, addr6x+40+7, 579 addr6x+14, &prefix_len, &slen, addr6x+40+7,
577 &metric, &use, &refcnt, &iflags, iface); 580 &metric, &refcnt, &use, &iflags, iface);
578 if (r != 9) { 581 if (r != 9) {
579 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */ 582 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
580 break; 583 break;
@@ -606,10 +609,6 @@ static void INET6_displayroutes(void)
606 } while (i < 40+28+7); 609 } while (i < 40+28+7);
607 } 610 }
608 611
609 if (!(iflags & RTF_UP)) { /* Skip interfaces that are down. */
610 continue;
611 }
612
613 set_flags(flags, (iflags & IPV6_MASK)); 612 set_flags(flags, (iflags & IPV6_MASK));
614 613
615 r = 0; 614 r = 0;