netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesse Gross <jesse@nicira.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, dev@openvswitch.org,
	Thomas Graf <tgraf@suug.ch>, Zoltan Kiss <zoltan.kiss@citrix.com>,
	Jesse Gross <jesse@nicira.com>
Subject: [PATCH net 1/5] openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed
Date: Tue,  4 Feb 2014 22:59:17 -0800	[thread overview]
Message-ID: <1391583561-25399-2-git-send-email-jesse@nicira.com> (raw)
In-Reply-To: <1391583561-25399-1-git-send-email-jesse@nicira.com>

From: Thomas Graf <tgraf@suug.ch>

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().

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Zoltan Kiss <zoltan.kiss@citrix.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
---
 net/openvswitch/datapath.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index df46928..d1a73a6 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -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);
-- 
1.8.3.2

  reply	other threads:[~2014-02-05  6:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05  6:59 [GIT net] Open vSwitch Jesse Gross
2014-02-05  6:59 ` Jesse Gross [this message]
2014-02-05  6:59 ` [PATCH net 3/5] openvswitch: Fix ovs_dp_cmd_msg_size() Jesse Gross
     [not found] ` <1391583561-25399-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2014-02-05  6:59   ` [PATCH net 2/5] openvswitch: Fix kernel panic on ovs_flow_free Jesse Gross
2014-02-05  6:59   ` [PATCH net 4/5] openvswitch: Fix ovs_flow_free() ovs-lock assert Jesse Gross
2014-02-05  6:59   ` [PATCH net 5/5] openvswitch: Suppress error messages on megaflow updates Jesse Gross
2014-02-06  7:09   ` [GIT net] Open vSwitch Or Gerlitz
     [not found]     ` <CAJZOPZK17fAaDfYj21i0F=cOg0uX52X9BPfdxZaExGyNTQqtdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-06  7:32       ` Jesse Gross
2014-02-06  0:26 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2014-02-03  1:08 Jesse Gross
     [not found] ` <1391389686-34303-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2014-02-03  1:08   ` [PATCH net 1/5] openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed Jesse Gross
     [not found]     ` <1391389686-34303-2-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2014-02-03 16:43       ` Sergei Shtylyov
     [not found]         ` <52EFC74E.8040906-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-02-05  6:02           ` Jesse Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391583561-25399-2-git-send-email-jesse@nicira.com \
    --to=jesse@nicira.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    --cc=zoltan.kiss@citrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).