Message ID | 20140114161640.GA24121@casper.infradead.org |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
On 01/14/14 at 04:16pm, Thomas Graf wrote: > 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> > --- > 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..24e93f5 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) > + skb_put(user_skb, plen); While this fixes the padding issue, it leaves the padding uninitialized, I will send v2 with an additional memset(). -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index df46928..24e93f5 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) + skb_put(user_skb, plen); + ((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len; err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid);
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> --- net/openvswitch/datapath.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html