Skip to content

Commit 2b1bdae

Browse files
authored
Merge pull request intel#3 from G-Core/gcore-linux-rex
Gcore linux rex
2 parents 64a995b + 071dae5 commit 2b1bdae

File tree

100 files changed

+26955
-28050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+26955
-28050
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ autojunk
2525
.libs
2626
bin
2727

28+
# kernel binaries
29+
*.o.d
30+
*.cmd
31+
*.ko
32+
*.mod
33+
*.mod.c
34+
modules.order
35+
Module.symvers
36+
2837
# Merge files created by git.
2938
*.orig
3039

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 2.8.11)
1+
cmake_minimum_required (VERSION 3.12)
22
project (hyperscan C CXX)
33

44
set (HS_MAJOR_VERSION 5)
@@ -505,7 +505,7 @@ if (NOT WIN32)
505505
endforeach()
506506

507507
configure_file(libhs.pc.in libhs.pc @ONLY) # only replace @ quoted vars
508-
install(FILES ${CMAKE_BINARY_DIR}/libhs.pc
508+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libhs.pc
509509
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
510510
endif()
511511

@@ -579,7 +579,7 @@ set (hs_exec_common_SRCS
579579

580580
set (hs_exec_SRCS
581581
${hs_HEADERS}
582-
src/hs_version.h
582+
${PROJECT_BINARY_DIR}/hs_version.h
583583
src/ue2common.h
584584
src/allocator.h
585585
src/crc32.c
@@ -730,13 +730,13 @@ set (hs_exec_avx2_SRCS
730730

731731
SET (hs_compile_SRCS
732732
${hs_HEADERS}
733+
${PROJECT_BINARY_DIR}/hs_version.h
733734
src/crc32.h
734735
src/database.h
735736
src/grey.cpp
736737
src/grey.h
737738
src/hs.cpp
738739
src/hs_internal.h
739-
src/hs_version.h
740740
src/scratch.h
741741
src/state.h
742742
src/ue2common.h
@@ -1412,3 +1412,5 @@ option(BUILD_EXAMPLES "Build Hyperscan example code (default TRUE)" TRUE)
14121412
if(NOT WIN32 AND BUILD_EXAMPLES)
14131413
add_subdirectory(examples)
14141414
endif()
1415+
1416+
option(TEST_XDPSCAN "Build Hyperscan unit tests for XDP module" FALSE)

LICENSE

Lines changed: 372 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
1-
# Hyperscan
1+
# eBPF REGEX helper
22

3-
Hyperscan is a high-performance multiple regex matching library. It follows the
4-
regular expression syntax of the commonly-used libpcre library, but is a
5-
standalone library with its own C API.
6-
7-
Hyperscan uses hybrid automata techniques to allow simultaneous matching of
8-
large numbers (up to tens of thousands) of regular expressions and for the
9-
matching of regular expressions across streams of data.
10-
11-
Hyperscan is typically used in a DPI library stack.
3+
The `linux-rex` is a loadable kernel module providing eBPF helper functions
4+
for processing regular expressions. It uses Hyperscan as a runtime and
5+
configuration tool.
126

13-
# Documentation
7+
License: GPLv2
148

15-
Information on building the Hyperscan library and using its API is available in
16-
the [Developer Reference Guide](http://intel.github.io/hyperscan/dev-reference/).
9+
## Documentation
1710

18-
# License
11+
Refer to [the project wiki pages](https://github.com/G-Core/linux-regex-module/wiki)
12+
to find all the necessary documentation.
1913

20-
Hyperscan is licensed under the BSD License. See the LICENSE file in the
21-
project repository.
14+
## Talks and videos
2215

23-
# Versioning
16+
The `linux-rex` module [was introduced on the Netdev 0x16, Technical Conference
17+
on Linux Networking](https://netdevconf.info/0x16/session.html?When-regular-expressions-meet-XDP#)
2418

25-
The `master` branch on Github will always contain the most recent release of
26-
Hyperscan. Each version released to `master` goes through QA and testing before
27-
it is released; if you're a user, rather than a developer, this is the version
28-
you should be using.
19+
## Hyperscan
2920

30-
Further development towards the next release takes place on the `develop`
31-
branch.
21+
Hyperscan is a high-performance multiple regex matching library. It follows the
22+
regular expression syntax of the commonly-used libpcre library, but is a
23+
standalone library with its own C API.
3224

33-
# Get Involved
25+
Hyperscan uses hybrid automata techniques to allow simultaneous matching of
26+
large numbers (up to tens of thousands) of regular expressions and for the
27+
matching of regular expressions across streams of data.
3428

35-
The official homepage for Hyperscan is at [www.hyperscan.io](https://www.hyperscan.io).
29+
Hyperscan is typically used in a DPI library stack.
3630

37-
If you have questions or comments, we encourage you to [join the mailing
38-
list](https://lists.01.org/mailman/listinfo/hyperscan). Bugs can be filed by
39-
sending email to the list, or by creating an issue on Github.
31+
More information can be found at
32+
[Hyperscan project repo](https://github.com/intel/hyperscan)
4033

41-
If you wish to contact the Hyperscan team at Intel directly, without posting
42-
publicly to the mailing list, send email to
43-
[hyperscan@intel.com](mailto:hyperscan@intel.com).
34+
License: BSD

cmake/FindLibBpf.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# - Try to find libbpf
2+
# Once done this will define
3+
# LIBBPF_FOUND - System has libbpf
4+
# LIBBPF_INCLUDE_DIRS - The libbpf include directories
5+
# LIBBPF_LIBRARIES - The libraries needed to use libbpf
6+
7+
find_package(PkgConfig QUIET)
8+
pkg_check_modules(PC_LIBBPF QUIET libbpf)
9+
pkg_check_modules(PC_LIBELF QUIET libelf)
10+
pkg_check_modules(PC_ZLIB QUIET zlib)
11+
12+
find_path(LIBBPF_INCLUDE_DIR
13+
NAMES bpf/bpf.h
14+
HINTS ${PC_LIBBPF_INCLUDE_DIRS}
15+
)
16+
find_library(LIBBPF_LIBRARY
17+
NAMES bpf
18+
HINTS ${PC_LIBBPF_LIBRARY_DIRS}
19+
)
20+
21+
include(FindPackageHandleStandardArgs)
22+
# handle the QUIETLY and REQUIRED arguments and set LIBBPF_FOUND
23+
# to TRUE if all listed variables are TRUE and the requested version
24+
# matches.
25+
find_package_handle_standard_args(LibBpf REQUIRED_VARS
26+
LIBBPF_LIBRARY LIBBPF_INCLUDE_DIR
27+
VERSION_VAR LIBBPF_VERSION
28+
)
29+
30+
if(LIBBPF_FOUND)
31+
set(LIBBPF_LIBRARIES ${LIBBPF_LIBRARY} ${PC_LIBELF_LIBRARIES} ${PC_ZLIB_LIBRARIES})
32+
set(LIBBPF_INCLUDE_DIRS ${LIBBPF_INCLUDE_DIR} ${PC_LIBELF_INCLUDE_DIRS} ${PC_ZLIB_INCLUDE_DIRS})
33+
endif()
34+
35+
mark_as_advanced(LIBBPF_INCLUDE_DIR LIBBPF_LIBRARY)

cmake/build_wrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ KEEPSYMS=$(mktemp -p /tmp keep.syms.XXXXX)
1717
LIBC_SO=$("$@" --print-file-name=libc.so.6)
1818
cp ${KEEPSYMS_IN} ${KEEPSYMS}
1919
# get all symbols from libc and turn them into patterns
20-
nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ ]*\).*/^\1$/' >> ${KEEPSYMS}
20+
nm -f p -g -D ${LIBC_SO} | sed -s 's/\([^ @]*\).*/^\1$/' >> ${KEEPSYMS}
2121
# build the object
2222
"$@"
2323
# rename the symbols in the object

debian.dkms/README.Debian

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dkms build linux-rex/0.1

debian.dkms/build.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash -xe
2+
3+
kernel_source_dir="$1"
4+
linux_image=/boot/"vmlinuz-${kernelver}"
5+
shift 1
6+
7+
# Make our own source tree and extract vmlinux into it.
8+
subdirs=$(ls -A "${kernel_source_dir}"/)
9+
mkdir -p linux
10+
for d in $subdirs; do
11+
ln -s "${kernel_source_dir}"/"$d" linux/"$d"
12+
done
13+
14+
linux/scripts/extract-vmlinux "${linux_image}" \
15+
> linux/vmlinux
16+
17+
exec make -C linux "$@"

debian.dkms/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
linux-rex (0.1) unstable; urgency=medium
2+
3+
* Initial release
4+
5+
-- Sergey Nizovtsev <sn@tempesta-tech.com> Tue, 14 Jul 2022 16:24:30 +0300

debian.dkms/clean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.o
2+
Module.symvers
3+
*.ko
4+
.*.cmd
5+
xdp_rex.mod
6+
xdp_rex.mod.c
7+
modules.order

0 commit comments

Comments
 (0)