43
43
#include <hs.h>
44
44
#include <openssl/evp.h>
45
45
46
- #define MPM_RXP_DESCRIPTORS 2048 // descriptors used in the rxp queues
46
+ #define MPM_RXP_DESCRIPTORS 1024 // descriptors used in the rxp queues
47
47
#define MPM_RXP_OPERATIONS 32 // number of operations when de/enqueueing to RXP queues
48
48
#define MPM_RXP_MAX_WORKERS 8 // should correspond to the number of workers
49
49
#define MPM_RXP_PATTERNS_PATH "/tmp/suricata-mpm.patterns" // path to where extracted contents from Suricata rules will be temporarily stored
@@ -944,8 +944,8 @@ uint32_t SCRXPFinalizeSearchAndBulkDequeueAll(PrefilterRuleStore *pmq)
944
944
g_rxp_ops ,
945
945
MPM_RXP_OPERATIONS );
946
946
if (deqed == 0 ) {
947
- rte_delay_us_sleep (1 );
948
- pthread_yield ();
947
+ rte_delay_us_sleep (g_rxp_deq_retry_after_us );
948
+ sched_yield ();
949
949
}
950
950
951
951
// convert RXP results to PMQ
@@ -1017,7 +1017,7 @@ uint32_t SCRXPFinalizeSearchAndBulkDequeueAll(PrefilterRuleStore *pmq)
1017
1017
* \retval matches Match count.
1018
1018
*/
1019
1019
static uint32_t SCRXPSearchBulk (const MpmCtx * mpm_ctx , MpmThreadCtx * mpm_thread_ctx ,
1020
- PrefilterRuleStore * pmq , const uint8_t * buf , const uint32_t buflen )
1020
+ PrefilterRuleStore * pmq , const uint8_t * buf , uint32_t buflen )
1021
1021
{
1022
1022
uint32_t ret = 0 ;
1023
1023
SCRXPCtx * rxp_ctx = (SCRXPCtx * )mpm_ctx -> ctx ;
@@ -1026,16 +1026,15 @@ static uint32_t SCRXPSearchBulk(const MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_
1026
1026
uint16_t enqed = 0 ;
1027
1027
uint16_t prep_i = 0 ;
1028
1028
1029
- if (unlikely (buflen == 0 )) {
1029
+ if (unlikely (buflen == 0 || buflen == MPM_RXP_REQUIRED_HS_OFFSET )) {
1030
1030
return 0 ;
1031
1031
}
1032
- // TODO:
1033
- // try to think of traffic and rules that would be more suitable
1034
- // continue with stats - measure the time
1035
-
1032
+ if ( buflen > MPM_RXP_REQUIRED_HS_OFFSET ) {
1033
+ buflen -= MPM_RXP_REQUIRED_HS_OFFSET ;
1034
+ goto hs_fallback ;
1035
+ }
1036
1036
uint32_t seg_len = rxp_ctx -> max_payload_size ; // rxp_ctx->max_payload_size
1037
-
1038
- if (buflen < 1 ) {
1037
+ if (buflen < g_rxp_minlength ) {
1039
1038
goto hs_fallback ;
1040
1039
}
1041
1040
@@ -1539,14 +1538,46 @@ void RXPInit()
1539
1538
FatalError ("Unable to get %s configuration node" , dpdk_node_query );
1540
1539
}
1541
1540
const char iface_name [] = "0000:51:00.0" ;
1541
+ int32_t entry_int ;
1542
1542
ConfNode * if_node = ConfNodeLookupKeyValue (dpdk_node , "interface" , iface_name );
1543
1543
const char * entry_str = NULL ;
1544
1544
int retval = ConfGetChildValue (if_node , "threads" , & entry_str );
1545
1545
if (retval < 0 )
1546
1546
FatalError ("Unable to get threads configuration node" );
1547
- if (StringParseInt32 (& g_worker_threads_cnt , 10 , 0 , entry_str ) < 0 ) {
1547
+ if (StringParseInt32 (& entry_int , 10 , 0 , entry_str ) < 0 ) {
1548
1548
FatalError ("Unable to parse threads configuration node" );
1549
1549
}
1550
+ if (entry_int < 1 ) {
1551
+ FatalError ("Invalid threads configuration node" );
1552
+ }
1553
+ g_worker_threads_cnt = (uint16_t )entry_int ;
1554
+ if (run_mode == RUNMODE_PCAP_FILE ) {
1555
+ // this mode runs in autofp mode and the 1 RX thread does the applayer
1556
+ // protocol detection, so we need to add 1 extra queue
1557
+ g_worker_threads_cnt += 1 ;
1558
+ }
1559
+
1560
+ retval = ConfGetChildValue (if_node , "rxp-min-buflen" , & entry_str );
1561
+ if (retval < 0 )
1562
+ FatalError ("Unable to get rxp-min-buflen configuration node" );
1563
+ if (StringParseInt32 (& entry_int , 10 , 0 , entry_str ) < 0 ) {
1564
+ FatalError ("Unable to parse rxp-min-buflen configuration node" );
1565
+ }
1566
+ if (entry_int < 1 ) {
1567
+ FatalError ("Invalid rxp-min-buflen configuration node" );
1568
+ }
1569
+ g_rxp_minlength = (uint16_t )entry_int ;
1570
+
1571
+ retval = ConfGetChildValue (if_node , "rxp-dequeue-retry-after-us" , & entry_str );
1572
+ if (retval < 0 )
1573
+ FatalError ("Unable to get rxp-dequeue-retry-after-us configuration node" );
1574
+ if (StringParseInt32 (& entry_int , 10 , 0 , entry_str ) < 0 ) {
1575
+ FatalError ("Unable to parse rxp-dequeue-retry-after-us configuration node" );
1576
+ }
1577
+ if (entry_int < 1 ) {
1578
+ FatalError ("Invalid rxp-dequeue-retry-after-us configuration node" );
1579
+ }
1580
+ g_rxp_deq_retry_after_us = (uint16_t )entry_int ;
1550
1581
1551
1582
SCLogNotice ("nb queues %u nb groups %u" , g_worker_threads_cnt , g_mpm_groups_cnt );
1552
1583
dev_conf .nb_queue_pairs = g_worker_threads_cnt ;
0 commit comments