• J
    bridge: netlink dump interface at par with brctl · 5e6d2435
    Jamal Hadi Salim 提交于
    Actually better than brctl showmacs because we can filter by bridge
    port in the kernel.
    The current bridge netlink interface doesnt scale when you have many
    bridges each with large fdbs or even bridges with many bridge ports
    
    And now for the science non-fiction novel you have all been
    waiting for..
    
    //lets see what bridge ports we have
    root@moja-1:/configs/may30-iprt/bridge# ./bridge link show
    8: eth1 state DOWN : <BROADCAST,MULTICAST> mtu 1500 master br0 state
    disabled priority 32 cost 19
    17: sw1-p1 state DOWN : <BROADCAST,NOARP> mtu 1500 master br0 state
    disabled priority 32 cost 100
    
    // show all..
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show
    33:33:00:00:00:01 dev bond0 self permanent
    33:33:00:00:00:01 dev dummy0 self permanent
    33:33:00:00:00:01 dev ifb0 self permanent
    33:33:00:00:00:01 dev ifb1 self permanent
    33:33:00:00:00:01 dev eth0 self permanent
    01:00:5e:00:00:01 dev eth0 self permanent
    33:33:ff:22:01:01 dev eth0 self permanent
    02:00:00:12:01:02 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:05 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:07 dev eth1 self permanent
    33:33:00:00:00:01 dev eth1 self permanent
    33:33:00:00:00:01 dev gretap0 self permanent
    da:ac:46:27:d9:53 dev sw1-p1 vlan 0 master br0 permanent
    33:33:00:00:00:01 dev sw1-p1 self permanent
    
    //filter by bridge
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show br br0
    02:00:00:12:01:02 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:05 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:07 dev eth1 self permanent
    33:33:00:00:00:01 dev eth1 self permanent
    da:ac:46:27:d9:53 dev sw1-p1 vlan 0 master br0 permanent
    33:33:00:00:00:01 dev sw1-p1 self permanent
    
    // bridge sw1 has no ports attached..
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show br sw1
    
    //filter by port
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show brport eth1
    02:00:00:12:01:02 vlan 0 master br0 permanent
    00:17:42:8a:b4:05 vlan 0 master br0 permanent
    00:17:42:8a:b4:07 self permanent
    33:33:00:00:00:01 self permanent
    
    // filter by port + bridge
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show br br0 brport
    sw1-p1
    da:ac:46:27:d9:53 vlan 0 master br0 permanent
    33:33:00:00:00:01 self permanent
    
    // for shits and giggles (as they say in New Brunswick), lets
    // change the mac that br0 uses
    // Note: a magical fdb entry with no brport is added ...
    root@moja-1:/configs/may30-iprt/bridge# ip link set dev br0 address
    02:00:00:12:01:04
    
    // lets see if we can see the unicorn ..
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show
    33:33:00:00:00:01 dev bond0 self permanent
    33:33:00:00:00:01 dev dummy0 self permanent
    33:33:00:00:00:01 dev ifb0 self permanent
    33:33:00:00:00:01 dev ifb1 self permanent
    33:33:00:00:00:01 dev eth0 self permanent
    01:00:5e:00:00:01 dev eth0 self permanent
    33:33:ff:22:01:01 dev eth0 self permanent
    02:00:00:12:01:02 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:05 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:07 dev eth1 self permanent
    33:33:00:00:00:01 dev eth1 self permanent
    33:33:00:00:00:01 dev gretap0 self permanent
    02:00:00:12:01:04 dev br0 vlan 0 master br0 permanent <=== there it is
    da:ac:46:27:d9:53 dev sw1-p1 vlan 0 master br0 permanent
    33:33:00:00:00:01 dev sw1-p1 self permanent
    
    //can we see it if we filter by bridge?
    root@moja-1:/configs/may30-iprt/bridge# ./bridge fdb show br br0
    02:00:00:12:01:02 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:05 dev eth1 vlan 0 master br0 permanent
    00:17:42:8a:b4:07 dev eth1 self permanent
    33:33:00:00:00:01 dev eth1 self permanent
    02:00:00:12:01:04 dev br0 vlan 0 master br0 permanent <=== there it is
    da:ac:46:27:d9:53 dev sw1-p1 vlan 0 master br0 permanent
    33:33:00:00:00:01 dev sw1-p1 self permanent
    Signed-off-by: NJamal Hadi Salim <jhs@mojatatu.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    5e6d2435
rtnetlink.c 73.6 KB