]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/test/bpf/t3.c
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / test / bpf / t3.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 * Dump the mbuf into stdout if it is an ARP packet (aka tcpdump 'arp').
9 * To compile:
10 * clang -O2 -I${RTE_SDK}/${RTE_TARGET}/include \
11 * -target bpf -Wno-int-to-void-pointer-cast -c t3.c
12 */
13
14 #include <stdint.h>
15 #include <stddef.h>
16 #include <stdio.h>
17 #include <net/ethernet.h>
18 #include <rte_config.h>
19 #include "mbuf.h"
20
21 extern void rte_pktmbuf_dump(FILE *, const struct rte_mbuf *, unsigned int);
22
23 uint64_t
24 entry(const void *pkt)
25 {
26 const struct rte_mbuf *mb;
27 const struct ether_header *eth;
28
29 mb = pkt;
30 eth = rte_pktmbuf_mtod(mb, const struct ether_header *);
31
32 if (eth->ether_type == __builtin_bswap16(ETHERTYPE_ARP))
33 rte_pktmbuf_dump(stdout, mb, 64);
34
35 return 1;
36 }