With gopacket inactive handle, SetPromisc is not setting the interfaces in PROMISC mode if
/sys/devices/virtual/net/bond1/flags
has value 0x1403. It only works if this value is set to 0x1503. Is there a way I could set interfaces to PROMISC mode regardless of the above value just like tcpdump does?
I am new to this and any help with this is highly appreciated!
Promiscuous mode isn't set until a
pcap_tis activated, so presumably your program eventually activates the inactive handle with{the inactive handle}.Activate(). If it doesn't do that, it won't set promiscuous mode regardless of the setting of the flags. Tcpdump does callpcap_activate()(which is what theActivatemethod calls).The difference between 0x1403 and 0x1503 is that the latter has
IFF_PROMISCset. If what you mean by "It only works if this value is set to 0x1503." is that, if you run your program when flags is set to 0x1403, the interface doesn't go into promiscuous mode, but if you set it to 0x1503 yourself, for example, by writing "0x1503" to /sys/devices/virtual/net/bond1/flags, and then run your program, the interface is in promiscuous mode, what put it into promiscuous was writing "0x1503" to /sys/devices/virtual/net/bond1/flags, not your program - which, if it's not activating the handle, it will never do.If you want your program to put the interface into promiscuous mode, make it activate the handle. Then the interface will be in promiscuous mode as long as the activated handle is open; as soon as it's closed, unless something else also put the interface into promiscuous mode, the interface will go out of promiscuous mode.
This means that if your program exits, the interface will go out of promiscuous mode.