Skip to contentSkip to conversation

net: wwan: iosm: fix netdev tx stats

PATCH Superseded M Chetan Kumar 3 participants 3 messages Jun 30, 2021 – Jul 1, 2021

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/5 net: wwan: iosm: fix netdev tx stats

Update tx stats on successful packet consume, drop.

---
 drivers/net/wwan/iosm/iosm_ipc_wwan.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wwan/iosm/iosm_ipc_wwan.c +4 -1
index 84e37c4b0f74..561944a33725 100644
@@ -123,6 +123,8 @@ static int ipc_wwan_link_transmit(struct sk_buff *skb,
 
 	/* Return code of zero is success */
 	if (ret == 0) {
+		netdev->stats.tx_packets++;
+		netdev->stats.tx_bytes += skb->len;
 		ret = NETDEV_TX_OK;
 	} else if (ret == -EBUSY) {
 		ret = NETDEV_TX_BUSY;
@@ -140,7 +142,8 @@ static int ipc_wwan_link_transmit(struct sk_buff *skb,
 			ret);
 
 	dev_kfree_skb_any(skb);
-	return ret;
+	netdev->stats.tx_dropped++;
+	return NETDEV_TX_OK;
 }
 
 /* Ops structure for wwan net link */
Signature · 1 line
2.25.1
#1 lore raw
Quoted 12 lines · M Chetan Kumar

Update tx stats on successful packet consume, drop.

---
 drivers/net/wwan/iosm/iosm_ipc_wwan.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wwan/iosm/iosm_ipc_wwan.c +0 -0
index 84e37c4b0f74..561944a33725 100644

drivers/net/wwan/iosm/iosm_ipc_wwan.c static int ipc_wwan_link_transmit(struct sk_buff *skb, · line 127

Quoted 5 lines
drivers/net/wwan/iosm/iosm_ipc_wwan.c +2 -0
@@ -123,6 +123,8 @@ static int ipc_wwan_link_transmit(struct sk_buff *skb,
 
 	/* Return code of zero is success */
 	if (ret == 0) {
+		netdev->stats.tx_packets++;
+		netdev->stats.tx_bytes += skb->len;

What makes you think skb has not been consumed already ?
It seems clear it has been given, this thread can not expect skb has not been mangled/freed. skb->len might now contain garbage, or even crash the kernel under appropriate debug features.

Quoted 14 lines
drivers/net/wwan/iosm/iosm_ipc_wwan.c +2 -1
 		ret = NETDEV_TX_OK;
 	} else if (ret == -EBUSY) {
 		ret = NETDEV_TX_BUSY;
@@ -140,7 +142,8 @@ static int ipc_wwan_link_transmit(struct sk_buff *skb,
 			ret);
 
 	dev_kfree_skb_any(skb);
-	return ret;
+	netdev->stats.tx_dropped++;
+	return NETDEV_TX_OK;
 }
 
 /* Ops structure for wwan net link */
#2 lore raw
Quoted 16 lines · Eric Dumazet
Quoted 13 lines · M Chetan Kumar

Update tx stats on successful packet consume, drop.

---
 drivers/net/wwan/iosm/iosm_ipc_wwan.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wwan/iosm/iosm_ipc_wwan.c +0 -0
index 84e37c4b0f74..561944a33725 100644
@@ -123,6 +123,8 @@ static int ipc_wwan_link_transmit(struct sk_buff *skb,
 
Quoted 8 lines

drivers/net/wwan/iosm/iosm_ipc_wwan.c static int ipc_wwan_link_transmit(struct sk_buff *skb, · line 127

Quoted 4 lines
drivers/net/wwan/iosm/iosm_ipc_wwan.c +2 -0
 	/* Return code of zero is success */
 	if (ret == 0) {
+		netdev->stats.tx_packets++;
+		netdev->stats.tx_bytes += skb->len;

What makes you think skb has not been consumed already ?
It seems clear it has been given, this thread can not expect skb has not been mangled/freed. skb->len might now contain garbage, or even crash the kernel under appropriate debug features.

Ya. there could be a possibility skb might have been dequeued from ul_list and UL task is already processing it. We can't rule out.

Will backup skb->len to local var and use it for tx_bytes update.

Regards,
Chetan