xdp-bpf

Unicast/multicast packet using xdp/tc eBPF

不问归期 提交于 2021-01-29 18:19:13
问题 I trying a design a load balancer using ebpf. I want to transmit the incoming packet to different destinations (devices connected in the same network). Although I have used the clone_bpf_redirect helper function to redirect the packet to real/ virtual interfaces and its working fine. Now I want to broadcast/unicast the packet to other devices connected in the same network. XDP does not support it, as far as I know. Therefore, using tc bpf hook. Is there any helper function or which action

AF_XDP: No packets for socket with queue-id 0 even though every packet is redirect

試著忘記壹切 提交于 2020-04-18 05:43:15
问题 I am based on this tutorial: https://github.com/xdp-project/xdp-tutorial/tree/master/advanced03-AF_XDP I create a socket with Queue-ID 0 in userspace. In my kernel af-xdp program I filter for UDP-packets and redirect them to the userspace socket via a xskmap . Because I obviously want the userspace-program to receive packets, I redirect the packets in the kernel program to index 0 : int index = 0; if (bpf_map_lookup_elem(&xsks_map, &index)) { return bpf_redirect_map(&xsks_map, index, 0); }

AF_XDP: map `(SRC-IP, DST-IP, DST-Port)` to index to `BPF_MAP_TYPE_XSKMAP`

空扰寡人 提交于 2020-04-17 18:51:24
问题 I want to spawn multiple user-space processes with each one processing packets from a single source (triple of (SRC-IP, DST-IP, DST-Port) ). Because there are going to pass a lot of packets through the AF-XDP kernel program and time is critical, I thought of a separate map in the kernel-program which is populated by a user-space program beforehand. This map defines a mapping from the previously mentioned triple to an index which is then used in bpf_redirect_map(&xsks_map, index, 0) to send

AF_XDP: map `(SRC-IP, DST-IP, DST-Port)` to index to `BPF_MAP_TYPE_XSKMAP`

不羁岁月 提交于 2020-04-17 18:47:30
问题 I want to spawn multiple user-space processes with each one processing packets from a single source (triple of (SRC-IP, DST-IP, DST-Port) ). Because there are going to pass a lot of packets through the AF-XDP kernel program and time is critical, I thought of a separate map in the kernel-program which is populated by a user-space program beforehand. This map defines a mapping from the previously mentioned triple to an index which is then used in bpf_redirect_map(&xsks_map, index, 0) to send

AF_XDP: map `(SRC-IP, DST-IP, DST-Port)` to index to `BPF_MAP_TYPE_XSKMAP`

北城以北 提交于 2020-04-17 18:47:17
问题 I want to spawn multiple user-space processes with each one processing packets from a single source (triple of (SRC-IP, DST-IP, DST-Port) ). Because there are going to pass a lot of packets through the AF-XDP kernel program and time is critical, I thought of a separate map in the kernel-program which is populated by a user-space program beforehand. This map defines a mapping from the previously mentioned triple to an index which is then used in bpf_redirect_map(&xsks_map, index, 0) to send

AF-XDP: Implement Shared Umem sockets

廉价感情. 提交于 2020-04-07 08:10:35
问题 I want to implement XDP_SHARED_UMEM: https://www.kernel.org/doc/html/latest/networking/af_xdp.html#xdp-shared-umem-bind-flag The libbpf library function xsk_socket__create (https://github.com/libbpf/libbpf/blob/master/src/xsk.c) checks the xsk_umem->refcount value. In case it is greater than 1, the XDP_SHARED_UMEM option of a struct sockaddr_xdp is set. So as far as I understand correctly, I "just" need to pass the original umem struct of the socket I want to share the umem with and the rest

AF-XDP: Implement Shared Umem sockets

和自甴很熟 提交于 2020-04-07 08:08:41
问题 I want to implement XDP_SHARED_UMEM: https://www.kernel.org/doc/html/latest/networking/af_xdp.html#xdp-shared-umem-bind-flag The libbpf library function xsk_socket__create (https://github.com/libbpf/libbpf/blob/master/src/xsk.c) checks the xsk_umem->refcount value. In case it is greater than 1, the XDP_SHARED_UMEM option of a struct sockaddr_xdp is set. So as far as I understand correctly, I "just" need to pass the original umem struct of the socket I want to share the umem with and the rest

AF-XDP: Implement Shared Umem sockets

。_饼干妹妹 提交于 2020-04-07 08:07:13
问题 I want to implement XDP_SHARED_UMEM: https://www.kernel.org/doc/html/latest/networking/af_xdp.html#xdp-shared-umem-bind-flag The libbpf library function xsk_socket__create (https://github.com/libbpf/libbpf/blob/master/src/xsk.c) checks the xsk_umem->refcount value. In case it is greater than 1, the XDP_SHARED_UMEM option of a struct sockaddr_xdp is set. So as far as I understand correctly, I "just" need to pass the original umem struct of the socket I want to share the umem with and the rest

XDP program ip link error: Prog section rejected: Operation not permitted

北城以北 提交于 2020-04-05 06:07:28
问题 I try to get into XDP , for this I have this very small program: // SPDX-License-Identifier: GPL-2.0 #include <linux/bpf.h> #include "bpf/bpf_helpers.h" #include "xdpsock.h" struct { __uint(type, BPF_MAP_TYPE_ARRAY); __uint(max_entries, MAX_SOCKS); __uint(key_size, sizeof(int)); __uint(value_size, sizeof(int)); } xsks_map SEC(".maps"); SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) { return XDP_DROP; } But if I try to load it into a virtual interface veth-basic02 , I get this error: $

XDP program ip link error: Prog section rejected: Operation not permitted

孤人 提交于 2020-04-05 06:07:03
问题 I try to get into XDP , for this I have this very small program: // SPDX-License-Identifier: GPL-2.0 #include <linux/bpf.h> #include "bpf/bpf_helpers.h" #include "xdpsock.h" struct { __uint(type, BPF_MAP_TYPE_ARRAY); __uint(max_entries, MAX_SOCKS); __uint(key_size, sizeof(int)); __uint(value_size, sizeof(int)); } xsks_map SEC(".maps"); SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx) { return XDP_DROP; } But if I try to load it into a virtual interface veth-basic02 , I get this error: $