0

I create a VLAN interface with the following command in shell.

ip link add link port-1 name port-1.10 type vlan id 10

and I want my netdevice driver kernel module be able to get all the information of VLAN interfaces I create including vlan ID.

What struct member should I look into or kernel code should I call?

I tried to look into linux/netdevice.h and got no idea what function should I call. I wish there is a list of VLAN interfaces of a real interface for me to look up.

Inu1997
  • 3
  • 2
  • Check this link I think you might find your answer https://askubuntu.com/questions/495969/how-can-i-see-which-vlan-a-virtual-network-interface-is-assigned-to – ArushD Feb 14 '23 at 08:44
  • VLAN interfaces are real interfaces. I think you mean to distinguish between physical and logical (virtual) interfaces. Both types are real interfaces and can be used. – Ron Maupin Feb 14 '23 at 13:42
  • Thank you both for giving me the idea and the right directions to look into. – Inu1997 Feb 15 '23 at 03:44

1 Answers1

0

I realized that I do not need to check ALL the VLAN interfaces that I've created. Instead I check whether the VLAN tag in the packet has a match VLAN interface with the following code.

struct net_device *vlan_dev;
...
vlan_dev = __vlan_find_dev_deep_rcu(dev, svlan ? htons(ETH_P_8021AD) : htons(ETH_P_8021Q), vid);
if (vlan_dev == NULL) {
    /* There's no match VLAN interface. */
    ...
}
/* There's a match VLAN interface */
...
0andriy
  • 4,183
  • 1
  • 24
  • 37
Inu1997
  • 3
  • 2