[quagga-dev 10966] Re: Getting full interface list from zebra

Christian Franke nobody at nowhere.ws
Sat Dec 14 09:29:38 GMT 2013


On 12/13/2013 10:15 PM, Adrian Ban wrote:
> My question is now to save some time for looking in the sources: how I
> create that periodical scanning using the Quagga functions?

The current implementation in Zebra is not really targeted that much at
polling although you could also poll on the interface information in
your client by just registering a periodic timeout. Maybe it helps if I
write a short description how these parts fit together and then you can
decide how you want to go about that.

Whenever an interface is added or removed from the kernel, Zebra will
notice this as it is subscribed to netlink (as far as Linux is
concerned, other platforms use different mechanisms) and will propagate
that information to the connected Zebra clients.
So whenever an interface is added/removed from the kernel, the callback
interface_add/interface_delete which you can register in your zclient
will be called.

For an example assume that a user has configured an L2VPN interface to
be bridged to some other interface, but that L2VPN interface is not
present yet. As soon as the interface becomes available, the kernel will
immediately notify Zebra using netlink. Zebra will then send your daemon
a ZEBRA_INTERFACE_ADD message with the information about the new
interface. In your daemon, the zclient code from libzebra will receive
that and call zclient->interface_add, allowing you to react to this new
interface as soon as it becomes available.

In libzebra there is some code to handle interface_add/interface_delete
messages and build a local list of physical interfaces from that. Most
Quagga daemons make use of that, OSPFd would be an example you could
look at. If you feel that polling is better, you could regularly walk
the whole interface list maintained by these functions.


More information about the Quagga-dev mailing list