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 37AC042B8C for ; Wed, 24 May 2023 12:05:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ACCA842D17; Wed, 24 May 2023 12:04:47 +0200 (CEST) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by mails.dpdk.org (Postfix) with ESMTP id 3ACE642D73 for ; Wed, 24 May 2023 12:04:45 +0200 (CEST) Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-53482b44007so46448a12.2 for ; Wed, 24 May 2023 03:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684922684; x=1687514684; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WYz0ZiNdEgXt9wGhK7GFYGb9807n3y7ZiEGVlzHQv+4=; b=jVNlZU7n2K2JYW1e+63wr8AmKuwoTcyjTH+WW+PcqS++DbLtmX/zYzyzF1+MnL4Vsr QolAXVCr+HJRiifZ5T3O84KhzcgOYruErx7J4pHr4k81i2SmaTYGoYgHydS8/FfmsP2m uiGaH5PQQiQe4r+VwxmPcD4LPpW1xzSEVpR2ovaFW2TJNi5zuJU4QDvzGyJ5ffVaCzaU HAriyBtPk7iIgZrmuNRkMWUTeaIz3a8cYlhfx4vTr9vSCcjNi0GW5y7Ajr7me4eo4Tos sXmANzp/+tuQ9X8APNJQZm5iP/Zf5icFuS11zhQCPULd8e4GeKvzlitzGc/g3EwNNwGy FM/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684922684; x=1687514684; 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=WYz0ZiNdEgXt9wGhK7GFYGb9807n3y7ZiEGVlzHQv+4=; b=THf5fL50+E9rWnqNh/6nuyGUJZvjtxCSNXGaSEOTdLswcckybtMfeaO8DYm6xsxHAC 0uk5RtFmNJVA+6tiV9WLwhz2dAkvkQEXPmKrTcZwDnF4WZHiY2TtypwfldfATBDSb76a mh8y24gVzqMXPRZJ8qQLRZGfTrufFRgZPQRhX1fA8waI9TB4cRJJzLeAVcs543KKvQRU 1XBJqGxEkblRzC4+2BAvXrqE8fPjPelH9rureXdOlC5TxoqpNoGDHddWhPE7oEY6YA8k hZsTfJahogwPUH8W1pkNjVUmTtkgsTS9kYmo/R4gH9AEs8Fbh+iOP/DOZVRKQZFNg+Dw IAlw== X-Gm-Message-State: AC+VfDxqJjO81A1ATqegA56KWET0QpVyDvi+zbKdM7SXgOpgQNZFiGJu sfffBtX9yaMaryl1A9QbyzsX3R0tVSzGs+BulEDhIIHh/q8= X-Google-Smtp-Source: ACHHUZ5UF/rlKicgmj80f8+gtVc+Ftw2PhlNHZtw36IwHry2x1Nug/EZTxjNc265kszxqvxHTlH0kHr62xzAUS5rL3I= X-Received: by 2002:a17:903:1208:b0:1ae:b38:b6a with SMTP id l8-20020a170903120800b001ae0b380b6amr17186044plh.58.1684922684469; Wed, 24 May 2023 03:04:44 -0700 (PDT) MIME-Version: 1.0 References: <20230523092322.25757e84@hermes.local> In-Reply-To: <20230523092322.25757e84@hermes.local> From: Igor de Paula Date: Wed, 24 May 2023 11:04:33 +0100 Message-ID: Subject: Re: help with virtio_port To: Stephen Hemminger Cc: users@dpdk.org Content-Type: multipart/alternative; boundary="00000000000014f5a705fc6da20e" 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 --00000000000014f5a705fc6da20e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry I replied privately. I am replying here again. WIth the KNI, I have a listener listener as follows: static void *kni_monitor_system_networking(void *data) { struct mnl_socket *nl; char buf[MNL_SOCKET_BUFFER_SIZE]; int ret; nl =3D mnl_socket_open(NETLINK_ROUTE); if (nl =3D=3D NULL) { perror("mnl_socket_open"); exit(EXIT_FAILURE); } if (mnl_socket_bind(nl, RTMGRP_LINK | RTMGRP_IPV4_IFADDR, MNL_SOCKET_AUTOPID) < 0) { perror("mnl_socket_bind"); exit(EXIT_FAILURE); } ret =3D mnl_socket_recvfrom(nl, buf, sizeof(buf)); while (ret > 0) { ret =3D mnl_cb_run(buf, ret, 0, 0, data_cb, NULL); if (ret <=3D 0) break; ret =3D mnl_socket_recvfrom(nl, buf, sizeof(buf)); } if (ret =3D=3D -1) { perror("error"); exit(EXIT_FAILURE); } mnl_socket_close(nl); return 0; } But also I have a thread looping over rte_kni_handle_request: while (1) { for (t =3D kni_tracker; t; t =3D t->next) { struct rte_kni *kni =3D ( struct rte_kni * )t->kni; if (ppo->kni) { rte_kni_handle_request(kni); } usleep(10000); } The rte_kni_handle_request calls the kni_config_promiscusity. So from what you are saying, I can replace this call with another monitor on the netlink ports (the work will be on finding the correct flags and to implement the callback I guess)? I from what I see, mnl_socket_bind(nl, RTMGRP_LINK | RTMGRP_IPV4_IFADDR, MNL_SOCKET_AUTOPID) < 0) this linke should get also requests that are link related, but it doesn't seem to get any packets when I use tcpdump on the interface. On Tue, May 23, 2023 at 5:23=E2=80=AFPM Stephen Hemminger < stephen@networkplumber.org> wrote: > On Tue, 23 May 2023 16:46:24 +0100 > Igor de Paula wrote: > > > Hi, > > I am running the DPDK version: 21.08.0 and Ubuntu 20.04.3 LTS. > > I have an application that uses KNI to interface with the kernel. > > I want to replace it with virtio_user ports as KNI will be deprecated i= n > > the future. > > Most of the functionality I am able to replace but there is one thing I > am > > struggling with. > > In KNI we can add functions that will be called in case the network sta= ck > > makes a request. The following code shows this: > > struct rte_kni *kni; > > struct rte_kni_conf conf; > > struct rte_kni_ops ops; > > struct rte_eth_dev_info dev_info; > > int ret; > > /* Clear conf at first */ > > memset(&conf, 0, sizeof(conf)); > > conf.core_id =3D 0; > > memset(&ops, 0, sizeof(ops)); > > ops.port_id =3D ppo->id; > > ops.config_promiscusity =3D ippe_ppo_set_kni_promiscuous_mode; > > ops.change_mtu =3D ippe_ppo_set_kni_mtu; > > ops.config_network_if =3D ippe_ppo_set_kni_interface; > > ops.config_mac_address =3D ippe_ppo_set_kni_mac_address; > > kni =3D rte_kni_alloc(pktmbuf_pool[0], &conf, &ops); > > > > > > And there is a handle_request function supplied by KNI that calls these > > functions when need be, > > I haven't found any documentation on how to replace this functionality.= I > > am no expert in how to set up and interact with the kernel stack, Some > help > > on how to achieve this would be appreciated. > > If you want to handle changes to kernel network device, then you > will have to build a netlink listener that monitors these changes. > --00000000000014f5a705fc6da20e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sorry I replied privately. I am replying here again.
WI= th the KNI, I have a listener listener as follows:
static void *kni_moni= tor_system_networking(void *data)
{
=C2=A0 =C2=A0 struct mnl_socket *= nl;
=C2=A0 =C2=A0 char buf[MNL_SOCKET_BUFFER_SIZE];
=C2=A0 =C2=A0 int= ret;

=C2=A0 =C2=A0 nl =3D mnl_socket_open(NETLINK_ROUTE);
=C2=A0= =C2=A0 if (nl =3D=3D NULL)
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 perror("mnl_socket_open");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 exi= t(EXIT_FAILURE);
=C2=A0 =C2=A0 }

