Skip to content

Commit 4efd001

Browse files
author
Sabrina Dubroca
committed
macsec: clean up local variables in macsec_notify
JIRA: https://issues.redhat.com/browse/RHEL-26055 commit f29d24a Author: Sabrina Dubroca <sd@queasysnail.net> Date: Thu Nov 7 00:13:30 2024 +0100 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> Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
1 parent 555883d commit 4efd001

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

drivers/net/macsec.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4441,31 +4441,26 @@ static int macsec_notify(struct notifier_block *this, unsigned long event,
44414441
void *ptr)
44424442
{
44434443
struct net_device *real_dev = netdev_notifier_info_to_dev(ptr);
4444+
struct macsec_rxh_data *rxd;
4445+
struct macsec_dev *m, *n;
44444446
LIST_HEAD(head);
44454447

44464448
if (!is_macsec_master(real_dev))
44474449
return NOTIFY_DONE;
44484450

4451+
rxd = macsec_data_rtnl(real_dev);
4452+
44494453
switch (event) {
44504454
case NETDEV_DOWN:
44514455
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:
44574457
list_for_each_entry_safe(m, n, &rxd->secys, secys) {
44584458
struct net_device *dev = m->secy.netdev;
44594459

44604460
netif_stacked_transfer_operstate(real_dev, dev);
44614461
}
44624462
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:
44694464
list_for_each_entry_safe(m, n, &rxd->secys, secys) {
44704465
macsec_common_dellink(m->secy.netdev, &head);
44714466
}
@@ -4475,12 +4470,7 @@ static int macsec_notify(struct notifier_block *this, unsigned long event,
44754470

44764471
unregister_netdevice_many(&head);
44774472
break;
4478-
}
4479-
case NETDEV_CHANGEMTU: {
4480-
struct macsec_dev *m;
4481-
struct macsec_rxh_data *rxd;
4482-
4483-
rxd = macsec_data_rtnl(real_dev);
4473+
case NETDEV_CHANGEMTU:
44844474
list_for_each_entry(m, &rxd->secys, secys) {
44854475
struct net_device *dev = m->secy.netdev;
44864476
unsigned int mtu = real_dev->mtu - (m->secy.icv_len +
@@ -4490,7 +4480,6 @@ static int macsec_notify(struct notifier_block *this, unsigned long event,
44904480
dev_set_mtu(dev, mtu);
44914481
}
44924482
}
4493-
}
44944483

44954484
return NOTIFY_OK;
44964485
}

0 commit comments

Comments
 (0)