rtnetlink: fix rtnl message size computation for XDP
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 15 Nov 2016 10:16:35 +0000 (11:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Nov 2016 03:40:07 +0000 (22:40 -0500)
rtnl_xdp_size() only considers the size of the actual payload attribute,
and misses the space taken by the attribute used for nesting (IFLA_XDP).

Fixes: d1fdd9138682 ("rtnl: add option for setting link xdp prog")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Brenden Blanco <bblanco@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index 96f4bf274e30715fbdc06e82ae0f335646555b60..a6529c55ffb7adc5c48203e1a57c59c0ba01b806 100644 (file)
@@ -901,7 +901,8 @@ static size_t rtnl_port_size(const struct net_device *dev,
 
 static size_t rtnl_xdp_size(const struct net_device *dev)
 {
-       size_t xdp_size = nla_total_size(1);    /* XDP_ATTACHED */
+       size_t xdp_size = nla_total_size(0) +   /* nest IFLA_XDP */
+                         nla_total_size(1);    /* XDP_ATTACHED */
 
        if (!dev->netdev_ops->ndo_xdp)
                return 0;