@@ -933,7 +933,7 @@ static bool team_port_find(const struct team *team,
933
933
* Enable/disable port by adding to enabled port hashlist and setting
934
934
* port->index (Might be racy so reader could see incorrect ifindex when
935
935
* processing a flying packet, but that is not a problem). Write guarded
936
- * by team->lock .
936
+ * by RTNL .
937
937
*/
938
938
static void team_port_enable (struct team * team ,
939
939
struct team_port * port )
@@ -1660,8 +1660,6 @@ static int team_init(struct net_device *dev)
1660
1660
goto err_options_register ;
1661
1661
netif_carrier_off (dev );
1662
1662
1663
- lockdep_register_key (& team -> team_lock_key );
1664
- __mutex_init (& team -> lock , "team->team_lock_key" , & team -> team_lock_key );
1665
1663
netdev_lockdep_set_classes (dev );
1666
1664
1667
1665
return 0 ;
@@ -1682,7 +1680,8 @@ static void team_uninit(struct net_device *dev)
1682
1680
struct team_port * port ;
1683
1681
struct team_port * tmp ;
1684
1682
1685
- mutex_lock (& team -> lock );
1683
+ ASSERT_RTNL ();
1684
+
1686
1685
list_for_each_entry_safe (port , tmp , & team -> port_list , list )
1687
1686
team_port_del (team , port -> dev );
1688
1687
@@ -1691,9 +1690,7 @@ static void team_uninit(struct net_device *dev)
1691
1690
team_mcast_rejoin_fini (team );
1692
1691
team_notify_peers_fini (team );
1693
1692
team_queue_override_fini (team );
1694
- mutex_unlock (& team -> lock );
1695
1693
netdev_change_features (dev );
1696
- lockdep_unregister_key (& team -> team_lock_key );
1697
1694
}
1698
1695
1699
1696
static void team_destructor (struct net_device * dev )
@@ -1778,7 +1775,8 @@ static void team_change_rx_flags(struct net_device *dev, int change)
1778
1775
struct team_port * port ;
1779
1776
int inc ;
1780
1777
1781
- mutex_lock (& team -> lock );
1778
+ ASSERT_RTNL ();
1779
+
1782
1780
list_for_each_entry (port , & team -> port_list , list ) {
1783
1781
if (change & IFF_PROMISC ) {
1784
1782
inc = dev -> flags & IFF_PROMISC ? 1 : -1 ;
@@ -1789,7 +1787,6 @@ static void team_change_rx_flags(struct net_device *dev, int change)
1789
1787
dev_set_allmulti (port -> dev , inc );
1790
1788
}
1791
1789
}
1792
- mutex_unlock (& team -> lock );
1793
1790
}
1794
1791
1795
1792
static void team_set_rx_mode (struct net_device * dev )
@@ -1811,14 +1808,14 @@ static int team_set_mac_address(struct net_device *dev, void *p)
1811
1808
struct team * team = netdev_priv (dev );
1812
1809
struct team_port * port ;
1813
1810
1811
+ ASSERT_RTNL ();
1812
+
1814
1813
if (dev -> type == ARPHRD_ETHER && !is_valid_ether_addr (addr -> sa_data ))
1815
1814
return - EADDRNOTAVAIL ;
1816
1815
dev_addr_set (dev , addr -> sa_data );
1817
- mutex_lock (& team -> lock );
1818
1816
list_for_each_entry (port , & team -> port_list , list )
1819
1817
if (team -> ops .port_change_dev_addr )
1820
1818
team -> ops .port_change_dev_addr (team , port );
1821
- mutex_unlock (& team -> lock );
1822
1819
return 0 ;
1823
1820
}
1824
1821
@@ -1828,11 +1825,8 @@ static int team_change_mtu(struct net_device *dev, int new_mtu)
1828
1825
struct team_port * port ;
1829
1826
int err ;
1830
1827
1831
- /*
1832
- * Alhough this is reader, it's guarded by team lock. It's not possible
1833
- * to traverse list in reverse under rcu_read_lock
1834
- */
1835
- mutex_lock (& team -> lock );
1828
+ ASSERT_RTNL ();
1829
+
1836
1830
team -> port_mtu_change_allowed = true;
1837
1831
list_for_each_entry (port , & team -> port_list , list ) {
1838
1832
err = dev_set_mtu (port -> dev , new_mtu );
@@ -1843,7 +1837,6 @@ static int team_change_mtu(struct net_device *dev, int new_mtu)
1843
1837
}
1844
1838
}
1845
1839
team -> port_mtu_change_allowed = false;
1846
- mutex_unlock (& team -> lock );
1847
1840
1848
1841
WRITE_ONCE (dev -> mtu , new_mtu );
1849
1842
@@ -1853,7 +1846,6 @@ static int team_change_mtu(struct net_device *dev, int new_mtu)
1853
1846
list_for_each_entry_continue_reverse (port , & team -> port_list , list )
1854
1847
dev_set_mtu (port -> dev , dev -> mtu );
1855
1848
team -> port_mtu_change_allowed = false;
1856
- mutex_unlock (& team -> lock );
1857
1849
1858
1850
return err ;
1859
1851
}
@@ -1903,24 +1895,19 @@ static int team_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
1903
1895
struct team_port * port ;
1904
1896
int err ;
1905
1897
1906
- /*
1907
- * Alhough this is reader, it's guarded by team lock. It's not possible
1908
- * to traverse list in reverse under rcu_read_lock
1909
- */
1910
- mutex_lock (& team -> lock );
1898
+ ASSERT_RTNL ();
1899
+
1911
1900
list_for_each_entry (port , & team -> port_list , list ) {
1912
1901
err = vlan_vid_add (port -> dev , proto , vid );
1913
1902
if (err )
1914
1903
goto unwind ;
1915
1904
}
1916
- mutex_unlock (& team -> lock );
1917
1905
1918
1906
return 0 ;
1919
1907
1920
1908
unwind :
1921
1909
list_for_each_entry_continue_reverse (port , & team -> port_list , list )
1922
1910
vlan_vid_del (port -> dev , proto , vid );
1923
- mutex_unlock (& team -> lock );
1924
1911
1925
1912
return err ;
1926
1913
}
@@ -1930,10 +1917,10 @@ static int team_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
1930
1917
struct team * team = netdev_priv (dev );
1931
1918
struct team_port * port ;
1932
1919
1933
- mutex_lock (& team -> lock );
1920
+ ASSERT_RTNL ();
1921
+
1934
1922
list_for_each_entry (port , & team -> port_list , list )
1935
1923
vlan_vid_del (port -> dev , proto , vid );
1936
- mutex_unlock (& team -> lock );
1937
1924
1938
1925
return 0 ;
1939
1926
}
@@ -1955,9 +1942,9 @@ static void team_netpoll_cleanup(struct net_device *dev)
1955
1942
{
1956
1943
struct team * team = netdev_priv (dev );
1957
1944
1958
- mutex_lock (& team -> lock );
1945
+ ASSERT_RTNL ();
1946
+
1959
1947
__team_netpoll_cleanup (team );
1960
- mutex_unlock (& team -> lock );
1961
1948
}
1962
1949
1963
1950
static int team_netpoll_setup (struct net_device * dev )
@@ -1966,15 +1953,15 @@ static int team_netpoll_setup(struct net_device *dev)
1966
1953
struct team_port * port ;
1967
1954
int err = 0 ;
1968
1955
1969
- mutex_lock (& team -> lock );
1956
+ ASSERT_RTNL ();
1957
+
1970
1958
list_for_each_entry (port , & team -> port_list , list ) {
1971
1959
err = __team_port_enable_netpoll (port );
1972
1960
if (err ) {
1973
1961
__team_netpoll_cleanup (team );
1974
1962
break ;
1975
1963
}
1976
1964
}
1977
- mutex_unlock (& team -> lock );
1978
1965
return err ;
1979
1966
}
1980
1967
#endif
@@ -1985,9 +1972,9 @@ static int team_add_slave(struct net_device *dev, struct net_device *port_dev,
1985
1972
struct team * team = netdev_priv (dev );
1986
1973
int err ;
1987
1974
1988
- mutex_lock (& team -> lock );
1975
+ ASSERT_RTNL ();
1976
+
1989
1977
err = team_port_add (team , port_dev , extack );
1990
- mutex_unlock (& team -> lock );
1991
1978
1992
1979
if (!err )
1993
1980
netdev_change_features (dev );
@@ -2000,18 +1987,13 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev)
2000
1987
struct team * team = netdev_priv (dev );
2001
1988
int err ;
2002
1989
2003
- mutex_lock (& team -> lock );
1990
+ ASSERT_RTNL ();
1991
+
2004
1992
err = team_port_del (team , port_dev );
2005
- mutex_unlock (& team -> lock );
2006
1993
2007
1994
if (err )
2008
1995
return err ;
2009
1996
2010
- if (netif_is_team_master (port_dev )) {
2011
- lockdep_unregister_key (& team -> team_lock_key );
2012
- lockdep_register_key (& team -> team_lock_key );
2013
- lockdep_set_class (& team -> lock , & team -> team_lock_key );
2014
- }
2015
1997
netdev_change_features (dev );
2016
1998
2017
1999
return err ;
@@ -2304,9 +2286,10 @@ int team_nl_noop_doit(struct sk_buff *skb, struct genl_info *info)
2304
2286
static struct team * team_nl_team_get (struct genl_info * info )
2305
2287
{
2306
2288
struct net * net = genl_info_net (info );
2307
- int ifindex ;
2308
2289
struct net_device * dev ;
2309
- struct team * team ;
2290
+ int ifindex ;
2291
+
2292
+ ASSERT_RTNL ();
2310
2293
2311
2294
if (!info -> attrs [TEAM_ATTR_TEAM_IFINDEX ])
2312
2295
return NULL ;
@@ -2318,14 +2301,11 @@ static struct team *team_nl_team_get(struct genl_info *info)
2318
2301
return NULL ;
2319
2302
}
2320
2303
2321
- team = netdev_priv (dev );
2322
- mutex_lock (& team -> lock );
2323
- return team ;
2304
+ return netdev_priv (dev );
2324
2305
}
2325
2306
2326
2307
static void team_nl_team_put (struct team * team )
2327
2308
{
2328
- mutex_unlock (& team -> lock );
2329
2309
dev_put (team -> dev );
2330
2310
}
2331
2311
@@ -2515,9 +2495,13 @@ int team_nl_options_get_doit(struct sk_buff *skb, struct genl_info *info)
2515
2495
int err ;
2516
2496
LIST_HEAD (sel_opt_inst_list );
2517
2497
2498
+ rtnl_lock ();
2499
+
2518
2500
team = team_nl_team_get (info );
2519
- if (!team )
2520
- return - EINVAL ;
2501
+ if (!team ) {
2502
+ err = - EINVAL ;
2503
+ goto rtnl_unlock ;
2504
+ }
2521
2505
2522
2506
list_for_each_entry (opt_inst , & team -> option_inst_list , list )
2523
2507
list_add_tail (& opt_inst -> tmp_list , & sel_opt_inst_list );
@@ -2527,6 +2511,9 @@ int team_nl_options_get_doit(struct sk_buff *skb, struct genl_info *info)
2527
2511
2528
2512
team_nl_team_put (team );
2529
2513
2514
+ rtnl_unlock :
2515
+ rtnl_unlock ();
2516
+
2530
2517
return err ;
2531
2518
}
2532
2519
@@ -2805,15 +2792,22 @@ int team_nl_port_list_get_doit(struct sk_buff *skb,
2805
2792
struct team * team ;
2806
2793
int err ;
2807
2794
2795
+ rtnl_lock ();
2796
+
2808
2797
team = team_nl_team_get (info );
2809
- if (!team )
2810
- return - EINVAL ;
2798
+ if (!team ) {
2799
+ err = - EINVAL ;
2800
+ goto rtnl_unlock ;
2801
+ }
2811
2802
2812
2803
err = team_nl_send_port_list_get (team , info -> snd_portid , info -> snd_seq ,
2813
2804
NLM_F_ACK , team_nl_send_unicast , NULL );
2814
2805
2815
2806
team_nl_team_put (team );
2816
2807
2808
+ rtnl_unlock :
2809
+ rtnl_unlock ();
2810
+
2817
2811
return err ;
2818
2812
}
2819
2813
@@ -2961,11 +2955,9 @@ static void __team_port_change_port_removed(struct team_port *port)
2961
2955
2962
2956
static void team_port_change_check (struct team_port * port , bool linkup )
2963
2957
{
2964
- struct team * team = port -> team ;
2958
+ ASSERT_RTNL () ;
2965
2959
2966
- mutex_lock (& team -> lock );
2967
2960
__team_port_change_check (port , linkup );
2968
- mutex_unlock (& team -> lock );
2969
2961
}
2970
2962
2971
2963
0 commit comments