Skip to contentSkip to conversation

Open vSwitch

GIT net In review Jesse Gross 3 participants 17 messages Feb 3, 2014 – Feb 5, 2014 7 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:
* Regression 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 9895c503ef5b32c1ff4c4c224d6e8db2935dc3c0:

ksz884x: delete useless variable (2014-01-15 13:43:03 -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 dd3bceef108f99e21900c872d8b7ec632cfb88ac:

openvswitch: Suppress error messages on megaflow updates (2014-02-02 16:39:48 -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   | 22 +++++++----
 net/openvswitch/flow_table.c | 87 +++++++++++++++++++++-----------------------
 net/openvswitch/flow_table.h |  2 +-
 3 files changed, 57 insertions(+), 54 deletions(-)

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

#2 lore raw

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

From: Thomas Graf <tgraf-G/[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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +6 -1
index df46928..3ca9121 100644
@@ -396,7 +396,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 		.dst_sk = ovs_dp_get_net(dp)->genl_sock,
 		.snd_portid = upcall_info->portid,
 	};
-	size_t len;
+	size_t len, plen;
 	unsigned int hlen;
 	int err, dp_ifindex;
 
@@ -466,6 +466,11 @@ 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) &&
+	    (plen = (ALIGN(user_skb->len, NLA_ALIGNTO) - user_skb->len)) > 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

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

#4 lore raw

Re: [PATCH net 1/5] openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed

Hello.

Quoted 22 lines · Jesse Gross

From: Thomas Graf <tgraf-G/[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 | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +0 -0
index df46928..3ca9121 100644

[...]

net/openvswitch/datapath.c static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, · line 471

Quoted 7 lines
net/openvswitch/datapath.c +3 -0
@@ -466,6 +466,11 @@ 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) &&
+	    (plen = (ALIGN(user_skb->len, NLA_ALIGNTO) - user_skb->len)) > 0)

This shouldn't pass checkpatch.pl which complains about assignments inside
*if* statements.

WBR, Sergei

A message that is not in the archive (sent off-list or not yet received): 52EFC74E.8040906-M4DtvfQ/[email protected]

#6 lore raw

Re: [PATCH net 1/5] openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed

Quoted 39 lines · Sergei Shtylyov

Hello.

Quoted 26 lines · Jesse Gross

From: Thomas Graf <tgraf-G/[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 | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
net/openvswitch/datapath.c +0 -0
index df46928..3ca9121 100644

[...]

Quoted 5 lines
net/openvswitch/datapath.c +0 -0
@@ -466,6 +466,11 @@ static int queue_userspace_packet(struct datapath
 *dp, struct sk_buff *skb,
 
        skb_zerocopy(user_skb, skb, skb->len, hlen);
 
Quoted 8 lines

net/openvswitch/datapath.c static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,

Quoted 4 lines
net/openvswitch/datapath.c +3 -0
+       /* Pad OVS_PACKET_ATTR_PACKET if linear copy was performed */
+       if (!(dp->user_features & OVS_DP_F_UNALIGNED) &&
+           (plen = (ALIGN(user_skb->len, NLA_ALIGNTO) - user_skb->len)) >
 0)

This shouldn't pass checkpatch.pl which complains about assignments
inside *if* statements.

I've fixed both of these issues and will resubmit.

#7 lore raw

PATCH 2/5 openvswitch: Fix kernel panic on ovs_flow_free

In reply to a message not in the archive

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 3ca9121..ea0b30f 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);
@@ -1284,7 +1284,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);
@@ -1311,10 +1311,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
#8 lore raw

PATCH 3/5 openvswitch: Fix ovs_dp_cmd_msg_size()

In reply to a message not in the archive

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 ea0b30f..8b392cc 100644
@@ -1084,6 +1084,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
#9 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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/flow_table.c +3 -2
index bd14052..ad0bda0 100644
@@ -158,11 +158,12 @@ 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

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

#11 lore raw

Re: [PATCH net 4/5] openvswitch: Fix ovs_flow_free() ovs-lock assert.

Hello.

Quoted 20 lines · Jesse Gross

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 | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
net/openvswitch/flow_table.c +0 -0
index bd14052..ad0bda0 100644

net/openvswitch/flow_table.c void ovs_flow_free(struct sw_flow *flow, bool deferred) · line 165

Quoted 10 lines
net/openvswitch/flow_table.c +2 -2
@@ -158,11 +158,12 @@ 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. */

Networking multi-line comment style is:

/* bla
* bla
*/

WBR, Sergei

#12 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 8b392cc..947a9a8 100644
@@ -857,11 +857,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

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

#14 lore raw

RFC PATCH 1/1 openvswitch: Use net_ratelimit in OVS_NLERR

