aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/iptunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/libiproute/iptunnel.c')
-rw-r--r--networking/libiproute/iptunnel.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index dbde477a0..a67803ff4 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -409,46 +409,46 @@ static void print_tunnel(struct ip_tunnel_parm *p)
409 if (p->iph.tos) { 409 if (p->iph.tos) {
410 SPRINT_BUF(b1); 410 SPRINT_BUF(b1);
411 printf(" tos"); 411 printf(" tos");
412 if (p->iph.tos&1) 412 if (p->iph.tos & 1)
413 printf(" inherit"); 413 printf(" inherit");
414 if (p->iph.tos&~1) 414 if (p->iph.tos & ~1)
415 printf("%c%s ", p->iph.tos&1 ? '/' : ' ', 415 printf("%c%s ", p->iph.tos & 1 ? '/' : ' ',
416 rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1))); 416 rtnl_dsfield_n2a(p->iph.tos & ~1, b1, sizeof(b1)));
417 } 417 }
418 if (!(p->iph.frag_off&htons(IP_DF))) 418 if (!(p->iph.frag_off & htons(IP_DF)))
419 printf(" nopmtudisc"); 419 printf(" nopmtudisc");
420 420
421 if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key) 421 if ((p->i_flags & GRE_KEY) && (p->o_flags & GRE_KEY) && p->o_key == p->i_key)
422 printf(" key %s", s3); 422 printf(" key %s", s3);
423 else if ((p->i_flags|p->o_flags)&GRE_KEY) { 423 else if ((p->i_flags | p->o_flags) & GRE_KEY) {
424 if (p->i_flags&GRE_KEY) 424 if (p->i_flags & GRE_KEY)
425 printf(" ikey %s ", s3); 425 printf(" ikey %s ", s3);
426 if (p->o_flags&GRE_KEY) 426 if (p->o_flags & GRE_KEY)
427 printf(" okey %s ", s4); 427 printf(" okey %s ", s4);
428 } 428 }
429 429
430 if (p->i_flags&GRE_SEQ) 430 if (p->i_flags & GRE_SEQ)
431 printf("%s Drop packets out of sequence.\n", _SL_); 431 printf("%s Drop packets out of sequence.\n", _SL_);
432 if (p->i_flags&GRE_CSUM) 432 if (p->i_flags & GRE_CSUM)
433 printf("%s Checksum in received packet is required.", _SL_); 433 printf("%s Checksum in received packet is required.", _SL_);
434 if (p->o_flags&GRE_SEQ) 434 if (p->o_flags & GRE_SEQ)
435 printf("%s Sequence packets on output.", _SL_); 435 printf("%s Sequence packets on output.", _SL_);
436 if (p->o_flags&GRE_CSUM) 436 if (p->o_flags & GRE_CSUM)
437 printf("%s Checksum output packets.", _SL_); 437 printf("%s Checksum output packets.", _SL_);
438} 438}
439 439
440static int do_tunnels_list(struct ip_tunnel_parm *p) 440static int do_tunnels_list(struct ip_tunnel_parm *p)
441{ 441{
442 char name[IFNAMSIZ]; 442 char name[IFNAMSIZ];
443 unsigned long rx_bytes, rx_packets, rx_errs, rx_drops, 443 unsigned long rx_bytes, rx_packets, rx_errs, rx_drops,
444 rx_fifo, rx_frame, 444 rx_fifo, rx_frame,
445 tx_bytes, tx_packets, tx_errs, tx_drops, 445 tx_bytes, tx_packets, tx_errs, tx_drops,
446 tx_fifo, tx_colls, tx_carrier, rx_multi; 446 tx_fifo, tx_colls, tx_carrier, rx_multi;
447 int type; 447 int type;
448 struct ip_tunnel_parm p1; 448 struct ip_tunnel_parm p1;
449
450 char buf[512]; 449 char buf[512];
451 FILE *fp = fopen("/proc/net/dev", "r"); 450 FILE *fp = fopen("/proc/net/dev", "r");
451
452 if (fp == NULL) { 452 if (fp == NULL) {
453 perror("fopen"); 453 perror("fopen");
454 return -1; 454 return -1;
@@ -459,8 +459,10 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
459 459
460 while (fgets(buf, sizeof(buf), fp) != NULL) { 460 while (fgets(buf, sizeof(buf), fp) != NULL) {
461 char *ptr; 461 char *ptr;
462 buf[sizeof(buf) - 1] = 0; 462
463 if ((ptr = strchr(buf, ':')) == NULL || 463 /*buf[sizeof(buf) - 1] = 0; - fgets is safe anyway */
464 ptr = strchr(buf, ':');
465 if (ptr == NULL ||
464 (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) { 466 (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
465 bb_error_msg("wrong format of /proc/net/dev. Sorry"); 467 bb_error_msg("wrong format of /proc/net/dev. Sorry");
466 return -1; 468 return -1;
@@ -541,6 +543,5 @@ int do_iptunnel(int argc, char **argv)
541 } else 543 } else
542 return do_show(0, NULL); 544 return do_show(0, NULL);
543 545
544 bb_error_msg("command \"%s\" is unknown", *argv); 546 bb_error_msg_and_die("command \"%s\" is unknown", *argv);
545 exit(-1);
546} 547}