最近对bridge状态下的mac learning 做了限制学习到的mac的数目。具体可以参照以下:
一:针对桥的brctl的命令行,
如果要限制mac的学习能力,可以将老化时间设置为0.
即:brctl setageing br-lan1 0
但是这个会清除掉所有的mac表,并且之后一直不会学习mac表
二:通过对添加表项的限制
1)限制表项的添加
对于底层linux的修改,在对表项做了限制:
表项添加的接口如下:
linux\net\bridge\br_fdb
static void fdb_count_mactable(struct net_bridge *br, int * maccount)
{
int i;
if(maccount)
{
spin_lock_bh(&br->hash_lock);
for (i = 0; i < BR_HASH_SIZE; i++)
{
struct net_bridge_fdb_entry *f;
struct hlist_node *h, *n;
hlist_for_each_entry_safe(f, h, n, &br->hash[i], hlist)
{
(*maccount)++;
}
}
spin_unlock_bh(&br->hash_lock);
}
}
此接口是查询对应的bridge interface learning tables counts
然后在 bridge里面添加一个字段,这个字段是学习表项的能力,字段添加在下列文件中:
linux\net\bridge\br_private
struct net_bridge -- 此结构体最后添加一个字段表示学习的能力
/* add by cdd for limiting the mac tables number */
int limitmactable; /* 0 -- 表示不限制 */
三:关于一些详细的介绍可以参照以下网址
http://ask.xmodulo.com/disable-mac-learning-linux-bridge.html