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>
This commit is contained in:
committed by
David S. Miller
parent
c7881b4a97
commit
ae0be8de9a
@@ -687,14 +687,14 @@ static int __tipc_nl_add_bearer(struct tipc_nl_msg *msg,
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_BEARER);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_BEARER);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
if (nla_put_string(msg->skb, TIPC_NLA_BEARER_NAME, bearer->name))
|
||||
goto attr_msg_full;
|
||||
|
||||
prop = nla_nest_start(msg->skb, TIPC_NLA_BEARER_PROP);
|
||||
prop = nla_nest_start_noflag(msg->skb, TIPC_NLA_BEARER_PROP);
|
||||
if (!prop)
|
||||
goto prop_msg_full;
|
||||
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, bearer->priority))
|
||||
@@ -1033,14 +1033,14 @@ static int __tipc_nl_add_media(struct tipc_nl_msg *msg,
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_MEDIA);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_MEDIA);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
if (nla_put_string(msg->skb, TIPC_NLA_MEDIA_NAME, media->name))
|
||||
goto attr_msg_full;
|
||||
|
||||
prop = nla_nest_start(msg->skb, TIPC_NLA_MEDIA_PROP);
|
||||
prop = nla_nest_start_noflag(msg->skb, TIPC_NLA_MEDIA_PROP);
|
||||
if (!prop)
|
||||
goto prop_msg_full;
|
||||
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, media->priority))
|
||||
|
||||
@@ -917,7 +917,7 @@ void tipc_group_member_evt(struct tipc_group *grp,
|
||||
|
||||
int tipc_group_fill_sock_diag(struct tipc_group *grp, struct sk_buff *skb)
|
||||
{
|
||||
struct nlattr *group = nla_nest_start(skb, TIPC_NLA_SOCK_GROUP);
|
||||
struct nlattr *group = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_GROUP);
|
||||
|
||||
if (!group)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -2228,7 +2228,7 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s)
|
||||
(s->accu_queue_sz / s->queue_sz_counts) : 0}
|
||||
};
|
||||
|
||||
stats = nla_nest_start(skb, TIPC_NLA_LINK_STATS);
|
||||
stats = nla_nest_start_noflag(skb, TIPC_NLA_LINK_STATS);
|
||||
if (!stats)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -2260,7 +2260,7 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_LINK);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
@@ -2282,7 +2282,7 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
|
||||
if (nla_put_flag(msg->skb, TIPC_NLA_LINK_ACTIVE))
|
||||
goto attr_msg_full;
|
||||
|
||||
prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
|
||||
prop = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK_PROP);
|
||||
if (!prop)
|
||||
goto attr_msg_full;
|
||||
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_PRIO, link->priority))
|
||||
@@ -2349,7 +2349,7 @@ static int __tipc_nl_add_bc_link_stat(struct sk_buff *skb,
|
||||
(stats->accu_queue_sz / stats->queue_sz_counts) : 0}
|
||||
};
|
||||
|
||||
nest = nla_nest_start(skb, TIPC_NLA_LINK_STATS);
|
||||
nest = nla_nest_start_noflag(skb, TIPC_NLA_LINK_STATS);
|
||||
if (!nest)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -2389,7 +2389,7 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_LINK);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
@@ -2406,7 +2406,7 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
|
||||
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_TX, 0))
|
||||
goto attr_msg_full;
|
||||
|
||||
prop = nla_nest_start(msg->skb, TIPC_NLA_LINK_PROP);
|
||||
prop = nla_nest_start_noflag(msg->skb, TIPC_NLA_LINK_PROP);
|
||||
if (!prop)
|
||||
goto attr_msg_full;
|
||||
if (nla_put_u32(msg->skb, TIPC_NLA_PROP_WIN, bcl->window))
|
||||
|
||||
@@ -696,7 +696,7 @@ static int __tipc_nl_add_monitor_peer(struct tipc_peer *peer,
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_MON_PEER);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_MON_PEER);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
@@ -785,7 +785,7 @@ int __tipc_nl_add_monitor(struct net *net, struct tipc_nl_msg *msg,
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_MON);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_MON);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
|
||||
@@ -829,11 +829,11 @@ static int __tipc_nl_add_nametable_publ(struct tipc_nl_msg *msg,
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_NAME_TABLE);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_NAME_TABLE);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
b = nla_nest_start(msg->skb, TIPC_NLA_NAME_TABLE_PUBL);
|
||||
b = nla_nest_start_noflag(msg->skb, TIPC_NLA_NAME_TABLE_PUBL);
|
||||
if (!b)
|
||||
goto attr_msg_full;
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ static int __tipc_nl_add_net(struct net *net, struct tipc_nl_msg *msg)
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_NET);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_NET);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ static int tipc_nl_compat_bearer_enable(struct tipc_nl_compat_cmd_doit *cmd,
|
||||
|
||||
b = (struct tipc_bearer_config *)TLV_DATA(msg->req);
|
||||
|
||||
bearer = nla_nest_start(skb, TIPC_NLA_BEARER);
|
||||
bearer = nla_nest_start_noflag(skb, TIPC_NLA_BEARER);
|
||||
if (!bearer)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -419,7 +419,7 @@ static int tipc_nl_compat_bearer_enable(struct tipc_nl_compat_cmd_doit *cmd,
|
||||
return -EMSGSIZE;
|
||||
|
||||
if (ntohl(b->priority) <= TIPC_MAX_LINK_PRI) {
|
||||
prop = nla_nest_start(skb, TIPC_NLA_BEARER_PROP);
|
||||
prop = nla_nest_start_noflag(skb, TIPC_NLA_BEARER_PROP);
|
||||
if (!prop)
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u32(skb, TIPC_NLA_PROP_PRIO, ntohl(b->priority)))
|
||||
@@ -441,7 +441,7 @@ static int tipc_nl_compat_bearer_disable(struct tipc_nl_compat_cmd_doit *cmd,
|
||||
|
||||
name = (char *)TLV_DATA(msg->req);
|
||||
|
||||
bearer = nla_nest_start(skb, TIPC_NLA_BEARER);
|
||||
bearer = nla_nest_start_noflag(skb, TIPC_NLA_BEARER);
|
||||
if (!bearer)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -685,7 +685,7 @@ static int tipc_nl_compat_media_set(struct sk_buff *skb,
|
||||
|
||||
lc = (struct tipc_link_config *)TLV_DATA(msg->req);
|
||||
|
||||
media = nla_nest_start(skb, TIPC_NLA_MEDIA);
|
||||
media = nla_nest_start_noflag(skb, TIPC_NLA_MEDIA);
|
||||
if (!media)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -696,7 +696,7 @@ static int tipc_nl_compat_media_set(struct sk_buff *skb,
|
||||
if (nla_put_string(skb, TIPC_NLA_MEDIA_NAME, lc->name))
|
||||
return -EMSGSIZE;
|
||||
|
||||
prop = nla_nest_start(skb, TIPC_NLA_MEDIA_PROP);
|
||||
prop = nla_nest_start_noflag(skb, TIPC_NLA_MEDIA_PROP);
|
||||
if (!prop)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -717,7 +717,7 @@ static int tipc_nl_compat_bearer_set(struct sk_buff *skb,
|
||||
|
||||
lc = (struct tipc_link_config *)TLV_DATA(msg->req);
|
||||
|
||||
bearer = nla_nest_start(skb, TIPC_NLA_BEARER);
|
||||
bearer = nla_nest_start_noflag(skb, TIPC_NLA_BEARER);
|
||||
if (!bearer)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -728,7 +728,7 @@ static int tipc_nl_compat_bearer_set(struct sk_buff *skb,
|
||||
if (nla_put_string(skb, TIPC_NLA_BEARER_NAME, lc->name))
|
||||
return -EMSGSIZE;
|
||||
|
||||
prop = nla_nest_start(skb, TIPC_NLA_BEARER_PROP);
|
||||
prop = nla_nest_start_noflag(skb, TIPC_NLA_BEARER_PROP);
|
||||
if (!prop)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -748,14 +748,14 @@ static int __tipc_nl_compat_link_set(struct sk_buff *skb,
|
||||
|
||||
lc = (struct tipc_link_config *)TLV_DATA(msg->req);
|
||||
|
||||
link = nla_nest_start(skb, TIPC_NLA_LINK);
|
||||
link = nla_nest_start_noflag(skb, TIPC_NLA_LINK);
|
||||
if (!link)
|
||||
return -EMSGSIZE;
|
||||
|
||||
if (nla_put_string(skb, TIPC_NLA_LINK_NAME, lc->name))
|
||||
return -EMSGSIZE;
|
||||
|
||||
prop = nla_nest_start(skb, TIPC_NLA_LINK_PROP);
|
||||
prop = nla_nest_start_noflag(skb, TIPC_NLA_LINK_PROP);
|
||||
if (!prop)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -811,7 +811,7 @@ static int tipc_nl_compat_link_reset_stats(struct tipc_nl_compat_cmd_doit *cmd,
|
||||
|
||||
name = (char *)TLV_DATA(msg->req);
|
||||
|
||||
link = nla_nest_start(skb, TIPC_NLA_LINK);
|
||||
link = nla_nest_start_noflag(skb, TIPC_NLA_LINK);
|
||||
if (!link)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -973,7 +973,7 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock)
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
nest = nla_nest_start(args, TIPC_NLA_SOCK);
|
||||
nest = nla_nest_start_noflag(args, TIPC_NLA_SOCK);
|
||||
if (!nest) {
|
||||
kfree_skb(args);
|
||||
return -EMSGSIZE;
|
||||
@@ -1100,7 +1100,7 @@ static int tipc_nl_compat_net_set(struct tipc_nl_compat_cmd_doit *cmd,
|
||||
|
||||
val = ntohl(*(__be32 *)TLV_DATA(msg->req));
|
||||
|
||||
net = nla_nest_start(skb, TIPC_NLA_NET);
|
||||
net = nla_nest_start_noflag(skb, TIPC_NLA_NET);
|
||||
if (!net)
|
||||
return -EMSGSIZE;
|
||||
|
||||
|
||||
@@ -1359,7 +1359,7 @@ static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node)
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_NODE);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_NODE);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
@@ -2353,7 +2353,7 @@ static int __tipc_nl_add_monitor_prop(struct net *net, struct tipc_nl_msg *msg)
|
||||
if (!hdr)
|
||||
return -EMSGSIZE;
|
||||
|
||||
attrs = nla_nest_start(msg->skb, TIPC_NLA_MON);
|
||||
attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_MON);
|
||||
if (!attrs)
|
||||
goto msg_full;
|
||||
|
||||
|
||||
@@ -3273,7 +3273,7 @@ static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk)
|
||||
peer_node = tsk_peer_node(tsk);
|
||||
peer_port = tsk_peer_port(tsk);
|
||||
|
||||
nest = nla_nest_start(skb, TIPC_NLA_SOCK_CON);
|
||||
nest = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_CON);
|
||||
if (!nest)
|
||||
return -EMSGSIZE;
|
||||
|
||||
@@ -3332,7 +3332,7 @@ static int __tipc_nl_add_sk(struct sk_buff *skb, struct netlink_callback *cb,
|
||||
if (!hdr)
|
||||
goto msg_cancel;
|
||||
|
||||
attrs = nla_nest_start(skb, TIPC_NLA_SOCK);
|
||||
attrs = nla_nest_start_noflag(skb, TIPC_NLA_SOCK);
|
||||
if (!attrs)
|
||||
goto genlmsg_cancel;
|
||||
|
||||
@@ -3437,7 +3437,7 @@ int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,
|
||||
if (!(sk_filter_state & (1 << sk->sk_state)))
|
||||
return 0;
|
||||
|
||||
attrs = nla_nest_start(skb, TIPC_NLA_SOCK);
|
||||
attrs = nla_nest_start_noflag(skb, TIPC_NLA_SOCK);
|
||||
if (!attrs)
|
||||
goto msg_cancel;
|
||||
|
||||
@@ -3455,7 +3455,7 @@ int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,
|
||||
TIPC_NLA_SOCK_PAD))
|
||||
goto attr_msg_cancel;
|
||||
|
||||
stat = nla_nest_start(skb, TIPC_NLA_SOCK_STAT);
|
||||
stat = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_STAT);
|
||||
if (!stat)
|
||||
goto attr_msg_cancel;
|
||||
|
||||
@@ -3512,7 +3512,7 @@ static int __tipc_nl_add_sk_publ(struct sk_buff *skb,
|
||||
if (!hdr)
|
||||
goto msg_cancel;
|
||||
|
||||
attrs = nla_nest_start(skb, TIPC_NLA_PUBL);
|
||||
attrs = nla_nest_start_noflag(skb, TIPC_NLA_PUBL);
|
||||
if (!attrs)
|
||||
goto genlmsg_cancel;
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ int tipc_udp_nl_add_bearer_data(struct tipc_nl_msg *msg, struct tipc_bearer *b)
|
||||
if (!ub)
|
||||
return -ENODEV;
|
||||
|
||||
nest = nla_nest_start(msg->skb, TIPC_NLA_BEARER_UDP_OPTS);
|
||||
nest = nla_nest_start_noflag(msg->skb, TIPC_NLA_BEARER_UDP_OPTS);
|
||||
if (!nest)
|
||||
goto msg_full;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user