diff options
-rw-r--r-- | networking/libiproute/ipaddress.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 8f491f327..dd5a91426 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -129,7 +129,7 @@ int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) | |||
129 | memset(tb, 0, sizeof(tb)); | 129 | memset(tb, 0, sizeof(tb)); |
130 | parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); | 130 | parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); |
131 | if (tb[IFLA_IFNAME] == NULL) { | 131 | if (tb[IFLA_IFNAME] == NULL) { |
132 | fprintf(stderr, "BUG: nil ifname\n"); | 132 | error_msg("nil ifname"); |
133 | return -1; | 133 | return -1; |
134 | } | 134 | } |
135 | if (filter.label && | 135 | if (filter.label && |
@@ -211,7 +211,7 @@ int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) | |||
211 | return 0; | 211 | return 0; |
212 | len -= NLMSG_LENGTH(sizeof(*ifa)); | 212 | len -= NLMSG_LENGTH(sizeof(*ifa)); |
213 | if (len < 0) { | 213 | if (len < 0) { |
214 | fprintf(stderr, "BUG: wrong nlmsg len %d\n", len); | 214 | error_msg("wrong nlmsg len %d", len); |
215 | return -1; | 215 | return -1; |
216 | } | 216 | } |
217 | 217 | ||
@@ -436,32 +436,28 @@ int ipaddr_list(int argc, char **argv) | |||
436 | exit(1); | 436 | exit(1); |
437 | 437 | ||
438 | if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { | 438 | if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { |
439 | perror("Cannot send dump request"); | 439 | perror_msg_and_die("Cannot send dump request"); |
440 | exit(1); | ||
441 | } | 440 | } |
442 | 441 | ||
443 | if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { | 442 | if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { |
444 | fprintf(stderr, "Dump terminated\n"); | 443 | error_msg_and_die("Dump terminated"); |
445 | exit(1); | ||
446 | } | 444 | } |
447 | 445 | ||
448 | if (filter_dev) { | 446 | if (filter_dev) { |
449 | filter.ifindex = ll_name_to_index(filter_dev); | 447 | filter.ifindex = ll_name_to_index(filter_dev); |
450 | if (filter.ifindex <= 0) { | 448 | if (filter.ifindex <= 0) { |
451 | fprintf(stderr, "Device \"%s\" does not exist.\n", filter_dev); | 449 | error_msg("Device \"%s\" does not exist.", filter_dev); |
452 | return -1; | 450 | return -1; |
453 | } | 451 | } |
454 | } | 452 | } |
455 | 453 | ||
456 | if (filter.family != AF_PACKET) { | 454 | if (filter.family != AF_PACKET) { |
457 | if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { | 455 | if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { |
458 | perror("Cannot send dump request"); | 456 | perror_msg_and_die("Cannot send dump request"); |
459 | exit(1); | ||
460 | } | 457 | } |
461 | 458 | ||
462 | if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { | 459 | if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { |
463 | fprintf(stderr, "Dump terminated\n"); | 460 | error_msg_and_die("Dump terminated"); |
464 | exit(1); | ||
465 | } | 461 | } |
466 | } | 462 | } |
467 | 463 | ||
@@ -654,12 +650,11 @@ int ipaddr_modify(int cmd, int argc, char **argv) | |||
654 | argc--; argv++; | 650 | argc--; argv++; |
655 | } | 651 | } |
656 | if (d == NULL) { | 652 | if (d == NULL) { |
657 | fprintf(stderr, "Not enough information: \"dev\" argument is required.\n"); | 653 | error_msg("Not enough information: \"dev\" argument is required."); |
658 | return -1; | 654 | return -1; |
659 | } | 655 | } |
660 | if (l && matches(d, l) != 0) { | 656 | if (l && matches(d, l) != 0) { |
661 | fprintf(stderr, "\"dev\" (%s) must match \"label\" (%s).\n", d, l); | 657 | error_msg_and_die("\"dev\" (%s) must match \"label\" (%s).", d, l); |
662 | exit(1); | ||
663 | } | 658 | } |
664 | 659 | ||
665 | if (peer_len == 0 && local_len && cmd != RTM_DELADDR) { | 660 | if (peer_len == 0 && local_len && cmd != RTM_DELADDR) { |
@@ -673,7 +668,7 @@ int ipaddr_modify(int cmd, int argc, char **argv) | |||
673 | inet_prefix brd; | 668 | inet_prefix brd; |
674 | int i; | 669 | int i; |
675 | if (req.ifa.ifa_family != AF_INET) { | 670 | if (req.ifa.ifa_family != AF_INET) { |
676 | fprintf(stderr, "Broadcast can be set only for IPv4 addresses\n"); | 671 | error_msg("Broadcast can be set only for IPv4 addresses"); |
677 | return -1; | 672 | return -1; |
678 | } | 673 | } |
679 | brd = peer; | 674 | brd = peer; |
@@ -697,7 +692,7 @@ int ipaddr_modify(int cmd, int argc, char **argv) | |||
697 | ll_init_map(&rth); | 692 | ll_init_map(&rth); |
698 | 693 | ||
699 | if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) { | 694 | if ((req.ifa.ifa_index = ll_name_to_index(d)) == 0) { |
700 | fprintf(stderr, "Cannot find device \"%s\"\n", d); | 695 | error_msg("Cannot find device \"%s\"", d); |
701 | return -1; | 696 | return -1; |
702 | } | 697 | } |
703 | 698 | ||
@@ -718,6 +713,6 @@ int do_ipaddr(int argc, char **argv) | |||
718 | if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 | 713 | if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 |
719 | || matches(*argv, "lst") == 0) | 714 | || matches(*argv, "lst") == 0) |
720 | return ipaddr_list(argc-1, argv+1); | 715 | return ipaddr_list(argc-1, argv+1); |
721 | fprintf(stderr, "Command \"%s\" is unknown, try \"ip address help\".\n", *argv); | 716 | error_msg("Command \"%s\" is unknown, try \"ip address help\".", *argv); |
722 | exit(-1); | 717 | exit(-1); |
723 | } | 718 | } |