mpls: fix warning with multi-label encap
authorGeorge Wilkie <gwilkie@vyatta.att-mail.com>
Fri, 7 Jun 2019 10:49:41 +0000 (11:49 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 9 Jun 2019 20:26:34 +0000 (13:26 -0700)
If you configure a route with multiple labels, e.g.
  ip route add 10.10.3.0/24 encap mpls 16/100 via 10.10.2.2 dev ens4
A warning is logged:
  kernel: [  130.561819] netlink: 'ip': attribute type 1 has an invalid
  length.

This happens because mpls_iptunnel_policy has set the type of
MPLS_IPTUNNEL_DST to fixed size NLA_U32.
Change it to a minimum size.
nla_get_labels() does the remaining validation.

Fixes: e3e4712ec096 ("mpls: ip tunnel support")
Signed-off-by: George Wilkie <gwilkie@vyatta.att-mail.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mpls/mpls_iptunnel.c

index 50059613076066e4cf3d901be05506b6370de7c3..d25e91d7bdc18526301c6228f5943aec7f9becc8 100644 (file)
@@ -23,7 +23,7 @@
 #include "internal.h"
 
 static const struct nla_policy mpls_iptunnel_policy[MPLS_IPTUNNEL_MAX + 1] = {
-       [MPLS_IPTUNNEL_DST]     = { .type = NLA_U32 },
+       [MPLS_IPTUNNEL_DST]     = { .len = sizeof(u32) },
        [MPLS_IPTUNNEL_TTL]     = { .type = NLA_U8 },
 };