Skip to content

Commit 83b2874

Browse files
mauriciobomfimVictorNogueiraRio
authored andcommitted
Add files for performance test
1 parent 096c904 commit 83b2874

File tree

6 files changed

+536
-12
lines changed

6 files changed

+536
-12
lines changed

samples/bpf/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ always-y += hbm_edt_kern.o
178178
always-y += xdpsock_kern.o
179179
# CONFIG_XDP_LUA
180180
always-y += xdplua_map_kern.o
181+
always-y += xdp_ssl_sni_drop_all.o
182+
always-y += xdp_ssl_sni_drop_ebpf.o
183+
always-y += xdp_ssl_sni_drop_lua.o
181184

182185
ifeq ($(ARCH), arm)
183186
# Strip all except -D__LINUX_ARM_ARCH__ option needed to handle linux
@@ -221,6 +224,7 @@ OPT ?= opt
221224
LLVM_DIS ?= llvm-dis
222225
LLVM_OBJCOPY ?= llvm-objcopy
223226
BTF_PAHOLE ?= pahole
227+
LLVM_READELF ?= llvm-readelf
224228

225229
# Detect that we're cross compiling and use the cross compiler
226230
ifdef CROSS_COMPILE
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2019-2021 Victor Nogueira <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License as
6+
* published by the Free Software Foundation version 2.
7+
*
8+
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
9+
* kind, whether express or implied; without even the implied warranty
10+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*/
13+
struct sslsni_wrapper {
14+
char sslsni[100];
15+
};

samples/bpf/xdp_ssl_sni_drop_all.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2019-2021 Victor Nogueira <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License as
6+
* published by the Free Software Foundation version 2.
7+
*
8+
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
9+
* kind, whether express or implied; without even the implied warranty
10+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*/
13+
#define KBUILD_MODNAME "foo"
14+
15+
#include <uapi/linux/bpf.h>
16+
#include "bpf_helpers.h"
17+
#include "bpf_endian.h"
18+
19+
struct bpf_map_def SEC("maps") rx_cnt = {
20+
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
21+
.key_size = sizeof(u32),
22+
.value_size = sizeof(long),
23+
.max_entries = 1,
24+
};
25+
26+
SEC("sslparser")
27+
int handle_ingress(struct xdp_md *ctx)
28+
{
29+
u32 key_rx = 0;
30+
long *cnt;
31+
32+
cnt = bpf_map_lookup_elem(&rx_cnt, &key_rx);
33+
if (!cnt)
34+
return XDP_PASS;
35+
36+
(*cnt)++;
37+
38+
return XDP_DROP;
39+
}
40+
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)