=C2=A0 =C2=A0 if (mnl_socket_bin= d(nl, RTMGRP_LINK | RTMGRP_IPV4_IFADDR, MNL_SOCKET_AUTOPID) < 0)
=C2= =A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 perror("mnl_socket_bind&qu= ot;);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 exit(EXIT_FAILURE);
=C2=A0 =C2=A0 }=

=C2=A0 =C2=A0 ret =3D mnl_socket_recvfrom(nl, buf, sizeof(buf));=C2=A0 =C2=A0 while (ret > 0)
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 ret =3D mnl_cb_run(buf, ret, 0, 0, data_cb, NULL);
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 if (ret <=3D 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D mnl_socket_recvfrom(nl= , buf, sizeof(buf));
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 if (ret =3D=3D -1)=
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 perror("error"= );
=C2=A0 =C2=A0 =C2=A0 =C2=A0 exit(EXIT_FAILURE);
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 mnl_socket_close(nl);

=C2=A0 =C2=A0 return 0;
= }

But also I have a thread looping over rte_kni_handle_request:
w= hile (1)
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (t =3D kni_t= racker; t; t =3D t->next)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct rte_kni *kni =3D ( =C2=A0struct rte_= kni *=C2=A0 )t->kni;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if= (ppo->kni)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rte_kni_handle_request(kni);<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 usleep(= 10000);
=C2=A0 =C2=A0 }

