aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2019-04-26 05:13:06 -0400
committerDavid S. Miller <davem@davemloft.net>2019-04-27 17:03:44 -0400
commitae0be8de9a53cda3505865c11826d8ff0640237c (patch)
tree43bc8a0d58965d57e4ed1bedf8d892c3fe72e8b5 /net/ipv6
parentc7881b4a97e21b617b8243094dfa4b62028b956c (diff)
netlink: make nla_nest_start() add NLA_F_NESTED flag
Even if the NLA_F_NESTED flag was introduced more than 11 years ago, most netlink based interfaces (including recently added ones) are still not setting it in kernel generated messages. Without the flag, message parsers not aware of attribute semantics (e.g. wireshark dissector or libmnl's mnl_nlmsg_fprintf()) cannot recognize nested attributes and won't display the structure of their contents. Unfortunately we cannot just add the flag everywhere as there may be userspace applications which check nlattr::nla_type directly rather than through a helper masking out the flags. Therefore the patch renames nla_nest_start() to nla_nest_start_noflag() and introduces nla_nest_start() as a wrapper adding NLA_F_NESTED. The calls which add NLA_F_NESTED manually are rewritten to use nla_nest_start(). Except for changes in include/net/netlink.h, the patch was generated using this semantic patch: @@ expression E1, E2; @@ -nla_nest_start(E1, E2) +nla_nest_start_noflag(E1, E2) @@ expression E1, E2; @@ -nla_nest_start_noflag(E1, E2 | NLA_F_NESTED) +nla_nest_start(E1, E2) Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Acked-by: Jiri Pirko <jiri@mellanox.com> Acked-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/seg6_local.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 340a0f06f974..01f081aa718c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5752,7 +5752,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
5752 nla_put_u8(skb, IFLA_OPERSTATE, 5752 nla_put_u8(skb, IFLA_OPERSTATE,
5753 netif_running(dev) ? dev->operstate : IF_OPER_DOWN)) 5753 netif_running(dev) ? dev->operstate : IF_OPER_DOWN))
5754 goto nla_put_failure; 5754 goto nla_put_failure;
5755 protoinfo = nla_nest_start(skb, IFLA_PROTINFO); 5755 protoinfo = nla_nest_start_noflag(skb, IFLA_PROTINFO);
5756 if (!protoinfo) 5756 if (!protoinfo)
5757 goto nla_put_failure; 5757 goto nla_put_failure;
5758 5758
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9c0127a44f9f..e2b47f47de92 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4777,7 +4777,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
4777 struct fib6_info *sibling, *next_sibling; 4777 struct fib6_info *sibling, *next_sibling;
4778 struct nlattr *mp; 4778 struct nlattr *mp;
4779 4779
4780 mp = nla_nest_start(skb, RTA_MULTIPATH); 4780 mp = nla_nest_start_noflag(skb, RTA_MULTIPATH);
4781 if (!mp) 4781 if (!mp)
4782 goto nla_put_failure; 4782 goto nla_put_failure;
4783 4783
diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index 60325dbfe88b..67005ac71341 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -853,7 +853,7 @@ static int put_nla_bpf(struct sk_buff *skb, struct seg6_local_lwt *slwt)
853 if (!slwt->bpf.prog) 853 if (!slwt->bpf.prog)
854 return 0; 854 return 0;
855 855
856 nest = nla_nest_start(skb, SEG6_LOCAL_BPF); 856 nest = nla_nest_start_noflag(skb, SEG6_LOCAL_BPF);
857 if (!nest) 857 if (!nest)
858 return -EMSGSIZE; 858 return -EMSGSIZE;
859 859