测试DPDK示例程序l3fwd

测试环境

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

测试拓扑:

                      |----------------|
                      |  Ubuntu(DPDK)  |
                      |                |
                      |  eth0   eth1   |
              1.1.1.1 |----|------|----|  2.1.1.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
           1.1.1.2   |                  |  2.1.1.2
            |--------|------|   |-------|-------|
            |      eth0     |   |     eth0      |
            |               |   |               |
            |    Ubuntu0    |   |    Ubuntu1    |
            |---------------|   |---------------|

环境配置

如下l3fwd_lpm.c文件中的默认路由表项,port0的网段为:1.1.1.0/24;port1的网段为:2.1.1.0/24。以上拓扑假定port0的IP地址为:1.1.1.1;port1的IP地址为:2.1.1.1,当然也可以使用其它的地址,只要是同一网段即可。

 42 static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = {
 43     {IPv4(1, 1, 1, 0), 24, 0},
 44     {IPv4(2, 1, 1, 0), 24, 1},

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

/ # ip route add default via 1.1.1.1
/ #
/ # ip r
default via 1.1.1.1 dev eth0 proto zebra 
1.1.1.0/24 dev eth0 proto kernel scope link src 1.1.1.2 
/ # 

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

/ # ip nei add 1.1.1.1 lladdr 00:60:E0:6F:C8:7D dev m1/1
/ # 
/ # ip ne
1.1.1.1 dev m1/1 lladdr 00:60:e0:6f:c8:7d PERMANENT

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

/ # ip route add default via 2.1.1.1
/ #
/ # ip r
default via 2.1.1.1 dev m1/2 proto zebra 
2.1.1.0/24 dev m1/2 proto kernel scope link src 2.1.1.2 
/ # 

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

/ # ip nei add 2.1.1.1 lladdr 00:60:E0:6F:C8:7E dev m1/2
/ #
/ # ip nei
2.1.1.1 dev m1/2 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中的路由项。

Initializing port 0 ... Creating queues: nb_rxq=2 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:7A:6C:78, Allocated mbuf pool on socket 0
LPM: Adding route 0x01010100 / 24 (0)
LPM: Adding route 0x02010100 / 24 (1)

Initializing port 1 ... Creating queues: nb_rxq=2 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:7A:6C:79, txq=1,0,0 

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

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

因项目需求,需要用到dpdk l3fwd-power例子,每个核处理0号port的单个队列,但尝试后用单核单队列命令可以跑,多核下每个线程都卡在epoll_wait上,无响应,例子是自带的 参数: ./l3fwd-power -l 0-3 -n 4 -- -p 3 --config "(0,0,0),(0,1,1)" 输出: root@ubuntu:~/dpdk-18.08/examples/l3fwd-power/build# ./l3fwd-power -l 0-1 -n 4 -- -p 3 --config "(0,0,0),(0,1,1)" EAL: Detected 4 lcore(s) EAL: Detected 1 NUMA nodes EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Probing VFIO support... EAL: no supported IOMMU extensions found! EAL: VFIO support could not be initialized EAL: PCI device 0000:01:00.0 on NUMA socket -1 EAL: Invalid NUMA socket, default to 0 EAL: probe driver: 8086:1539 net_e1000_igb EAL: PCI device 0000:02:00.0 on NUMA socket -1 EAL: Invalid NUMA socket, default to 0 EAL: probe driver: 8086:1539 net_e1000_igb EAL: PCI device 0000:03:00.0 on NUMA socket -1 EAL: Invalid NUMA socket, default to 0 EAL: probe driver: 8086:1539 net_e1000_igb EAL: PCI device 0000:06:00.0 on NUMA socket -1 EAL: Invalid NUMA socket, default to 0 EAL: probe driver: 8086:1539 net_e1000_igb EAL: PCI device 0000:07:00.0 on NUMA socket -1 EAL: Invalid NUMA socket, default to 0 EAL: probe driver: 8086:1539 net_e1000_igb EAL: PCI device 0000:08:00.0 on NUMA socket -1 EAL: Invalid NUMA socket, default to 0 EAL: probe driver: 8086:1539 net_e1000_igb POWER: Attempting to initialise ACPI cpufreq power management... POWER: Power management governor of lcore 0 has been set to user space successfully POWER: File not openned POWER: Cannot get available frequencies of lcore 0 POWER: Attempting to initialise VM power management... GUEST_CHANNEL: Opening channel '/dev/virtio-ports/virtio.serial.port.poweragent.0' for lcore 0 GUEST_CHANNEL: Unable to to connect to '/dev/virtio-ports/virtio.serial.port.poweragent.0' with error No such file or directory POWER: Unable to set Power Management Environment for lcore 0 POWER: Library initialization failed on core 0 POWER: Attempting to initialise ACPI cpufreq power management... POWER: Power management governor of lcore 1 has been set to user space successfully POWER: File not openned POWER: Cannot get available frequencies of lcore 1 POWER: Attempting to initialise VM power management... GUEST_CHANNEL: Opening channel '/dev/virtio-ports/virtio.serial.port.poweragent.1' for lcore 1 GUEST_CHANNEL: Unable to to connect to '/dev/virtio-ports/virtio.serial.port.poweragent.1' with error No such file or directory POWER: Unable to set Power Management Environment for lcore 1 POWER: Library initialization failed on core 1 Initializing port 0 ... Creating queues: nb_rxq=2 nb_txq=2... Address:00:02:B6:85:1E:C2, Allocated mbuf pool on socket 0 LPM: Adding route 0x01010100 / 24 (0) LPM: Adding route 0x02010100 / 24 (1) LPM: Adding route 0x03010100 / 24 (2) LPM: Adding route 0x04010100 / 24 (3) LPM: Adding route 0x05010100 / 24 (4) LPM: Adding route 0x06010100 / 24 (5) LPM: Adding route 0x07010100 / 24 (6) LPM: Adding route 0x08010100 / 24 (7) txq=0,0,0 txq=1,1,0 Initializing port 1 ... Creating queues: nb_rxq=0 nb_txq=2... Address:00:02:B6:85:1E:C3, txq=0,0,0 txq=1,1,0 Skipping disabled port 2 Skipping disabled port 3 Initializing rx queues on lcore 0 ... rxq=0,0,0 Initializing rx queues on lcore 1 ... rxq=0,1,0 Checking link status.........................................done Port 0 Link Up - speed 100 Mbps - full-duplex Port 1 Link Up - speed 1000 Mbps - full-duplex L3FWD_POWER: entering main loop on lcore 1 L3FWD_POWER: -- lcoreid=1 portid=0 rxqueueid=1 L3FWD_POWER: entering main loop on lcore 0 L3FWD_POWER: -- lcoreid=0 portid=0 rxqueueid=0 EAL: Event already been added. L3FWD_POWER: lcore 1 sleeps until interrupt triggers L3FWD_POWER: lcore 0 sleeps until interrupt triggers L3FWD_POWER: lcore 1 is waked up from rx interrupt on port 0 queue 1 L3FWD_POWER: lcore 1 sleeps until interrupt triggers 备注: intel电源管理技术没开启,不过从代码看应该不影响 系统环境: Linux ubuntu 4.4.0 x64 Ubuntu 16.04.5 LTS dpdk18.08 网卡I211 4口 2队列 4核
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页