]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ipaddress: simplify ipaddr_flush()
authorPhil Sutter <phil@nwl.cc>
Tue, 24 Nov 2015 14:31:00 +0000 (15:31 +0100)
committerStephen Hemminger <shemming@brocade.com>
Sun, 29 Nov 2015 19:47:29 +0000 (11:47 -0800)
Since it's no longer relevant whether an IP address is primary or
secondary when flushing, ipaddr_flush() can be simplified a bit.

Signed-off-by: Phil Sutter <phil@nwl.cc>
ip/ipaddress.c

index 05358c97c114f8e8d4b486c7a7fb340ab87c3de3..26e91c9b5d6f72fe174970d76439641c8fafb262 100644 (file)
@@ -1148,28 +1148,6 @@ brief_exit:
        return 0;
 }
 
-static int print_addrinfo_primary(const struct sockaddr_nl *who,
-                                 struct nlmsghdr *n, void *arg)
-{
-       struct ifaddrmsg *ifa = NLMSG_DATA(n);
-
-       if (ifa->ifa_flags & IFA_F_SECONDARY)
-               return 0;
-
-       return print_addrinfo(who, n, arg);
-}
-
-static int print_addrinfo_secondary(const struct sockaddr_nl *who,
-                                   struct nlmsghdr *n, void *arg)
-{
-       struct ifaddrmsg *ifa = NLMSG_DATA(n);
-
-       if (!(ifa->ifa_flags & IFA_F_SECONDARY))
-               return 0;
-
-       return print_addrinfo(who, n, arg);
-}
-
 struct nlmsg_list
 {
        struct nlmsg_list *next;
@@ -1420,26 +1398,12 @@ static int ipaddr_flush(void)
        filter.flushe = sizeof(flushb);
 
        while ((max_flush_loops == 0) || (round < max_flush_loops)) {
-               const struct rtnl_dump_filter_arg a[3] = {
-                       {
-                               .filter = print_addrinfo_secondary,
-                               .arg1 = stdout,
-                       },
-                       {
-                               .filter = print_addrinfo_primary,
-                               .arg1 = stdout,
-                       },
-                       {
-                               .filter = NULL,
-                               .arg1 = NULL,
-                       },
-               };
                if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
                        perror("Cannot send dump request");
                        exit(1);
                }
                filter.flushed = 0;
-               if (rtnl_dump_filter_l(&rth, a) < 0) {
+               if (rtnl_dump_filter(&rth, print_addrinfo, stdout) < 0) {
                        fprintf(stderr, "Flush terminated\n");
                        exit(1);
                }