]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
Revert "ip address: Change print_linkinfo_brief to take filter as an input"
authorSerhey Popovych <serhe.popovych@gmail.com>
Thu, 1 Feb 2018 11:25:52 +0000 (13:25 +0200)
committerDavid Ahern <dsahern@gmail.com>
Thu, 1 Feb 2018 16:27:29 +0000 (08:27 -0800)
This reverts commit 63891c70137f200105c539c92eb73abade2c05d5.

It seems print_linkinfo_brief() never accepts filter different than
default one and David Ahern suggests to revert it instead of making
new change that actually do revert.

Conflicts:
ip/ipaddress.c
ip/iplink.c

These are caused by JSON support addition after commit we reverting.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
ip/ip_common.h
ip/ipaddress.c
ip/iplink.c

index 3203f0cd5b52af1b6233dd352084be8aef62d9e7..f5adbad959aa76cf256ccf2e58085273431f5dfa 100644 (file)
@@ -30,8 +30,7 @@ int get_operstate(const char *name);
 int print_linkinfo(const struct sockaddr_nl *who,
                   struct nlmsghdr *n, void *arg);
 int print_linkinfo_brief(const struct sockaddr_nl *who,
-                        struct nlmsghdr *n, void *arg,
-                        struct link_filter *filter);
+                        struct nlmsghdr *n, void *arg);
 int print_addrinfo(const struct sockaddr_nl *who,
                   struct nlmsghdr *n, void *arg);
 int print_addrlabel(const struct sockaddr_nl *who,
index 051a05f00d40590e5e10fefb6235fa3677834e3e..b18b6f44c9609cc1e89bbd34efa1982aa1fd90ba 100644 (file)
@@ -919,8 +919,7 @@ static void print_link_stats(FILE *fp, struct nlmsghdr *n)
 }
 
 int print_linkinfo_brief(const struct sockaddr_nl *who,
-                        struct nlmsghdr *n, void *arg,
-                        struct link_filter *pfilter)
+                               struct nlmsghdr *n, void *arg)
 {
        FILE *fp = (FILE *)arg;
        struct ifinfomsg *ifi = NLMSG_DATA(n);
@@ -937,12 +936,9 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
        if (len < 0)
                return -1;
 
-       if (!pfilter)
-               pfilter = &filter;
-
-       if (pfilter->ifindex && ifi->ifi_index != pfilter->ifindex)
+       if (filter.ifindex && ifi->ifi_index != filter.ifindex)
                return -1;
-       if (pfilter->up && !(ifi->ifi_flags&IFF_UP))
+       if (filter.up && !(ifi->ifi_flags&IFF_UP))
                return -1;
 
        parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
@@ -953,30 +949,30 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
                name = rta_getattr_str(tb[IFLA_IFNAME]);
        }
 
-       if (pfilter->label &&
-           (!pfilter->family || pfilter->family == AF_PACKET) &&
-           fnmatch(pfilter->label, RTA_DATA(tb[IFLA_IFNAME]), 0))
+       if (filter.label &&
+           (!filter.family || filter.family == AF_PACKET) &&
+           fnmatch(filter.label, RTA_DATA(tb[IFLA_IFNAME]), 0))
                return -1;
 
        if (tb[IFLA_GROUP]) {
                int group = rta_getattr_u32(tb[IFLA_GROUP]);
 
-               if (pfilter->group != -1 && group != pfilter->group)
+               if (filter.group != -1 && group != filter.group)
                        return -1;
        }
 
        if (tb[IFLA_MASTER]) {
                int master = rta_getattr_u32(tb[IFLA_MASTER]);
 
-               if (pfilter->master > 0 && master != pfilter->master)
+               if (filter.master > 0 && master != filter.master)
                        return -1;
-       } else if (pfilter->master > 0)
+       } else if (filter.master > 0)
                return -1;
 
-       if (pfilter->kind && match_link_kind(tb, pfilter->kind, 0))
+       if (filter.kind && match_link_kind(tb, filter.kind, 0))
                return -1;
 
-       if (pfilter->slave_kind && match_link_kind(tb, pfilter->slave_kind, 1))
+       if (filter.slave_kind && match_link_kind(tb, filter.slave_kind, 1))
                return -1;
 
        if (n->nlmsg_type == RTM_DELLINK)
@@ -1006,7 +1002,7 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
        if (tb[IFLA_OPERSTATE])
                print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));
 
-       if (pfilter->family == AF_PACKET) {
+       if (filter.family == AF_PACKET) {
                SPRINT_BUF(b1);
 
                if (tb[IFLA_ADDRESS]) {
@@ -1020,10 +1016,11 @@ int print_linkinfo_brief(const struct sockaddr_nl *who,
                }
        }
 
-       if (pfilter->family == AF_PACKET) {
+       if (filter.family == AF_PACKET) {
                print_link_flags(fp, ifi->ifi_flags, m_flag);
                print_string(PRINT_FP, NULL, "%s", "\n");
        }
+
        fflush(fp);
        return 0;
 }
@@ -2197,8 +2194,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 
                open_json_object(NULL);
                if (brief) {
-                       if (print_linkinfo_brief(NULL, &l->h,
-                                                stdout, NULL) == 0)
+                       if (print_linkinfo_brief(NULL, &l->h, stdout) == 0)
                                if (filter.family != AF_PACKET)
                                        print_selected_addrinfo(ifi,
                                                                ainfo->head,
index 230f4c5377d9fee8e34a7c625aef536b72455201..882cd13103c800940e2c6581766dd57b33253e8a 100644 (file)
@@ -1077,7 +1077,7 @@ int iplink_get(unsigned int flags, char *name, __u32 filt_mask)
 
        open_json_object(NULL);
        if (brief)
-               print_linkinfo_brief(NULL, answer, stdout, NULL);
+               print_linkinfo_brief(NULL, answer, stdout);
        else
                print_linkinfo(NULL, answer, stdout);
        close_json_object();