From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 06E8846183 for ; Mon, 3 Feb 2025 16:06:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE19A4042C; Mon, 3 Feb 2025 16:06:05 +0100 (CET) Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by mails.dpdk.org (Postfix) with ESMTP id ACFC7402ED for ; Mon, 3 Feb 2025 16:06:03 +0100 (CET) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-6f6c90b51c3so25110347b3.2 for ; Mon, 03 Feb 2025 07:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738595163; x=1739199963; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8V5mlQYSFWinTGv803ZqancMSul+E+F2of+4/9WFbcc=; b=QTZ4rINr+ECab2fVvog/m9Ua83ak+ykDBIeGgyC7+Y1aCW6sFPs9dlq03RDb7ReWvq Yyry+p/lPlsl45YKh7SUa5fmVi6DTocae6rP05hQ6Vw4cSOQcAyRuQs+OgRXIg96j+j4 X/+xlUavFbUP2HDlXlwxDfbyZtMiuSeqpa2brKpzz6zDyHGjhV074DZW6QExx/xfL6LU k2gvPZqJ8pa7X/p5E9TIoVxL/5/bucxDzo+m+lSrPi21eICTI5m49m/mObA7XdocEVLx ODY6WHbzxjYzraQ2oOExkIp/o0ebbl4gCAiuWgF+Pwwhxe81yEuG7At2QrHH7YcrTi35 9KDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738595163; x=1739199963; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8V5mlQYSFWinTGv803ZqancMSul+E+F2of+4/9WFbcc=; b=q+xCT+uLNsYAv7rzO6nENFubjo00SoQ1eAxGXVsj6aN8V47A7A4INnWRBmzUBB6xFV YJ2SyW7u4omP0HtsAuuQEQe5VzRwfXhrDuVHvL+rc0dSYS8qxupLlliOJWlj7qY46B+Z EfXbDfQ8J/dXK3KCSNLUliw3JJ46UFnqJYEwY3t6aZdV39Gz+SkBovpxZy10b7NthoSC WJ0CIBYtgAT7E6xTVFXlZfjpPEEKucf6nrxzAdHPM5EhEFEtgqyMDoLbaqe1k4DqpAbs i9vEywjKGYZmEob0eKb7/yVZb4UmsdNXg5IzTcp2DqCVIuWsFtI/J2uxggh6GIYyoQvc 9rRA== X-Gm-Message-State: AOJu0Yzg3iZPKjBtz+jZefeDPbDrhwsGs/QH9a1yeWvauD3Mn47ml6Ue H99B81Do7VYQ0sIzo1XR3XdCvDnbhmpx/V0HO3qnLOIx3HUKh/C1aPSL5xzqQH6vYB8Z4l9tUYA CB1PXmDhJqo93MIk9M0KEgD3Hkc27pyDVSxM= X-Gm-Gg: ASbGnctoZ1TubQrTnhSyM1/AjetLwmeYB11FGyKzhhxTbhtZJdiMyYLIG1R9CA5T8y+ 0t/yH7oxBKikKMzTBc6TWWSqQ43YrA/+XYhCy0UKEu4Ot4k7+zWN8/q080+4Hb71D2E8e1lc= X-Google-Smtp-Source: AGHT+IHATMbcB1rmo3TpvU3xr4zQB21HoEgMZT6QkRlT4+vE/2472mLfmilOm/OeIuMvhSO26CplaCtkXntqorPGjWs= X-Received: by 2002:a05:690c:4c10:b0:6f6:7b02:2565 with SMTP id 00721157ae682-6f7a8409f75mr191160437b3.26.1738595162919; Mon, 03 Feb 2025 07:06:02 -0800 (PST) MIME-Version: 1.0 References: <20250128214616.3f9324de@sovereign> <20250203180007.2c5e0607@sovereign> In-Reply-To: <20250203180007.2c5e0607@sovereign> From: Sid ali cherrati Date: Mon, 3 Feb 2025 16:05:51 +0100 X-Gm-Features: AWEUYZl3PYnf5Nh08wl8qbFEwOZHBGuK4IVjVKys8EuJBV79UXpHc6naFyVD8TA Message-ID: Subject: Re: DPDK Flow Filtering Not Working as Expected To: Dmitry Kozlyuk Cc: users@dpdk.org Content-Type: multipart/alternative; boundary="000000000000181c18062d3e3b21" X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org --000000000000181c18062d3e3b21 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I pointed where the error is occurring on the code below : #include "../include/flow.h" #include #include int flow_filtering(uint16_t port_id, uint32_t ip_addr, uint16_t udp_port) { struct rte_flow_error error; struct rte_flow_attr attr =3D { .ingress =3D 1, .priority =3D 0 }; struct rte_flow_item pattern[4]; struct rte_flow_action action[2]; struct rte_flow *flow; // D=C3=A9finir le motif Ethernet memset(pattern, 0, sizeof(pattern)); pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH; // D=C3=A9finir le motif IPv4 struct rte_flow_item_ipv4 ipv4_spec =3D { .hdr.dst_addr =3D RTE_BE32(ip_add= r) }; struct rte_flow_item_ipv4 ipv4_mask =3D { .hdr.dst_addr =3D RTE_BE32(0xFFFF= FFFF) }; pattern[1].type =3D RTE_FLOW_ITEM_TYPE_IPV4; pattern[1].spec =3D &ipv4_spec; pattern[1].mask =3D &ipv4_mask; // D=C3=A9finir le motif UDP struct rte_flow_item_udp udp_spec =3D { .hdr.dst_port =3D RTE_BE16(udp_port= ) }; struct rte_flow_item_udp udp_mask =3D { .hdr.dst_port =3D RTE_BE16(0xFFFF) = }; pattern[2].type =3D RTE_FLOW_ITEM_TYPE_UDP; pattern[2].spec =3D &udp_spec; pattern[2].mask =3D &udp_mask; // Terminer le motif pattern[3].type =3D RTE_FLOW_ITEM_TYPE_END; // D=C3=A9finir l'action action[0].type =3D RTE_FLOW_ACTION_TYPE_QUEUE; struct rte_flow_action_queue queue_action =3D { .index =3D 0 }; action[0].conf =3D &queue_action; action[1].type =3D RTE_FLOW_ACTION_TYPE_END; // Cr=C3=A9er la r=C3=A8gle de flux flow =3D rte_flow_create(port_id, &attr, pattern, action, &error); if (!flow) { printf("Erreur lors de la cr=C3=A9ation de la r=C3=A8gle de flux : %s\n", e= rror. message); return -1; } printf("R=C3=A8gle de flux cr=C3=A9=C3=A9e avec succ=C3=A8s pour IP %u.%u.%= u.%u et port UDP %u\n ", (ip_addr >> 24) & 0xFF, (ip_addr >> 16) & 0xFF, (ip_addr >> 8) & 0xFF, ip_addr & 0xFF, udp_port); return 0; } int create_drop_all_rule(uint16_t port_id) { struct rte_flow_attr attr =3D { .ingress =3D 1, .priority =3D 1}; struct rte_flow_item pattern[2]; struct rte_flow_action actions[2]; struct rte_flow *flow; struct rte_flow_error error; pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH; pattern[1].type =3D RTE_FLOW_ITEM_TYPE_END; actions[0].type =3D RTE_FLOW_ACTION_TYPE_DROP; actions[1].type =3D RTE_FLOW_ACTION_TYPE_END; if (!rte_flow_validate(port_id, &attr, pattern, actions, &error)){ flow =3D rte_flow_create(port_id, &attr, pattern, actions, &error); } if (flow !=3D 0) { // Its happening Here <--- !!! ---> printf("Erreur cr=C3=A9ation r=C3=A8gle DROP: %s (Type: %d, Cause: %p)\n", error.message, error.type, error.cause); return -1; } printf("Default drop rule created successfully.\n"); return 0; } Here is what it returns : > EAL: Detected CPU lcores: 6 > EAL: Detected NUMA nodes: 1 > EAL: Detected shared linkage of DPDK > EAL: Multi-process socket /var/run/dpdk/rte/mp_socket > EAL: Selected IOVA mode 'VA' > EAL: VFIO support initialized > EAL: Using IOMMU type 1 (Type 1) > Port 0 initialis=C3=A9 avec succ=C3=A8s > Capacit=C3=A9s de la NIC (port 0): > - Groupes support=C3=A9s : 232756 > - Actions support=C3=A9es : 9a69f > R=C3=A8gle de flux cr=C3=A9=C3=A9e avec succ=C3=A8s pour IP 10.81.16.111 = et port UDP 1234 > Erreur cr=C3=A9ation r=C3=A8gle DROP: Not supported action. (Type: 16, Ca= use: > 0x7ffe87ef63e0) > EAL: Error - exiting with code: 1 > Erreur cr=C3=A9ation r=C3=A8gle drop-all > Le lun. 3 f=C3=A9vr. 2025 =C3=A0 16:00, Dmitry Kozlyuk a =C3=A9crit : > 2025-02-03 14:51 (UTC+0100), Sid ali cherrati: > > [...] > > if (!rte_flow_validate(port_id, &attr, pattern, actions, &error)){ > > flow =3D rte_flow_create(port_id, &attr, pattern, actions, &error); > > } > > > > if(flow !=3D 0){ > > printf("Filed to create drop flow filter \n"); > > return -1; > > } > > [...] > > 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? > > There is no this exact error text in your code or DPDK, > I assume we're talking about the quoted fragment. > `flow` is a pointer, the correct error condition is `if (flow =3D=3D NULL= )`, > so your code probably misinterprets success as error. > Also `flow` is not assigned if `rte_flow_validate()` returns non-0. > --000000000000181c18062d3e3b21 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I pointed where the error is occurring on the code below :=

