What I have:
I have a system with two interfaces (eth0 and eth1) which are bonded (bond0).
What I want:
I want to know when a link goes up or down and in or out of promiscuous mode without polling each interface all the time. I need this information for logging purposes - to write to a log file automatically.
What I have already done:
I know how to get the link up /down status by polling each interface continuously but, I don't want to do that. I tried some of the example NETLINK socket programs which listen and receive interface names. Using the flags
Code:
ifinfo -> ifi_flags
I was able to distinguish between link up and link down since there are only two flag values I saw when plugging / unplugging the link. However, I don't know what they mean. If they are listed in /usr/include/net/if.h , then I am not able to interpret them properly.
When the interfaces are not bonded I noted the flags integer:
eth0 :4098 For link down
eth0 :4099 For link up
When the interfaces are bonded I noted the flags integer:
eth0 :6146 For link down
eth0 :6147 For link up
And bond0 has a different flags integer which shows up when I change the active slave without touching eth0 or eth1.
However I do not receive the status of the bonded interface when in enters or leaves promiscuous mode.
My questions:
1) How do I understand the flags correctly?
2) I am okay with sending a single request per interface once I have received the bond0 status. Using sendmsg I have not been able to do this. How do I accomplish this ?
3) Is there any easier way around this ?