实际中遇到需要将vpp接受的数据包送入到内核,采用桥接veth口方式,借鉴了https://blog.csdn.net/Illina/article/details/81669944?spm=1001.2014.3001.5501该篇博主的方案进行了修改,拓扑还是如下,只要是没有再去创建套接字命名空间,另外,创建虚拟口vethns0 时需要设置该mac地址与GigabitEthernet4/0/0 mac地址一样,具体命令如下:
配置veth网口
ip link add vpp0 type veth peer name vethns0
ip link set vethns0 up
ifconfig vethns0 172.16.0.2 netmask 255.255.255.0 hw ether 52:54:9e:45:38:52
ethtool -K vethns0 rx off tx off
route add default gw 172.16.0.1 dev vethns0
vpp配置网口
vpp# set int l2 bridge GigabitEthernet4/0/0 1
vpp# set int state GigabitEthernet4/0/0 up
vpp# create host-interface name vpp0
vpp# set interface state host-vpp0 up
vpp# set interface l2 bridge host-vpp0 1