Get all VLAN interfaces of a real interface

557 Views Asked by At

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.

1

There are 1 best solutions below

0
Inu1997 On

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 */
...