cisco vpp NAT VLAN支持

来源:互联网 发布:xampp mysql登陆 编辑:程序博客网 时间:2024/05/23 18:32

What is implemented:
====================
* NAT44 UDP, TCP, ICMP protocols
* Show and config commands for various parameters for the same
* NF9 logging is implemented but is not tested
 
What is not implemented:
=========================
* TCP MSS
* TCP refresh direction
* Static port forwarding
* Syslog support
* Destination based logging or session logging
* None of the ALGs
* Performance optimization
* Binary APIs, suitable for configuring the feature from netconf/restconf/yang
* Support for VLANs
 

以上是cisco VPP插件vcgn中的readme,表明代码暂不支持VLAN的NAT功能(现在是2016.7.29,VPP代码是此时最新代码)。经过代码分析,发现可以修改代码实现vlan的支持,主要修改地点有两个地方

修改点1:在源代码/vnet/vnet/devices/dpdk/node.s中的函数dpdk_device_input(),原始代码会把收入报文的物理接口索引添加到报文结构体中,但在NAT VLAN中,需要知道的是VLAN子接口的索引,这里通过VLAN ID查找对应子接口,添加位置在vnet_buffer(b0)->sw_if_index[VLIB_TX] = (u32)~0;代码前,也就是设置报文添加接口索引的位置(我的代码是在472行),代码为

/*VLAN*/                    ethernet_header_t *eth0;          u16 *etype;                    eth0 = (ethernet_header_t *) vlib_buffer_get_current(b0);          etype = ð0->type;                     vnet_buffer(b0)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;                    /* vlan tag 0x8100 */                if (*etype == clib_host_to_net_u16(ETHERNET_TYPE_VLAN))             {               vnet_main_t * vnm = vnet_get_main();              vnet_hw_interface_t * hi;              u16 vlan_id;              u16 *id;              uword *vlue = NULL;                            id = (etype + 1);               vlan_id = clib_net_to_host_u16(*id);              hi = vnet_get_hw_interface (vnm, xd->vlib_sw_if_index);              vlue = hash_get(hi->sub_interface_sw_if_index_by_id, vlan_id);              if (vlue)                vnet_buffer(b0)->sw_if_index[VLIB_RX] = (u32)*vlue;            }/*VLAN end*/ 

修改点2:在源代码plugins/vcgn-plugin/vcgn/vcgn_classify.c 中的函数vcgn_classify_node_fn(),解析VLAN ID不正确,将1修改为2

          /* vlan tag 0x8100 */                if (*etype == clib_host_to_net_u16(ETHERNET_TYPE_VLAN)) {             l3_type = (etype + 2); /* Skip 2 bytes of vlan id */              vlib_buffer_advance(b0, 18);                    } else {            l3_type = etype;            vlib_buffer_advance(b0, 14);          }

测试环境:ABC3台服务器,A安装vpp,通过接口eth0 连接交换机,BC各通过自己的接口连接交换机,划分B(vlan10) ,C(vlan20).在A的eth0口创建2个子接口(单臂路由),一个属于vlan10,另一个属于vlan20,配置A中的vpp,vlan10的子接口为进口,vlan20子接口为出口。详细配置见vpp vcgn配置,也就是源代码vcgn插件中的readme。测试结果成功。

备注:配置vcgn后,vpp 不能处理arp,需要手动添加arp表项,ABC都得添加


遗留问题:当show vcgn config时,vpp挂掉,原因就是遍历接口时出错,可以解决

0 0
原创粉丝点击