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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1519155598-22137-8-git-send-email-serhe.popovych@gmail.com>
Date:   Tue, 20 Feb 2018 21:39:57 +0200
From:   Serhey Popovych <serhe.popovych@...il.com>
To:     netdev@...r.kernel.org
Cc:     dsahern@...il.com
Subject: [PATCH iproute2-next 7/8] iplink: Move data structures to block of their users

This will consolidate data and code using it in single place and prepare
for upcoming ->parse_opt() method change.

Signed-off-by: Serhey Popovych <serhe.popovych@...il.com>
---
 ip/link_gre.c    |   32 ++++++++++++++++----------------
 ip/link_gre6.c   |   32 ++++++++++++++++----------------
 ip/link_ip6tnl.c |   32 ++++++++++++++++----------------
 ip/link_iptnl.c  |   32 ++++++++++++++++----------------
 ip/link_vti.c    |   32 ++++++++++++++++----------------
 ip/link_vti6.c   |   32 ++++++++++++++++----------------
 6 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/ip/link_gre.c b/ip/link_gre.c
index 9c5457a..a43cf6a 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -66,22 +66,6 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
 static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 			 struct nlmsghdr *n)
 {
-	struct ifinfomsg *ifi = NLMSG_DATA(n);
-	struct {
-		struct nlmsghdr n;
-		struct ifinfomsg i;
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
-		.n.nlmsg_flags = NLM_F_REQUEST,
-		.n.nlmsg_type = RTM_GETLINK,
-		.i.ifi_family = preferred_family,
-		.i.ifi_index = ifi->ifi_index,
-	};
-	struct nlmsghdr *answer;
-	struct rtattr *tb[IFLA_MAX + 1];
-	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
-	struct rtattr *greinfo[IFLA_GRE_MAX + 1];
-	int len;
 	__u16 iflags = 0;
 	__u16 oflags = 0;
 	__be32 ikey = 0;
@@ -107,7 +91,23 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 	inet_prefix_reset(&daddr);
 
 	if (!(n->nlmsg_flags & NLM_F_CREATE)) {
+		struct ifinfomsg *ifi = NLMSG_DATA(n);
+		struct {
+			struct nlmsghdr n;
+			struct ifinfomsg i;
+		} req = {
+			.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
+			.n.nlmsg_flags = NLM_F_REQUEST,
+			.n.nlmsg_type = RTM_GETLINK,
+			.i.ifi_family = preferred_family,
+			.i.ifi_index = ifi->ifi_index,
+		};
+		struct nlmsghdr *answer;
+		struct rtattr *tb[IFLA_MAX + 1];
+		struct rtattr *linkinfo[IFLA_INFO_MAX+1];
+		struct rtattr *greinfo[IFLA_GRE_MAX + 1];
 		const struct rtattr *rta;
+		int len;
 
 		if (rtnl_talk(&rth, &req.n, &answer) < 0) {
 get_failed:
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 267f79e..d7e0d8e 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -77,22 +77,6 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
 static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 			 struct nlmsghdr *n)
 {
-	struct ifinfomsg *ifi = NLMSG_DATA(n);
-	struct {
-		struct nlmsghdr n;
-		struct ifinfomsg i;
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
-		.n.nlmsg_flags = NLM_F_REQUEST,
-		.n.nlmsg_type = RTM_GETLINK,
-		.i.ifi_family = preferred_family,
-		.i.ifi_index = ifi->ifi_index,
-	};
-	struct nlmsghdr *answer;
-	struct rtattr *tb[IFLA_MAX + 1];
-	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
-	struct rtattr *greinfo[IFLA_GRE_MAX + 1];
-	int len;
 	__u16 iflags = 0;
 	__u16 oflags = 0;
 	__be32 ikey = 0;
@@ -118,7 +102,23 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
 	inet_prefix_reset(&daddr);
 
 	if (!(n->nlmsg_flags & NLM_F_CREATE)) {
+		struct ifinfomsg *ifi = NLMSG_DATA(n);
+		struct {
+			struct nlmsghdr n;
+			struct ifinfomsg i;
+		} req = {
+			.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
+			.n.nlmsg_flags = NLM_F_REQUEST,
+			.n.nlmsg_type = RTM_GETLINK,
+			.i.ifi_family = preferred_family,
+			.i.ifi_index = ifi->ifi_index,
+		};
+		struct nlmsghdr *answer;
+		struct rtattr *tb[IFLA_MAX + 1];
+		struct rtattr *linkinfo[IFLA_INFO_MAX+1];
+		struct rtattr *greinfo[IFLA_GRE_MAX + 1];
 		const struct rtattr *rta;
+		int len;
 
 		if (rtnl_talk(&rth, &req.n, &answer) < 0) {
 get_failed:
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index c681c3a..bffccbd 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -77,22 +77,6 @@ static void ip6tunnel_print_help(struct link_util *lu, int argc, char **argv,
 static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
 			       struct nlmsghdr *n)
 {
-	struct ifinfomsg *ifi = NLMSG_DATA(n);
-	struct {
-		struct nlmsghdr n;
-		struct ifinfomsg i;
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
-		.n.nlmsg_flags = NLM_F_REQUEST,
-		.n.nlmsg_type = RTM_GETLINK,
-		.i.ifi_family = preferred_family,
-		.i.ifi_index = ifi->ifi_index,
-	};
-	struct nlmsghdr *answer;
-	struct rtattr *tb[IFLA_MAX + 1];
-	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
-	struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
-	int len;
 	inet_prefix saddr, daddr;
 	__u8 hop_limit = DEFAULT_TNL_HOP_LIMIT;
 	__u8 encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
@@ -111,7 +95,23 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
 	inet_prefix_reset(&daddr);
 
 	if (!(n->nlmsg_flags & NLM_F_CREATE)) {
+		struct ifinfomsg *ifi = NLMSG_DATA(n);
+		struct {
+			struct nlmsghdr n;
+			struct ifinfomsg i;
+		} req = {
+			.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
+			.n.nlmsg_flags = NLM_F_REQUEST,
+			.n.nlmsg_type = RTM_GETLINK,
+			.i.ifi_family = preferred_family,
+			.i.ifi_index = ifi->ifi_index,
+		};
+		struct nlmsghdr *answer;
+		struct rtattr *tb[IFLA_MAX + 1];
+		struct rtattr *linkinfo[IFLA_INFO_MAX+1];
+		struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
 		const struct rtattr *rta;
+		int len;
 
 		if (rtnl_talk(&rth, &req.n, &answer) < 0) {
 get_failed:
diff --git a/ip/link_iptnl.c b/ip/link_iptnl.c
index 636e216..6c49739 100644
--- a/ip/link_iptnl.c
+++ b/ip/link_iptnl.c
@@ -74,22 +74,6 @@ static void iptunnel_print_help(struct link_util *lu, int argc, char **argv,
 static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
 			      struct nlmsghdr *n)
 {
-	struct ifinfomsg *ifi = NLMSG_DATA(n);
-	struct {
-		struct nlmsghdr n;
-		struct ifinfomsg i;
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
-		.n.nlmsg_flags = NLM_F_REQUEST,
-		.n.nlmsg_type = RTM_GETLINK,
-		.i.ifi_family = preferred_family,
-		.i.ifi_index = ifi->ifi_index,
-	};
-	struct nlmsghdr *answer;
-	struct rtattr *tb[IFLA_MAX + 1];
-	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
-	struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
-	int len;
 	inet_prefix saddr, daddr, ip6rdprefix, ip6rdrelayprefix;
 	__u8 pmtudisc = 1;
 	__u8 tos = 0;
@@ -111,7 +95,23 @@ static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
 	inet_prefix_reset(&ip6rdrelayprefix);
 
 	if (!(n->nlmsg_flags & NLM_F_CREATE)) {
+		struct ifinfomsg *ifi = NLMSG_DATA(n);
+		struct {
+			struct nlmsghdr n;
+			struct ifinfomsg i;
+		} req = {
+			.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
+			.n.nlmsg_flags = NLM_F_REQUEST,
+			.n.nlmsg_type = RTM_GETLINK,
+			.i.ifi_family = preferred_family,
+			.i.ifi_index = ifi->ifi_index,
+		};
+		struct nlmsghdr *answer;
+		struct rtattr *tb[IFLA_MAX + 1];
+		struct rtattr *linkinfo[IFLA_INFO_MAX+1];
+		struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
 		const struct rtattr *rta;
+		int len;
 
 		if (rtnl_talk(&rth, &req.n, &answer) < 0) {
 get_failed:
diff --git a/ip/link_vti.c b/ip/link_vti.c
index 3d3a70a..1429f07 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -47,33 +47,33 @@ static void vti_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
 static int vti_parse_opt(struct link_util *lu, int argc, char **argv,
 			 struct nlmsghdr *n)
 {
-	struct ifinfomsg *ifi = NLMSG_DATA(n);
-	struct {
-		struct nlmsghdr n;
-		struct ifinfomsg i;
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
-		.n.nlmsg_flags = NLM_F_REQUEST,
-		.n.nlmsg_type = RTM_GETLINK,
-		.i.ifi_family = preferred_family,
-		.i.ifi_index = ifi->ifi_index,
-	};
-	struct nlmsghdr *answer;
-	struct rtattr *tb[IFLA_MAX + 1];
-	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
-	struct rtattr *vtiinfo[IFLA_VTI_MAX + 1];
 	__be32 ikey = 0;
 	__be32 okey = 0;
 	inet_prefix saddr, daddr;
 	unsigned int link = 0;
 	__u32 fwmark = 0;
-	int len;
 
 	inet_prefix_reset(&saddr);
 	inet_prefix_reset(&daddr);
 
 	if (!(n->nlmsg_flags & NLM_F_CREATE)) {
+		struct ifinfomsg *ifi = NLMSG_DATA(n);
+		struct {
+			struct nlmsghdr n;
+			struct ifinfomsg i;
+		} req = {
+			.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
+			.n.nlmsg_flags = NLM_F_REQUEST,
+			.n.nlmsg_type = RTM_GETLINK,
+			.i.ifi_family = preferred_family,
+			.i.ifi_index = ifi->ifi_index,
+		};
+		struct nlmsghdr *answer;
+		struct rtattr *tb[IFLA_MAX + 1];
+		struct rtattr *linkinfo[IFLA_INFO_MAX+1];
+		struct rtattr *vtiinfo[IFLA_VTI_MAX + 1];
 		const struct rtattr *rta;
+		int len;
 
 		if (rtnl_talk(&rth, &req.n, &answer) < 0) {
 get_failed:
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index 4c26e21..2956c0e 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -49,33 +49,33 @@ static void vti6_print_help(struct link_util *lu, int argc, char **argv,
 static int vti6_parse_opt(struct link_util *lu, int argc, char **argv,
 			  struct nlmsghdr *n)
 {
-	struct ifinfomsg *ifi = NLMSG_DATA(n);
-	struct {
-		struct nlmsghdr n;
-		struct ifinfomsg i;
-	} req = {
-		.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
-		.n.nlmsg_flags = NLM_F_REQUEST,
-		.n.nlmsg_type = RTM_GETLINK,
-		.i.ifi_family = preferred_family,
-		.i.ifi_index = ifi->ifi_index,
-	};
-	struct nlmsghdr *answer;
-	struct rtattr *tb[IFLA_MAX + 1];
-	struct rtattr *linkinfo[IFLA_INFO_MAX+1];
-	struct rtattr *vtiinfo[IFLA_VTI_MAX + 1];
 	__be32 ikey = 0;
 	__be32 okey = 0;
 	inet_prefix saddr, daddr;
 	unsigned int link = 0;
 	__u32 fwmark = 0;
-	int len;
 
 	inet_prefix_reset(&saddr);
 	inet_prefix_reset(&daddr);
 
 	if (!(n->nlmsg_flags & NLM_F_CREATE)) {
+		struct ifinfomsg *ifi = NLMSG_DATA(n);
+		struct {
+			struct nlmsghdr n;
+			struct ifinfomsg i;
+		} req = {
+			.n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
+			.n.nlmsg_flags = NLM_F_REQUEST,
+			.n.nlmsg_type = RTM_GETLINK,
+			.i.ifi_family = preferred_family,
+			.i.ifi_index = ifi->ifi_index,
+		};
+		struct nlmsghdr *answer;
+		struct rtattr *tb[IFLA_MAX + 1];
+		struct rtattr *linkinfo[IFLA_INFO_MAX+1];
+		struct rtattr *vtiinfo[IFLA_VTI_MAX + 1];
 		const struct rtattr *rta;
+		int len;
 
 		if (rtnl_talk(&rth, &req.n, &answer) < 0) {
 get_failed:
-- 
1.7.10.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