[PATCH 3/3] kernel: 5.10: simplify logic in packet mangling patch
Mathias Kresin
dev at kresin.me
Sat Oct 23 12:14:04 PDT 2021
I had quite a hard time to understand what the change to net/core/dev.c
is supposed to do.
Simplify the change by returning NETDEV_TX_OK in case a eth_mangle_tx
callback was set but returned NULL instead of setting the return value
in the else branch.
Signed-off-by: Mathias Kresin <dev at kresin.me>
---
.../721-net-add-packet-mangeling.patch | 29 +++++--------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch b/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch
index f656472ef9..26ed829363 100644
--- a/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch
+++ b/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch
@@ -105,33 +105,18 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
help
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -3638,11 +3638,21 @@ static int xmit_one(struct sk_buff *skb,
+@@ -3638,6 +3638,11 @@ static int xmit_one(struct sk_buff *skb,
if (dev_nit_active(dev))
dev_queue_xmit_nit(skb, dev);
-- len = skb->len;
-- PRANDOM_ADD_NOISE(skb, dev, txq, len + jiffies);
-- trace_net_dev_start_xmit(skb, dev);
-- rc = netdev_start_xmit(skb, dev, txq, more);
-- trace_net_dev_xmit(skb, rc, dev, len);
+#ifdef CONFIG_ETHERNET_PACKET_MANGLE
-+ if (!dev->eth_mangle_tx ||
-+ (skb = dev->eth_mangle_tx(dev, skb)) != NULL)
-+#else
-+ if (1)
++ if (dev->eth_mangle_tx && !(skb = dev->eth_mangle_tx(dev, skb)))
++ return NETDEV_TX_OK;
+#endif
-+ {
-+ len = skb->len;
-+ PRANDOM_ADD_NOISE(skb, dev, txq, len + jiffies);
-+ trace_net_dev_start_xmit(skb, dev);
-+ rc = netdev_start_xmit(skb, dev, txq, more);
-+ trace_net_dev_xmit(skb, rc, dev, len);
-+ } else {
-+ rc = NETDEV_TX_OK;
-+ }
-
- return rc;
- }
++
+ len = skb->len;
+ PRANDOM_ADD_NOISE(skb, dev, txq, len + jiffies);
+ trace_net_dev_start_xmit(skb, dev);
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -60,6 +60,7 @@
--
2.25.1
More information about the openwrt-devel
mailing list