netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset
@ 2018-09-27 23:00 Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 02/11] net: inet_rtm_getroute() " Maciej Żenczykowski
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv4/route.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index dce2ed66ebe1..02482b71498b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1217,18 +1217,15 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt)
 		src = ip_hdr(skb)->saddr;
 	else {
 		struct fib_result res;
-		struct flowi4 fl4;
-		struct iphdr *iph;
-
-		iph = ip_hdr(skb);
-
-		memset(&fl4, 0, sizeof(fl4));
-		fl4.daddr = iph->daddr;
-		fl4.saddr = iph->saddr;
-		fl4.flowi4_tos = RT_TOS(iph->tos);
-		fl4.flowi4_oif = rt->dst.dev->ifindex;
-		fl4.flowi4_iif = skb->dev->ifindex;
-		fl4.flowi4_mark = skb->mark;
+		struct iphdr *iph = ip_hdr(skb);
+		struct flowi4 fl4 = {
+			.daddr = iph->daddr,
+			.saddr = iph->saddr,
+			.flowi4_tos = RT_TOS(iph->tos),
+			.flowi4_oif = rt->dst.dev->ifindex,
+			.flowi4_iif = skb->dev->ifindex,
+			.flowi4_mark = skb->mark,
+		};
 
 		rcu_read_lock();
 		if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 02/11] net: inet_rtm_getroute() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 03/11] net: fib_multipath_hash() " Maciej Żenczykowski
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv4/route.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 02482b71498b..048919713f4e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2780,7 +2780,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 	struct rtable *rt = NULL;
 	struct sk_buff *skb;
 	struct rtmsg *rtm;
-	struct flowi4 fl4;
+	struct flowi4 fl4 = {};
 	__be32 dst = 0;
 	__be32 src = 0;
 	kuid_t uid;
@@ -2820,7 +2820,6 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 	if (!skb)
 		return -ENOBUFS;
 
