Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

macsec: clean up local variables in macsec_notify

For all events, we need to loop over the list of secys, so let's move
the common variables out of the switch/case.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/9b8996af518fbeb3b7d527feb15d5788495e3108.1730929545.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Sabrina Dubroca and committed by
Jakub Kicinski
f29d24a2 bd97c29f

+7 -18
+7 -18
drivers/net/macsec.c
··· 4441 4441 void *ptr) 4442 4442 { 4443 4443 struct net_device *real_dev = netdev_notifier_info_to_dev(ptr); 4444 + struct macsec_rxh_data *rxd; 4445 + struct macsec_dev *m, *n; 4444 4446 LIST_HEAD(head); 4445 4447 4446 4448 if (!is_macsec_master(real_dev)) 4447 4449 return NOTIFY_DONE; 4448 4450 4451 + rxd = macsec_data_rtnl(real_dev); 4452 + 4449 4453 switch (event) { 4450 4454 case NETDEV_DOWN: 4451 4455 case NETDEV_UP: 4452 - case NETDEV_CHANGE: { 4453 - struct macsec_dev *m, *n; 4454 - struct macsec_rxh_data *rxd; 4455 - 4456 - rxd = macsec_data_rtnl(real_dev); 4456 + case NETDEV_CHANGE: 4457 4457 list_for_each_entry_safe(m, n, &rxd->secys, secys) { 4458 4458 struct net_device *dev = m->secy.netdev; 4459 4459 4460 4460 netif_stacked_transfer_operstate(real_dev, dev); 4461 4461 } 4462 4462 break; 4463 - } 4464 - case NETDEV_UNREGISTER: { 4465 - struct macsec_dev *m, *n; 4466 - struct macsec_rxh_data *rxd; 4467 - 4468 - rxd = macsec_data_rtnl(real_dev); 4463 + case NETDEV_UNREGISTER: 4469 4464 list_for_each_entry_safe(m, n, &rxd->secys, secys) { 4470 4465 macsec_common_dellink(m->secy.netdev, &head); 4471 4466 } ··· 4470 4475 4471 4476 unregister_netdevice_many(&head); 4472 4477 break; 4473 - } 4474 - case NETDEV_CHANGEMTU: { 4475 - struct macsec_dev *m; 4476 - struct macsec_rxh_data *rxd; 4477 - 4478 - rxd = macsec_data_rtnl(real_dev); 4478 + case NETDEV_CHANGEMTU: 4479 4479 list_for_each_entry(m, &rxd->secys, secys) { 4480 4480 struct net_device *dev = m->secy.netdev; 4481 4481 unsigned int mtu = real_dev->mtu - (m->secy.icv_len + ··· 4479 4489 if (dev->mtu > mtu) 4480 4490 dev_set_mtu(dev, mtu); 4481 4491 } 4482 - } 4483 4492 } 4484 4493 4485 4494 return NOTIFY_OK;