lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1517484352-2696-1-git-send-email-serhe.popovych@gmail.com>
Date:   Thu,  1 Feb 2018 13:25:52 +0200
From:   Serhey Popovych <serhe.popovych@...il.com>
To:     netdev@...r.kernel.org
Subject: [PATCH iproute2-next] Revert "ip address: Change print_linkinfo_brief to take filter as an input"

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@...il.com>
---
 ip/ip_common.h |    3 +--
 ip/ipaddress.c |   34 +++++++++++++++-------------------
 ip/iplink.c    |    2 +-
 3 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/ip/ip_common.h b/ip/ip_common.h
index 3203f0c..f5adbad 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -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,
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 051a05f..b18b6f4 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -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,
diff --git a/ip/iplink.c b/ip/iplink.c
index 230f4c5..882cd13 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -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();
-- 
1.7.10.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