patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob f1a2baca019a8e82af577c941fc51a14e5a248e0 666 bytes (raw)
name: tools/xdp-forwarder/set_router_iface.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
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev>

#include <stdio.h>
#include <net/if.h>
#include <bpf/bpf.h>

int main(int argc, char **argv)
{
	if (argc < 2) {
		fprintf(stderr, "missing interface name\n");
		return 1;
	}

	int router_idx = if_nametoindex(argv[1]);
	if (router_idx <= 0) {
		perror("error getting router interface");
		return 1;
	}

	int map_fd = bpf_obj_get("/sys/fs/bpf/router_iface");
	if (map_fd < 0) {
		perror("failed to open bpf map");
		return 1;
	}

	int id = 0;
	if (bpf_map_update_elem(map_fd, &id, &router_idx, 0) < 0) {
		perror("failed to update bpf map");
		return 1;
	}
}

debug log:

solving f1a2bac ...
found f1a2bac in https://inbox.spectrum-os.org/spectrum-devel/20250831205808.3962245-2-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/set_router_iface.c b/tools/xdp-forwarder/set_router_iface.c
new file mode 100644
index 0000000..f1a2bac

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

skipping https://inbox.spectrum-os.org/spectrum-devel/20250901201248.19794-2-yureka@cyberchaos.dev/ for f1a2bac
index at:
100644 f1a2baca019a8e82af577c941fc51a14e5a248e0	tools/xdp-forwarder/set_router_iface.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).