DPDK usage discussions
 help / color / mirror / Atom feed
From: Igor de Paula <igordptx@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: users@dpdk.org
Subject: Re: help with virtio_port
Date: Wed, 24 May 2023 11:04:33 +0100	[thread overview]
Message-ID: <CALDr01SrYk1p2ODNKdXKrPuNd15u=M0tMae4e1N-SyGZ_UrBgQ@mail.gmail.com> (raw)
In-Reply-To: <20230523092322.25757e84@hermes.local>

[-- Attachment #1: Type: text/plain, Size: 3600 bytes --]

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 = mnl_socket_open(NETLINK_ROUTE);
    if (nl == 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 = mnl_socket_recvfrom(nl, buf, sizeof(buf));
    while (ret > 0)
    {
        ret = mnl_cb_run(buf, ret, 0, 0, data_cb, NULL);
        if (ret <= 0)
            break;
        ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
    }
    if (ret == -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 = kni_tracker; t; t = t->next)
        {
            struct rte_kni *kni = (  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 PM Stephen Hemminger <
stephen@networkplumber.org> wrote:

> On Tue, 23 May 2023 16:46:24 +0100
> Igor de Paula <igordptx@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 stack
> > 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 = 0;
> >         memset(&ops, 0, sizeof(ops));
> >         ops.port_id = ppo->id;
> >         ops.config_promiscusity = ippe_ppo_set_kni_promiscuous_mode;
> >         ops.change_mtu = ippe_ppo_set_kni_mtu;
> >         ops.config_network_if = ippe_ppo_set_kni_interface;
> >         ops.config_mac_address = ippe_ppo_set_kni_mac_address;
> >         kni = 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.
>

[-- Attachment #2: Type: text/html, Size: 4492 bytes --]

  reply	other threads:[~2023-05-24 10:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 15:46 Igor de Paula
2023-05-23 16:23 ` Stephen Hemminger
2023-05-24 10:04   ` Igor de Paula [this message]
2023-05-27 10:04   ` Igor de Paula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALDr01SrYk1p2ODNKdXKrPuNd15u=M0tMae4e1N-SyGZ_UrBgQ@mail.gmail.com' \
    --to=igordptx@gmail.com \
    --cc=stephen@networkplumber.org \
    --cc=users@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).