patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 2446e561cd1bf45858b033cca30ea8419cbc81bf 1158 bytes (raw)
name: vm/sys/net/xdp-forwarder/include/parsing_helpers.h 	 # 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
 
/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-clause) */
/* SPDX-FileCopyrightText: 2021 The xdp-tutorial Authors */
/* SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev> */
/* Based on  https://github.com/xdp-project/xdp-tutorial/blob/main/common/parsing_helpers.h */

#ifndef __PARSING_HELPERS_H
#define __PARSING_HELPERS_H

#include <bpf/bpf_endian.h>

//#include <linux/if_ether.h>
#define ETH_P_8021Q     0x8100          /* 802.1Q VLAN Extended Header  */
#define ETH_P_8021AD    0x88A8          /* 802.1ad Service VLAN		*/

static __always_inline int proto_is_vlan(__u16 h_proto)
{
	return !!(h_proto == bpf_htons(ETH_P_8021Q) ||
	          h_proto == bpf_htons(ETH_P_8021AD));
}

static __always_inline int parse_ethhdr(struct xdp_md *ctx,
                                        struct ethhdr **ethhdr)
{
	void *data_end = (void *)(long)ctx->data_end;
	struct ethhdr *eth = (void *) (long) ctx->data;

	/* Byte-count bounds check; check if current pointer + size of header
	 * is after data_end.
	 */
	if ((void *) (eth + 1) > data_end)
		return -1;

	*ethhdr = eth;

	return eth->h_proto; /* network-byte-order */
}

#endif

debug log:

solving 2446e56 ...
found 2446e56 in https://inbox.spectrum-os.org/spectrum-devel/20250823222134.1772413-2-yureka@cyberchaos.dev/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20250823222134.1772413-2-yureka@cyberchaos.dev/
diff --git a/vm/sys/net/xdp-forwarder/include/parsing_helpers.h b/vm/sys/net/xdp-forwarder/include/parsing_helpers.h
new file mode 100644
index 0000000..2446e56

Checking patch vm/sys/net/xdp-forwarder/include/parsing_helpers.h...
Applied patch vm/sys/net/xdp-forwarder/include/parsing_helpers.h cleanly.

index at:
100644 2446e561cd1bf45858b033cca30ea8419cbc81bf	vm/sys/net/xdp-forwarder/include/parsing_helpers.h

(*) 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).