-	memset(&fl4, 0, sizeof(fl4));
 	fl4.daddr = dst;
 	fl4.saddr = src;
 	fl4.flowi4_tos = rtm->rtm_tos;
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 03/11] net: fib_multipath_hash() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 02/11] net: inet_rtm_getroute() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-28 17:47   ` David Ahern
  2018-09-27 23:00 ` [PATCH 04/11] net: ip6_multipath_l3_keys() " Maciej Żenczykowski
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv4/route.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 048919713f4e..17953a52fbd0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1821,12 +1821,11 @@ static void ip_multipath_l3_keys(const struct sk_buff *skb,
 int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
 		       const struct sk_buff *skb, struct flow_keys *flkeys)
 {
-	struct flow_keys hash_keys;
+	struct flow_keys hash_keys = {};
 	u32 mhash;
 
 	switch (net->ipv4.sysctl_fib_multipath_hash_policy) {
 	case 0:
-		memset(&hash_keys, 0, sizeof(hash_keys));
 		hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
 		if (skb) {
 			ip_multipath_l3_keys(skb, &hash_keys);
@@ -1845,8 +1844,6 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
 			if (skb->l4_hash)
 				return skb_get_hash_raw(skb) >> 1;
 
-			memset(&hash_keys, 0, sizeof(hash_keys));
-
 			if (!flkeys) {
 				skb_flow_dissect_flow_keys(skb, &keys, flag);
 				flkeys = &keys;
@@ -1859,7 +1856,6 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
 			hash_keys.ports.dst = flkeys->ports.dst;
 			hash_keys.basic.ip_proto = flkeys->basic.ip_proto;
 		} else {
-			memset(&hash_keys, 0, sizeof(hash_keys));
 			hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
 			hash_keys.addrs.v4addrs.src = fl4->saddr;
 			hash_keys.addrs.v4addrs.dst = fl4->daddr;
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 04/11] net: ip6_multipath_l3_keys() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 02/11] net: inet_rtm_getroute() " Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 03/11] net: fib_multipath_hash() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-28 17:48   ` David Ahern
  2018-09-27 23:00 ` [PATCH 05/11] net: ip6_redirect() " Maciej Żenczykowski
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d28f83e01593..9cb024451fc5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1981,12 +1981,11 @@ static void ip6_multipath_l3_keys(const struct sk_buff *skb,
 u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
 		       const struct sk_buff *skb, struct flow_keys *flkeys)
 {
-	struct flow_keys hash_keys;
+	struct flow_keys hash_keys = {};
 	u32 mhash;
 
 	switch (ip6_multipath_hash_policy(net)) {
 	case 0:
-		memset(&hash_keys, 0, sizeof(hash_keys));
 		hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
 		if (skb) {
 			ip6_multipath_l3_keys(skb, &hash_keys, flkeys);
@@ -2006,8 +2005,6 @@ u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
 			if (skb->l4_hash)
 				return skb_get_hash_raw(skb) >> 1;
 
-			memset(&hash_keys, 0, sizeof(hash_keys));
-
                         if (!flkeys) {
 				skb_flow_dissect_flow_keys(skb, &keys, flag);
 				flkeys = &keys;
@@ -2019,7 +2016,6 @@ u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
 			hash_keys.ports.dst = flkeys->ports.dst;
 			hash_keys.basic.ip_proto = flkeys->basic.ip_proto;
 		} else {
-			memset(&hash_keys, 0, sizeof(hash_keys));
 			hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
 			hash_keys.addrs.v6addrs.src = fl6->saddr;
 			hash_keys.addrs.v6addrs.dst = fl6->daddr;
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 05/11] net: ip6_redirect() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (2 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 04/11] net: ip6_multipath_l3_keys() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 06/11] net: ip6_redirect_no_header() " Maciej Żenczykowski
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9cb024451fc5..e148d197d628 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2504,16 +2504,15 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark,
 {
 	const struct ipv6hdr *iph = (struct ipv6hdr *) skb->data;
 	struct dst_entry *dst;
-	struct flowi6 fl6;
-
-	memset(&fl6, 0, sizeof(fl6));
-	fl6.flowi6_iif = LOOPBACK_IFINDEX;
-	fl6.flowi6_oif = oif;
-	fl6.flowi6_mark = mark;
-	fl6.daddr = iph->daddr;
-	fl6.saddr = iph->saddr;
-	fl6.flowlabel = ip6_flowinfo(iph);
-	fl6.flowi6_uid = uid;
+	struct flowi6 fl6 = {
+		.flowi6_iif = LOOPBACK_IFINDEX,
+		.flowi6_oif = oif,
+		.flowi6_mark = mark,
+		.daddr = iph->daddr,
+		.saddr = iph->saddr,
+		.flowlabel = ip6_flowinfo(iph),
+		.flowi6_uid = uid,
+	};
 
 	dst = ip6_route_redirect(net, &fl6, skb, &ipv6_hdr(skb)->saddr);
 	rt6_do_redirect(dst, NULL, skb);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 06/11] net: ip6_redirect_no_header() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (3 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 05/11] net: ip6_redirect() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 07/11] net: remove 1 always zero parameter from ip6_redirect_no_header() Maciej Żenczykowski
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index e148d197d628..dd8c04f253d5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2526,15 +2526,14 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
 	const struct ipv6hdr *iph = ipv6_hdr(skb);
 	const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
 	struct dst_entry *dst;
-	struct flowi6 fl6;
-
-	memset(&fl6, 0, sizeof(fl6));
-	fl6.flowi6_iif = LOOPBACK_IFINDEX;
-	fl6.flowi6_oif = oif;
-	fl6.flowi6_mark = mark;
-	fl6.daddr = msg->dest;
-	fl6.saddr = iph->daddr;
-	fl6.flowi6_uid = sock_net_uid(net, NULL);
+	struct flowi6 fl6 = {
+		.flowi6_iif = LOOPBACK_IFINDEX,
+		.flowi6_oif = oif,
+		.flowi6_mark = mark,
+		.daddr = msg->dest,
+		.saddr = iph->daddr,
+		.flowi6_uid = sock_net_uid(net, NULL),
+	};
 
 	dst = ip6_route_redirect(net, &fl6, skb, &iph->saddr);
 	rt6_do_redirect(dst, NULL, skb);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 07/11] net: remove 1 always zero parameter from ip6_redirect_no_header()
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (4 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 06/11] net: ip6_redirect_no_header() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 08/11] net: ip6_update_pmtu() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(the parameter in question is mark)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 include/net/ip6_route.h | 3 +--
 net/ipv6/ndisc.c        | 2 +-
 net/ipv6/route.c        | 4 +---
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 7b9c82de11cc..cef186dbd2ce 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -165,8 +165,7 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, int oif,
 void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu);
 void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark,
 		  kuid_t uid);
-void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
-			    u32 mark);
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif);
 void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk);
 
 struct netlink_callback;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 0ec273997d1d..51863ada15a4 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1533,7 +1533,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 
 	if (!ndopts.nd_opts_rh) {
 		ip6_redirect_no_header(skb, dev_net(skb->dev),
-					skb->dev->ifindex, 0);
+					skb->dev->ifindex);
 		return;
 	}
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dd8c04f253d5..27f1260e053a 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2520,8 +2520,7 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark,
 }
 EXPORT_SYMBOL_GPL(ip6_redirect);
 
-void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
-			    u32 mark)
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif)
 {
 	const struct ipv6hdr *iph = ipv6_hdr(skb);
 	const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
@@ -2529,7 +2528,6 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
 	struct flowi6 fl6 = {
 		.flowi6_iif = LOOPBACK_IFINDEX,
 		.flowi6_oif = oif,
-		.flowi6_mark = mark,
 		.daddr = msg->dest,
 		.saddr = iph->daddr,
 		.flowi6_uid = sock_net_uid(net, NULL),
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 08/11] net: ip6_update_pmtu() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (5 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 07/11] net: remove 1 always zero parameter from ip6_redirect_no_header() Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 09/11] net: rtmsg_to_fib6_config() " Maciej Żenczykowski
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 27f1260e053a..a87b79574a91 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2345,15 +2345,14 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,
 {
 	const struct ipv6hdr *iph = (struct ipv6hdr *) skb->data;
 	struct dst_entry *dst;
-	struct flowi6 fl6;
-
-	memset(&fl6, 0, sizeof(fl6));
-	fl6.flowi6_oif = oif;
-	fl6.flowi6_mark = mark ? mark : IP6_REPLY_MARK(net, skb->mark);
-	fl6.daddr = iph->daddr;
-	fl6.saddr = iph->saddr;
-	fl6.flowlabel = ip6_flowinfo(iph);
-	fl6.flowi6_uid = uid;
+	struct flowi6 fl6 = {
+		.flowi6_oif = oif,
+		.flowi6_mark = mark ? mark : IP6_REPLY_MARK(net, skb->mark),
+		.daddr = iph->daddr,
+		.saddr = iph->saddr,
+		.flowlabel = ip6_flowinfo(iph),
+		.flowi6_uid = uid,
+	};
 
 	dst = ip6_route_output(net, NULL, &fl6);
 	if (!dst->error)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 09/11] net: rtmsg_to_fib6_config() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (6 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 08/11] net: ip6_update_pmtu() - use new style struct initializer instead of memset Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 10/11] net: rtm_to_fib6_config() " Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 11/11] net: inet6_rtm_getroute() " Maciej Żenczykowski
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a87b79574a91..b8fece1d6021 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3600,23 +3600,23 @@ static void rtmsg_to_fib6_config(struct net *net,
 				 struct in6_rtmsg *rtmsg,
 				 struct fib6_config *cfg)
 {
-	memset(cfg, 0, sizeof(*cfg));
+	*cfg = (struct fib6_config){
+		.fc_table = l3mdev_fib_table_by_index(net, rtmsg->rtmsg_ifindex) ?
+			 : RT6_TABLE_MAIN,
+		.fc_ifindex = rtmsg->rtmsg_ifindex,
+		.fc_metric = rtmsg->rtmsg_metric,
+		.fc_expires = rtmsg->rtmsg_info,
+		.fc_dst_len = rtmsg->rtmsg_dst_len,
+		.fc_src_len = rtmsg->rtmsg_src_len,
+		.fc_flags = rtmsg->rtmsg_flags,
+		.fc_type = rtmsg->rtmsg_type,
+
+		.fc_nlinfo.nl_net = net,
 
-	cfg->fc_table = l3mdev_fib_table_by_index(net, rtmsg->rtmsg_ifindex) ?
-			 : RT6_TABLE_MAIN;
-	cfg->fc_ifindex = rtmsg->rtmsg_ifindex;
-	cfg->fc_metric = rtmsg->rtmsg_metric;
-	cfg->fc_expires = rtmsg->rtmsg_info;
-	cfg->fc_dst_len = rtmsg->rtmsg_dst_len;
-	cfg->fc_src_len = rtmsg->rtmsg_src_len;
-	cfg->fc_flags = rtmsg->rtmsg_flags;
-	cfg->fc_type = rtmsg->rtmsg_type;
-
-	cfg->fc_nlinfo.nl_net = net;
-
-	cfg->fc_dst = rtmsg->rtmsg_dst;
-	cfg->fc_src = rtmsg->rtmsg_src;
-	cfg->fc_gateway = rtmsg->rtmsg_gateway;
+		.fc_dst = rtmsg->rtmsg_dst,
+		.fc_src = rtmsg->rtmsg_src,
+		.fc_gateway = rtmsg->rtmsg_gateway,
+	};
 }
 
 int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg)
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 10/11] net: rtm_to_fib6_config() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (7 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 09/11] net: rtmsg_to_fib6_config() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  2018-09-27 23:00 ` [PATCH 11/11] net: inet6_rtm_getroute() " Maciej Żenczykowski
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

(allows for better compiler optimization)

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b8fece1d6021..9aca81772c93 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4139,14 +4139,19 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	err = -EINVAL;
 	rtm = nlmsg_data(nlh);
-	memset(cfg, 0, sizeof(*cfg));
 
-	cfg->fc_table = rtm->rtm_table;
-	cfg->fc_dst_len = rtm->rtm_dst_len;
-	cfg->fc_src_len = rtm->rtm_src_len;
-	cfg->fc_flags = RTF_UP;
-	cfg->fc_protocol = rtm->rtm_protocol;
-	cfg->fc_type = rtm->rtm_type;
+	*cfg = (struct fib6_config){
+		.fc_table = rtm->rtm_table,
+		.fc_dst_len = rtm->rtm_dst_len,
+		.fc_src_len = rtm->rtm_src_len,
+		.fc_flags = RTF_UP,
+		.fc_protocol = rtm->rtm_protocol,
+		.fc_type = rtm->rtm_type,
+
+		.fc_nlinfo.portid = NETLINK_CB(skb).portid,
+		.fc_nlinfo.nlh = nlh,
+		.fc_nlinfo.nl_net = sock_net(skb->sk),
+	};
 
 	if (rtm->rtm_type == RTN_UNREACHABLE ||
 	    rtm->rtm_type == RTN_BLACKHOLE ||
@@ -4162,10 +4167,6 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	cfg->fc_flags |= (rtm->rtm_flags & RTNH_F_ONLINK);
 
-	cfg->fc_nlinfo.portid = NETLINK_CB(skb).portid;
-	cfg->fc_nlinfo.nlh = nlh;
-	cfg->fc_nlinfo.nl_net = sock_net(skb->sk);
-
 	if (tb[RTA_GATEWAY]) {
 		cfg->fc_gateway = nla_get_in6_addr(tb[RTA_GATEWAY]);
 		cfg->fc_flags |= RTF_GATEWAY;
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 11/11] net: inet6_rtm_getroute() - use new style struct initializer instead of memset
  2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
                   ` (8 preceding siblings ...)
  2018-09-27 23:00 ` [PATCH 10/11] net: rtm_to_fib6_config() " Maciej Żenczykowski
@ 2018-09-27 23:00 ` Maciej Żenczykowski
  9 siblings, 0 replies; 13+ messages in thread
From: Maciej Żenczykowski @ 2018-09-27 23:00 UTC (permalink / raw)
  To: Maciej Żenczykowski, David S . Miller; +Cc: netdev

From: Maciej Żenczykowski <maze@google.com>

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/route.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9aca81772c93..aca6a84de794 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4819,7 +4819,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 	struct rt6_info *rt;
 	struct sk_buff *skb;
 	struct rtmsg *rtm;
-	struct flowi6 fl6;
+	struct flowi6 fl6 = {};
 	bool fibmatch;
 
 	err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy,
@@ -4828,7 +4828,6 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 		goto errout;
 
 	err = -EINVAL;
-	memset(&fl6, 0, sizeof(fl6));
 	rtm = nlmsg_data(nlh);
 	fl6.flowlabel = ip6_make_flowinfo(rtm->rtm_tos, 0);
 	fibmatch = !!(rtm->rtm_flags & RTM_F_FIB_MATCH);
-- 
2.19.0.605.g01d371f741-goog

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 03/11] net: fib_multipath_hash() - use new style struct initializer instead of memset
  2018-09-27 23:00 ` [PATCH 03/11] net: fib_multipath_hash() " Maciej Żenczykowski
@ 2018-09-28 17:47   ` David Ahern
  0 siblings, 0 replies; 13+ messages in thread
From: David Ahern @ 2018-09-28 17:47 UTC (permalink / raw)
  To: Maciej Żenczykowski, Maciej Żenczykowski,
	David S . Miller; +Cc: netdev

On 9/27/18 5:00 PM, Maciej Żenczykowski wrote:
> From: Maciej Żenczykowski <maze@google.com>
> 
> Signed-off-by: Maciej Żenczykowski <maze@google.com>
> ---
>  net/ipv4/route.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 048919713f4e..17953a52fbd0 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -1821,12 +1821,11 @@ static void ip_multipath_l3_keys(const struct sk_buff *skb,
>  int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
>  		       const struct sk_buff *skb, struct flow_keys *flkeys)
>  {
> -	struct flow_keys hash_keys;
> +	struct flow_keys hash_keys = {};
>  	u32 mhash;
>  
>  	switch (net->ipv4.sysctl_fib_multipath_hash_policy) {
>  	case 0:
> -		memset(&hash_keys, 0, sizeof(hash_keys));
>  		hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
>  		if (skb) {
>  			ip_multipath_l3_keys(skb, &hash_keys);
> @@ -1845,8 +1844,6 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
>  			if (skb->l4_hash)
>  				return skb_get_hash_raw(skb) >> 1;
>  
> -			memset(&hash_keys, 0, sizeof(hash_keys));
> -
>  			if (!flkeys) {
>  				skb_flow_dissect_flow_keys(skb, &keys, flag);
>  				flkeys = &keys;
> @@ -1859,7 +1856,6 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
>  			hash_keys.ports.dst = flkeys->ports.dst;
>  			hash_keys.basic.ip_proto = flkeys->basic.ip_proto;
>  		} else {
> -			memset(&hash_keys, 0, sizeof(hash_keys));
>  			hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
>  			hash_keys.addrs.v4addrs.src = fl4->saddr;
>  			hash_keys.addrs.v4addrs.dst = fl4->daddr;
> 

NACK on this one.

This is the hot path and the memset was done right before use for least
overhead.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 04/11] net: ip6_multipath_l3_keys() - use new style struct initializer instead of memset
  2018-09-27 23:00 ` [PATCH 04/11] net: ip6_multipath_l3_keys() " Maciej Żenczykowski
@ 2018-09-28 17:48   ` David Ahern
  0 siblings, 0 replies; 13+ messages in thread
From: David Ahern @ 2018-09-28 17:48 UTC (permalink / raw)
  To: Maciej Żenczykowski, Maciej Żenczykowski,
	David S . Miller; +Cc: netdev

On 9/27/18 5:00 PM, Maciej Żenczykowski wrote:
> From: Maciej Żenczykowski <maze@google.com>
> 
> Signed-off-by: Maciej Żenczykowski <maze@google.com>
> ---
>  net/ipv6/route.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index d28f83e01593..9cb024451fc5 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1981,12 +1981,11 @@ static void ip6_multipath_l3_keys(const struct sk_buff *skb,
>  u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
>  		       const struct sk_buff *skb, struct flow_keys *flkeys)
>  {
> -	struct flow_keys hash_keys;
> +	struct flow_keys hash_keys = {};
>  	u32 mhash;
>  
>  	switch (ip6_multipath_hash_policy(net)) {
>  	case 0:
> -		memset(&hash_keys, 0, sizeof(hash_keys));
>  		hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
>  		if (skb) {
>  			ip6_multipath_l3_keys(skb, &hash_keys, flkeys);
> @@ -2006,8 +2005,6 @@ u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
>  			if (skb->l4_hash)
>  				return skb_get_hash_raw(skb) >> 1;
>  
> -			memset(&hash_keys, 0, sizeof(hash_keys));
> -
>                          if (!flkeys) {
>  				skb_flow_dissect_flow_keys(skb, &keys, flag);
>  				flkeys = &keys;
> @@ -2019,7 +2016,6 @@ u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
>  			hash_keys.ports.dst = flkeys->ports.dst;
>  			hash_keys.basic.ip_proto = flkeys->basic.ip_proto;
>  		} else {
> -			memset(&hash_keys, 0, sizeof(hash_keys));
>  			hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
>  			hash_keys.addrs.v6addrs.src = fl6->saddr;
>  			hash_keys.addrs.v6addrs.dst = fl6->daddr;
> 

ditto for this one.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-09-29  0:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-27 23:00 [PATCH 01/11] net: ip_rt_get_source() - use new style struct initializer instead of memset Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 02/11] net: inet_rtm_getroute() " Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 03/11] net: fib_multipath_hash() " Maciej Żenczykowski
2018-09-28 17:47   ` David Ahern
2018-09-27 23:00 ` [PATCH 04/11] net: ip6_multipath_l3_keys() " Maciej Żenczykowski
2018-09-28 17:48   ` David Ahern
2018-09-27 23:00 ` [PATCH 05/11] net: ip6_redirect() " Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 06/11] net: ip6_redirect_no_header() " Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 07/11] net: remove 1 always zero parameter from ip6_redirect_no_header() Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 08/11] net: ip6_update_pmtu() - use new style struct initializer instead of memset Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 09/11] net: rtmsg_to_fib6_config() " Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 10/11] net: rtm_to_fib6_config() " Maciej Żenczykowski
2018-09-27 23:00 ` [PATCH 11/11] net: inet6_rtm_getroute() " Maciej Żenczykowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).