<div dir="ltr"><div dir="ltr"><p>Hello Dmitry,</p><p>I followed your suggestions, and this is what I came up with:</p><div style="color:rgb(204,204,204);background-color:rgb(31,31,31);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)">"../include/flow.h"</span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><stdio.h></span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><string.h></span></div><span class="gmail-im"><br><div><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">flow_filtering</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(78,201,176)">uint16_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">port_id</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(78,201,176)">uint32_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(78,201,176)">uint16_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">udp_port</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_error</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">error</span><span style="color:rgb(204,204,204)">;</span></div></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_attr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">attr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">ingress</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">, .</span><span style="color:rgb(156,220,254)">priority</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)"> };</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_item</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">4</span><span style="color:rgb(204,204,204)">];</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_action</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">action</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(204,204,204)">];</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(156,220,254)">flow</span><span style="color:rgb(204,204,204)">;</span></div><br></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Définir le motif Ethernet</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(220,220,170)">memset</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">sizeof</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">));</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ITEM_TYPE_ETH</span><span style="color:rgb(204,204,204)">;</span></div><br></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Définir le motif IPv4</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_item_ipv4</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">ipv4_spec</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">hdr</span><span style="color:rgb(204,204,204)">.</span><span style="color:rgb(156,220,254)">dst_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">RTE_BE32</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)">) };</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_item_ipv4</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">ipv4_mask</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">hdr</span><span style="color:rgb(204,204,204)">.</span><span style="color:rgb(156,220,254)">dst_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">RTE_BE32</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(181,206,168)">0xFFFFFFFF</span><span style="color:rgb(204,204,204)">) };</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ITEM_TYPE_IPV4</span><span style="color:rgb(204,204,204)">;</span></div></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">spec</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">ipv4_spec</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">mask</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">ipv4_mask</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Définir le motif UDP</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_item_udp</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">udp_spec</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">hdr</span><span style="color:rgb(204,204,204)">.</span><span style="color:rgb(156,220,254)">dst_port</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">RTE_BE16</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">udp_port</span><span style="color:rgb(204,204,204)">) };</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_item_udp</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">udp_mask</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">hdr</span><span style="color:rgb(204,204,204)">.</span><span style="color:rgb(156,220,254)">dst_port</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">RTE_BE16</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(181,206,168)">0xFFFF</span><span style="color:rgb(204,204,204)">) };</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ITEM_TYPE_UDP</span><span style="color:rgb(204,204,204)">;</span></div></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">spec</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">udp_spec</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">mask</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">udp_mask</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Terminer le motif</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">3</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ITEM_TYPE_END</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Définir l'action</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">action</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ACTION_TYPE_QUEUE</span><span style="color:rgb(204,204,204)">;</span></div></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_action_queue</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">queue_action</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">index</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)"> };</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">action</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">conf</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">queue_action</span><span style="color:rgb(204,204,204)">;</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">action</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ACTION_TYPE_END</span><span style="color:rgb(204,204,204)">;</span></div><br></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Créer la règle de flux</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">flow</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">rte_flow_create</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">port_id</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">attr</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">action</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">error</span><span style="color:rgb(204,204,204)">);</span></div></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(212,212,212)">!</span><span style="color:rgb(156,220,254)">flow</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Erreur lors de la création de la règle de flux : </span><span style="color:rgb(156,220,254)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">error</span><span style="color:rgb(204,204,204)">.</span><span style="color:rgb(156,220,254)">message</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">-</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// rte_flow_isolate(port_id, 1, &error);</span></div><div><span style="color:rgb(204,204,204)">    </span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Règle de flux créée avec succès pour IP </span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)">.</span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)">.</span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)">.</span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)"> et port UDP </span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">,</span></div><span class="gmail-im"><div><span style="color:rgb(204,204,204)">           (</span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">>></span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">24</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0xFF</span><span style="color:rgb(204,204,204)">, (</span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">>></span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">16</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0xFF</span><span style="color:rgb(204,204,204)">,</span></div><div><span style="color:rgb(204,204,204)">           (</span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">>></span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">8</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0xFF</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0xFF</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">udp_port</span><span style="color:rgb(204,204,204)">);</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">}</span></div><br></span><div><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">create_drop_all_rule</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(78,201,176)">uint16_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">port_id</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_attr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">attr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> { .</span><span style="color:rgb(156,220,254)">ingress</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">, .</span><span style="color:rgb(156,220,254)">priority</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">};</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_item</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(204,204,204)">];</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_action</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">actions</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">2</span><span style="color:rgb(204,204,204)">];</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(156,220,254)">flow</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_flow_error</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">error</span><span style="color:rgb(204,204,204)">;</span></div><span class="gmail-im"><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ITEM_TYPE_ETH</span><span style="color:rgb(204,204,204)">;</span></div></span><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ITEM_TYPE_END</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">actions</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ACTION_TYPE_DROP</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">actions</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">].</span><span style="color:rgb(156,220,254)">type</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(79,193,255)">RTE_FLOW_ACTION_TYPE_END</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(212,212,212)">!</span><span style="color:rgb(220,220,170)">rte_flow_validate</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">port_id</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">attr</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">actions</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">error</span><span style="color:rgb(204,204,204)">)){</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(156,220,254)">flow</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">rte_flow_create</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">port_id</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">attr</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">pattern</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">actions</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">error</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">flow</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">!=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">){</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Filed to create drop flow filter </span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">-</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Default drop rule created successfully.</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">}</span></div><div><span style="color:rgb(204,204,204)"><br></span></div><div><div style="color:rgb(204,204,204);background-color:rgb(31,31,31);font-family:"Droid Sans Mono","monospace",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)">"../include/port.h"</span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)">"../include/flow.h"</span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><rte_eal.h></span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><rte_mbuf.h></span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><rte_ethdev.h></span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><rte_ether.h></span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><rte_ip.h></span></div><div><span style="color:rgb(197,134,192)">#include</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(206,145,120)"><arpa/inet.h></span></div><br><div><span style="color:rgb(197,134,192)">#define</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(86,156,214)">MAX_PKT_BURST</span><span style="color:rgb(86,156,214)"> </span><span style="color:rgb(181,206,168)">32</span></div><br><div><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">main</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">argc</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">char</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">**</span><span style="color:rgb(156,220,254)">argv</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_mempool</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(156,220,254)">mbuf_pool</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">int</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">ret</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Initialiser l'EAL</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">ret</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">rte_eal_init</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">argc</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">argv</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(156,220,254)">ret</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)"><</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">rte_exit</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">EXIT_FAILURE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(206,145,120)">"Erreur lors de l'initialisation de l'EAL</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Créer le pool de mbufs</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(156,220,254)">mbuf_pool</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">rte_pktmbuf_pool_create</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"MBUF_POOL"</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">NUM_MBUFS</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">MBUF_CACHE_SIZE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">,</span></div><div><span style="color:rgb(204,204,204)">                                        </span><span style="color:rgb(86,156,214)">RTE_MBUF_DEFAULT_BUF_SIZE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(220,220,170)">rte_socket_id</span><span style="color:rgb(204,204,204)">());</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(212,212,212)">!</span><span style="color:rgb(156,220,254)">mbuf_pool</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">rte_exit</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">EXIT_FAILURE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(206,145,120)">"Impossible de créer le pool de mbufs</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(220,220,170)">port_init</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">PORT_ID</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">mbuf_pool</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">!=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">rte_exit</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">EXIT_FAILURE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(206,145,120)">"Erreur initialisation port</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Créer la règle principale</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(78,201,176)">uint32_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">RTE_IPV4</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(181,206,168)">10</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(181,206,168)">81</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(181,206,168)">16</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(181,206,168)">111</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(78,201,176)">uint16_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">udp_port</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">1234</span><span style="color:rgb(204,204,204)">;</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(220,220,170)">flow_filtering</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">PORT_ID</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">ip_addr</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">udp_port</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">!=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">rte_exit</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">EXIT_FAILURE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(206,145,120)">"Erreur création règle principale</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Créer la règle drop-all</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(220,220,170)">create_drop_all_rule</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">PORT_ID</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">!=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">rte_exit</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">EXIT_FAILURE</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(206,145,120)">"Erreur création règle drop-all</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Traitement des paquets...</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_mbuf</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(156,220,254)">bufs</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(86,156,214)">MAX_PKT_BURST</span><span style="color:rgb(204,204,204)">];</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">while</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(106,153,85)">// Récupérer un burst de paquets sur la file RX de la queue 0</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(86,156,214)">const</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">uint16_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">nb_rx</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(220,220,170)">rte_eth_rx_burst</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">PORT_ID</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">bufs</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">MAX_PKT_BURST</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(156,220,254)">nb_rx</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">></span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">            </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Reçu </span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)"> paquet(s)</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">nb_rx</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">            </span><span style="color:rgb(197,134,192)">for</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(78,201,176)">uint16_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">; </span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)"><</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">nb_rx</span><span style="color:rgb(204,204,204)">; </span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(212,212,212)">++</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(106,153,85)">// Afficher la taille du paquet</span></div><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Paquet </span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)"> : taille = </span><span style="color:rgb(156,220,254)">%u</span><span style="color:rgb(206,145,120)"> octets</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">,</span></div><div><span style="color:rgb(204,204,204)">                       </span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">rte_pktmbuf_pkt_len</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">bufs</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(204,204,204)">]));</span></div><br><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(106,153,85)">// Traiter le paquet pour afficher les adresses source et destination</span></div><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_ether_hdr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(156,220,254)">eth_hdr</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(156,220,254)">eth_hdr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">rte_pktmbuf_mtod</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">bufs</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(204,204,204)">], </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> rte_ether_hdr </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(204,204,204)">);</span></div><br><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(106,153,85)">// Vérifier que le paquet est de type IPv4</span></div><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(86,156,214)">rte_be_to_cpu_16</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">eth_hdr</span><span style="color:rgb(204,204,204)">-></span><span style="color:rgb(156,220,254)">ether_type</span><span style="color:rgb(204,204,204)">) </span><span style="color:rgb(212,212,212)">==</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">RTE_ETHER_TYPE_IPV4</span><span style="color:rgb(204,204,204)">) {</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_ipv4_hdr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(156,220,254)">ip_hdr</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(156,220,254)">ip_hdr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> (</span><span style="color:rgb(86,156,214)">struct</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(78,201,176)">rte_ipv4_hdr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">*</span><span style="color:rgb(204,204,204)">)(</span><span style="color:rgb(156,220,254)">eth_hdr</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">+</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(204,204,204)">);</span></div><br><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(106,153,85)">// Récupérer les adresses source et destination (conversion en format hôte)</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(78,201,176)">uint32_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">src_ip</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">rte_be_to_cpu_32</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">ip_hdr</span><span style="color:rgb(204,204,204)">-></span><span style="color:rgb(156,220,254)">src_addr</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(78,201,176)">uint32_t</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">dst_ip</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(86,156,214)">rte_be_to_cpu_32</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">ip_hdr</span><span style="color:rgb(204,204,204)">-></span><span style="color:rgb(156,220,254)">dst_addr</span><span style="color:rgb(204,204,204)">);</span></div><br><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(106,153,85)">// Convertir les adresses en chaîne de caractères lisible</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(86,156,214)">char</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">src_str</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(86,156,214)">INET_ADDRSTRLEN</span><span style="color:rgb(204,204,204)">];</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(86,156,214)">char</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(156,220,254)">dst_str</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(86,156,214)">INET_ADDRSTRLEN</span><span style="color:rgb(204,204,204)">];</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(220,220,170)">inet_ntop</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">AF_INET</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">src_ip</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">src_str</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">INET_ADDRSTRLEN</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(220,220,170)">inet_ntop</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">AF_INET</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(212,212,212)">&</span><span style="color:rgb(156,220,254)">dst_ip</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">dst_str</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(86,156,214)">INET_ADDRSTRLEN</span><span style="color:rgb(204,204,204)">);</span></div><br><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Adresse source : </span><span style="color:rgb(156,220,254)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">src_str</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Adresse destination : </span><span style="color:rgb(156,220,254)">%s</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">, </span><span style="color:rgb(156,220,254)">dst_str</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">                } </span><span style="color:rgb(197,134,192)">else</span><span style="color:rgb(204,204,204)"> {</span></div><div><span style="color:rgb(204,204,204)">                    </span><span style="color:rgb(220,220,170)">printf</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(206,145,120)">"Paquet non IPv4, impossible d'extraire les adresses</span><span style="color:rgb(215,186,125)">\n</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">                }</span></div><br><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(106,153,85)">// Libérer le mbuf une fois le traitement terminé</span></div><div><span style="color:rgb(204,204,204)">                </span><span style="color:rgb(220,220,170)">rte_pktmbuf_free</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(156,220,254)">bufs</span><span style="color:rgb(204,204,204)">[</span><span style="color:rgb(156,220,254)">i</span><span style="color:rgb(204,204,204)">]);</span></div><div><span style="color:rgb(204,204,204)">            }</span></div><div><span style="color:rgb(204,204,204)">        }</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(106,153,85)">// Petite pause pour éviter une utilisation CPU trop intensive</span></div><div><span style="color:rgb(204,204,204)">        </span><span style="color:rgb(220,220,170)">rte_delay_us_block</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(181,206,168)">100</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    }</span></div><br><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(106,153,85)">// Nettoyage</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(220,220,170)">port_cleanup</span><span style="color:rgb(204,204,204)">(</span><span style="color:rgb(86,156,214)">PORT_ID</span><span style="color:rgb(204,204,204)">);</span></div><div><span style="color:rgb(204,204,204)">    </span><span style="color:rgb(197,134,192)">return</span><span style="color:rgb(204,204,204)"> </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(204,204,204)">;</span></div><div><span style="color:rgb(204,204,204)">}</span></div></div></div></div><p></p><p><br></p><p><br></p><p>The
 issue is that when I implement this, I get an error on the drop filter:
 "Failed to create rule." Do you have any idea why this might be 
