So what I'm looking for is an interface index (or name) but the real one.
if_nametoindex(3)
and ioctl(2)
don't seem to help me here. Now the only way I found how to do this is via /sys
. Let me demonstrate on example what I need:
# cat /sys/class/net/bond0.1007/ifindex
26
# cat /sys/class/net/bond0.1007/iflink
23 <-- I need either this or a reference to bond0
# cat /sys/class/net/bond0/ifindex
23
Is there a way to do it with a function call or the only way is sysfs
?
ip link show
does (probably using the netlink api)/proc/net/vlan/config
or/proc/net/vlan/bond0.1007
if it's a vlan interface./sys
./proc
or/sys
are more or less the same in that sense. I just wanted to check if there is a syscall to get this kind of info, it turns out there is not.RTM_GETLINK
message and look forIFLA_LINK
attribute in reply.