Commit 96cfc505 authored by Sabrina Dubroca's avatar Sabrina Dubroca Committed by David S. Miller

macsec: add consistency check to netlink dumps

Use genl_dump_check_consistent in dump_secy.

Fixes: c09440f7 ("macsec: introduce IEEE 802.1AE driver")
Suggested-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Acked-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3b7d0bd
...@@ -2271,6 +2271,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev, ...@@ -2271,6 +2271,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
if (!hdr) if (!hdr)
return -EMSGSIZE; return -EMSGSIZE;
genl_dump_check_consistent(cb, hdr, &macsec_fam);
if (nla_put_u32(skb, MACSEC_ATTR_IFINDEX, dev->ifindex)) if (nla_put_u32(skb, MACSEC_ATTR_IFINDEX, dev->ifindex))
goto nla_put_failure; goto nla_put_failure;
...@@ -2439,6 +2441,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev, ...@@ -2439,6 +2441,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
return -EMSGSIZE; return -EMSGSIZE;
} }
static int macsec_generation = 1; /* protected by RTNL */
static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb) static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
...@@ -2449,6 +2453,9 @@ static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2449,6 +2453,9 @@ static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)
d = 0; d = 0;
rtnl_lock(); rtnl_lock();
cb->seq = macsec_generation;
for_each_netdev(net, dev) { for_each_netdev(net, dev) {
struct macsec_secy *secy; struct macsec_secy *secy;
...@@ -2920,6 +2927,8 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head) ...@@ -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 net_device *real_dev = macsec->real_dev;
struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev); struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);
macsec_generation++;
unregister_netdevice_queue(dev, head); unregister_netdevice_queue(dev, head);
list_del_rcu(&macsec->secys); list_del_rcu(&macsec->secys);
if (list_empty(&rxd->secys)) if (list_empty(&rxd->secys))
...@@ -3066,6 +3075,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev, ...@@ -3066,6 +3075,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
if (err < 0) if (err < 0)
goto del_dev; goto del_dev;
macsec_generation++;
dev_hold(real_dev); dev_hold(real_dev);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment