[v2] net/af_xdp: enable a sock path alongside use_cni
Stephen Hemminger
stephen at networkplumber.org
Fri Dec 8 18:23:34 CET 2023
On Mon, 4 Dec 2023 18:41:18 +0000
Maryam Tahhan <mtahhan at redhat.com> wrote:
> Hi Shibin
>
> I'm not really sure what you are suggesting, is to make an assumption on
> the path part where the socket resides (aka hard code it) and then try
> to build the full UDS path in DPDK?
>
> Yes the plugin is using constants ATM for certain parts of the UDS path,
> but that's not say that it's something that won't become configurable
> later on. Someone may not want to use "/tmp/afxdp_dp/" as the base
> directory. Then we'd have to change DPDK's implementation again. These
> are not really things that are configured by hand and are generated by
> initialization scripts (typically). I would rather build this with the
> idea that things can change in the future without having to change the
> DPDK implementation again.
> BR
> Maryam
In UNIX(7) man page:
abstract
an abstract socket address is distinguished (from a pathname
socket) by the fact that sun_path[0] is a null byte ('\0'). The
socket's address in this namespace is given by the additional
bytes in sun_path that are covered by the specified length of
the address structure. (Null bytes in the name have no special
significance.) The name has no connection with filesystem path‐
names. When the address of an abstract socket is returned, the
returned addrlen is greater than sizeof(sa_family_t) (i.e.,
greater than 2), and the name of the socket is contained in the
first (addrlen - sizeof(sa_family_t)) bytes of sun_path.
Something like this:
diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 353c8688ec9c..f41632a9df5a 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -1362,7 +1362,10 @@ init_uds_sock(struct sockaddr_un *server)
}
server->sun_family = AF_UNIX;
- strlcpy(server->sun_path, UDS_SOCK, sizeof(server->sun_path));
+
+ /* Use an abstract socket (not in filesystem) */
+ memset(server.sun_path, '\0', sizeof(server.sun_path));
+ strlcpy(server->sun_path + 1, UDS_SOCK, sizeof(server->sun_path) - 1);
if (connect(sock, (struct sockaddr *)server, sizeof(struct sockaddr_un)) < 0) {
close(sock);
@@ -1393,7 +1396,10 @@ send_msg(int sock, char *request, int *fd)
memset(&dst, 0, sizeof(dst));
dst.sun_family = AF_UNIX;
- strlcpy(dst.sun_path, UDS_SOCK, sizeof(dst.sun_path));
+
+ /* Use an abstract socket (not in filesystem) */
+ memset(server.sun_path, '\0', sizeof(server.sun_path));
+ strlcpy(server->sun_path + 1, UDS_SOCK, sizeof(server->sun_path) - 1);
/* Initialize message header structure */
memset(&msgh, 0, sizeof(msgh));
More information about the dev
mailing list