Skip to content

Commit

Permalink
datapath: Specify the minimal length of OVS_PACKET_ATTR_PACKET in the…
Browse files Browse the repository at this point in the history
… policy

Specifying the minimal length in the policy makes it reuseable
and documents the interface.

Signed-off-by: Thomas Graf <[email protected]>
Signed-off-by: Jesse Gross <[email protected]>
tgraf authored and jessegross committed Mar 30, 2013
1 parent 8e63fd1 commit 7c3072c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
@@ -815,8 +815,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]);
@@ -891,7 +890,11 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
}

static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
[OVS_PACKET_ATTR_PACKET] = { .type = NLA_UNSPEC },
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
[OVS_PACKET_ATTR_PACKET] = { .len = ETH_HLEN },
#else
[OVS_PACKET_ATTR_PACKET] = { .minlen = ETH_HLEN },
#endif
[OVS_PACKET_ATTR_KEY] = { .type = NLA_NESTED },
[OVS_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
};

0 comments on commit 7c3072c

Please sign in to comment.