From: Thomas Graf Date: Tue, 14 Jan 2014 09:27:02 +0000 (-0800) Subject: datapath: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed X-Git-Tag: v2.1.0~35 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=a4d3e338904f7276230bfcdebf11bfe7e7ff8a7e datapath: Pad OVS_PACKET_ATTR_PACKET if linear copy was performed 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 Acked-by: Zoltan Kiss Signed-off-by: Jesse Gross --- diff --git a/datapath/datapath.c b/datapath/datapath.c index b42fd8bd4..9e9c73a9c 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -400,7 +400,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, #endif .snd_portid = upcall_info->portid, }; - size_t len; + size_t len, plen; unsigned int hlen; int err, dp_ifindex; @@ -471,6 +471,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);