Skip to content

Commit aea0bb4

Browse files
tgrafjessegross
authored andcommitted
openvswitch: 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 <tgraf@suug.ch> Acked-by: Zoltan Kiss <zoltan.kiss@citrix.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent bce3ea8 commit aea0bb4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎net/openvswitch/datapath.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
466466

467467
skb_zerocopy(user_skb, skb, skb->len, hlen);
468468

469+
/* Pad OVS_PACKET_ATTR_PACKET if linear copy was performed */
470+
if (!(dp->user_features & OVS_DP_F_UNALIGNED)) {
471+
size_t plen = NLA_ALIGN(user_skb->len) - user_skb->len;
472+
473+
if (plen > 0)
474+
memset(skb_put(user_skb, plen), 0, plen);
475+
}
476+
469477
((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len;
470478

471479
err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid);

0 commit comments

Comments
 (0)