aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/macsec.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-04-27 17:03:44 -0400
committerDavid S. Miller <davem@davemloft.net>2019-04-27 17:03:44 -0400
commitf6ad55a6a184ebdf3d98a90eab0895f73ce9797e (patch)
treeb49e3af8f5cac309bae80ad390ee8fc3b3679065 /drivers/net/macsec.c
parentc7881b4a97e21b617b8243094dfa4b62028b956c (diff)
parentf78c6032c4cb89b408190afd4feb61ff4461a114 (diff)
Merge branch 'nla_nest_start'
Michal Kubecek says: ==================== make nla_nest_start() add NLA_F_NESTED flag One of the comments in recent review of the ethtool netlink series pointed out that proposed ethnl_nest_start() helper which adds NLA_F_NESTED to second argument of nla_nest_start() is not really specific to ethtool netlink code. That is hard to argue with as closer inspection revealed that exactly the same helper already exists in ipset code (except it's a macro rather than an inline function). Another observation was that even if NLA_F_NESTED flag was introduced in 2007, only few netlink based interfaces set it in kernel generated messages and even many recently added APIs omit it. That is unfortunate as without the flag, message parsers not familiar with attribute semantics cannot recognize nested attributes and do not see message structure; this affects e.g. wireshark dissector or mnl_nlmsg_fprintf() from libmnl. This is why I'm suggesting to rename existing nla_nest_start() to different name (nla_nest_start_noflag) and reintroduce nla_nest_start() as a wrapper adding NLA_F_NESTED flag. This is implemented in first patch which is mostly generated by spatch. Second patch drops ipset helper macros which lose their purpose. Third patch cleans up minor coding style issues found by checkpatch.pl in first patch. We could leave nla_nest_start() untouched and simply add a wrapper adding NLA_F_NESTED but that would probably preserve the state when even most new code doesn't set the flag. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macsec.c')
-rw-r--r--drivers/net/macsec.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 263bfafdb004..8dedb9a9781e 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2365,7 +2365,8 @@ copy_secy_stats(struct sk_buff *skb, struct pcpu_secy_stats __percpu *pstats)
2365static int nla_put_secy(struct macsec_secy *secy, struct sk_buff *skb) 2365static int nla_put_secy(struct macsec_secy *secy, struct sk_buff *skb)
2366{ 2366{
2367 struct macsec_tx_sc *tx_sc = &secy->tx_sc; 2367 struct macsec_tx_sc *tx_sc = &secy->tx_sc;
2368 struct nlattr *secy_nest = nla_nest_start(skb, MACSEC_ATTR_SECY); 2368 struct nlattr *secy_nest = nla_nest_start_noflag(skb,
2369 MACSEC_ATTR_SECY);
2369 u64 csid; 2370 u64 csid;
2370 2371
2371 if (!secy_nest) 2372 if (!secy_nest)
@@ -2435,7 +2436,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2435 if (nla_put_secy(secy, skb)) 2436 if (nla_put_secy(secy, skb))
2436 goto nla_put_failure; 2437 goto nla_put_failure;
2437 2438
2438 attr = nla_nest_start(skb, MACSEC_ATTR_TXSC_STATS); 2439 attr = nla_nest_start_noflag(skb, MACSEC_ATTR_TXSC_STATS);
2439 if (!attr) 2440 if (!attr)
2440 goto nla_put_failure; 2441 goto nla_put_failure;
2441 if (copy_tx_sc_stats(skb, tx_sc->stats)) { 2442 if (copy_tx_sc_stats(skb, tx_sc->stats)) {
@@ -2444,7 +2445,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2444 } 2445 }
2445 nla_nest_end(skb, attr); 2446 nla_nest_end(skb, attr);
2446 2447
2447 attr = nla_nest_start(skb, MACSEC_ATTR_SECY_STATS); 2448 attr = nla_nest_start_noflag(skb, MACSEC_ATTR_SECY_STATS);
2448 if (!attr) 2449 if (!attr)
2449 goto nla_put_failure; 2450 goto nla_put_failure;
2450 if (copy_secy_stats(skb, macsec_priv(dev)->stats)) { 2451 if (copy_secy_stats(skb, macsec_priv(dev)->stats)) {
@@ -2453,7 +2454,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2453 } 2454 }
2454 nla_nest_end(skb, attr); 2455 nla_nest_end(skb, attr);
2455 2456
2456 txsa_list = nla_nest_start(skb, MACSEC_ATTR_TXSA_LIST); 2457 txsa_list = nla_nest_start_noflag(skb, MACSEC_ATTR_TXSA_LIST);
2457 if (!txsa_list) 2458 if (!txsa_list)
2458 goto nla_put_failure; 2459 goto nla_put_failure;
2459 for (i = 0, j = 1; i < MACSEC_NUM_AN; i++) { 2460 for (i = 0, j = 1; i < MACSEC_NUM_AN; i++) {
@@ -2463,7 +2464,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2463 if (!tx_sa) 2464 if (!tx_sa)
2464 continue; 2465 continue;
2465 2466
2466 txsa_nest = nla_nest_start(skb, j++); 2467 txsa_nest = nla_nest_start_noflag(skb, j++);
2467 if (!txsa_nest) { 2468 if (!txsa_nest) {
2468 nla_nest_cancel(skb, txsa_list); 2469 nla_nest_cancel(skb, txsa_list);
2469 goto nla_put_failure; 2470 goto nla_put_failure;
@@ -2478,7 +2479,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2478 goto nla_put_failure; 2479 goto nla_put_failure;
2479 } 2480 }
2480 2481
2481 attr = nla_nest_start(skb, MACSEC_SA_ATTR_STATS); 2482 attr = nla_nest_start_noflag(skb, MACSEC_SA_ATTR_STATS);
2482 if (!attr) { 2483 if (!attr) {
2483 nla_nest_cancel(skb, txsa_nest); 2484 nla_nest_cancel(skb, txsa_nest);
2484 nla_nest_cancel(skb, txsa_list); 2485 nla_nest_cancel(skb, txsa_list);
@@ -2496,7 +2497,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2496 } 2497 }
2497 nla_nest_end(skb, txsa_list); 2498 nla_nest_end(skb, txsa_list);
2498 2499
2499 rxsc_list = nla_nest_start(skb, MACSEC_ATTR_RXSC_LIST); 2500 rxsc_list = nla_nest_start_noflag(skb, MACSEC_ATTR_RXSC_LIST);
2500 if (!rxsc_list) 2501 if (!rxsc_list)
2501 goto nla_put_failure; 2502 goto nla_put_failure;
2502 2503
@@ -2504,7 +2505,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2504 for_each_rxsc_rtnl(secy, rx_sc) { 2505 for_each_rxsc_rtnl(secy, rx_sc) {
2505 int k; 2506 int k;
2506 struct nlattr *rxsa_list; 2507 struct nlattr *rxsa_list;
2507 struct nlattr *rxsc_nest = nla_nest_start(skb, j++); 2508 struct nlattr *rxsc_nest = nla_nest_start_noflag(skb, j++);
2508 2509
2509 if (!rxsc_nest) { 2510 if (!rxsc_nest) {
2510 nla_nest_cancel(skb, rxsc_list); 2511 nla_nest_cancel(skb, rxsc_list);
@@ -2519,7 +2520,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2519 goto nla_put_failure; 2520 goto nla_put_failure;
2520 } 2521 }
2521 2522
2522 attr = nla_nest_start(skb, MACSEC_RXSC_ATTR_STATS); 2523 attr = nla_nest_start_noflag(skb, MACSEC_RXSC_ATTR_STATS);
2523 if (!attr) { 2524 if (!attr) {
2524 nla_nest_cancel(skb, rxsc_nest); 2525 nla_nest_cancel(skb, rxsc_nest);
2525 nla_nest_cancel(skb, rxsc_list); 2526 nla_nest_cancel(skb, rxsc_list);
@@ -2533,7 +2534,8 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2533 } 2534 }
2534 nla_nest_end(skb, attr); 2535 nla_nest_end(skb, attr);
2535 2536
2536 rxsa_list = nla_nest_start(skb, MACSEC_RXSC_ATTR_SA_LIST); 2537 rxsa_list = nla_nest_start_noflag(skb,
2538 MACSEC_RXSC_ATTR_SA_LIST);
2537 if (!rxsa_list) { 2539 if (!rxsa_list) {
2538 nla_nest_cancel(skb, rxsc_nest); 2540 nla_nest_cancel(skb, rxsc_nest);
2539 nla_nest_cancel(skb, rxsc_list); 2541 nla_nest_cancel(skb, rxsc_list);
@@ -2547,7 +2549,7 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2547 if (!rx_sa) 2549 if (!rx_sa)
2548 continue; 2550 continue;
2549 2551
2550 rxsa_nest = nla_nest_start(skb, k++); 2552 rxsa_nest = nla_nest_start_noflag(skb, k++);
2551 if (!rxsa_nest) { 2553 if (!rxsa_nest) {
2552 nla_nest_cancel(skb, rxsa_list); 2554 nla_nest_cancel(skb, rxsa_list);
2553 nla_nest_cancel(skb, rxsc_nest); 2555 nla_nest_cancel(skb, rxsc_nest);
@@ -2555,7 +2557,8 @@ dump_secy(struct macsec_secy *secy, struct net_device *dev,
2555 goto nla_put_failure; 2557 goto nla_put_failure;
2556 } 2558 }
2557 2559
2558 attr = nla_nest_start(skb, MACSEC_SA_ATTR_STATS); 2560 attr = nla_nest_start_noflag(skb,
2561 MACSEC_SA_ATTR_STATS);
2559 if (!attr) { 2562 if (!attr) {
2560 nla_nest_cancel(skb, rxsa_list); 2563 nla_nest_cancel(skb, rxsa_list);
2561 nla_nest_cancel(skb, rxsc_nest); 2564 nla_nest_cancel(skb, rxsc_nest);