#include "../= include/flow.h"
#include <stdio.h>
#include <string.h>
int flo= w_filtering(uint16_t port_id, uint32_t ip_addr, uint16_t udp_port) {
struct rte_flow_error = error;
struct rte_flow_attr attr =3D { .ingress =3D 1, .priority =3D 0 };
struct rte_flow_item pattern[4];
= struct rte_flow_action action= [2];<= /div>
struct= rte_flow *flow;

// D=C3=A9finir le m= otif Ethernet
<= /span>memset(patter= n, 0, sizeof(pattern));
pattern[0= ].type =3D RTE_FLOW_ITEM_TYPE_ETH;

<= /span>// D=C3=A9finir le motif IPv4
struct rte_flow_item_ipv4 ipv4_spec =3D { .hdr<= span style=3D"color:rgb(204,204,204)">.dst_addr =3D RTE_BE32(ip_addr) };
struct rte_flow_item_ipv4 ipv4_mask =3D { .hdr.dst_addr =3D RTE_BE32(= 0xFFFFFFFF) };
pattern[1].type =3D RTE_FLOW_ITEM_TYPE_IPV4;
pattern[1].spec =3D &= ;ipv4_spec;
pattern= [1].mask =3D = &ipv4_mask;

// D=C3= =A9finir le motif UDP
struct = rte_flow_item_udp udp_spec =3D { .hdr.dst_port =3D RTE_BE16(udp_port) };
struct rte_flow_i= tem_udp udp_mask =3D { .= hdr.dst_port= =3D RTE_BE16= (0xFFFF) };<= /span>
pattern[2].type =3D RTE_FLOW_ITEM_TYPE_UDP;
patter= n[2].= spec =3D &udp_spec;
patte= rn[2].mask =3D &udp_mask<= span style=3D"color:rgb(204,204,204)">;

/= / Terminer le motif
pattern[3].type =3D RTE_FLOW_ITE= M_TYPE_END;

<= div> // D=C3=A9finir l'action
action[0= ].type =3D RTE_FLOW_ACTION_TYPE_QUEUE;
<= /span>struct rte_flow= _action_queue queue_action =3D { .index =3D 0 };
action[0].conf =3D = &queue_action;
action[1].type =3D RTE_FLOW_ACTION_TYPE_END;<= /span>

// Cr=C3=A9er la r=C3=A8gle de flux
flow =3D rte_= flow_create(port_id, &attr, pattern, action, &error);
if (!flow) {
=
printf= ("Erreur lors de la cr= =C3=A9ation de la r=C3=A8gle de flux : %s\n", error.message);
return -1;
}

printf("R=C3=A8gle de flux cr=C3=A9=C3=A9= e avec succ=C3=A8s pour IP %u= .%u.<= span style=3D"color:rgb(156,220,254)">%u.%u et port UDP %u\n",
= (ip_addr >> 24) & = 0xFF, (ip_addr >> = 16) & 0xFF,
(ip_addr<= span style=3D"color:rgb(204,204,204)"> >> 8) & 0xFF, ip_addr & 0xFF, udp_port);

return 0;
}

