Skip to contentSkip to conversation

Open vSwitch

GIT net New Jesse Gross 4 participants 9 messages Feb 5, 2014 – Feb 6, 2014 2 messages not in the archive

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

A handful of bug fixes for net/3.14. High level fixes are:
* Regressions introduced by the zerocopy changes, particularly with old userspaces.
* A few bugs lingering from the introduction of megaflows.
* Overly zealous error checking that is now being triggered frequently in common cases.

The following changes since commit bce3ea81d5b2a33ed0e275d58a45f10ce95cbd50:

xen-netfront: handle backend CLOSED without CLOSING (2014-02-04 20:42:36 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch.git fixes

for you to fetch changes up to c14e0953ca51dbcb8d1ac92acbdcff23d0caa158:

openvswitch: Suppress error messages on megaflow updates (2014-02-04 22:32:38 -0800)

----------------------------------------------------------------
Andy Zhou (2):
openvswitch: Fix kernel panic on ovs_flow_free
openvswitch: Suppress error messages on megaflow updates

Daniele Di Proietto (1):
openvswitch: Fix ovs_dp_cmd_msg_size()

Pravin B Shelar (1):
openvswitch: Fix ovs_flow_free() ovs-lock assert.

Thomas Graf (1):
openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed

 net/openvswitch/datapath.c   | 23 ++++++++----
 net/openvswitch/flow_table.c | 88 ++++++++++++++++++++++----------------------
 net/openvswitch/flow_table.h |  2 +-
 3 files changed, 60 insertions(+), 53 deletions(-)

A message that is not in the archive (sent off-list or not yet received): 1391583561-25399-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 2/5 openvswitch: Fix kernel panic on ovs_flow_free

From: Andy Zhou <[email protected]>

Both mega flow mask's reference counter and per flow table mask list should only be accessed when holding ovs_mutex() lock. However this is not true with ovs_flow_table_flush(). The patch fixes this bug.

---
 net/openvswitch/datapath.c   |  9 +++--
 net/openvswitch/flow_table.c | 84 +++++++++++++++++++++-----------------------
 net/openvswitch/flow_table.h |  2 +-
 3 files changed, 47 insertions(+), 48 deletions(-)
net/openvswitch/datapath.c +6 -3
index d1a73a6..e1b337e 100644
@@ -55,6 +55,7 @@
 
 #include "datapath.h"
 #include "flow.h"
+#include "flow_table.h"
 #include "flow_netlink.h"
 #include "vport-internal_dev.h"
 #include "vport-netdev.h"
@@ -160,7 +161,6 @@ static void destroy_dp_rcu(struct rcu_head *rcu)
 {
 	struct datapath *dp = container_of(rcu, struct datapath, rcu);
 
-	ovs_flow_tbl_destroy(&dp->table);
 	free_percpu(dp->stats_percpu);
 	release_net(ovs_dp_get_net(dp));
 	kfree(dp->ports);
@@ -1287,7 +1287,7 @@ err_destroy_ports_array:
 err_destroy_percpu:
 	free_percpu(dp->stats_percpu);
 err_destroy_table:
-	ovs_flow_tbl_destroy(&dp->table);
+	ovs_flow_tbl_destroy(&dp->table, false);
 err_free_dp:
 	release_net(ovs_dp_get_net(dp));
 	kfree(dp);
@@ -1314,10 +1314,13 @@ static void __dp_destroy(struct datapath *dp)
 	list_del_rcu(&dp->list_node);
 
 	/* OVSP_LOCAL is datapath internal port. We need to make sure that
-	 * all port in datapath are destroyed first before freeing datapath.
+	 * all ports in datapath are destroyed first before freeing datapath.
 	 */
 	ovs_dp_detach_port(ovs_vport_ovsl(dp, OVSP_LOCAL));
 
+	/* RCU destroy the flow table */
+	ovs_flow_tbl_destroy(&dp->table, true);
+
 	call_rcu(&dp->rcu, destroy_dp_rcu);
 }
 
net/openvswitch/flow_table.c +40 -44

140 lines not on this page · raw message

net/openvswitch/flow_table.h +1 -1
index 1996e34..baaeb10 100644
@@ -60,7 +60,7 @@ void ovs_flow_free(struct sw_flow *, bool deferred);
 
 int ovs_flow_tbl_init(struct flow_table *);
 int ovs_flow_tbl_count(struct flow_table *table);
-void ovs_flow_tbl_destroy(struct flow_table *table);
+void ovs_flow_tbl_destroy(struct flow_table *table, bool deferred);
 int ovs_flow_tbl_flush(struct flow_table *flow_table);
 
 int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
Signature · 1 line
1.8.3.2
#3 lore raw

PATCH 4/5 openvswitch: Fix ovs_flow_free() ovs-lock assert.

In reply to a message not in the archive

From: Pravin B Shelar <[email protected]>

ovs_flow_free() is not called under ovs-lock during packet execute path (ovs_packet_cmd_execute()). Since packet execute does not touch flow->mask, there is no need to take that lock either. So move assert in case where flow->mask is checked.

Found by code inspection.

---
 net/openvswitch/flow_table.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/openvswitch/flow_table.c +4 -2
index bd14052..3c268b3 100644
@@ -158,11 +158,13 @@ void ovs_flow_free(struct sw_flow *flow, bool deferred)
 	if (!flow)
 		return;
 
-	ASSERT_OVSL();
-
 	if (flow->mask) {
 		struct sw_flow_mask *mask = flow->mask;
 
+		/* ovs-lock is required to protect mask-refcount and
+		 * mask list.
+		 */
+		ASSERT_OVSL();
 		BUG_ON(!mask->ref_count);
 		mask->ref_count--;
 
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH 5/5 openvswitch: Suppress error messages on megaflow updates

In reply to a message not in the archive

From: Andy Zhou <[email protected]>

With subfacets, we'd expect megaflow updates message to carry the original micro flow. If not, EINVAL is returned and kernel logs an error message. Now that the user space subfacet layer is removed, it is expected that flow updates can arrive with a micro flow other than the original. Change the return code to EEXIST and remove the kernel error log message.

---
 net/openvswitch/datapath.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
net/openvswitch/datapath.c +1 -4
index 58689dd..e9a48ba 100644
@@ -860,11 +860,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
 			goto err_unlock_ovs;
 
 		/* The unmasked key has to be the same for flow updates. */
-		error = -EINVAL;
-		if (!ovs_flow_cmp_unmasked_key(flow, &match)) {
-			OVS_NLERR("Flow modification message rejected, unmasked key does not match.\n");
+		if (!ovs_flow_cmp_unmasked_key(flow, &match))
 			goto err_unlock_ovs;
-		}
 
 		/* Update actions. */
 		old_acts = ovsl_dereference(flow->sf_acts);
Signature · 1 line
1.8.3.2
#5 lore raw
In reply to a message not in the archive
Quoted 4 lines · Jesse Gross

A handful of bug fixes for net/3.14. High level fixes are:
* Regressions introduced by the zerocopy changes, particularly with old userspaces.

Hi, so this post was the 2nd version of the five patches you posted earlier, right? it would be very helpful if you
denote that on the subject line (e.g just use --subject-prefix="PATCH net V1" for git format-patch) and provide
crash diff listing from V0. Also, on a related note to the patch that deals with locking, I see these two smatch
complaints, which might be false-positives, what's your thinking?

net/openvswitch/flow.c:127 ovs_flow_stats_get() warn: returning with unbalanced local_bh_disable
net/openvswitch/flow.c:160 ovs_flow_stats_clear() warn: returning with unbalanced local_bh_disable

A message that is not in the archive (sent off-list or not yet received): CAJZOPZK17fAaDfYj21i0F=cOg0uX52X9BPfdxZaExGyNTQqtdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw
Quoted 14 lines · Or Gerlitz
Quoted 4 lines · Jesse Gross

A handful of bug fixes for net/3.14. High level fixes are:
* Regressions introduced by the zerocopy changes, particularly with old userspaces.

Hi, so this post was the 2nd version of the five patches you posted earlier, right? it would be very helpful if you
denote that on the subject line (e.g just use --subject-prefix="PATCH net V1" for git format-patch) and provide
crash diff listing from V0. Also, on a related note to the patch that deals with locking, I see these two smatch
complaints, which might be false-positives, what's your thinking?

Quoted 4 lines

net/openvswitch/flow.c:127 ovs_flow_stats_get() warn: returning with unbalanced local_bh_disable
net/openvswitch/flow.c:160 ovs_flow_stats_clear() warn: returning with unbalanced local_bh_disable

Yes, it looks like a false positive to me.

#8 lore raw

PATCH 1/5 openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed

In reply to Jesse Gross

From: Thomas Graf <[email protected]>

While the zerocopy method is correctly omitted if user space does not support unaligned Netlink messages. The attribute is still not padded correctly as skb_zerocopy() will not ensure padding and the attribute size is no longer pre calculated though nla_reserve() which ensured padding previously.

This patch applies appropriate padding if a linear data copy was performed in skb_zerocopy().

---
 net/openvswitch/datapath.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/openvswitch/datapath.c +8 -0
index df46928..d1a73a6 100644
@@ -466,6 +466,14 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 
 	skb_zerocopy(user_skb, skb, skb->len, hlen);
 
+	/* Pad OVS_PACKET_ATTR_PACKET if linear copy was performed */
+	if (!(dp->user_features & OVS_DP_F_UNALIGNED)) {
+		size_t plen = NLA_ALIGN(user_skb->len) - user_skb->len;
+
+		if (plen > 0)
+			memset(skb_put(user_skb, plen), 0, plen);
+	}
+
 	((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len;
 
 	err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid);
Signature · 1 line
1.8.3.2
#9 lore raw

PATCH 3/5 openvswitch: Fix ovs_dp_cmd_msg_size()

In reply to Jesse Gross

From: Daniele Di Proietto <[email protected]>

commit 43d4be9cb55f3bac5253e9289996fd9d735531db (openvswitch: Allow user space to announce ability to accept unaligned Netlink messages) introduced OVS_DP_ATTR_USER_FEATURES netlink attribute in datapath responses, but the attribute size was not taken into account in ovs_dp_cmd_msg_size().

---
 net/openvswitch/datapath.c | 1 +
 1 file changed, 1 insertion(+)
net/openvswitch/datapath.c +1 -0
index e1b337e..58689dd 100644
@@ -1087,6 +1087,7 @@ static size_t ovs_dp_cmd_msg_size(void)
 	msgsize += nla_total_size(IFNAMSIZ);
 	msgsize += nla_total_size(sizeof(struct ovs_dp_stats));
 	msgsize += nla_total_size(sizeof(struct ovs_dp_megaflow_stats));
+	msgsize += nla_total_size(sizeof(u32)); /* OVS_DP_ATTR_USER_FEATURES */
 
 	return msgsize;
 }
Signature · 1 line
1.8.3.2
#10 lore raw
In reply to Jesse Gross

From: Jesse Gross <[email protected]>
Date: Tue, 4 Feb 2014 22:59:16 -0800

Quoted 6 lines

A handful of bug fixes for net/3.14. High level fixes are:
* Regressions introduced by the zerocopy changes, particularly with old userspaces.
* A few bugs lingering from the introduction of megaflows.
* Overly zealous error checking that is now being triggered frequently in common cases.

Pulled, thanks Jesse.