接续前节:[dpdk] 熟悉SDK与初步使用 (三)(IP Fragmentation源码分析)
前文中的最后一个问题,搁置,并没有找到答案。所以继续阅读其他例子的代码,想必定能在其他位置看到答案。
使用,大致过了一般文档和代码,试运行一下:
绑定2,3,6,7四颗CPU核心。使用port1,port2.
port0/queue0/core2映射在一起。port0/queue1/core3映射在一起。port1/queue0/core6映射在一起。port1/queue1/core7映射在一起。
与前边的例子相同,依然要在代码级关掉 hw_ip_checksum。
[root@dpdk build]# ./l3fwd -l2,3,6,7 -- -p 3 --config "(0,0,2),(0,1,3),(1,0,6),(1,1,7)" EAL: Detected 8 lcore(s) EAL: Probing VFIO support... EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable clock cycles ! PMD: bnxt_rte_pmd_init() called for (null) EAL: PCI device 0000:00:03.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd EAL: PCI device 0000:00:04.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd EAL: PCI device 0000:00:05.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd EAL: PCI device 0000:00:06.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd L3FWD: LPM or EM none selected, default LPM on Initializing port 0 ... Creating queues: nb_rxq=2 nb_txq=4... Address:00:00:00:01:00:01, Destination:02:00:00:00:00:00, Allocated mbuf pool on socket 0 LPM: Adding route 0x01010100 / 24 (0) LPM: Adding route 0x02010100 / 24 (1) LPM: Adding route IPV6 / 48 (0) LPM: Adding route IPV6 / 48 (1) Allocated mbuf pool on socket 1 LPM: Adding route 0x01010100 / 24 (0) LPM: Adding route 0x02010100 / 24 (1) LPM: Adding route IPV6 / 48 (0) LPM: Adding route IPV6 / 48 (1) txq=2,0,0 txq=3,1,0 txq=6,2,1 txq=7,3,1 Initializing port 1 ... Creating queues: nb_rxq=2 nb_txq=4... Address:00:00:00:01:00:02, Destination:02:00:00:00:00:01, txq=2,0,0 txq=3,1,0 txq=6,2,1 txq=7,3,1 Skipping disabled port 2 Initializing rx queues on lcore 2 ... rxq=0,0,0 Initializing rx queues on lcore 3 ... rxq=0,1,0 Initializing rx queues on lcore 6 ... rxq=1,0,1 Initializing rx queues on lcore 7 ... rxq=1,1,1 port 0 cannot parse packet type, please add --parse-ptype EAL: Error - exiting with code: 1 Cause: ptype check fails [root@dpdk build]#
以上出现的ERROR,刚好回答了(三)最后留下的疑问。此程序依然依赖硬件来完成packet type的识别。该参数“--parse-ptype”应该是启用了软件识别类型的功能,如下:
已经可以正常启动了。
[root@dpdk build]# ./l3fwd -l2,3,6,7 -- -p 3 --config "(0,0,2),(0,1,3),(1,0,6),(1,1,7)" --parse-ptype EAL: Detected 8 lcore(s) EAL: Probing VFIO support... EAL: WARNING: cpu flags constant_tsc=yes nonstop_tsc=no -> using unreliable clock cycles ! PMD: bnxt_rte_pmd_init() called for (null) EAL: PCI device 0000:00:03.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd EAL: PCI device 0000:00:04.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd EAL: PCI device 0000:00:05.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd EAL: PCI device 0000:00:06.0 on NUMA socket -1 EAL: probe driver: 1af4:1000 rte_virtio_pmd soft parse-ptype is enabled L3FWD: LPM or EM none selected, default LPM on Initializing port 0 ... Creating queues: nb_rxq=2 nb_txq=4... Address:00:00:00:01:00:01, Destination:02:00:00:00:00:00, Allocated mbuf pool on socket 0 LPM: Adding route 0x01010100 / 24 (0) LPM: Adding route 0x02010100 / 24 (1) LPM: Adding route IPV6 / 48 (0) LPM: Adding route IPV6 / 48 (1) Allocated mbuf pool on socket 1 LPM: Adding route 0x01010100 / 24 (0) LPM: Adding route 0x02010100 / 24 (1) LPM: Adding route IPV6 / 48 (0) LPM: Adding route IPV6 / 48 (1) txq=2,0,0 txq=3,1,0 txq=6,2,1 txq=7,3,1 Initializing port 1 ... Creating queues: nb_rxq=2 nb_txq=4... Address:00:00:00:01:00:02, Destination:02:00:00:00:00:01, txq=2,0,0 txq=3,1,0 txq=6,2,1 txq=7,3,1 Skipping disabled port 2 Initializing rx queues on lcore 2 ... rxq=0,0,0 Initializing rx queues on lcore 3 ... rxq=0,1,0 Initializing rx queues on lcore 6 ... rxq=1,0,1 Initializing rx queues on lcore 7 ... rxq=1,1,1 Port 0: softly parse packet type info Port 0: softly parse packet type info Port 1: softly parse packet type info Port 1: softly parse packet type info Checking link statusdone Port 0 Link Up - speed 10000 Mbps - full-duplex Port 1 Link Up - speed 10000 Mbps - full-duplex L3FWD: entering main loop on lcore 3 L3FWD: -- lcoreid=3 portid=0 rxqueueid=1 L3FWD: entering main loop on lcore 6 L3FWD: -- lcoreid=6 portid=1 rxqueueid=0 L3FWD: entering main loop on lcore 2 L3FWD: -- lcoreid=2 portid=0 rxqueueid=0 L3FWD: entering main loop on lcore 7 L3FWD: -- lcoreid=7 portid=1 rxqueueid=1
接下来通过对代码的阅读调试,印证一下之前的想法。
先来一组测试包:
/home/tong/Data [tong@T7] [16:10] > sudo tcpreplay-edit -D 0.0.0.0/0:2.1.1.1/24 -i tap-dpdk-1 -t -L 1 oicq-bak.pcap
基于代码里写死的路由规则,必要nat成2.1.1.1才能被转发。
发现了与参数 --parse-ptype 对应的函数:
rte_eth_add_rx_callback(portid, queueid, l3fwd_lkp.cb_parse_ptype, NULL)
此回调函数,设置了IP包的类型。
至此,解答了(三)中留下的问题。