int create_drop_all_rule(uint16_t port_id) {
struct rte_flow_attr attr =3D { .ingress =3D 1, .<= /span>priority =3D<= /span> 1};
struct = rte_flow_item pattern[2= ];
struct rte_flow_action actions[= 2];
<= /span>struct rte_flow= *flow;
str= uct rte_flow_error error;

pattern[0].type =3D RTE_FLOW_ITEM_TYPE_ETH;
pattern[1].ty= pe =3D RTE_FLOW_ITEM_TYPE_END;

actio= ns[0].type =3D RTE_FLOW_ACTION_TYPE_DROP;
actions[1].type =3D RTE_FLOW_ACTION_TYPE_END;

if (!= rte_flow_validate(port_id, &attr, pattern<= span style=3D"color:rgb(204,204,204)">, actions, &error)){<= /div>
flow =3D rte_= flow_create(port_id, &attr, pattern, actions, &error);
}

if (flow !=3D = 0) { // Its happening Here <--- !!! --->
=
printf= ("Erreur cr=C3=A9ation r= =C3=A8gle DROP: %s (Type: %d, Cause: %p)\n",
= error.message, error.type, error.cause= );
<= span style=3D"color:rgb(197,134,192)">return -1;
}

printf("Default drop ru= le created successfully.\n");
return 0;
}

