openvswitch: Specify the minimal length of OVS_PACKET_ATTR_PACKET in the policy
authorThomas Graf <tgraf@suug.ch>
Fri, 29 Mar 2013 13:46:47 +0000 (14:46 +0100)
committerJesse Gross <jesse@nicira.com>
Sat, 30 Mar 2013 00:53:18 +0000 (17:53 -0700)
Specifying the minimal length in the policy makes it reuseable
and documents the interface.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Jesse Gross <jesse@nicira.com>
net/openvswitch/datapath.c

index 8759265a3e46b5c6fb268db70767b2b6e3bd11db..5b58d163a4dc06abf4c90d17441f3a8c4d58536c 100644 (file)
@@ -662,8 +662,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
 
        err = -EINVAL;
        if (!a[OVS_PACKET_ATTR_PACKET] || !a[OVS_PACKET_ATTR_KEY] ||
-           !a[OVS_PACKET_ATTR_ACTIONS] ||
-           nla_len(a[OVS_PACKET_ATTR_PACKET]) < ETH_HLEN)
+           !a[OVS_PACKET_ATTR_ACTIONS])
                goto err;
 
        len = nla_len(a[OVS_PACKET_ATTR_PACKET]);
@@ -744,7 +743,7 @@ err:
 }
 
 static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
-       [OVS_PACKET_ATTR_PACKET] = { .type = NLA_UNSPEC },
+       [OVS_PACKET_ATTR_PACKET] = { .len = ETH_HLEN },
        [OVS_PACKET_ATTR_KEY] = { .type = NLA_NESTED },
        [OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
 };