netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Zoltan Kiss <zoltan.kiss@citrix.com>
Cc: Thomas Graf <tgraf@redhat.com>, Jesse Gross <jesse@nicira.com>,
	David Miller <davem@davemloft.net>,
	"dev@openvswitch.org" <dev@openvswitch.org>,
	netdev <netdev@vger.kernel.org>
Subject: [PATCH net-next v2] openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed
Date: Tue, 14 Jan 2014 16:27:49 +0000	[thread overview]
Message-ID: <20140114162749.GC24121@casper.infradead.org> (raw)
In-Reply-To: <20140114161911.GB24121@casper.infradead.org>

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>
---
v2: initialize padding to 0's

 net/openvswitch/datapath.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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

  reply	other threads:[~2014-01-14 16:27 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07  0:15 [GIT net-next] Open vSwitch Jesse Gross
     [not found] ` <1389053776-62865-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org>
2014-01-07  0:16   ` [PATCH net-next 01/17] openvswitch: Correct comment Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 02/17] openvswitch: Shrink sw_flow_mask by 8 bytes (64-bit) or 4 bytes (32-bit) Jesse Gross
2014-01-07 21:36     ` Sergei Shtylyov
2014-01-07  0:16   ` [PATCH net-next 03/17] openvswitch: Change ovs_flow_tbl_lookup_xx() APIs Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 04/17] openvswitch: Silence RCU lockdep checks from flow lookup Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 05/17] genl: Add genlmsg_new_unicast() for unicast message allocation Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 06/17] netlink: Avoid netlink mmap alloc if msg size exceeds frame size Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 07/17] openvswitch: Enable memory mapped Netlink i/o Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 08/17] openvswitch: Per cpu flow stats Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 09/17] net: ovs: use kfree_rcu instead of rcu_free_{sw_flow_mask_cb, acts_callback} Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 10/17] openvswitch: remove duplicated include from flow_table.c Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 11/17] net: Export skb_zerocopy() to zerocopy from one skb to another Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 12/17] openvswitch: Allow user space to announce ability to accept unaligned Netlink messages Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 13/17] openvswitch: Drop user features if old user space attempted to create datapath Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 14/17] openvswitch: Pass datapath into userspace queue functions Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 15/17] openvswitch: Use skb_zerocopy() for upcall Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 16/17] openvswitch: Compute checksum in skb_gso_segment() if needed Jesse Gross
2014-01-07  0:16   ` [PATCH net-next 17/17] ovs: make functions local Jesse Gross
2014-01-07  0:49   ` [GIT net-next] Open vSwitch David Miller
2014-01-08 14:49 ` [ovs-dev] " Zoltan Kiss
     [not found]   ` <52CD657F.7080806-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
2014-01-08 15:10     ` Jesse Gross
2014-01-13 18:04       ` [ovs-dev] " Zoltan Kiss
     [not found]         ` <52D42A9E.1030805-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
2014-01-14  0:31           ` Zoltan Kiss
     [not found]             ` <52D4857C.7020902-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
2014-01-14  1:30               ` Jesse Gross
     [not found]                 ` <CAEP_g=8nG6AHV9Y+5=48nPhkf5Oe=mG8EiyaKSqN4omnmGhv4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-14  9:46                   ` Thomas Graf
2014-01-14 12:31                     ` [ovs-dev] " Zoltan Kiss
2014-01-14 16:16                       ` [PATCH net-next] openvswitch: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed Thomas Graf
2014-01-14 16:19                         ` Thomas Graf
2014-01-14 16:27                           ` Thomas Graf [this message]
2014-01-14 18:56                             ` [PATCH net-next v2] " Zoltan Kiss
2014-01-15  3:03                             ` David Miller
2014-01-15 22:53                               ` 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=20140114162749.GC24121@casper.infradead.org \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@redhat.com \
    --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).