<div dir="ltr">Sorry I replied privately. I am replying here again.<br>WIth the KNI, I have a listener listener as follows:<br>static void *kni_monitor_system_networking(void *data)<br>{<br> struct mnl_socket *nl;<br> char buf[MNL_SOCKET_BUFFER_SIZE];<br> int ret;<br><br> nl = mnl_socket_open(NETLINK_ROUTE);<br> if (nl == NULL)<br> {<br> perror("mnl_socket_open");<br> exit(EXIT_FAILURE);<br> }<br><br> if (mnl_socket_bind(nl, RTMGRP_LINK | RTMGRP_IPV4_IFADDR, MNL_SOCKET_AUTOPID) < 0)<br> {<br> perror("mnl_socket_bind");<br> exit(EXIT_FAILURE);<br> }<br><br> ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));<br> while (ret > 0)<br> {<br> ret = mnl_cb_run(buf, ret, 0, 0, data_cb, NULL);<br> if (ret <= 0)<br> break;<br> ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));<br> }<br> if (ret == -1)<br> {<br> perror("error");<br> exit(EXIT_FAILURE);<br> }<br><br> mnl_socket_close(nl);<br><br> return 0;<br>}<br><br>But also I have a thread looping over rte_kni_handle_request:<br>while (1)<br> {<br> for (t = kni_tracker; t; t = t->next)<br> {<br> struct rte_kni *kni = ( struct rte_kni * )t->kni;<br><br> if (ppo->kni)<br> {<br> rte_kni_handle_request(kni);<br> }<br><br> usleep(10000);<br> }<br><br>The rte_kni_handle_request calls the kni_config_promiscusity.<br>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)?<br>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.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 23, 2023 at 5:23 PM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org">stephen@networkplumber.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 23 May 2023 16:46:24 +0100<br>
Igor de Paula <<a href="mailto:igordptx@gmail.com" target="_blank">igordptx@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
> I am running the DPDK version: 21.08.0 and Ubuntu 20.04.3 LTS.<br>
> I have an application that uses KNI to interface with the kernel.<br>
> I want to replace it with virtio_user ports as KNI will be deprecated in<br>
> the future.<br>
> Most of the functionality I am able to replace but there is one thing I am<br>
> struggling with.<br>
> In KNI we can add functions that will be called in case the network stack<br>
> makes a request. The following code shows this:<br>
> struct rte_kni *kni;<br>
> struct rte_kni_conf conf;<br>
> struct rte_kni_ops ops;<br>
> struct rte_eth_dev_info dev_info;<br>
> int ret;<br>
> /* Clear conf at first */<br>
> memset(&conf, 0, sizeof(conf));<br>
> conf.core_id = 0;<br>
> memset(&ops, 0, sizeof(ops));<br>
> ops.port_id = ppo->id;<br>
> ops.config_promiscusity = ippe_ppo_set_kni_promiscuous_mode;<br>
> ops.change_mtu = ippe_ppo_set_kni_mtu;<br>
> ops.config_network_if = ippe_ppo_set_kni_interface;<br>
> ops.config_mac_address = ippe_ppo_set_kni_mac_address;<br>
> kni = rte_kni_alloc(pktmbuf_pool[0], &conf, &ops);<br>
> <br>
> <br>
> And there is a handle_request function supplied by KNI that calls these<br>
> functions when need be,<br>
> I haven't found any documentation on how to replace this functionality. I<br>
> am no expert in how to set up and interact with the kernel stack, Some help<br>
> on how to achieve this would be appreciated.<br>
<br>
If you want to handle changes to kernel network device, then you<br>
will have to build a netlink listener that monitors these changes.<br>
</blockquote></div>