How do you get VLAN information like addition and deletion of VLAN sub interface from kernel to userspace using NETLINK socket in C?
I did little study in NETLINK man as suggested in comments. I added and deleted a VLAN sub interface and monitored using netlink socket program. For addition & deletion each receiving 3 messages. Addition sends 3 NEWLINK message and deletion sends 2 NEWLINK & 1 DELLINK message. Why is that so?
For addition of new VLAN interface eth1.75:
RTM_NEWLINK Link eth2.75 Down
RTM_NEWLINK Link eth2 Up
RTM_NEWLINK Link eth2.75 Up
For Deletion of VLAN interface eth2.75:
RTM_NEWLINK Link eth2 Up
RTM_NEWLINK Link eth2.75 Down
RTM_DELLINK eth2.75
man 7 netlink
and thenman 7 rtnetlink
. I think you'll get aRTM_NEWLINK
for addition andRTM_DELINK
for removal. Look in the source code for Network Manager for examples. – Croon