Skip to content

Commit

Permalink
macsec: add consistency check to netlink dumps
Browse files Browse the repository at this point in the history
Use genl_dump_check_consistent in dump_secy.

Fixes: c09440f ("macsec: introduce IEEE 802.1AE driver")
Suggested-by: Johannes Berg <[email protected]>
Signed-off-by: Sabrina Dubroca <[email protected]>
Acked-by: Hannes Frederic Sowa <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
qsn authored and davem330 committed Apr 24, 2016
1 parent c3b7d0b commit 96cfc50
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/net/macsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
if (!hdr)
return -EMSGSIZE;

genl_dump_check_consistent(cb, hdr, &macsec_fam);

if (nla_put_u32(skb, MACSEC_ATTR_IFINDEX, dev->ifindex))
goto nla_put_failure;

Expand Down Expand Up @@ -2439,6 +2441,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
return -EMSGSIZE;
}

static int macsec_generation = 1; /* protected by RTNL */

static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)
{
struct net *net = sock_net(skb->sk);
Expand All @@ -2449,6 +2453,9 @@ static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)

d = 0;
rtnl_lock();

cb->seq = macsec_generation;

for_each_netdev(net, dev) {
struct macsec_secy *secy;

Expand Down Expand Up @@ -2920,6 +2927,8 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
struct net_device *real_dev = macsec->real_dev;
struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);

macsec_generation++;

unregister_netdevice_queue(dev, head);
list_del_rcu(&macsec->secys);
if (list_empty(&rxd->secys))
Expand Down Expand Up @@ -3066,6 +3075,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
if (err < 0)
goto del_dev;

macsec_generation++;

dev_hold(real_dev);

return 0;
Expand Down

0 comments on commit 96cfc50

Please sign in to comment.