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,收到回覆,鏈路是通的。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章