Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #822 - AF_XDP socket extension #823

Merged
merged 9 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 0 additions & 303 deletions INSTALL

This file was deleted.

44 changes: 44 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ AC_ARG_ENABLE(force-libdnet,
AS_HELP_STRING([--enable-force-libdnet],[Force using libdnet for sending packets]),
[ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])

AC_ARG_ENABLE(force-libxdp,
AS_HELP_STRING([--enable-force-libxdp],[Force using libxdp for sending packets]),
[ AC_DEFINE([FORCE_INJECT_LIBXDP], [1], [Force using libxdp for sending packets])])

AC_ARG_ENABLE(force-inject,
AS_HELP_STRING([--enable-force-inject],[Force using libpcap's pcap_inject() for sending packets]),
[ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
Expand Down Expand Up @@ -844,6 +848,12 @@ fi
AC_SEARCH_LIBS([nl_handle_alloc], [nl],
[AC_MSG_NOTICE([Unable to find nl library - may be needed by libpcap])])

AC_CHECK_LIB(bpf, bpf_object__open_file,,
[AC_MSG_NOTICE([Unable to find libbpf library ])])

AC_CHECK_LIB(xdp, xsk_umem__delete,,
[AC_MSG_NOTICE([Unable to find libxdp library ])])

##
## If not automatically configured,
## check for newer and full-featured libpcap's
Expand Down Expand Up @@ -1399,6 +1409,36 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_MSG_RESULT(no)
])

have_libxdp=no
dnl Check for LIBXDP AF_XDP socket support
AC_MSG_CHECKING(for LIBXDP XDP packet sending support)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <xdp/xsk.h>
#include <sys/socket.h>
]], [[
struct xsk_socket {
struct xsk_ring_cons *rx;
struct xsk_ring_prod *tx;
struct xsk_ctx *ctx;
struct xsk_socket_config config;
int fd;
};
struct xsk_socket xsk;
struct xsk_ring_cons *rxr = NULL;
struct xsk_ring_prod *txr = NULL;
int queue_id = 0;
xsk_socket__create(&xsk, "lo", queue_id, NULL, rxr, txr, NULL);
socket(AF_XDP, SOCK_RAW, 0);
]])],[
AC_DEFINE([HAVE_LIBXDP], [1],
[Do we have LIBXDP AF_XDP socket support?])
AC_MSG_RESULT(yes)
have_libxdp=yes
],[
AC_MSG_RESULT(no)
])

have_tx_ring=no
dnl Check for older Linux TX_RING support
AC_MSG_CHECKING(for TX_RING socket sending support)
Expand All @@ -1420,6 +1460,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_MSG_RESULT(no)
])

AC_CHECK_HEADERS([bpf/libbpf.h])
AC_CHECK_HEADERS([bpf/bpf.h])
AC_CHECK_HEADERS([xdp/libxdp.h])

AC_CHECK_HEADERS([net/bpf.h], [have_bpf=yes], [have_bpf=no])
if test $have_bpf = yes ; then
Expand Down Expand Up @@ -1948,6 +1991,7 @@ pcap_sendpacket: ${have_pcap_sendpacket} **
pcap_netmap ${have_pcap_netmap}
Linux/BSD netmap: ${have_netmap}
Tuntap device support: ${have_tuntap}
LIBXDP for AF_XDP socket: ${have_libxdp}

* In order of preference; see configure --help to override
** Required for tcpbridge
Expand Down
Loading