DPDK-l3fwd示例IPv6测试

测试环境

操作系统: Ubuntu 20.04 LTS;
处理器为: Intel® Core™ i7-4790K CPU @ 4.00GHz。
网卡使用的是Intel的X710万兆网卡。
DPDK版本19.02。

测试拓扑:

                      |----------------|
                      |  Ubuntu(DPDK)  |
                      |                |
                      |  eth0   eth1   |
           2001:11::1 |----|------|----|  2001:22::1
    00:60:E0:6F:C8:7D      |      |       00:60:E0:6F:C8:7E
                          /        \
                         /          \
                        /            \
                       /              \
  00:60:E0:7A:6C:78   /                \   00:60:E0:7A:6C:79
     2001:11::2/64   |                  |  2001:22::2/64
            |--------|------|   |-------|-------|
            |      eth0     |   |     eth0      |
            |               |   |               |
            |    Ubuntu0    |   |    Ubuntu1    |
            |---------------|   |---------------|

环境配置

如下l3fwd_lpm.c文件中的默认路由表项(经过了修改),port0的网段为:2001:11::0/64;port1的网段为:2001:22::0/64。以上拓扑假定port0的IP地址为:2001:11::1;port1的IP地址为:2001:22::1,当然也可以使用其它的地址,只要是同一网段即可。

 53 static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = {
 54     {{0x20, 1, 0, 0x11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 0},
 55     {{0x20, 1, 0, 0x22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 1},

以下为Ubuntu0的配置,其接口eth0的IP地址为2001:11::2,默认网关设置为Ubuntu(DPDK)的eth0(DPDK中的port0):

/ # ip -6 r add default via 2001:11::1
/ #
/ # ip -6 r
2001:11::/64 dev eth0 proto kernel metric 256 
fe80::/64 dev eth0 proto kernel metric 256 
default via 2001:11::1 dev eth0 metric 1024 

由于DPDK的l3fwd不能处理ARP,需要在Ubuntu0上静态指定Ubuntu(DPDK)的eth0接口IP地址对应的MAC地址:

/ # ip -6 n add 2001:11::1 lladdr 00:60:E0:6F:C8:7D dev eth0
/ # 
/ # ip ne
2001:11::1 dev eth0 lladdr 00:60:e0:6f:c8:7d PERMANENT

以下为Ubuntu1的配置,配置与Ubuntu0类似。其接口eth0的IP地址为2001:22::2,默认网关设置为Ubuntu(DPDK)的eth1(DPDK中的port1):

/ # ip -6 route add default via 2001:22::1
/ #
/ # ip -6 r
2001:22::/64 dev eth0 proto kernel metric 256 
fe80::/64 dev eth0 proto kernel metric 256 
default via 2001:22::1 dev eth0 metric 1024 
/ # 

由于DPDK的l3fwd不能处理ARP,需要在Ubuntu1上静态指定Ubuntu(DPDK)的eth1接口IP地址对应的MAC地址:

/ # ip -6 n add 2001:22::1 lladdr 00:60:E0:6F:C8:7E dev eth0
/ #
/ # ip nei
2001:22::1 dev eth0 lladdr 00:60:e0:6f:c8:7e PERMANENT

启动l3fwd

如下命令启动l3fwd例程,eth-dest参数分别指定Ubuntu0和Ubuntu1的eth0接口的MAC地址。

./l3fwd -c 0x6 -- -p 0x3 -P --eth-dest=0,00:60:E0:7A:6C:78 --eth-dest=1,00:60:E0:7A:6C:79

如下的启动信息,port0发送报文时,使用源MAC地址为:00:60:E0:6F:C8:7D,目的MAC地址为:00:60:E0:7A:6C:78。port1发送报文时,使用源MAC地址00:60:E0:6F:C8:7E,目的MAC地址为00:60:E0:7A:6C:79。

另外,也可看到添加到LPM中的IPv6路由项,原始的l3fwd并不打印LPM6路由表项,以下显示为自行添加。

LPM or EM none selected, default LPM on
Initializing port 0 ... Creating queues: nb_rxq=1 nb_txq=2... 
Port 0 modified RSS hash function based on hardware support,requested:0xa38c configured:0x2288
Address:00:60:E0:6F:C8:7D, Destination:00:60:E0:6D:90:76, Allocated mbuf pool on socket 0
LPM: Adding route 0x01010100 / 24 (0)
LPM: Adding route 0x02010100 / 24 (1)
LPM6: Adding route 2001:0011:0000:0000:0000:0000:0000:0000 / 64 (0)
LPM6: Adding route 2001:0022:0000:0000:0000:0000:0000:0000 / 64 (1)
txq=1,0,0 (lcoreid, queueid, socketid)txq=2,1,0 (lcoreid, queueid, socketid)
Initializing port 1 ... Creating queues: nb_rxq=1 nb_txq=2... 
Port 1 modified RSS hash function based on hardware support,requested:0xa38c configured:0x2288
Address:00:60:E0:6F:C8:7E, Destination:00:60:E0:6D:90:77, 
txq=1,0,0 (lcoreid, queueid, socketid)txq=2,1,0 (lcoreid, queueid, socketid)

Initializing rx queues on lcore 1 ... rxq=0,0,0 
Initializing rx queues on lcore 2 ... rxq=1,0,0 

Checking link statusdone
Port0 Link Up. Speed 10000 Mbps -full-duplex
Port1 Link Up. Speed 10000 Mbps -full-duplex
L3FWD: entering main loop on lcore 2
L3FWD:  -- lcoreid=2 portid=1 rxqueueid=0
L3FWD: entering main loop on lcore 1
L3FWD:  -- lcoreid=1 portid=0 rxqueueid=0

在Ubuntu0上ping主机Ubuntu1的IP地址:2001:22::2,收到回复,链路是通的。

你可能感兴趣的:(DPDK,ipv6,lpm)