Perhaps it'd make sense to use net_ratelimit()
instead of printk_once for OVS_NLERR

---
 net/openvswitch/datapath.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/openvswitch/datapath.h +5 -3
index 6be9fbb..0f5e77c 100644
@@ -194,7 +194,9 @@ struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
 int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb);
 void ovs_dp_notify_wq(struct work_struct *work);
 
-#define OVS_NLERR(fmt, ...) \
-	pr_info_once("netlink: " fmt, ##__VA_ARGS__)
-
+#define OVS_NLERR(fmt, ...)					\
+do {								\
+	if (net_ratelimit())					\
+		pr_info("netlink: " fmt, ##__VA_ARGS__);	\
+} while (0)
 #endif /* datapath.h */
#15 lore raw

Re: [RFC PATCH] openvswitch: Use net_ratelimit in OVS_NLERR

Quoted 2 lines · Joe Perches

Perhaps it'd make sense to use net_ratelimit()
instead of printk_once for OVS_NLERR

I guess I could see it going either way but I'm not sure I see a strong argument for changing.

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

#17 lore raw

Re: [RFC PATCH] openvswitch: Use net_ratelimit in OVS_NLERR

Quoted 6 lines · Jesse Gross
Quoted 2 lines · Joe Perches

Perhaps it'd make sense to use net_ratelimit()
instead of printk_once for OVS_NLERR

I guess I could see it going either way but I'm not sure I see a strong argument for changing.

pr_<level>_once is a per-site flag.

Some of these messages look as if seeing them
multiple times could be useful.

#18 lore raw

Re: [RFC PATCH] openvswitch: Use net_ratelimit in OVS_NLERR

Quoted 5 lines · Joe Perches
Quoted 4 lines · Jesse Gross
Quoted 2 lines · Joe Perches

Perhaps it'd make sense to use net_ratelimit()
instead of printk_once for OVS_NLERR

Quoted 7 lines
Quoted 2 lines

I guess I could see it going either way but I'm not sure I see a strong argument for changing.

pr_<level>_once is a per-site flag.

Some of these messages look as if seeing them
multiple times could be useful.

OK, I guess it's fine. Can you provide a signed-off-by line?

A message that is not in the archive (sent off-list or not yet received): CAEP_g=83oVtSTMmLB7O8g=a3e5ghjHp7Bgs-f4nvgqCvWqE5VQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#20 lore raw

PATCH 1/1 openvswitch: Use net_ratelimit in OVS_NLERR

Each use of pr_<level>_once has a per-site flag.

Some of the OVS_NLERR messages look as if seeing them multiple times could be useful, so use net_ratelimit() instead of pr_info_once.

---

Quoted 1 line

OK, I guess it's fine. Can you provide a signed-off-by line?

 net/openvswitch/datapath.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/openvswitch/datapath.h +5 -3
index 6be9fbb..0f5e77c 100644
@@ -194,7 +194,9 @@ struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
 int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb);
 void ovs_dp_notify_wq(struct work_struct *work);
 
-#define OVS_NLERR(fmt, ...) \
-	pr_info_once("netlink: " fmt, ##__VA_ARGS__)
-
+#define OVS_NLERR(fmt, ...)					\
+do {								\
+	if (net_ratelimit())					\
+		pr_info("netlink: " fmt, ##__VA_ARGS__);	\
+} while (0)
 #endif /* datapath.h */
#21 lore raw

Re: [PATCH] openvswitch: flow_netlink: Use pr_fmt to OVS_NLERR output

Add "openvswitch: " prefix to OVS_NLERR output
to match the other OVS_NLERR output of datapath.c

---
 net/openvswitch/flow_netlink.c | 2 ++
 1 file changed, 2 insertions(+)
net/openvswitch/flow_netlink.c +2 -0
index 4d000ac..c4e1326 100644
@@ -16,6 +16,8 @@
  * 02110-1301, USA
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include "flow.h"
 #include "datapath.h"
 #include <linux/uaccess.h>
#22 lore raw

Re: [PATCH] openvswitch: flow_netlink: Use pr_fmt to OVS_NLERR output

Quoted 4 lines · Joe Perches

Add "openvswitch: " prefix to OVS_NLERR output
to match the other OVS_NLERR output of datapath.c

Also applied.

author Applied
#23 lore raw

Re: [PATCH] openvswitch: Use net_ratelimit in OVS_NLERR

In reply to Joe Perches
Quoted 7 lines · Joe Perches

Each use of pr_<level>_once has a per-site flag.

Some of the OVS_NLERR messages look as if seeing them multiple times could be useful, so use net_ratelimit() instead of pr_info_once.

Applied, thanks.