<= div>Here is what it returns :
EAL: Detected CPU lcores: 6
EAL: Detected NUMA nodes: 1
EA= L: Detected shared linkage of DPDK
EAL: Multi-process socket /var/run/dp= dk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: VFIO suppo= rt initialized
EAL: Using IOMMU type 1 (Type 1)
Port 0 initialis=C3= =A9 avec succ=C3=A8s
Capacit=C3=A9s de la NIC (port 0):
- Groupes sup= port=C3=A9s : 232756
- Actions support=C3=A9es : 9a69f
R=C3=A8gle de = flux cr=C3=A9=C3=A9e avec succ=C3=A8s pour IP 10.81.16.111 et port UDP 1234=
Erreur cr=C3=A9ation r=C3=A8gle DROP: Not supported action. (Type: 16, = Cause: 0x7ffe87ef63e0)
EAL: Error - exiting with code: 1
Erreur cr=C3= =A9ation r=C3=A8gle drop-all

Le= =C2=A0lun. 3 f=C3=A9vr. 2025 =C3=A0=C2=A016:00, Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> a =C3= =A9crit=C2=A0:
2= 025-02-03 14:51 (UTC+0100), Sid ali cherrati:
> [...]
> if (!rte_flow_validate(port_id, &attr, pattern, actions, &erro= r)){
> flow =3D rte_flow_create(port_id, &attr, pattern, actions, &er= ror);
> }
>
> if(flow !=3D 0){
> printf("Filed to create drop flow filter \n");
> return -1;
> }
> [...]
> The issue is that when I implement this, I get an error on the drop fi= lter:
> "Failed to create rule." Do you have any idea why this might= be happening?

There is no this exact error text in your code or DPDK,
I assume we're talking about the quoted fragment.
`flow` is a pointer, the correct error condition is `if (flow =3D=3D NULL)`= ,
so your code probably misinterprets success as error.
Also `flow` is not assigned if `rte_flow_validate()` returns non-0.
--000000000000181c18062d3e3b21--