netlink: Refine calculation of maximum-length attributes.
authorBen Pfaff <blp@nicira.com>
Wed, 7 Jan 2015 21:19:41 +0000 (13:19 -0800)
committerBen Pfaff <blp@nicira.com>
Sun, 11 Jan 2015 21:51:55 +0000 (13:51 -0800)
commitf3c7ec6a2a19bffdfa5218f984bda53582ecb8dc
treea1131143f683903a23c2e3c60bb19a3b8113e376
parent78d9bbb45efc7227b2efd4a94394ee574742c1ca
netlink: Refine calculation of maximum-length attributes.

Until now the Netlink code has considered an attribute to exceed the
maximum length if the *padded* size of the attribute exceeds 65535 bytes.
For example, an attribute with a 65529-byte payload, together with 4-byte
header and 3 bytes of padding, takes up 65536 bytes and therefore the
existing code rejected it.

However, the restriction on Netlink attribute sizes is to ensure that the
length fits in the 16-bit nla_len field.  This field includes the 4-byte
header but not the padding, so a 65529-byte payload is acceptable because,
with the header but not the padding, it comes to only 65533 bytes.

Thus, this commit relaxes the restriction on Netlink attribute sizes by
omitting padding from size checks.  It also changes one piece of code that
inlined a size check to use the central function nl_attr_oversized().

This change should fix an assertion failure when OVS userspace passes a
maximum-size (65529+ byte) packet back to the kernel.

Reported-by: Shuping Cui <scui@redhat.com>
Reported-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
lib/netlink.c
lib/netlink.h