Skip to content

Conversation

@biathlon3
Copy link
Contributor

No description provided.

@biathlon3 biathlon3 linked an issue Jul 5, 2024 that may be closed by this pull request
@biathlon3 biathlon3 marked this pull request as draft July 5, 2024 14:08
@biathlon3
Copy link
Contributor Author

For deployment see file install.txt. Description will be expanded.

@biathlon3
Copy link
Contributor Author

This PR works on Kernel 6.8.9

Description of using hscollider - http://intel.github.io/hyperscan/dev-reference/tools.html

Description of regular expression syntax - https://perldoc.perl.org/perlre
It is supported in Hyperscan not fully, constraints described here - http://intel.github.io/hyperscan/dev-reference/compilation.html

Now regex implemented in tempasta config as fallows:
for locations, added keyword "regex" and regex started with "^";
for httptables, regex started with "^".

for example:

location regex "^/new/" {
    frang_limits {
	http_body_len 5;
	http_strict_host_checking true;
    }
}

http_chain {
  uri == "^/html/" -> default;
  -> default;
}

@biathlon3 biathlon3 force-pushed the ag_Multi-pattern-regular-expressions branch 2 times, most recently from 5c02ff5 to 8c64bfa Compare July 8, 2024 17:09
@biathlon3 biathlon3 force-pushed the ag_Multi-pattern-regular-expressions branch 2 times, most recently from 4f4608e to d932ab5 Compare July 25, 2024 11:13
@biathlon3 biathlon3 marked this pull request as ready for review July 26, 2024 13:24
@biathlon3
Copy link
Contributor Author

I squashed it into one commit so it can be reviewed.

@biathlon3 biathlon3 force-pushed the ag_Multi-pattern-regular-expressions branch 2 times, most recently from 5f2b864 to 09f70b3 Compare July 29, 2024 18:23
@krizhanovsky krizhanovsky requested review from EvgeniiMekhanik, const-t and krizhanovsky and removed request for EvgeniiMekhanik and krizhanovsky July 30, 2024 19:40
@const-t const-t marked this pull request as draft April 11, 2025 13:33
supervisor and others added 8 commits October 27, 2025 18:00
Made regex configuration same way as in Nginx.
`rex_scan_tfwstr()` is intended to be called in softIRQ
context, therefore don't call `kernel_fpu_begin()`
because it being called before handling softIRQ.
Beside the part which allows to apply regular expressions to raw
headers this patch changes string matching for raw headers. Matching
consist of two parts: matching a header name and matching a header
value. Name always matches by simple string comparison, when this
part is successfull Tempesta matches value by string comparasion or
using regular expressions.

Name matching relies on header validity that guaranteed by parser,
it always assume that name of a header doesn't have OWS for HTTP1 and
always lower case for HTTP2. OWS are allowed only for value and only
for HTTP1. For HTTP2 we use memcmp_fast() to compare chunks of header
name, because a lot of small chunks not expected for HTTP2, we place
headers into big contigious chunks during hpack decoding. However, for
HTTP1 we use __str_cmp() that is simplified version of strncasecmp(),
but doesn't do tolower() for pattern, only for headwer part. Pattern
for string comparison now always lower case and space trimmed during
configuration stage on startup of Tempesta.

Also I did my best to get rid of branches inside the loops where it
is possible, making function inline with conditional argument known at
compile time. Alternatives are indirect calls and macroses: the former
might be slow (they are in my benchmarks) the second make the code
hard to read.
Enabling avx512 causing compilation time wanings relateed to
string fortification. Compiler can't check the size of the data,
because the length of the data calculates at runtime. Do unsafe
copy to suppress the warnings.
@const-t const-t force-pushed the ag_Multi-pattern-regular-expressions branch from 09f70b3 to 7f2013e Compare October 27, 2025 16:01
@const-t const-t force-pushed the ag_Multi-pattern-regular-expressions branch from 7f2013e to 88c3570 Compare October 27, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-pattern regular expressions

3 participants