Skip to content

Commit 156f886

Browse files
kkdwvdAlexei Starovoitov
authored andcommitted
samples: bpf: Add basic infrastructure for XDP samples
This file implements some common helpers to consolidate differences in features and functionality between the various XDP samples and give them a consistent look, feel, and reporting capabilities. This commit only adds support for receive statistics, which does not rely on any tracepoint, but on the XDP program installed on the device by each XDP redirect sample. Some of the key features are: * A concise output format accompanied by helpful text explaining its fields. * An elaborate output format building upon the concise one, and folding out details in case of errors and staying out of view otherwise. * Printing driver names for devices redirecting packets. * Getting mac address for interface. * Printing summarized total statistics for the entire session. * Ability to dynamically switch between concise and verbose mode, using SIGQUIT (Ctrl + \). In later patches, the support will be extended for each tracepoint with its own custom output in concise and verbose mode. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210821002010.845777-4-memxor@gmail.com
1 parent f2e85d4 commit 156f886

3 files changed

Lines changed: 915 additions & 0 deletions

File tree

‎samples/bpf/xdp_sample_shared.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
#ifndef _XDP_SAMPLE_SHARED_H
3+
#define _XDP_SAMPLE_SHARED_H
4+
5+
struct datarec {
6+
size_t processed;
7+
size_t dropped;
8+
size_t issue;
9+
union {
10+
size_t xdp_pass;
11+
size_t info;
12+
};
13+
size_t xdp_drop;
14+
size_t xdp_redirect;
15+
} __attribute__((aligned(64)));
16+
17+
#endif

0 commit comments

Comments
 (0)