patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob fe6a6b5bf1275a1a1e455d98a48a37cc0feedabd 956 bytes (raw)
name: tools/xdp-forwarder/prog_router.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev>

#define VLAN_MAX_DEPTH 1

#include <linux/bpf.h>
#include <bpf/bpf_endian.h>
#include "parsing_helpers.h"
#include "rewrite_helpers.h"

// The map is actually not used by this program, but just included
// to keep the reference-counted pin alive before any physical interfaces
// are added.
struct {
	__uint(type, BPF_MAP_TYPE_DEVMAP);
	__type(key, int);
	__type(value, int);
	__uint(max_entries, 1);
	__uint(pinning, LIBBPF_PIN_BY_NAME);
} router_iface SEC(".maps");


SEC("xdp")
int router(struct xdp_md *ctx)
{
	void *data_end = (void *)(long)ctx->data_end;
	void *data = (void *)(long)ctx->data;

	struct hdr_cursor nh;
	nh.pos = data;

	struct ethhdr *eth;
	int r;
	if (r = parse_ethhdr(&nh, data_end, &eth) < 0)
		return XDP_DROP;

	int vlid = vlan_tag_pop(ctx, eth);
	if (vlid < 0) {
		return XDP_DROP;
	}

	return bpf_redirect(vlid, 0);
}

debug log:

solving fe6a6b5 ...
found fe6a6b5 in https://inbox.spectrum-os.org/spectrum-devel/20250831205808.3962245-2-yureka@cyberchaos.dev/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20250906141228.2357630-1-yureka@cyberchaos.dev/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20250901201248.19794-2-yureka@cyberchaos.dev/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20250831205808.3962245-2-yureka@cyberchaos.dev/
diff --git a/tools/xdp-forwarder/prog_router.c b/tools/xdp-forwarder/prog_router.c
new file mode 100644
index 0000000..fe6a6b5

Checking patch tools/xdp-forwarder/prog_router.c...
Applied patch tools/xdp-forwarder/prog_router.c cleanly.

skipping https://inbox.spectrum-os.org/spectrum-devel/20250906141228.2357630-1-yureka@cyberchaos.dev/ for fe6a6b5
skipping https://inbox.spectrum-os.org/spectrum-devel/20250901201248.19794-2-yureka@cyberchaos.dev/ for fe6a6b5
index at:
100644 fe6a6b5bf1275a1a1e455d98a48a37cc0feedabd	tools/xdp-forwarder/prog_router.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).