The rte_kni_handle_request calls the kni_= config_promiscusity.
So from what you are saying, I can replace this cal= l with another monitor on the netlink ports (the work will be on finding th= e correct flags and to implement the callback I guess)?
I from what I se= e,=C2=A0 mnl_socket_bind(nl, RTMGRP_LINK | RTMGRP_IPV4_IFADDR, MNL_SOCKET_AUTOPID) &= lt; 0) this linke should get also requests that are link related, but it do= esn't seem to get any packets when I use tcpdump on the interface.
On Tu= e, May 23, 2023 at 5:23=E2=80=AFPM Stephen Hemminger <stephen@networkplumber.org> wrote:
On Tue, 23 May 2023 1= 6:46:24 +0100
Igor de Paula <i= gordptx@gmail.com> wrote:

> Hi,
> I am running the DPDK version: 21.08.0 and Ubuntu 20.04.3 LTS.
> I have an application that uses KNI to interface with the kernel.
> I want to replace it with virtio_user ports as KNI will be deprecated = in
> the future.
> Most of the functionality I am able to replace but there is one thing = I am
> struggling with.
> In KNI we can add functions that will be called in case the network st= ack
> makes a request. The following code shows this:
> struct rte_kni *kni;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct rte_kni_conf conf;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct rte_kni_ops ops;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0struct rte_eth_dev_info dev_info;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int ret;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Clear conf at first */
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memset(&conf, 0, sizeof(conf)); >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0conf.core_id =3D 0;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memset(&ops, 0, sizeof(ops));
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ops.port_id =3D ppo->id;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ops.config_promiscusity =3D ippe_ppo_= set_kni_promiscuous_mode;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ops.change_mtu =3D ippe_ppo_set_kni_m= tu;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ops.config_network_if =3D ippe_ppo_se= t_kni_interface;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ops.config_mac_address =3D ippe_ppo_s= et_kni_mac_address;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kni =3D rte_kni_alloc(pktmbuf_pool[0]= , &conf, &ops);
>
>
> And there is a handle_request function supplied by KNI that calls thes= e
> functions when need be,
> I haven't found any documentation on how to replace this functiona= lity. I
> am no expert in how to set up and interact with the kernel stack, Some= help
> on how to achieve this would be appreciated.

If you want to handle changes to kernel network device, then you
will have to build a netlink listener that monitors these changes.
--00000000000014f5a705fc6da20e--