Skip to content

Commit ee837a1

Browse files
shemmingerdavem330
authored andcommitted
hv_netvsc: simplify callback event code
The callback handler for netlink events can be simplified: * Consolidate check for netlink callback events about this driver itself. * Ignore non-Ethernet devices. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 07d0f00 commit ee837a1

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

drivers/net/hyperv/netvsc_drv.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,10 +1238,6 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
12381238
struct net_device *ndev;
12391239
struct net_device_context *net_device_ctx;
12401240
struct netvsc_device *netvsc_dev;
1241-
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
1242-
1243-
if (eth_ops == NULL || eth_ops == &ethtool_ops)
1244-
return NOTIFY_DONE;
12451241

12461242
/*
12471243
* We will use the MAC address to locate the synthetic interface to
@@ -1286,12 +1282,8 @@ static int netvsc_vf_up(struct net_device *vf_netdev)
12861282
{
12871283
struct net_device *ndev;
12881284
struct netvsc_device *netvsc_dev;
1289-
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
12901285
struct net_device_context *net_device_ctx;
12911286

1292-
if (eth_ops == &ethtool_ops)
1293-
return NOTIFY_DONE;
1294-
12951287
ndev = get_netvsc_net_device(vf_netdev->dev_addr);
12961288
if (!ndev)
12971289
return NOTIFY_DONE;
@@ -1329,10 +1321,6 @@ static int netvsc_vf_down(struct net_device *vf_netdev)
13291321
struct net_device *ndev;
13301322
struct netvsc_device *netvsc_dev;
13311323
struct net_device_context *net_device_ctx;
1332-
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
1333-
1334-
if (eth_ops == &ethtool_ops)
1335-
return NOTIFY_DONE;
13361324

13371325
ndev = get_netvsc_net_device(vf_netdev->dev_addr);
13381326
if (!ndev)
@@ -1361,12 +1349,8 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
13611349
{
13621350
struct net_device *ndev;
13631351
struct netvsc_device *netvsc_dev;
1364-
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
13651352
struct net_device_context *net_device_ctx;
13661353

1367-
if (eth_ops == &ethtool_ops)
1368-
return NOTIFY_DONE;
1369-
13701354
ndev = get_netvsc_net_device(vf_netdev->dev_addr);
13711355
if (!ndev)
13721356
return NOTIFY_DONE;
@@ -1542,13 +1526,21 @@ static int netvsc_netdev_event(struct notifier_block *this,
15421526
{
15431527
struct net_device *event_dev = netdev_notifier_info_to_dev(ptr);
15441528

1529+
/* Skip our own events */
1530+
if (event_dev->netdev_ops == &device_ops)
1531+
return NOTIFY_DONE;
1532+
1533+
/* Avoid non-Ethernet type devices */
1534+
if (event_dev->type != ARPHRD_ETHER)
1535+
return NOTIFY_DONE;
1536+
15451537
/* Avoid Vlan dev with same MAC registering as VF */
15461538
if (event_dev->priv_flags & IFF_802_1Q_VLAN)
15471539
return NOTIFY_DONE;
15481540

15491541
/* Avoid Bonding master dev with same MAC registering as VF */
1550-
if (event_dev->priv_flags & IFF_BONDING &&
1551-
event_dev->flags & IFF_MASTER)
1542+
if ((event_dev->priv_flags & IFF_BONDING) &&
1543+
(event_dev->flags & IFF_MASTER))
15521544
return NOTIFY_DONE;
15531545

15541546
switch (event) {

0 commit comments

Comments
 (0)