From f7f12495bc9725e221b595680c47c4240d437abb Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sat, 23 Oct 2021 21:14:04 +0200 Subject: [PATCH] kernel: 5.10: simplify logic in packet mangling patch 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 --- .../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 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.30.2