Skip to content

Commit

Permalink
macsec: update operstate when lower device changes (OnePlusOSS#7)
Browse files Browse the repository at this point in the history
[ Upstream commit e6ac075882b2afcdf2d5ab328ce4ab42a1eb9593 ]

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.

Change-Id: I27b2a5951814cf2b4150ccd1fa108ee7c1a79adc
Fixes: c09440f ("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>
Git-commit: 0fa5ff416504fd4c8a5ea3a1f0b4ba0b4204032c
Git-repo: https://github.com/aquantia/linux-4.14-atlantic-forwarding
Signed-off-by: Jinesh K. Jayakumar <jineshk@codeaurora.org>
  • Loading branch information
qsn authored and Jinesh K. Jayakumar committed Mar 14, 2020
1 parent e578d25 commit 18ee86a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/net/macsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3453,6 +3453,9 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
if (err < 0)
goto del_dev;

netif_stacked_transfer_operstate(real_dev, dev);
linkwatch_fire_event(dev);

macsec_generation++;

return 0;
Expand Down Expand Up @@ -3624,6 +3627,20 @@ static int macsec_notify(struct notifier_block *this, unsigned long event,
return NOTIFY_DONE;

switch (event) {
case NETDEV_DOWN:
case NETDEV_UP:
case NETDEV_CHANGE: {
struct macsec_dev *m, *n;
struct macsec_rxh_data *rxd;

rxd = macsec_data_rtnl(real_dev);
list_for_each_entry_safe(m, n, &rxd->secys, secys) {
struct net_device *dev = m->secy.netdev;

netif_stacked_transfer_operstate(real_dev, dev);
}
break;
}
case NETDEV_UNREGISTER: {
struct macsec_dev *m, *n;
struct macsec_rxh_data *rxd;
Expand Down

0 comments on commit 18ee86a

Please sign in to comment.