AF_XDP-interaction: Shared header for defining MAX_AF_SOCKS

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
Jesper Dangaard Brouer
2021-11-12 12:46:11 +01:00
parent 396854e2e1
commit de646516c3
3 changed files with 17 additions and 2 deletions

View File

@@ -7,10 +7,11 @@
#include <bpf/bpf_core_read.h> /* bpf_core_type_id_local */
#include "xdp/parsing_helpers.h"
#include "af_xdp_kern_shared.h"
struct {
__uint(type, BPF_MAP_TYPE_XSKMAP);
__uint(max_entries, 64); /* Assume netdev has no more than 64 queues */
__uint(max_entries, MAX_AF_SOCKS);
__uint(key_size, sizeof(int));
__uint(value_size, sizeof(int));
} xsks_map SEC(".maps");
@@ -19,7 +20,7 @@ struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__type(key, __u32);
__type(value, __u32);
__uint(max_entries, 64);
__uint(max_entries, MAX_AF_SOCKS);
} xdp_stats_map SEC(".maps");
/*

View File

@@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/* Used by both kernel side BPF-progs and userspace programs,
* for sharing common DEFINEs.
*/
#ifndef __AF_XDP_KERN_SHARED_H
#define __AF_XDP_KERN_SHARED_H
/* Assume netdev has no more than 64 queues */
#define MAX_AF_SOCKS 64
#endif /* __AF_XDP_KERN_SHARED_H */

View File

@@ -31,6 +31,7 @@
#include "common_params.h"
#include "common_user_bpf_xdp.h"
// #include "common_libbpf.h"
#include "af_xdp_kern_shared.h"
#include "lib_xsk_extend.h"
@@ -780,6 +781,7 @@ int main(int argc, char **argv)
};
struct xsk_umem_info *umem;
struct xsk_socket_info *xsk_socket;
struct xsk_socket_info *xsk_sockets[MAX_AF_SOCKS];
pthread_t stats_poll_thread;
struct bpf_object *bpf_obj = NULL;