happening?</p><p>Thank you for your time.</p><p>Best regards,<br>Ali</p></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Le mar. 28 janv. 2025 à 19:46, Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com">dmitry.kozliuk@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Ali,<br>
<br>
2025-01-28 17:54 (UTC+0100), Sid ali cherrati:<br>
> I am attempting to use DPDK's rte_flow API to filter incoming packets at<br>
> the hardware level. My goal is to drop all packets except those with a<br>
> specific IP address and UDP port.<br>
> <br>
> I have implemented the following flow filtering rule in my code:<br>
> [...] <br>
> However, despite this configuration, I continue to receive packets with<br>
> other IP addresses and ports that do not match the specified filter.<br>
<br>
Packets that do not match the rule pattern are processed as usual.<br>
If without the rule queue RX_ID could receive any packet,<br>
it will also receive them after the rule is created.<br>
You need another rule with lower priority (BTW, 0 is the highest one)<br>
that matches all packets and drops them or steers to other queues.<br>
If you want your DPDK app to only process packets matching the rule<br>
and to leave all other traffic for the OS to process,<br>
flow isolated mode may be what you're looking for:<br>
<br>
<a href="https://doc.dpdk.org/guides/prog_guide/ethdev/flow_offload.html#flow-isolated-mode" rel="noreferrer" target="_blank">https://doc.dpdk.org/guides/prog_guide/ethdev/flow_offload.html#flow-isolated-mode</a><br>
<br>
> Could you provide any insights into why the filtering isn't working as<br>
> expected? Any advice on ensuring the rule is properly applied at the<br>
> hardware level would be greatly appreciated.<br>
<br>
The usual way to check that the rule is matched<br>
is to all a counter to the rule and check if it increases.<br>
I suggest using testpmd for playing with flow rules:<br>
<br>
<a href="https://doc.dpdk.org/guides/testpmd_app_ug/testpmd_funcs.html#flow-rules-management" rel="noreferrer" target="_blank">https://doc.dpdk.org/guides/testpmd_app_ug/testpmd_funcs.html#flow-rules-management</a><br>
<br>
There was also a useful talk abound HW rules debugging on DPDK Summit:<br>
<br>
<a href="https://dpdksummit2024.sched.com/event/1iAtU/debug-functional-and-performance-issues-in-rteflow-dariusz-sosnowski-nvidia-corp" rel="noreferrer" target="_blank">https://dpdksummit2024.sched.com/event/1iAtU/debug-functional-and-performance-issues-in-rteflow-dariusz-sosnowski-nvidia-corp</a><br>
<br>
</blockquote></div>