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: <20221102021549.12213-1-linyunsheng@huawei.com>
Date:   Wed, 2 Nov 2022 10:15:49 +0800
From:   Yunsheng Lin <linyunsheng@...wei.com>
To:     <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <pabeni@...hat.com>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH net-next] ipvlan: minor optimization for ipvlan outbound process

Avoid some local variable initialization and remove some
redundant assignment in ipvlan outbound process.

Signed-off-by: Yunsheng Lin <linyunsheng@...wei.com>
---
 drivers/net/ipvlan/ipvlan_core.c | 56 +++++++++++++++-----------------
 1 file changed, 26 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index bb1c298c1e78..2b715035380b 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -417,7 +417,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
 	struct net_device *dev = skb->dev;
 	struct net *net = dev_net(dev);
 	struct rtable *rt;
-	int err, ret = NET_XMIT_DROP;
+	int err;
 	struct flowi4 fl4 = {
 		.flowi4_oif = dev->ifindex,
 		.flowi4_tos = RT_TOS(ip4h->tos),
@@ -438,15 +438,14 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
 	skb_dst_set(skb, &rt->dst);
 	err = ip_local_out(net, skb->sk, skb);
 	if (unlikely(net_xmit_eval(err)))
-		dev->stats.tx_errors++;
-	else
-		ret = NET_XMIT_SUCCESS;
-	goto out;
+		goto tx_errors_inc;
+
+	return NET_XMIT_SUCCESS;
 err:
-	dev->stats.tx_errors++;
 	kfree_skb(skb);
-out:
-	return ret;
+tx_errors_inc:
+	dev->stats.tx_errors++;
+	return NET_XMIT_DROP;
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
@@ -456,7 +455,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
 	struct net_device *dev = skb->dev;
 	struct net *net = dev_net(dev);
 	struct dst_entry *dst;
-	int err, ret = NET_XMIT_DROP;
+	int err;
 	struct flowi6 fl6 = {
 		.flowi6_oif = dev->ifindex,
 		.daddr = ip6h->daddr,
@@ -469,22 +468,23 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
 
 	dst = ip6_route_output(net, NULL, &fl6);
 	if (dst->error) {
-		ret = dst->error;
+		err = dst->error;
 		dst_release(dst);
 		goto err;
 	}
 	skb_dst_set(skb, dst);
 	err = ip6_local_out(net, skb->sk, skb);
-	if (unlikely(net_xmit_eval(err)))
-		dev->stats.tx_errors++;
-	else
-		ret = NET_XMIT_SUCCESS;
-	goto out;
+	if (unlikely(net_xmit_eval(err))) {
+		err = NET_XMIT_DROP;
+		goto tx_errors_inc;
+	}
+
+	return NET_XMIT_SUCCESS;
 err:
-	dev->stats.tx_errors++;
 	kfree_skb(skb);
-out:
-	return ret;
+tx_errors_inc:
+	dev->stats.tx_errors++;
+	return err;
 }
 #else
 static int ipvlan_process_v6_outbound(struct sk_buff *skb)
@@ -495,8 +495,6 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
 
 static int ipvlan_process_outbound(struct sk_buff *skb)
 {
-	int ret = NET_XMIT_DROP;
-
 	/* The ipvlan is a pseudo-L2 device, so the packets that we receive
 	 * will have L2; which need to discarded and processed further
 	 * in the net-ns of the main-device.
@@ -511,7 +509,7 @@ static int ipvlan_process_outbound(struct sk_buff *skb)
 				"Dropped {multi|broad}cast of type=[%x]\n",
 				ntohs(skb->protocol));
 			kfree_skb(skb);
-			goto out;
+			return NET_XMIT_DROP;
 		}
 
 		skb_pull(skb, sizeof(*ethh));
@@ -520,16 +518,14 @@ static int ipvlan_process_outbound(struct sk_buff *skb)
 	}
 
 	if (skb->protocol == htons(ETH_P_IPV6))
-		ret = ipvlan_process_v6_outbound(skb);
+		return ipvlan_process_v6_outbound(skb);
 	else if (skb->protocol == htons(ETH_P_IP))
-		ret = ipvlan_process_v4_outbound(skb);
-	else {
-		pr_warn_ratelimited("Dropped outbound packet type=%x\n",
-				    ntohs(skb->protocol));
-		kfree_skb(skb);
-	}
-out:
-	return ret;
+		return ipvlan_process_v4_outbound(skb);
+
+	pr_warn_ratelimited("Dropped outbound packet type=%x\n",
+			    ntohs(skb->protocol));
+	kfree_skb(skb);
+	return NET_XMIT_DROP;
 }
 
 static void ipvlan_multicast_enqueue(struct ipvl_port *port,
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