Skip to contentSkip to conversation

openvswitch: remove a couple of BUG_ON()

PATCH In review Paolo Abeni 2 participants 4 messages Dec 1, 2019

Subsystems (3)
lore
Share & tools
lore

Paolo Abeni

author maintainer
#0 lore raw

v2 cover openvswitch: remove a couple of BUG_ON()

The openvswitch kernel datapath includes some BUG_ON() statements to check for exceptional/unexpected failures. These patches drop a couple of them, where we can do that without introducing other side effects.

v1 -> v2:
- avoid memory leaks on error path

Paolo Abeni (2):
openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info()
openvswitch: remove another BUG_ON()

 net/openvswitch/datapath.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.0
author maintainer
#1 lore raw

PATCH v2 1/2 openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info()

All the callers of ovs_flow_cmd_build_info() already deal with error return code correctly, so we can handle the error condition in a more gracefull way. Still dump a warning to preserve debuggability.

v1 -> v2:
- clarify the commit message
- clean the skb and report the error (DaveM)

Fixes ccb1352e76cf ("net: Add Open vSwitch kernel components.")
---
 net/openvswitch/datapath.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +4 -1
index 293d5289c4a1..8cab3435d8da 100644
@@ -905,7 +905,10 @@ static struct sk_buff *ovs_flow_cmd_build_info(const struct sw_flow *flow,
 	retval = ovs_flow_cmd_fill_info(flow, dp_ifindex, skb,
 					info->snd_portid, info->snd_seq, 0,
 					cmd, ufid_flags);
-	BUG_ON(retval < 0);
+	if (WARN_ON_ONCE(retval < 0)) {
+		kfree_skb(skb);
+		skb = ERR_PTR(retval);
+	}
 	return skb;
 }
 
Signature · 1 line
2.21.0
author maintainer
#2 lore raw

PATCH v2 2/2 openvswitch: remove another BUG_ON()

In reply to Paolo Abeni

If we can't build the flow del notification, we can simply delete the flow, no need to crash the kernel. Still keep a WARN_ON to preserve debuggability.

Note: the BUG_ON() predates the Fixes tag, but this change can be applied only after the mentioned commit.

v1 -> v2:
- do not leak an skb on error

Fixes aed067783e50 ("openvswitch: Minimize ovs_flow_cmd_del critical section.")
---
 net/openvswitch/datapath.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +5 -1
index 8cab3435d8da..1047e8043084 100644
@@ -1372,7 +1372,10 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
 						     OVS_FLOW_CMD_DEL,
 						     ufid_flags);
 			rcu_read_unlock();
-			BUG_ON(err < 0);
+			if (WARN_ON_ONCE(err < 0)) {
+				kfree_skb(reply);
+				goto out_free;
+			}
 
 			ovs_notify(&dp_flow_genl_family, reply, info);
 		} else {
@@ -1380,6 +1383,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
 		}
 	}
 
+out_free:
 	ovs_flow_free(flow, true);
 	return 0;
 unlock:
Signature · 1 line
2.21.0
maintainer
#3 lore raw
In reply to Paolo Abeni

From: Paolo Abeni <[email protected]>
Date: Sun, 1 Dec 2019 18:41:23 +0100

Quoted 6 lines

The openvswitch kernel datapath includes some BUG_ON() statements to check for exceptional/unexpected failures. These patches drop a couple of them, where we can do that without introducing other side effects.

v1 -> v2:
- avoid memory leaks on error path

Series applied and queued up for -stable, thanks.