xref: /dpdk/examples/bpf/t2.c (revision 25d11a86c56d50947af33d0b79ede622809bd8b9)
1*25d11a86SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2*25d11a86SBruce Richardson  * Copyright(c) 2018 Intel Corporation
3*25d11a86SBruce Richardson  */
4*25d11a86SBruce Richardson 
5*25d11a86SBruce Richardson /*
6*25d11a86SBruce Richardson  * eBPF program sample.
7*25d11a86SBruce Richardson  * Accepts pointer to struct rte_mbuf as an input parameter.
8*25d11a86SBruce Richardson  * cleanup mbuf's vlan_tci and all related RX flags
9*25d11a86SBruce Richardson  * (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED).
10*25d11a86SBruce Richardson  * Doesn't touch contents of packet data.
11*25d11a86SBruce Richardson  * To compile:
12*25d11a86SBruce Richardson  * clang -O2 -I${RTE_SDK}/${RTE_TARGET}/include \
13*25d11a86SBruce Richardson  * -target bpf -Wno-int-to-void-pointer-cast -c t2.c
14*25d11a86SBruce Richardson  */
15*25d11a86SBruce Richardson 
16*25d11a86SBruce Richardson #include <stdint.h>
17*25d11a86SBruce Richardson #include <stddef.h>
18*25d11a86SBruce Richardson #include <rte_config.h>
19*25d11a86SBruce Richardson #include "mbuf.h"
20*25d11a86SBruce Richardson 
21*25d11a86SBruce Richardson uint64_t
22*25d11a86SBruce Richardson entry(void *pkt)
23*25d11a86SBruce Richardson {
24*25d11a86SBruce Richardson 	struct rte_mbuf *mb;
25*25d11a86SBruce Richardson 
26*25d11a86SBruce Richardson 	mb = pkt;
27*25d11a86SBruce Richardson 	mb->vlan_tci = 0;
28*25d11a86SBruce Richardson 	mb->ol_flags &= ~(PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED);
29*25d11a86SBruce Richardson 
30*25d11a86SBruce Richardson 	return 1;
31*25d11a86SBruce Richardson }
32