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