diff options
author | Ben Pfaff <blp@nicira.com> | 2013-10-04 08:48:48 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-10-04 08:48:48 -0700 |
commit | 542024c4c3d36b2d303efbe6c0da469c8e446476 (patch) | |
tree | b2729d36dad02a63273e05e5bcd71b8e965f1e71 /lib/netlink.c | |
parent | 98b07853dfd6046938c41937d60ce693437c1f25 (diff) |
ofproto-dpif-xlate: Suppress oversize datapath actions.
If we allow oversize datapath actions to make it out of translation, then
we will assert-fail later when we try to put those actions into a Netlink
attribute.
Bug #19277.
Reported-by: Paul ingram <paul@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'lib/netlink.c')
-rw-r--r-- | lib/netlink.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/netlink.c b/lib/netlink.c index 50444abd..40477eae 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -322,7 +322,7 @@ nl_msg_push_unspec_uninit(struct ofpbuf *msg, uint16_t type, size_t size) { size_t total_size = NLA_HDRLEN + size; struct nlattr* nla = nl_msg_push_uninit(msg, total_size); - ovs_assert(NLA_ALIGN(total_size) <= UINT16_MAX); + ovs_assert(!nl_attr_oversized(size)); nla->nla_len = total_size; nla->nla_type = type; return nla + 1; @@ -468,6 +468,16 @@ nl_msg_next(struct ofpbuf *buffer, struct ofpbuf *msg) msg->size = 0; return NULL; } + +/* Returns true if a Netlink attribute with a payload that is 'payload_size' + * bytes long would be oversized, that is, if it's not possible to create an + * nlattr of that size because its size wouldn't fit in the 16-bit nla_len + * field. */ +bool +nl_attr_oversized(size_t payload_size) +{ + return NL_ATTR_SIZE(payload_size) > UINT16_MAX; +} /* Attributes. */ |