DPDK 實戰之l3fwd vf(虛擬化環境)

2021-09-02 19:31:17 字數 4076 閱讀 1591

0x01 緣由

年初,學習了l3fwd的例子,進行三層**,現在學習下特定**,這個在虛擬化裝置中常見,也是加強對dpdk的熟悉。

0x02 介紹

在虛擬化環境下的l3層**應用是用dpdk處理資料報的乙個簡單例子。這個l3層**應用充分發揮sr-iov的特徵。

這個應用演示如何使用hash和lpm dpdk庫去實現資料報**。這個**策略是基於輸入包的資訊。

查詢方法既有基於hash的也有基於lpm的,你如何選擇在編譯的時候決定。當所選擇的查詢方法是基於hash時,使用hash物件來模擬流分類階段。 雜湊物件與流表相關使用,以便在執行時將每個輸入資料報對映到其流。

雜湊查詢鍵由diffserv 5元組表示,它由從輸入資料報讀取的以下字段組成:源ip位址,目標ip位址,協議,源埠和目標埠。 從識別的流表條目讀取輸入資料報的輸出介面的id。應用程式使用的一組流在初始化時靜態配置並載入到雜湊中。 當選擇的查詢方法是基於lpm時,使用lpm物件來模擬ipv4分組的**階段。 lpm物件用作路由表,用於在執行時識別每個輸入資料報的下一跳。

lpm查詢鍵由從輸入資料報讀取的目標ip位址字段表示。 輸入資料報的輸出介面的id是lpm查詢返回的下一跳。 應用程式使用的一組lpm規則在初始化時被靜態配置並載入到lpm物件中。

0x03 執行環境

執行引數樣板:

./build/l3fwd-vf [eal options] -- -p portmask --config(port,queue,lcore)[,(port,queue,lcore)]

引數解釋:

[eal options] eal選項已經在其他例子中已有說明。

-p [埠掩碼 -- 網絡卡掩碼,在部署dpdk執行環境時繫結的網絡卡]: 十六進製制表示

--config: 哪個網口哪個佇列繫結到哪個邏輯核

–no-numa: 是否關閉對numa結構的識別

執行例項:

./l3fwd-vf -l 1,2 -n 4 -- -p 0x3 --config="(0,0,1),(1,0,2)"

-這個例項占用的邏輯核為1,2

-啟動1、2號網絡卡

-埠對映關係為:

0號網絡卡0號佇列對映到1號邏輯核上;

1號網絡卡0號佇列對映到2號邏輯核上;

執行效果如下(新增了一些提示資訊):

lpm作為路由查詢表:

initializing port 0 ... creating queues: nb_rxq=1 nb_txq=1...  address:a0:36:9f:03:a8:ca, 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 pmd: eth_igb_tx_queue_setup(): sw_ring=0x7ffc3814d2c0 hw_ring=0x7ffc3814f300 dma_addr=0x6734f300

initializing port 1 ... creating queues: nb_rxq=1 nb_txq=1...  address:a0:36:9f:03:a8:cb, txq=1,0,0 pmd: eth_igb_tx_queue_setup(): sw_ring=0x

7ffc3813b040 hw_ring=0x7ffc3813d080 dma_addr=0x6733d080

initializing rx queues on lcore 1 ... rxq=0,0,0 pmd: eth_igb_rx_queue_setup(): sw_ring=0x7ffc3812aac0 hw_ring=0x7ffc3812af00 dma_addr=0x6732a

f00initializing rx queues on lcore 2 ... rxq=1,0,0 pmd: eth_igb_rx_queue_setup(): sw_ring=0x7ffc3811a540 hw_ring=0x7ffc3811a980 dma_addr=0x6731a

980pmd: eth_igb_start(): <<

done: port 0

pmd: eth_igb_start(): <<

done: port 1

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

hash作為路由查詢表:

initializing port 0 ... creating queues: nb_rxq=1 nb_txq=1...  address:a0:36:9f:03:a8:ca, allocated mbuf pool on socket 0

hash: adding key

ip dst = 640a0001, ip src = c80a0001, port dst = 101, port src = 11, proto = 6

hash: adding key

ip dst = 64140002, ip src = c8140002, port dst = 102, port src = 12, proto = 6

hash: adding key

ip dst = 641e0003, ip src = c81e0003, port dst = 103, port src = 13, proto = 6

hash: adding key

ip dst = 64280004, ip src = c8280004, port dst = 104, port src = 14, proto = 6

txq=0,0,0 pmd: eth_igb_tx_queue_setup(): sw_ring=0x7fd48af7fcc0 hw_ring=0x7fd48af81d00 dma_addr=0x67381d00

initializing port 1 ... creating queues: nb_rxq=1 nb_txq=1...  address:a0:36:9f:03:a8:cb, txq=1,0,0 pmd: eth_igb_tx_queue_setup(): sw_ring=0x

7fd48af6da40 hw_ring=0x7fd48af6fa80 dma_addr=0x6736fa80

initializing rx queues on lcore 1 ... rxq=0,0,0 pmd: eth_igb_rx_queue_setup(): sw_ring=0x7fd48af5d4c0 hw_ring=0x7fd48af5d900 dma_addr=0x6735d

900initializing rx queues on lcore 2 ... rxq=1,0,0 pmd: eth_igb_rx_queue_setup(): sw_ring=0x7fd48af4cf40 hw_ring=0x7fd48af4d380 dma_addr=0x6734d

380pmd: eth_igb_start(): <<

done: port 0

pmd: eth_igb_start(): <<

done: port 1

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

DPDK示例l3fwd效能測試

測試環境 cpu intel xeon gold 5122 cpu 3.60ghz cache 16896 kb memory 16g x710 driver i40e 2.11.29 x710 expansion rom version 4.53 0x80001cdf 0.0.0 dpdk dpd...

實戰錄 雲端衛士之DPDK技術簡介

雲端衛士的新欄目 實戰錄 將會定期分享一些我們的工程師夥伴們在產品研發的過程中總結的實踐經驗,希望對於熱愛技術且關注安全領域的受眾有所裨益。本期分享人為雲端衛士安全運營工程師陶濤。技術背景隨著網際網路飛速發展,基礎網路技術也面臨多需求和挑戰 網路服務運營商在業務拓展等問題上,提出nfv 網路功能虛擬...

Quantum中的L3模型實戰

截止到openstack folsom版,quantum中的物件模型有以下幾個 network,subnet,port,router,floatingip。前三個在我之前的部落格已有所分析,今天來看下router和floatingip。以官方文件中給出的乙個quantum部署示例為例 這個圖是使用者...