aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge/br_multicast.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-02-27 14:41:51 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-28 03:49:46 -0500
commitb195167fcf089dbdc650bb874084555035f07f98 (patch)
tree9b0c491bd1e6e13472d074986869a9aafcb3ae3f /net/bridge/br_multicast.c
parent561f1103a2b70de7e06e1e7fd072a5b142a4278c (diff)
bridge: Add hash elasticity/max sysfs entries
This patch allows the user to control the hash elasticity/max parameters. The elasticity setting does not take effect until the next new multicast group is added. At which point it is checked and if after rehashing it still can't be satisfied then snooping will be disabled. The max setting on the other hand takes effect immediately. It must be a power of two and cannot be set to a value less than the current number of multicast group entries. This is the only way to shrink the multicast hash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_multicast.c')
-rw-r--r--net/bridge/br_multicast.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index c7a1095ed84..2559fb53983 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -15,6 +15,7 @@
15#include <linux/igmp.h> 15#include <linux/igmp.h>
16#include <linux/jhash.h> 16#include <linux/jhash.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/log2.h>
18#include <linux/netdevice.h> 19#include <linux/netdevice.h>
19#include <linux/netfilter_bridge.h> 20#include <linux/netfilter_bridge.h>
20#include <linux/random.h> 21#include <linux/random.h>
@@ -1261,3 +1262,43 @@ unlock:
1261 1262
1262 return err; 1263 return err;
1263} 1264}
1265
1266int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val)
1267{
1268 int err = -ENOENT;
1269 u32 old;
1270
1271 spin_lock(&br->multicast_lock);
1272 if (!netif_running(br->dev))
1273 goto unlock;
1274
1275 err = -EINVAL;
1276 if (!is_power_of_2(val))
1277 goto unlock;
1278 if (br->mdb && val < br->mdb->size)
1279 goto unlock;
1280
1281 err = 0;
1282
1283 old = br->hash_max;
1284 br->hash_max = val;
1285
1286 if (br->mdb) {
1287 if (br->mdb->old) {
1288 err = -EEXIST;
1289rollback:
1290 br->hash_max = old;
1291 goto unlock;
1292 }
1293
1294 err = br_mdb_rehash(&br->mdb, br->hash_max,
1295 br->hash_elasticity);
1296 if (err)
1297 goto rollback;
1298 }
1299
1300unlock:
1301 spin_unlock(&br->multicast_lock);
1302
1303 return err;
1304}