summaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
authorLinus Lüssing <linus.luessing@c0d3.blue>2015-05-22 21:12:34 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-25 17:28:01 -0400
commit6ae4ae8e512bd229f806c22f8a2cd751e4f987c2 (patch)
tree97391e61e15ecc988786fe6b36a2db525c2694d7 /net/bridge
parent485fca664d76c47fb2a17dcd2ce705a0f137cc3b (diff)
bridge: allow setting hash_max + multicast_router if interface is down
Network managers like netifd (used in OpenWRT for instance) try to configure interface options after creation but before setting the interface up. Unfortunately the sysfs / bridge currently only allows to configure the hash_max and multicast_router options when the bridge interface is up. But since br_multicast_init() doesn't start any timers and only sets default values and initializes timers it should be save to reconfigure the default values after that, before things actually get active after the bridge is set up. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/br_multicast.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index d7e103e3538a..7c78b8df1d81 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1772,11 +1772,9 @@ out:
1772 1772
1773int br_multicast_set_router(struct net_bridge *br, unsigned long val) 1773int br_multicast_set_router(struct net_bridge *br, unsigned long val)
1774{ 1774{
1775 int err = -ENOENT; 1775 int err = -EINVAL;
1776 1776
1777 spin_lock_bh(&br->multicast_lock); 1777 spin_lock_bh(&br->multicast_lock);
1778 if (!netif_running(br->dev))
1779 goto unlock;
1780 1778
1781 switch (val) { 1779 switch (val) {
1782 case 0: 1780 case 0:
@@ -1787,13 +1785,8 @@ int br_multicast_set_router(struct net_bridge *br, unsigned long val)
1787 br->multicast_router = val; 1785 br->multicast_router = val;
1788 err = 0; 1786 err = 0;
1789 break; 1787 break;
1790
1791 default:
1792 err = -EINVAL;
1793 break;
1794 } 1788 }
1795 1789
1796unlock:
1797 spin_unlock_bh(&br->multicast_lock); 1790 spin_unlock_bh(&br->multicast_lock);
1798 1791
1799 return err; 1792 return err;
@@ -1802,11 +1795,9 @@ unlock:
1802int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val) 1795int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val)
1803{ 1796{
1804 struct net_bridge *br = p->br; 1797 struct net_bridge *br = p->br;
1805 int err = -ENOENT; 1798 int err = -EINVAL;
1806 1799
1807 spin_lock(&br->multicast_lock); 1800 spin_lock(&br->multicast_lock);
1808 if (!netif_running(br->dev) || p->state == BR_STATE_DISABLED)
1809 goto unlock;
1810 1801
1811 switch (val) { 1802 switch (val) {
1812 case 0: 1803 case 0:
@@ -1828,13 +1819,8 @@ int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val)
1828 1819
1829 br_multicast_add_router(br, p); 1820 br_multicast_add_router(br, p);
1830 break; 1821 break;
1831
1832 default:
1833 err = -EINVAL;
1834 break;
1835 } 1822 }
1836 1823
1837unlock:
1838 spin_unlock(&br->multicast_lock); 1824 spin_unlock(&br->multicast_lock);
1839 1825
1840 return err; 1826 return err;
@@ -1939,15 +1925,11 @@ unlock:
1939 1925
1940int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val) 1926int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val)
1941{ 1927{
1942 int err = -ENOENT; 1928 int err = -EINVAL;
1943 u32 old; 1929 u32 old;
1944 struct net_bridge_mdb_htable *mdb; 1930 struct net_bridge_mdb_htable *mdb;
1945 1931
1946 spin_lock_bh(&br->multicast_lock); 1932 spin_lock_bh(&br->multicast_lock);
1947 if (!netif_running(br->dev))
1948 goto unlock;
1949
1950 err = -EINVAL;
1951 if (!is_power_of_2(val)) 1933 if (!is_power_of_2(val))
1952 goto unlock; 1934 goto unlock;
1953 1935