patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 7e6c7a25e437c974a8c0f4e7fdbf790023b2dfee 688 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
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev>

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

int main(int argc, char **argv)
{
	if (argc < 2) {
		err(EXIT_FAILURE, "missing interface name");
	}

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

	int map_fd = bpf_obj_get("/sys/fs/bpf/router_iface");
	if (map_fd < 0) {
		err(EXIT_FAILURE, "failed to open bpf map");
	}

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

debug log:

solving 7e6c7a2 ...
found 7e6c7a2 in https://inbox.spectrum-os.org/spectrum-devel/20250923163519.48306-2-yureka@cyberchaos.dev/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20250923132012.28013-3-yureka@cyberchaos.dev/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20250924114300.100541-2-yureka@cyberchaos.dev/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20250923163519.48306-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..7e6c7a2

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/20250923132012.28013-3-yureka@cyberchaos.dev/ for 7e6c7a2
skipping https://inbox.spectrum-os.org/spectrum-devel/20250924114300.100541-2-yureka@cyberchaos.dev/ for 7e6c7a2
index at:
100644 7e6c7a25e437c974a8c0f4e7fdbf790023b2dfee	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).