Skip to content

Commit 0b17045

Browse files
magnus-karlssonanakryiko
authored andcommitted
libbpf: Deprecate AF_XDP support
Deprecate AF_XDP support in libbpf ([0]). This has been moved to libxdp as it is a better fit for that library. The AF_XDP support only uses the public libbpf functions and can therefore just use libbpf as a library from libxdp. The libxdp APIs are exactly the same so it should just be linking with libxdp instead of libbpf for the AF_XDP functionality. If not, please submit a bug report. Linking with both libraries is supported but make sure you link in the correct order so that the new functions in libxdp are used instead of the deprecated ones in libbpf. Libxdp can be found at https://github.com/xdp-project/xdp-tools. [0] Closes: libbpf/libbpf#270 Signed-off-by: Magnus Karlsson <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 9741e07 commit 0b17045

File tree

1 file changed

+52
-38
lines changed

1 file changed

+52
-38
lines changed

tools/lib/bpf/xsk.h

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
extern "C" {
2424
#endif
2525

26+
/* This whole API has been deprecated and moved to libxdp that can be found at
27+
* https://github.com/xdp-project/xdp-tools. The APIs are exactly the same so
28+
* it should just be linking with libxdp instead of libbpf for this set of
29+
* functionality. If not, please submit a bug report on the aforementioned page.
30+
*/
31+
2632
/* Load-Acquire Store-Release barriers used by the XDP socket
2733
* library. The following macros should *NOT* be considered part of
2834
* the xsk.h API, and is subject to change anytime.
@@ -245,8 +251,10 @@ static inline __u64 xsk_umem__add_offset_to_addr(__u64 addr)
245251
return xsk_umem__extract_addr(addr) + xsk_umem__extract_offset(addr);
246252
}
247253

248-
LIBBPF_API int xsk_umem__fd(const struct xsk_umem *umem);
249-
LIBBPF_API int xsk_socket__fd(const struct xsk_socket *xsk);
254+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
255+
int xsk_umem__fd(const struct xsk_umem *umem);
256+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
257+
int xsk_socket__fd(const struct xsk_socket *xsk);
250258

251259
#define XSK_RING_CONS__DEFAULT_NUM_DESCS 2048
252260
#define XSK_RING_PROD__DEFAULT_NUM_DESCS 2048
@@ -263,10 +271,10 @@ struct xsk_umem_config {
263271
__u32 flags;
264272
};
265273

266-
LIBBPF_API int xsk_setup_xdp_prog(int ifindex,
267-
int *xsks_map_fd);
268-
LIBBPF_API int xsk_socket__update_xskmap(struct xsk_socket *xsk,
269-
int xsks_map_fd);
274+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
275+
int xsk_setup_xdp_prog(int ifindex, int *xsks_map_fd);
276+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
277+
int xsk_socket__update_xskmap(struct xsk_socket *xsk, int xsks_map_fd);
270278

271279
/* Flags for the libbpf_flags field. */
272280
#define XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD (1 << 0)
@@ -280,40 +288,46 @@ struct xsk_socket_config {
280288
};
281289

282290
/* Set config to NULL to get the default configuration. */
283-
LIBBPF_API int xsk_umem__create(struct xsk_umem **umem,
284-
void *umem_area, __u64 size,
285-
struct xsk_ring_prod *fill,
286-
struct xsk_ring_cons *comp,
287-
const struct xsk_umem_config *config);
288-
LIBBPF_API int xsk_umem__create_v0_0_2(struct xsk_umem **umem,
289-
void *umem_area, __u64 size,
290-
struct xsk_ring_prod *fill,
291-
struct xsk_ring_cons *comp,
292-
const struct xsk_umem_config *config);
293-
LIBBPF_API int xsk_umem__create_v0_0_4(struct xsk_umem **umem,
294-
void *umem_area, __u64 size,
295-
struct xsk_ring_prod *fill,
296-
struct xsk_ring_cons *comp,
297-
const struct xsk_umem_config *config);
298-
LIBBPF_API int xsk_socket__create(struct xsk_socket **xsk,
299-
const char *ifname, __u32 queue_id,
300-
struct xsk_umem *umem,
301-
struct xsk_ring_cons *rx,
302-
struct xsk_ring_prod *tx,
303-
const struct xsk_socket_config *config);
304-
LIBBPF_API int
305-
xsk_socket__create_shared(struct xsk_socket **xsk_ptr,
306-
const char *ifname,
307-
__u32 queue_id, struct xsk_umem *umem,
308-
struct xsk_ring_cons *rx,
309-
struct xsk_ring_prod *tx,
310-
struct xsk_ring_prod *fill,
311-
struct xsk_ring_cons *comp,
312-
const struct xsk_socket_config *config);
291+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
292+
int xsk_umem__create(struct xsk_umem **umem,
293+
void *umem_area, __u64 size,
294+
struct xsk_ring_prod *fill,
295+
struct xsk_ring_cons *comp,
296+
const struct xsk_umem_config *config);
297+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
298+
int xsk_umem__create_v0_0_2(struct xsk_umem **umem,
299+
void *umem_area, __u64 size,
300+
struct xsk_ring_prod *fill,
301+
struct xsk_ring_cons *comp,
302+
const struct xsk_umem_config *config);
303+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
304+
int xsk_umem__create_v0_0_4(struct xsk_umem **umem,
305+
void *umem_area, __u64 size,
306+
struct xsk_ring_prod *fill,
307+
struct xsk_ring_cons *comp,
308+
const struct xsk_umem_config *config);
309+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
310+
int xsk_socket__create(struct xsk_socket **xsk,
311+
const char *ifname, __u32 queue_id,
312+
struct xsk_umem *umem,
313+
struct xsk_ring_cons *rx,
314+
struct xsk_ring_prod *tx,
315+
const struct xsk_socket_config *config);
316+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
317+
int xsk_socket__create_shared(struct xsk_socket **xsk_ptr,
318+
const char *ifname,
319+
__u32 queue_id, struct xsk_umem *umem,
320+
struct xsk_ring_cons *rx,
321+
struct xsk_ring_prod *tx,
322+
struct xsk_ring_prod *fill,
323+
struct xsk_ring_cons *comp,
324+
const struct xsk_socket_config *config);
313325

314326
/* Returns 0 for success and -EBUSY if the umem is still in use. */
315-
LIBBPF_API int xsk_umem__delete(struct xsk_umem *umem);
316-
LIBBPF_API void xsk_socket__delete(struct xsk_socket *xsk);
327+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
328+
int xsk_umem__delete(struct xsk_umem *umem);
329+
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "AF_XDP support deprecated and moved to libxdp")
330+
void xsk_socket__delete(struct xsk_socket *xsk);
317331

318332
#ifdef __cplusplus
319333
} /* extern "C" */

0 commit comments

Comments
 (0)