net: use DEV_STATS_xxx() helpers in virtio_net and l2tp_eth
Subsystems (4)
cover net: use DEV_STATS_xxx() helpers in virtio_net and l2tp_eth
Inspired by another (minor) KCSAN syzbot report. Both virtio_net and l2tp_eth can use DEV_STATS_xxx() helpers.
Eric Dumazet (3):
net: add DEV_STATS_READ() helper
virtio_net: avoid data-races on dev->stats fields
net: l2tp_eth: use generic dev->stats fields
drivers/net/macsec.c | 6 +++--- drivers/net/virtio_net.c | 30 +++++++++++++++--------------- include/linux/netdevice.h | 1 + net/l2tp/l2tp_eth.c | 32 ++++++++++++-------------------- 4 files changed, 31 insertions(+), 38 deletions(-)
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 1/3 net: add DEV_STATS_READ() helper
Companion of DEV_STATS_INC() & DEV_STATS_ADD().
This is going to be used in the series.
Use it in macsec_get_stats64().
--- drivers/net/macsec.c | 6 +++--- include/linux/netdevice.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/macsec.c +3 -3
@@ -3656,9 +3656,9 @@ static void macsec_get_stats64(struct net_device *dev,dev_fetch_sw_netstats (s, dev->tstats); - s->rx_dropped =atomic_long_read (&dev->stats.__rx_dropped); - s->tx_dropped =atomic_long_read (&dev->stats.__tx_dropped); - s->rx_errors =atomic_long_read (&dev->stats.__rx_errors); + s->rx_dropped =DEV_STATS_READ (dev, rx_dropped); + s->tx_dropped =DEV_STATS_READ (dev, tx_dropped); + s->rx_errors =DEV_STATS_READ (dev, rx_errors); }static int macsec_get_iflink (const struct net_device *dev)
include/linux/netdevice.h +1 -0
@@ -5214,5 +5214,6 @@ extern struct net_device *blackhole_netdev;#define DEV_STATS_INC (DEV ,FIELD ) atomic_long_inc(&(DEV)->stats.__##FIELD)#define DEV_STATS_ADD (DEV ,FIELD ,VAL ) \ atomic_long_add((VAL), &(DEV)->stats.__##FIELD) +#define DEV_STATS_READ (DEV ,FIELD ) atomic_long_read(&(DEV)->stats.__##FIELD)#endif /* _LINUX_NETDEVICE_H */
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 2/3 virtio_net: avoid data-races on dev->stats fields
In reply to Eric DumazetUse DEV_STATS_INC() and DEV_STATS_READ() which provide atomicity on paths that can be used concurrently.
--- drivers/net/virtio_net.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/virtio_net.c +15 -15
@@ -1085,7 +1085,7 @@ static struct sk_buff *receive_small(struct net_device *dev,if (unlikely (len >GOOD_PACKET_LEN )) {pr_debug ("%s: rx error: len %u exceeds max size %d\n" , dev->name, len,GOOD_PACKET_LEN ); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err; }
@@ -1150,7 +1150,7 @@ static void mergeable_buf_free(struct receive_queue *rq, int num_buf,if (unlikely (!buf)) {pr_debug ("%s: rx error: %d buffers missing\n" , dev->name, num_buf); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors);break ; } stats->bytes += len;
@@ -1259,7 +1259,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,pr_debug ("%s: rx error: %d buffers out of %d missing\n" , dev->name, *num_buf,virtio16_to_cpu (vi->vdev, hdr->num_buffers)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err; }
@@ -1278,7 +1278,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,put_page (page);pr_debug ("%s: rx error: len %u exceeds truesize %lu\n" , dev->name, len, (unsigned long )(truesize - room)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err; }
@@ -1457,7 +1457,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,if (unlikely (len > truesize - room)) {pr_debug ("%s: rx error: len %u exceeds truesize %lu\n" , dev->name, len, (unsigned long )(truesize - room)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err_skb; }
@@ -1489,7 +1489,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, dev->name, num_buf,virtio16_to_cpu (vi->vdev, hdr->num_buffers)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err_buf; }
@@ -1503,7 +1503,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,if (unlikely (len > truesize - room)) {pr_debug ("%s: rx error: len %u exceeds truesize %lu\n" , dev->name, len, (unsigned long )(truesize - room)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err_skb; }
@@ -1590,7 +1590,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,if (unlikely (len < vi->hdr_len +ETH_HLEN )) {pr_debug ("%s: short packet %i\n" , dev->name, len); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors);virtnet_rq_free_unused_buf (rq->vq, buf);return ; }
@@ -1630,7 +1630,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,return ; frame_err: - dev->stats.rx_frame_errors++; +DEV_STATS_INC (dev, rx_frame_errors);dev_kfree_skb (skb); }
@@ -2170,12 +2170,12 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)/* This should not happen! */ if (unlikely (err)) { - dev->stats.tx_fifo_errors++; +DEV_STATS_INC (dev, tx_fifo_errors);if (net_ratelimit ())dev_warn (&dev->dev,"Unexpected TXQ (%d) queue failure: %d\n" , qnum, err); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);dev_kfree_skb_any (skb);return NETDEV_TX_OK ; }
@@ -2394,10 +2394,10 @@ static void virtnet_stats(struct net_device *dev, tot->tx_errors += terrors; } - tot->tx_dropped = dev->stats.tx_dropped; - tot->tx_fifo_errors = dev->stats.tx_fifo_errors; - tot->rx_length_errors = dev->stats.rx_length_errors; - tot->rx_frame_errors = dev->stats.rx_frame_errors; + tot->tx_dropped =DEV_STATS_READ (dev, tx_dropped); + tot->tx_fifo_errors =DEV_STATS_READ (dev, tx_fifo_errors); + tot->rx_length_errors =DEV_STATS_READ (dev, rx_length_errors); + tot->rx_frame_errors =DEV_STATS_READ (dev, rx_frame_errors); }static void virtnet_ack_link_announce (struct virtnet_info *vi)
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Re: [PATCH net-next 2/3] virtio_net: avoid data-races on dev->stats fields
Quoted 5 lines · Eric Dumazet
Use
DEV_STATS_INC()andDEV_STATS_READ()which provide atomicity on paths that can be used concurrently.Reported-by syzbot <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Quoted 125 lines
Cc "Michael S. Tsirkin" <[email protected]>Cc Jason Wang <[email protected]>Cc Xuan Zhuo <[email protected]>--- drivers/net/virtio_net.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)drivers/net/virtio_net.c +15
-16@@ -1085,7 +1085,7 @@ static struct sk_buff *receive_small(struct net_device *dev,if (unlikely (len >GOOD_PACKET_LEN )) {pr_debug ("%s: rx error: len %u exceeds max size %d\n" , dev->name, len,GOOD_PACKET_LEN ); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err; }@@ -1150,7 +1150,7 @@ static void mergeable_buf_free(struct receive_queue *rq, int num_buf,if (unlikely (!buf)) {pr_debug ("%s: rx error: %d buffers missing\n" , dev->name, num_buf); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors);break ; } stats->bytes += len;@@ -1259,7 +1259,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,pr_debug ("%s: rx error: %d buffers out of %d missing\n" , dev->name, *num_buf,virtio16_to_cpu (vi->vdev, hdr->num_buffers)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err; }@@ -1278,7 +1278,7 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,put_page (page);pr_debug ("%s: rx error: len %u exceeds truesize %lu\n" , dev->name, len, (unsigned long )(truesize - room)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err; }@@ -1457,7 +1457,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,if (unlikely (len > truesize - room)) {pr_debug ("%s: rx error: len %u exceeds truesize %lu\n" , dev->name, len, (unsigned long )(truesize - room)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err_skb; }@@ -1489,7 +1489,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, dev->name, num_buf,virtio16_to_cpu (vi->vdev, hdr->num_buffers)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err_buf; }@@ -1503,7 +1503,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,if (unlikely (len > truesize - room)) {pr_debug ("%s: rx error: len %u exceeds truesize %lu\n" , dev->name, len, (unsigned long )(truesize - room)); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors); goto err_skb; }@@ -1590,7 +1590,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,if (unlikely (len < vi->hdr_len +ETH_HLEN )) {pr_debug ("%s: short packet %i\n" , dev->name, len); - dev->stats.rx_length_errors++; +DEV_STATS_INC (dev, rx_length_errors);virtnet_rq_free_unused_buf (rq->vq, buf);return ; }@@ -1630,7 +1630,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,return ; frame_err: - dev->stats.rx_frame_errors++; +DEV_STATS_INC (dev, rx_frame_errors);dev_kfree_skb (skb); }@@ -2170,12 +2170,12 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)/* This should not happen! */ if (unlikely (err)) { - dev->stats.tx_fifo_errors++; +DEV_STATS_INC (dev, tx_fifo_errors);if (net_ratelimit ())dev_warn (&dev->dev,"Unexpected TXQ (%d) queue failure: %d\n" , qnum, err); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);dev_kfree_skb_any (skb);return NETDEV_TX_OK ; }@@ -2394,10 +2394,10 @@ static void virtnet_stats(struct net_device *dev, tot->tx_errors += terrors; } - tot->tx_dropped = dev->stats.tx_dropped; - tot->tx_fifo_errors = dev->stats.tx_fifo_errors; - tot->rx_length_errors = dev->stats.rx_length_errors; - tot->rx_frame_errors = dev->stats.rx_frame_errors; + tot->tx_dropped =DEV_STATS_READ (dev, tx_dropped); + tot->tx_fifo_errors =DEV_STATS_READ (dev, tx_fifo_errors); + tot->rx_length_errors =DEV_STATS_READ (dev, rx_length_errors); + tot->rx_frame_errors =DEV_STATS_READ (dev, rx_frame_errors); }static void virtnet_ack_link_announce (struct virtnet_info *vi) --2.42.0.rc1.204.g551eb34607-goog
PATCH 3/3 net: l2tp_eth: use generic dev->stats fields
In reply to Eric DumazetCore networking has opt-in atomic variant of dev->stats, simply use DEV_STATS_INC(), DEV_STATS_ADD() and DEV_STATS_READ().
--- net/l2tp/l2tp_eth.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
net/l2tp/l2tp_eth.c +12 -20
@@ -37,12 +37,6 @@/* via netdev_priv() */ struct l2tp_eth {struct l2tp_session *session; -atomic_long_t tx_bytes; -atomic_long_t tx_packets; -atomic_long_t tx_dropped; -atomic_long_t rx_bytes; -atomic_long_t rx_packets; -atomic_long_t rx_errors; };/* via l2tp_session_priv() */
@@ -79,10 +73,10 @@ static netdev_tx_t l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *devint ret =l2tp_xmit_skb (session, skb);if (likely (ret ==NET_XMIT_SUCCESS )) { -atomic_long_add (len, &priv->tx_bytes); -atomic_long_inc (&priv->tx_packets); +DEV_STATS_ADD (dev, tx_bytes, len); +DEV_STATS_INC (dev, tx_packets); }else { -atomic_long_inc (&priv->tx_dropped); +DEV_STATS_INC (dev, tx_dropped); }return NETDEV_TX_OK ; }
@@ -90,14 +84,12 @@ static netdev_tx_t l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *devstatic void l2tp_eth_get_stats64 (struct net_device *dev,struct rtnl_link_stats64 *stats) { -struct l2tp_eth *priv =netdev_priv (dev); - - stats->tx_bytes = (unsigned long )atomic_long_read (&priv->tx_bytes); - stats->tx_packets = (unsigned long )atomic_long_read (&priv->tx_packets); - stats->tx_dropped = (unsigned long )atomic_long_read (&priv->tx_dropped); - stats->rx_bytes = (unsigned long )atomic_long_read (&priv->rx_bytes); - stats->rx_packets = (unsigned long )atomic_long_read (&priv->rx_packets); - stats->rx_errors = (unsigned long )atomic_long_read (&priv->rx_errors); + stats->tx_bytes =DEV_STATS_READ (dev, tx_bytes); + stats->tx_packets =DEV_STATS_READ (dev, tx_packets); + stats->tx_dropped =DEV_STATS_READ (dev, tx_dropped); + stats->rx_bytes =DEV_STATS_READ (dev, rx_bytes); + stats->rx_packets =DEV_STATS_READ (dev, rx_packets); + stats->rx_errors =DEV_STATS_READ (dev, rx_errors); }static const struct net_device_ops l2tp_eth_netdev_ops = {
@@ -146,10 +138,10 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, priv =netdev_priv (dev);if (dev_forward_skb (dev, skb) ==NET_RX_SUCCESS ) { -atomic_long_inc (&priv->rx_packets); -atomic_long_add (data_len, &priv->rx_bytes); +DEV_STATS_INC (dev, rx_packets); +DEV_STATS_ADD (dev, rx_bytes, data_len); }else { -atomic_long_inc (&priv->rx_errors); +DEV_STATS_INC (dev, rx_errors); }rcu_read_unlock ();
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Simon Horman
reviewerRe: [PATCH net-next 3/3] net: l2tp_eth: use generic dev->stats fields
Quoted 9 lines · Eric Dumazet
Core networking has opt-in atomic variant of
dev->stats, simply useDEV_STATS_INC(),DEV_STATS_ADD()andDEV_STATS_READ().Signed-off-by Eric Dumazet <[email protected]>--- net/l2tp/l2tp_eth.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)net/l2tp/l2tp_eth.c +0
-0
...
net/l2tp/l2tp_eth.c static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, · line 142
Quoted 8 lines
net/l2tp/l2tp_eth.c +2
-2@@ -146,10 +138,10 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, priv =netdev_priv (dev);if (dev_forward_skb (dev, skb) ==NET_RX_SUCCESS ) { -atomic_long_inc (&priv->rx_packets); -atomic_long_add (data_len, &priv->rx_bytes); +DEV_STATS_INC (dev, rx_packets); +DEV_STATS_ADD (dev, rx_bytes, data_len);
Hi Eric,
W=1 builds with clang-16 and gcc-13 tell me that priv is set but unused if this branch is taken.
Quoted 10 lines
net/l2tp/l2tp_eth.c +1
-1}else { -atomic_long_inc (&priv->rx_errors); +DEV_STATS_INC (dev, rx_errors); }rcu_read_unlock ();Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Re: [PATCH net-next 3/3] net: l2tp_eth: use generic dev->stats fields
Quoted 25 lines · Simon Horman
Quoted 9 lines · Eric Dumazet
Core networking has opt-in atomic variant of
dev->stats, simply useDEV_STATS_INC(),DEV_STATS_ADD()andDEV_STATS_READ().Signed-off-by Eric Dumazet <[email protected]>--- net/l2tp/l2tp_eth.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)net/l2tp/l2tp_eth.c +0
-0...
net/l2tp/l2tp_eth.c static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, · line 142
Quoted 8 lines
net/l2tp/l2tp_eth.c +2
-2@@ -146,10 +138,10 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, priv =netdev_priv (dev);if (dev_forward_skb (dev, skb) ==NET_RX_SUCCESS ) { -atomic_long_inc (&priv->rx_packets); -atomic_long_add (data_len, &priv->rx_bytes); +DEV_STATS_INC (dev, rx_packets); +DEV_STATS_ADD (dev, rx_bytes, data_len);Hi Eric,
Quoted 2 lines
W=1 builds with clang-16 and gcc-13 tell me that priv is set but unused if this branch is taken.
Oops, thanks, will fix in V2.
kernel test robot
build botRe: [PATCH net-next 3/3] net: l2tp_eth: use generic dev->stats fields
In reply to Eric Dumazetkernel test robot noticed the following build warnings:
Hi Eric,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-add-DEV_STATS_READ-helper/20230821-110051 base: net-next/main patch link: https://lore.kernel.org/r/20230819044059.833749-4-edumazet%40google.com patch subject: [PATCH net-next 3/3] net: l2tp_eth: use generic dev->stats fields config: i386-randconfig-015-20230822 (https://download.01.org/0day-ci/archive/20230822/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce: (https://download.01.org/0day-ci/archive/20230822/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> net/l2tp/l2tp_eth.c:121:19: warning: variable 'priv' set but not used [-Wunused-but-set-variable]
struct l2tp_eth *priv;
^1 warning generated.
vim +/priv +121 net/l2tp/l2tp_eth.c
d9e31d17ceba5f James Chapman 2010-04-02 116
d9e31d17ceba5f James Chapman 2010-04-02 117 static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
d9e31d17ceba5f James Chapman 2010-04-02 118 {
d9e31d17ceba5f James Chapman 2010-04-02 119 struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
ee28de6bbd78c2 Guillaume Nault 2017-10-27 120 struct net_device *dev;
ee28de6bbd78c2 Guillaume Nault 2017-10-27 @121 struct l2tp_eth *priv;
d9e31d17ceba5f James Chapman 2010-04-02 122
c0cc88a7627c33 Eric Dumazet 2012-09-04 123 if (!pskb_may_pull(skb, ETH_HLEN))
d9e31d17ceba5f James Chapman 2010-04-02 124 goto error;
d9e31d17ceba5f James Chapman 2010-04-02 125
d9e31d17ceba5f James Chapman 2010-04-02 126 secpath_reset(skb);
d9e31d17ceba5f James Chapman 2010-04-02 127
d9e31d17ceba5f James Chapman 2010-04-02 128 /* checksums verified by L2TP */
d9e31d17ceba5f James Chapman 2010-04-02 129 skb->ip_summed = CHECKSUM_NONE;
d9e31d17ceba5f James Chapman 2010-04-02 130
d9e31d17ceba5f James Chapman 2010-04-02 131 skb_dst_drop(skb);
895b5c9f206eb7 Florian Westphal 2019-09-29 132 nf_reset_ct(skb);
d9e31d17ceba5f James Chapman 2010-04-02 133
ee28de6bbd78c2 Guillaume Nault 2017-10-27 134 rcu_read_lock();
ee28de6bbd78c2 Guillaume Nault 2017-10-27 135 dev = rcu_dereference(spriv->dev);
ee28de6bbd78c2 Guillaume Nault 2017-10-27 136 if (!dev)
ee28de6bbd78c2 Guillaume Nault 2017-10-27 137 goto error_rcu;
ee28de6bbd78c2 Guillaume Nault 2017-10-27 138
ee28de6bbd78c2 Guillaume Nault 2017-10-27 139 priv = netdev_priv(dev);
d9e31d17ceba5f James Chapman 2010-04-02 140 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
b9494cd37a920d Eric Dumazet 2023-08-19 141 DEV_STATS_INC(dev, rx_packets);
b9494cd37a920d Eric Dumazet 2023-08-19 142 DEV_STATS_ADD(dev, rx_bytes, data_len);
a2842a1e663297 Eric Dumazet 2012-06-25 143 } else {
b9494cd37a920d Eric Dumazet 2023-08-19 144 DEV_STATS_INC(dev, rx_errors);
a2842a1e663297 Eric Dumazet 2012-06-25 145 }
ee28de6bbd78c2 Guillaume Nault 2017-10-27 146 rcu_read_unlock();
ee28de6bbd78c2 Guillaume Nault 2017-10-27 147
d9e31d17ceba5f James Chapman 2010-04-02 148 return;
d9e31d17ceba5f James Chapman 2010-04-02 149
ee28de6bbd78c2 Guillaume Nault 2017-10-27 150 error_rcu:
ee28de6bbd78c2 Guillaume Nault 2017-10-27 151 rcu_read_unlock();
d9e31d17ceba5f James Chapman 2010-04-02 152 error:
d9e31d17ceba5f James Chapman 2010-04-02 153 kfree_skb(skb);
d9e31d17ceba5f James Chapman 2010-04-02 154 }
d9e31d17ceba5f James Chapman 2010-04-02 155 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next 3/3] net: l2tp_eth: use generic dev->stats fields
In reply to Eric Dumazetkernel test robot noticed the following build warnings:
Hi Eric,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-add-DEV_STATS_READ-helper/20230821-110051 base: net-next/main patch link: https://lore.kernel.org/r/20230819044059.833749-4-edumazet%40google.com patch subject: [PATCH net-next 3/3] net: l2tp_eth: use generic dev->stats fields config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20230822/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230822/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
net/l2tp/l2tp_eth.c: In function 'l2tp_eth_dev_recv':
>> net/l2tp/l2tp_eth.c:121:26: warning: variable 'priv' set but not used [-Wunused-but-set-variable]
121 | struct l2tp_eth *priv;
| ^~~~vim +/priv +121 net/l2tp/l2tp_eth.c
d9e31d17ceba5f James Chapman 2010-04-02 116
d9e31d17ceba5f James Chapman 2010-04-02 117 static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
d9e31d17ceba5f James Chapman 2010-04-02 118 {
d9e31d17ceba5f James Chapman 2010-04-02 119 struct l2tp_eth_sess *spriv = l2tp_session_priv(session);
ee28de6bbd78c2 Guillaume Nault 2017-10-27 120 struct net_device *dev;
ee28de6bbd78c2 Guillaume Nault 2017-10-27 @121 struct l2tp_eth *priv;
d9e31d17ceba5f James Chapman 2010-04-02 122
c0cc88a7627c33 Eric Dumazet 2012-09-04 123 if (!pskb_may_pull(skb, ETH_HLEN))
d9e31d17ceba5f James Chapman 2010-04-02 124 goto error;
d9e31d17ceba5f James Chapman 2010-04-02 125
d9e31d17ceba5f James Chapman 2010-04-02 126 secpath_reset(skb);
d9e31d17ceba5f James Chapman 2010-04-02 127
d9e31d17ceba5f James Chapman 2010-04-02 128 /* checksums verified by L2TP */
d9e31d17ceba5f James Chapman 2010-04-02 129 skb->ip_summed = CHECKSUM_NONE;
d9e31d17ceba5f James Chapman 2010-04-02 130
d9e31d17ceba5f James Chapman 2010-04-02 131 skb_dst_drop(skb);
895b5c9f206eb7 Florian Westphal 2019-09-29 132 nf_reset_ct(skb);
d9e31d17ceba5f James Chapman 2010-04-02 133
ee28de6bbd78c2 Guillaume Nault 2017-10-27 134 rcu_read_lock();
ee28de6bbd78c2 Guillaume Nault 2017-10-27 135 dev = rcu_dereference(spriv->dev);
ee28de6bbd78c2 Guillaume Nault 2017-10-27 136 if (!dev)
ee28de6bbd78c2 Guillaume Nault 2017-10-27 137 goto error_rcu;
ee28de6bbd78c2 Guillaume Nault 2017-10-27 138
ee28de6bbd78c2 Guillaume Nault 2017-10-27 139 priv = netdev_priv(dev);
d9e31d17ceba5f James Chapman 2010-04-02 140 if (dev_forward_skb(dev, skb) == NET_RX_SUCCESS) {
b9494cd37a920d Eric Dumazet 2023-08-19 141 DEV_STATS_INC(dev, rx_packets);
b9494cd37a920d Eric Dumazet 2023-08-19 142 DEV_STATS_ADD(dev, rx_bytes, data_len);
a2842a1e663297 Eric Dumazet 2012-06-25 143 } else {
b9494cd37a920d Eric Dumazet 2023-08-19 144 DEV_STATS_INC(dev, rx_errors);
a2842a1e663297 Eric Dumazet 2012-06-25 145 }
ee28de6bbd78c2 Guillaume Nault 2017-10-27 146 rcu_read_unlock();
ee28de6bbd78c2 Guillaume Nault 2017-10-27 147
d9e31d17ceba5f James Chapman 2010-04-02 148 return;
d9e31d17ceba5f James Chapman 2010-04-02 149
ee28de6bbd78c2 Guillaume Nault 2017-10-27 150 error_rcu:
ee28de6bbd78c2 Guillaume Nault 2017-10-27 151 rcu_read_unlock();
d9e31d17ceba5f James Chapman 2010-04-02 152 error:
d9e31d17ceba5f James Chapman 2010-04-02 153 kfree_skb(skb);
d9e31d17ceba5f James Chapman 2010-04-02 154 }
d9e31d17ceba5f James Chapman 2010-04-02 155 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki