How to get the list of bridge interfaces configured in kernel using IPDB functionality.

37 views
Skip to first unread message

rishi narian

unread,
Feb 14, 2018, 9:39:29 PM2/14/18
to pyroute2-dev
Hi,

     I want to fetch the bridge information associated to the interfaces.
   
     1. How to get the list of bridge interfaces using IPDB functionality?
     2. How to identify the master (root) and slave bridge?
     3. How to get the associated vlans configured for the bridge?
     4. How to  get the information about the veth pairs configured in the kernel.

 >  brctl show command output


Thanks
--Muni

   

Peter Saveliev

unread,
Feb 15, 2018, 4:00:22 AM2/15/18
to rishi narian, pyroute2-dev
1. Let's assume we have an IPDB instance as ipdb:

[x.ifname for x in ipdb.by_name.values() if x.kind == 'bridge']
-> ['br0', 'virbr0']


2. Every bridge has an attribute named ports, every port has an attribute named master. NB: it doesn't work for OVS!
3. Every bridge and every port has an attribute named vlans
4. Filter out objects of the kind veth as in 1., and every veth object will have an attribute named link that points to the pair, like that:

[(x.ifname, ipdb.interfaces[x.link].ifname) for x in ipdb.by_name.values() if x.kind == 'veth' and x.link != 0]
->  [('vethX0', 'vethX1'), ('vethY0', 'vethY1')]

--
You received this message because you are subscribed to the Google Groups "pyroute2-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rishi narian

unread,
Feb 15, 2018, 8:15:26 AM2/15/18
to Peter Saveliev, pyroute2-dev
Hi Peter,

   Thanks a lot for your help.
   The provided information solves many of issues in my development.


Regards
-R

Peter Saveliev

unread,
Feb 15, 2018, 10:32:24 AM2/15/18
to rishi narian, pyroute2-dev
You're welcome :)
Reply all
Reply to author
Forward
0 new messages