1
0

051-02-bridge-allow-setting-hash_max-multicast_router-if-in.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. From 6ae4ae8e512bd229f806c22f8a2cd751e4f987c2 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
  3. Date: Sat, 23 May 2015 03:12:34 +0200
  4. Subject: [PATCH] bridge: allow setting hash_max + multicast_router if
  5. interface is down
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. Network managers like netifd (used in OpenWRT for instance) try to
  10. configure interface options after creation but before setting the
  11. interface up.
  12. Unfortunately the sysfs / bridge currently only allows to configure the
  13. hash_max and multicast_router options when the bridge interface is up.
  14. But since br_multicast_init() doesn't start any timers and only sets
  15. default values and initializes timers it should be save to reconfigure
  16. the default values after that, before things actually get active after
  17. the bridge is set up.
  18. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
  19. Signed-off-by: David S. Miller <davem@davemloft.net>
  20. ---
  21. net/bridge/br_multicast.c | 24 +++---------------------
  22. 1 file changed, 3 insertions(+), 21 deletions(-)
  23. --- a/net/bridge/br_multicast.c
  24. +++ b/net/bridge/br_multicast.c
  25. @@ -1948,11 +1948,9 @@ out:
  26. int br_multicast_set_router(struct net_bridge *br, unsigned long val)
  27. {
  28. - int err = -ENOENT;
  29. + int err = -EINVAL;
  30. spin_lock_bh(&br->multicast_lock);
  31. - if (!netif_running(br->dev))
  32. - goto unlock;
  33. switch (val) {
  34. case 0:
  35. @@ -1963,13 +1961,8 @@ int br_multicast_set_router(struct net_b
  36. br->multicast_router = val;
  37. err = 0;
  38. break;
  39. -
  40. - default:
  41. - err = -EINVAL;
  42. - break;
  43. }
  44. -unlock:
  45. spin_unlock_bh(&br->multicast_lock);
  46. return err;
  47. @@ -1978,11 +1971,9 @@ unlock:
  48. int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val)
  49. {
  50. struct net_bridge *br = p->br;
  51. - int err = -ENOENT;
  52. + int err = -EINVAL;
  53. spin_lock(&br->multicast_lock);
  54. - if (!netif_running(br->dev) || p->state == BR_STATE_DISABLED)
  55. - goto unlock;
  56. switch (val) {
  57. case 0:
  58. @@ -2004,13 +1995,8 @@ int br_multicast_set_port_router(struct
  59. br_multicast_add_router(br, p);
  60. break;
  61. -
  62. - default:
  63. - err = -EINVAL;
  64. - break;
  65. }
  66. -unlock:
  67. spin_unlock(&br->multicast_lock);
  68. return err;
  69. @@ -2115,15 +2101,11 @@ unlock:
  70. int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val)
  71. {
  72. - int err = -ENOENT;
  73. + int err = -EINVAL;
  74. u32 old;
  75. struct net_bridge_mdb_htable *mdb;
  76. spin_lock_bh(&br->multicast_lock);
  77. - if (!netif_running(br->dev))
  78. - goto unlock;
  79. -
  80. - err = -EINVAL;
  81. if (!is_power_of_2(val))
  82. goto unlock;