大致情况:板子接了个交换机,有16个POE口,和一个LAN口。并且17个口分了不同的vlan,8021q协议的。
需求:
1.需要在内核里获取vlanid,知道当前数据是从哪个口来的。
2.获取vlanid后,关掉vlan功能,让17个口,能ping通。
3.不能配置17个vlan的网口,ifconfig里只能有一个eth0物理网口。
解决方法:
1.内核使能8021q编译选项。
2.
vconfig add eth0 1
vconfig add eth0 2001
vconfig add eth0 2002
vconfig add eth0 2003
使用vconfig划分17个vlan后,使能eth0.
3.vlanid在stmmac_rx的stmmac_rx_vlan里获取。
4.kernel里注释掉vlan_do_receive的vlan dev的指针,即可。
kernel所有带有vlanid的数据,都会走eth0,并且都能互相ping通.