cisco vpp NAT VLAN支持

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行),代码为

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. /*VLAN*/            
  2.           ethernet_header_t *eth0;  
  3.           u16 *etype;  
  4.             
  5.           eth0 = (ethernet_header_t *) vlib_buffer_get_current(b0);  
  6.           etype = ð0->type;             
  7.   
  8.           vnet_buffer(b0)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;  
  9.             
  10.           /* vlan tag 0x8100 */        
  11.           if (*etype == clib_host_to_net_u16(ETHERNET_TYPE_VLAN))   
  12.             {   
  13.               vnet_main_t * vnm = vnet_get_main();  
  14.               vnet_hw_interface_t * hi;  
  15.               u16 vlan_id;  
  16.               u16 *id;  
  17.               uword *vlue = NULL;  
  18.                 
  19.               id = (etype + 1);   
  20.               vlan_id = clib_net_to_host_u16(*id);  
  21.               hi = vnet_get_hw_interface (vnm, xd->vlib_sw_if_index);  
  22.               vlue = hash_get(hi->sub_interface_sw_if_index_by_id, vlan_id);  
  23.   
  24.               if (vlue)  
  25.                 vnet_buffer(b0)->sw_if_index[VLIB_RX] = (u32)*vlue;  
  26.             }  
  27. /*VLAN end*/   

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

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. /* vlan tag 0x8100 */        
  2. if (*etype == clib_host_to_net_u16(ETHERNET_TYPE_VLAN)) {   
  3.   l3_type = (etype + 2); /* Skip 2 bytes of vlan id */    
  4.   vlib_buffer_advance(b0, 18);            
  5. } else {  
  6.   l3_type = etype;  
  7.   vlib_buffer_advance(b0, 14);  
  8. }  

测试环境: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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值