Skip to contentSkip to conversation

openvswitch: Fix double reporting of drops in dropwatch

PATCH Applied Mike Pattrick 2 participants 3 messages Aug 17, 2022 – Aug 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 openvswitch: Fix double reporting of drops in dropwatch

Frames sent to userspace can be reported as dropped in ovs_dp_process_packet, however, if they are dropped in the netlink code then netlink_attachskb will report the same frame as dropped.

This patch checks for error codes which indicate that the frame has already been freed.

---
Changes in v2:
- Corrected bugzilla link

---
 net/openvswitch/datapath.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
net/openvswitch/datapath.c +10 -3
index 7e8a39a35627..ca22aa73c6e0 100644
@@ -252,10 +252,17 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
 
 		upcall.mru = OVS_CB(skb)->mru;
 		error = ovs_dp_upcall(dp, skb, key, &upcall, 0);
-		if (unlikely(error))
-			kfree_skb(skb);
-		else
+		switch (error) {
+		case 0:
+		case -EAGAIN:
+		case -ERESTARTSYS:
+		case -EINTR:
 			consume_skb(skb);
+			break;
+		default:
+			kfree_skb(skb);
+			break;
+		}
 		stats_counter = &stats->n_missed;
 		goto out;
 	}
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 2/2 openvswitch: Fix overreporting of drops in dropwatch

Currently queue_userspace_packet will call kfree_skb for all frames, whether or not an error occurred. This can result in a single dropped frame being reported as multiple drops in dropwatch. This functions caller may also call kfree_skb in case of an error. This patch will consume the skbs instead and allow caller's to use kfree_skb.

---
Changes in v2:
- Corrected bugzilla link

---
 net/openvswitch/datapath.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/datapath.c +3 -2
index ca22aa73c6e0..45f9a7b3410e 100644
@@ -558,8 +558,9 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 out:
 	if (err)
 		skb_tx_error(skb);
-	kfree_skb(user_skb);
-	kfree_skb(nskb);
+	consume_skb(user_skb);
+	consume_skb(nskb);
+
 	return err;
 }
 
Signature · 1 line
2.31.1
#2 lore raw
In reply to Mike Pattrick
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 8 lines · On Wed, 17 Aug 2022 11:06:34 -0400 you wrote:

Frames sent to userspace can be reported as dropped in ovs_dp_process_packet, however, if they are dropped in the netlink code then netlink_attachskb will report the same frame as dropped.

This patch checks for error codes which indicate that the frame has already been freed.

[...]

Here is the summary with links:
- [net-next,v2,1/2] openvswitch: Fix double reporting of drops in dropwatch

    https://git.kernel.org/netdev/net-next/c/1100248a5c5c
  - [net-next,v2,2/2] openvswitch: Fix overreporting of drops in dropwatch
    https://git.kernel.org/netdev/net-next/c/c21ab2afa2c6

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html