]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ipvlan: properly track tx_errors
authorEric Dumazet <edumazet@google.com>
Thu, 26 Oct 2023 13:14:46 +0000 (13:14 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:08:16 +0000 (11:08 +0100)
[ Upstream commit ff672b9ffeb3f82135488ac16c5c5eb4b992999b ]

Both ipvlan_process_v4_outbound() and ipvlan_process_v6_outbound()
increment dev->stats.tx_errors in case of errors.

Unfortunately there are two issues :

1) ipvlan_get_stats64() does not propagate dev->stats.tx_errors to user.

2) Increments are not atomic. KCSAN would complain eventually.

Use DEV_STATS_INC() to not miss an update, and change ipvlan_get_stats64()
to copy the value back to user.

Fixes: 2ad7bf363841 ("ipvlan: Initial check-in of the IPVLAN driver.")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Mahesh Bandewar <maheshb@google.com>
Link: https://lore.kernel.org/r/20231026131446.3933175-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ipvlan/ipvlan_core.c
drivers/net/ipvlan/ipvlan_main.c

index e10cb98b0f4f507c0978d058e4f200f62741f6f5..905542df3b682793dc23fd8490c9fb89d6bd5f70 100644 (file)
@@ -442,12 +442,12 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
 
        err = ip_local_out(net, skb->sk, skb);
        if (unlikely(net_xmit_eval(err)))
-               dev->stats.tx_errors++;
+               DEV_STATS_INC(dev, tx_errors);
        else
                ret = NET_XMIT_SUCCESS;
        goto out;
 err:
-       dev->stats.tx_errors++;
+       DEV_STATS_INC(dev, tx_errors);
        kfree_skb(skb);
 out:
        return ret;
@@ -483,12 +483,12 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb)
 
        err = ip6_local_out(net, skb->sk, skb);
        if (unlikely(net_xmit_eval(err)))
-               dev->stats.tx_errors++;
+               DEV_STATS_INC(dev, tx_errors);
        else
                ret = NET_XMIT_SUCCESS;
        goto out;
 err:
-       dev->stats.tx_errors++;
+       DEV_STATS_INC(dev, tx_errors);
        kfree_skb(skb);
 out:
        return ret;
index c199f0b465cd013d7ede78d88aee46aa614a69c8..8660d452f642b99a885e0c7e36790dac404df8e7 100644 (file)
@@ -324,6 +324,7 @@ static void ipvlan_get_stats64(struct net_device *dev,
                s->rx_dropped = rx_errs;
                s->tx_dropped = tx_drps;
        }
+       s->tx_errors = DEV_STATS_READ(dev, tx_errors);
 }
 
 static int ipvlan_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)