@@ -110,7 +110,7 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
110110 return 0 ;
111111}
112112
113- static int dev_setifmap (struct net_device * dev , struct ifreq * ifr )
113+ static int netif_setifmap (struct net_device * dev , struct ifreq * ifr )
114114{
115115 struct compat_ifmap * cifmap = (struct compat_ifmap * )& ifr -> ifr_map ;
116116
@@ -240,20 +240,6 @@ int net_hwtstamp_validate(const struct kernel_hwtstamp_config *cfg)
240240 return 0 ;
241241}
242242
243- static int dev_eth_ioctl (struct net_device * dev ,
244- struct ifreq * ifr , unsigned int cmd )
245- {
246- const struct net_device_ops * ops = dev -> netdev_ops ;
247-
248- if (!ops -> ndo_eth_ioctl )
249- return - EOPNOTSUPP ;
250-
251- if (!netif_device_present (dev ))
252- return - ENODEV ;
253-
254- return ops -> ndo_eth_ioctl (dev , ifr , cmd );
255- }
256-
257243/**
258244 * dev_get_hwtstamp_phylib() - Get hardware timestamping settings of NIC
259245 * or of attached phylib PHY
@@ -305,7 +291,9 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)
305291 return - ENODEV ;
306292
307293 kernel_cfg .ifr = ifr ;
294+ netdev_lock_ops (dev );
308295 err = dev_get_hwtstamp_phylib (dev , & kernel_cfg );
296+ netdev_unlock_ops (dev );
309297 if (err )
310298 return err ;
311299
@@ -429,7 +417,9 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
429417 if (!netif_device_present (dev ))
430418 return - ENODEV ;
431419
420+ netdev_lock_ops (dev );
432421 err = dev_set_hwtstamp_phylib (dev , & kernel_cfg , & extack );
422+ netdev_unlock_ops (dev );
433423 if (err )
434424 return err ;
435425
@@ -504,10 +494,14 @@ static int dev_siocbond(struct net_device *dev,
504494 const struct net_device_ops * ops = dev -> netdev_ops ;
505495
506496 if (ops -> ndo_siocbond ) {
497+ int ret = - ENODEV ;
498+
499+ netdev_lock_ops (dev );
507500 if (netif_device_present (dev ))
508- return ops -> ndo_siocbond (dev , ifr , cmd );
509- else
510- return - ENODEV ;
501+ ret = ops -> ndo_siocbond (dev , ifr , cmd );
502+ netdev_unlock_ops (dev );
503+
504+ return ret ;
511505 }
512506
513507 return - EOPNOTSUPP ;
@@ -519,10 +513,14 @@ static int dev_siocdevprivate(struct net_device *dev, struct ifreq *ifr,
519513 const struct net_device_ops * ops = dev -> netdev_ops ;
520514
521515 if (ops -> ndo_siocdevprivate ) {
516+ int ret = - ENODEV ;
517+
518+ netdev_lock_ops (dev );
522519 if (netif_device_present (dev ))
523- return ops -> ndo_siocdevprivate (dev , ifr , data , cmd );
524- else
525- return - ENODEV ;
520+ ret = ops -> ndo_siocdevprivate (dev , ifr , data , cmd );
521+ netdev_unlock_ops (dev );
522+
523+ return ret ;
526524 }
527525
528526 return - EOPNOTSUPP ;
@@ -533,10 +531,14 @@ static int dev_siocwandev(struct net_device *dev, struct if_settings *ifs)
533531 const struct net_device_ops * ops = dev -> netdev_ops ;
534532
535533 if (ops -> ndo_siocwandev ) {
534+ int ret = - ENODEV ;
535+
536+ netdev_lock_ops (dev );
536537 if (netif_device_present (dev ))
537- return ops -> ndo_siocwandev (dev , ifs );
538- else
539- return - ENODEV ;
538+ ret = ops -> ndo_siocwandev (dev , ifs );
539+ netdev_unlock_ops (dev );
540+
541+ return ret ;
540542 }
541543
542544 return - EOPNOTSUPP ;
@@ -580,27 +582,38 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
580582 memcpy (dev -> broadcast , ifr -> ifr_hwaddr .sa_data ,
581583 min (sizeof (ifr -> ifr_hwaddr .sa_data_min ),
582584 (size_t )dev -> addr_len ));
585+ netdev_lock_ops (dev );
583586 call_netdevice_notifiers (NETDEV_CHANGEADDR , dev );
587+ netdev_unlock_ops (dev );
584588 return 0 ;
585589
586590 case SIOCSIFMAP :
587- return dev_setifmap (dev , ifr );
591+ netdev_lock_ops (dev );
592+ err = netif_setifmap (dev , ifr );
593+ netdev_unlock_ops (dev );
594+ return err ;
588595
589596 case SIOCADDMULTI :
590597 if (!ops -> ndo_set_rx_mode ||
591598 ifr -> ifr_hwaddr .sa_family != AF_UNSPEC )
592599 return - EINVAL ;
593600 if (!netif_device_present (dev ))
594601 return - ENODEV ;
595- return dev_mc_add_global (dev , ifr -> ifr_hwaddr .sa_data );
602+ netdev_lock_ops (dev );
603+ err = dev_mc_add_global (dev , ifr -> ifr_hwaddr .sa_data );
604+ netdev_unlock_ops (dev );
605+ return err ;
596606
597607 case SIOCDELMULTI :
598608 if (!ops -> ndo_set_rx_mode ||
599609 ifr -> ifr_hwaddr .sa_family != AF_UNSPEC )
600610 return - EINVAL ;
601611 if (!netif_device_present (dev ))
602612 return - ENODEV ;
603- return dev_mc_del_global (dev , ifr -> ifr_hwaddr .sa_data );
613+ netdev_lock_ops (dev );
614+ err = dev_mc_del_global (dev , ifr -> ifr_hwaddr .sa_data );
615+ netdev_unlock_ops (dev );
616+ return err ;
604617
605618 case SIOCSIFTXQLEN :
606619 if (ifr -> ifr_qlen < 0 )
0 commit comments