aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2018-10-28 04:33:09 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-28 22:26:42 -0400
commite6ac075882b2afcdf2d5ab328ce4ab42a1eb9593 (patch)
tree351f72f5042cc32cbe2935a9eb63bd013be0cad2
parent38b4f18d56372e1e21771ab7b0357b853330186c (diff)
macsec: update operstate when lower device changes
Like all other virtual devices (macvlan, vlan), the operstate of a macsec device should match the state of its lower device. This is done by calling netif_stacked_transfer_operstate from its netdevice notifier. We also need to call netif_stacked_transfer_operstate when a new macsec device is created, so that its operstate is set properly. This is only relevant when we try to bring the device up directly when we create it. Radu Rendec proposed a similar patch, inspired from the 802.1q driver, that included changing the administrative state of the macsec device, instead of just the operstate. This version is similar to what the macvlan driver does, and updates only the operstate. Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Reported-by: Radu Rendec <radu.rendec@gmail.com> Reported-by: Patrick Talbert <ptalbert@redhat.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/macsec.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 4bb90b6867a2..6195b8edafc0 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3306,6 +3306,9 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
3306 if (err < 0) 3306 if (err < 0)
3307 goto del_dev; 3307 goto del_dev;
3308 3308
3309 netif_stacked_transfer_operstate(real_dev, dev);
3310 linkwatch_fire_event(dev);
3311
3309 macsec_generation++; 3312 macsec_generation++;
3310 3313
3311 return 0; 3314 return 0;
@@ -3490,6 +3493,20 @@ static int macsec_notify(struct notifier_block *this, unsigned long event,
3490 return NOTIFY_DONE; 3493 return NOTIFY_DONE;
3491 3494
3492 switch (event) { 3495 switch (event) {
3496 case NETDEV_DOWN:
3497 case NETDEV_UP:
3498 case NETDEV_CHANGE: {
3499 struct macsec_dev *m, *n;
3500 struct macsec_rxh_data *rxd;
3501
3502 rxd = macsec_data_rtnl(real_dev);
3503 list_for_each_entry_safe(m, n, &rxd->secys, secys) {
3504 struct net_device *dev = m->secy.netdev;
3505
3506 netif_stacked_transfer_operstate(real_dev, dev);
3507 }
3508 break;
3509 }
3493 case NETDEV_UNREGISTER: { 3510 case NETDEV_UNREGISTER: {
3494 struct macsec_dev *m, *n; 3511 struct macsec_dev *m, *n;
3495 struct macsec_rxh_data *rxd; 3512 struct macsec_rxh_data *rxd;