aboutsummaryrefslogtreecommitdiffstats
path: root/net/dcb
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/dcb
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/dcb')
-rw-r--r--net/dcb/dcbnl.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index a556cd708885..3fd3aa7348bd 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -246,7 +246,7 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlmsghdr *nlh,
246 if (ret) 246 if (ret)
247 return ret; 247 return ret;
248 248
249 nest = nla_nest_start(skb, DCB_ATTR_PFC_CFG); 249 nest = nla_nest_start_noflag(skb, DCB_ATTR_PFC_CFG);
250 if (!nest) 250 if (!nest)
251 return -EMSGSIZE; 251 return -EMSGSIZE;
252 252
@@ -304,7 +304,7 @@ static int dcbnl_getcap(struct net_device *netdev, struct nlmsghdr *nlh,
304 if (ret) 304 if (ret)
305 return ret; 305 return ret;
306 306
307 nest = nla_nest_start(skb, DCB_ATTR_CAP); 307 nest = nla_nest_start_noflag(skb, DCB_ATTR_CAP);
308 if (!nest) 308 if (!nest)
309 return -EMSGSIZE; 309 return -EMSGSIZE;
310 310
@@ -348,7 +348,7 @@ static int dcbnl_getnumtcs(struct net_device *netdev, struct nlmsghdr *nlh,
348 if (ret) 348 if (ret)
349 return ret; 349 return ret;
350 350
351 nest = nla_nest_start(skb, DCB_ATTR_NUMTCS); 351 nest = nla_nest_start_noflag(skb, DCB_ATTR_NUMTCS);
352 if (!nest) 352 if (!nest)
353 return -EMSGSIZE; 353 return -EMSGSIZE;
354 354
@@ -479,7 +479,7 @@ static int dcbnl_getapp(struct net_device *netdev, struct nlmsghdr *nlh,
479 up = dcb_getapp(netdev, &app); 479 up = dcb_getapp(netdev, &app);
480 } 480 }
481 481
482 app_nest = nla_nest_start(skb, DCB_ATTR_APP); 482 app_nest = nla_nest_start_noflag(skb, DCB_ATTR_APP);
483 if (!app_nest) 483 if (!app_nest)
484 return -EMSGSIZE; 484 return -EMSGSIZE;
485 485
@@ -578,7 +578,7 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlmsghdr *nlh,
578 if (ret) 578 if (ret)
579 return ret; 579 return ret;
580 580
581 pg_nest = nla_nest_start(skb, DCB_ATTR_PG_CFG); 581 pg_nest = nla_nest_start_noflag(skb, DCB_ATTR_PG_CFG);
582 if (!pg_nest) 582 if (!pg_nest)
583 return -EMSGSIZE; 583 return -EMSGSIZE;
584 584
@@ -598,7 +598,7 @@ static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlmsghdr *nlh,
598 if (ret) 598 if (ret)
599 goto err_pg; 599 goto err_pg;
600 600
601 param_nest = nla_nest_start(skb, i); 601 param_nest = nla_nest_start_noflag(skb, i);
602 if (!param_nest) 602 if (!param_nest)
603 goto err_pg; 603 goto err_pg;
604 604
@@ -889,7 +889,7 @@ static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlmsghdr *nlh,
889 if (ret) 889 if (ret)
890 return ret; 890 return ret;
891 891
892 bcn_nest = nla_nest_start(skb, DCB_ATTR_BCN); 892 bcn_nest = nla_nest_start_noflag(skb, DCB_ATTR_BCN);
893 if (!bcn_nest) 893 if (!bcn_nest)
894 return -EMSGSIZE; 894 return -EMSGSIZE;
895 895
@@ -1002,7 +1002,7 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
1002 */ 1002 */
1003 err = -EMSGSIZE; 1003 err = -EMSGSIZE;
1004 1004
1005 app = nla_nest_start(skb, app_nested_type); 1005 app = nla_nest_start_noflag(skb, app_nested_type);
1006 if (!app) 1006 if (!app)
1007 goto nla_put_failure; 1007 goto nla_put_failure;
1008 1008
@@ -1036,7 +1036,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
1036 if (nla_put_string(skb, DCB_ATTR_IFNAME, netdev->name)) 1036 if (nla_put_string(skb, DCB_ATTR_IFNAME, netdev->name))
1037 return -EMSGSIZE; 1037 return -EMSGSIZE;
1038 1038
1039 ieee = nla_nest_start(skb, DCB_ATTR_IEEE); 1039 ieee = nla_nest_start_noflag(skb, DCB_ATTR_IEEE);
1040 if (!ieee) 1040 if (!ieee)
1041 return -EMSGSIZE; 1041 return -EMSGSIZE;
1042 1042
@@ -1106,7 +1106,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
1106 return -EMSGSIZE; 1106 return -EMSGSIZE;
1107 } 1107 }
1108 1108
1109 app = nla_nest_start(skb, DCB_ATTR_IEEE_APP_TABLE); 1109 app = nla_nest_start_noflag(skb, DCB_ATTR_IEEE_APP_TABLE);
1110 if (!app) 1110 if (!app)
1111 return -EMSGSIZE; 1111 return -EMSGSIZE;
1112 1112
@@ -1174,13 +1174,13 @@ static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev,
1174 u8 pgid, up_map, prio, tc_pct; 1174 u8 pgid, up_map, prio, tc_pct;
1175 const struct dcbnl_rtnl_ops *ops = dev->dcbnl_ops; 1175 const struct dcbnl_rtnl_ops *ops = dev->dcbnl_ops;
1176 int i = dir ? DCB_ATTR_CEE_TX_PG : DCB_ATTR_CEE_RX_PG; 1176 int i = dir ? DCB_ATTR_CEE_TX_PG : DCB_ATTR_CEE_RX_PG;
1177 struct nlattr *pg = nla_nest_start(skb, i); 1177 struct nlattr *pg = nla_nest_start_noflag(skb, i);
1178 1178
1179 if (!pg) 1179 if (!pg)
1180 return -EMSGSIZE; 1180 return -EMSGSIZE;
1181 1181
1182 for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) { 1182 for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) {
1183 struct nlattr *tc_nest = nla_nest_start(skb, i); 1183 struct nlattr *tc_nest = nla_nest_start_noflag(skb, i);
1184 1184
1185 if (!tc_nest) 1185 if (!tc_nest)
1186 return -EMSGSIZE; 1186 return -EMSGSIZE;
@@ -1231,7 +1231,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1231 1231
1232 if (nla_put_string(skb, DCB_ATTR_IFNAME, netdev->name)) 1232 if (nla_put_string(skb, DCB_ATTR_IFNAME, netdev->name))
1233 goto nla_put_failure; 1233 goto nla_put_failure;
1234 cee = nla_nest_start(skb, DCB_ATTR_CEE); 1234 cee = nla_nest_start_noflag(skb, DCB_ATTR_CEE);
1235 if (!cee) 1235 if (!cee)
1236 goto nla_put_failure; 1236 goto nla_put_failure;
1237 1237
@@ -1250,7 +1250,8 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1250 1250
1251 /* local pfc */ 1251 /* local pfc */
1252 if (ops->getpfccfg) { 1252 if (ops->getpfccfg) {
1253 struct nlattr *pfc_nest = nla_nest_start(skb, DCB_ATTR_CEE_PFC); 1253 struct nlattr *pfc_nest = nla_nest_start_noflag(skb,
1254 DCB_ATTR_CEE_PFC);
1254 1255
1255 if (!pfc_nest) 1256 if (!pfc_nest)
1256 goto nla_put_failure; 1257 goto nla_put_failure;
@@ -1265,14 +1266,14 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1265 1266
1266 /* local app */ 1267 /* local app */
1267 spin_lock_bh(&dcb_lock); 1268 spin_lock_bh(&dcb_lock);
1268 app = nla_nest_start(skb, DCB_ATTR_CEE_APP_TABLE); 1269 app = nla_nest_start_noflag(skb, DCB_ATTR_CEE_APP_TABLE);
1269 if (!app) 1270 if (!app)
1270 goto dcb_unlock; 1271 goto dcb_unlock;
1271 1272
1272 list_for_each_entry(itr, &dcb_app_list, list) { 1273 list_for_each_entry(itr, &dcb_app_list, list) {
1273 if (itr->ifindex == netdev->ifindex) { 1274 if (itr->ifindex == netdev->ifindex) {
1274 struct nlattr *app_nest = nla_nest_start(skb, 1275 struct nlattr *app_nest = nla_nest_start_noflag(skb,
1275 DCB_ATTR_APP); 1276 DCB_ATTR_APP);
1276 if (!app_nest) 1277 if (!app_nest)
1277 goto dcb_unlock; 1278 goto dcb_unlock;
1278 1279
@@ -1305,7 +1306,8 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1305 1306
1306 /* features flags */ 1307 /* features flags */
1307 if (ops->getfeatcfg) { 1308 if (ops->getfeatcfg) {
1308 struct nlattr *feat = nla_nest_start(skb, DCB_ATTR_CEE_FEAT); 1309 struct nlattr *feat = nla_nest_start_noflag(skb,
1310 DCB_ATTR_CEE_FEAT);
1309 if (!feat) 1311 if (!feat)
1310 goto nla_put_failure; 1312 goto nla_put_failure;
1311 1313
@@ -1607,7 +1609,7 @@ static int dcbnl_getfeatcfg(struct net_device *netdev, struct nlmsghdr *nlh,
1607 if (ret) 1609 if (ret)
1608 return ret; 1610 return ret;
1609 1611
1610 nest = nla_nest_start(skb, DCB_ATTR_FEATCFG); 1612 nest = nla_nest_start_noflag(skb, DCB_ATTR_FEATCFG);
1611 if (!nest) 1613 if (!nest)
1612 return -EMSGSIZE; 1614 return -EMSGSIZE;
1613 1615