Skip to content

Commit

Permalink
mpm: rename internal id for ac-tile to ac-ks
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjulien committed Feb 20, 2019
1 parent 2bd23bc commit 3f253cb
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/detect-engine-mpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ uint16_t PatternMatchDefaultMatcher(void)
done:
#ifdef __tile__
if (mpm_algo_val == MPM_AC)
mpm_algo_val = MPM_AC_TILE;
mpm_algo_val = MPM_AC_KS;
#endif

return mpm_algo_val;
Expand Down
2 changes: 1 addition & 1 deletion src/detect-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ static int DetectEngineCtxLoadConf(DetectEngineCtx *de_ctx)
if (sgh_mpm_context == NULL || strcmp(sgh_mpm_context, "auto") == 0) {
/* for now, since we still haven't implemented any intelligence into
* understanding the patterns and distributing mpm_ctx across sgh */
if (de_ctx->mpm_matcher == MPM_AC || de_ctx->mpm_matcher == MPM_AC_TILE ||
if (de_ctx->mpm_matcher == MPM_AC || de_ctx->mpm_matcher == MPM_AC_KS ||
#ifdef BUILD_HYPERSCAN
de_ctx->mpm_matcher == MPM_HS ||
#endif
Expand Down
82 changes: 41 additions & 41 deletions src/util-mpm-ac-tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1495,21 +1495,21 @@ void SCACTilePrintInfo(MpmCtx *mpm_ctx)
void MpmACTileRegister(void)
{
#ifdef __tile__
mpm_table[MPM_AC_TILE].name = "ac-tile";
mpm_table[MPM_AC_KS].name = "ac-tile";
#else
mpm_table[MPM_AC_TILE].name = "ac-ks";
mpm_table[MPM_AC_KS].name = "ac-ks";
#endif
mpm_table[MPM_AC_TILE].InitCtx = SCACTileInitCtx;
mpm_table[MPM_AC_TILE].InitThreadCtx = SCACTileInitThreadCtx;
mpm_table[MPM_AC_TILE].DestroyCtx = SCACTileDestroyCtx;
mpm_table[MPM_AC_TILE].DestroyThreadCtx = SCACTileDestroyThreadCtx;
mpm_table[MPM_AC_TILE].AddPattern = SCACTileAddPatternCS;
mpm_table[MPM_AC_TILE].AddPatternNocase = SCACTileAddPatternCI;
mpm_table[MPM_AC_TILE].Prepare = SCACTilePreparePatterns;
mpm_table[MPM_AC_TILE].Search = SCACTileSearch;
mpm_table[MPM_AC_TILE].PrintCtx = SCACTilePrintInfo;
mpm_table[MPM_AC_TILE].PrintThreadCtx = SCACTilePrintSearchStats;
mpm_table[MPM_AC_TILE].RegisterUnittests = SCACTileRegisterTests;
mpm_table[MPM_AC_KS].InitCtx = SCACTileInitCtx;
mpm_table[MPM_AC_KS].InitThreadCtx = SCACTileInitThreadCtx;
mpm_table[MPM_AC_KS].DestroyCtx = SCACTileDestroyCtx;
mpm_table[MPM_AC_KS].DestroyThreadCtx = SCACTileDestroyThreadCtx;
mpm_table[MPM_AC_KS].AddPattern = SCACTileAddPatternCS;
mpm_table[MPM_AC_KS].AddPatternNocase = SCACTileAddPatternCI;
mpm_table[MPM_AC_KS].Prepare = SCACTilePreparePatterns;
mpm_table[MPM_AC_KS].Search = SCACTileSearch;
mpm_table[MPM_AC_KS].PrintCtx = SCACTilePrintInfo;
mpm_table[MPM_AC_KS].PrintThreadCtx = SCACTilePrintSearchStats;
mpm_table[MPM_AC_KS].RegisterUnittests = SCACTileRegisterTests;
}


Expand All @@ -1526,7 +1526,7 @@ static int SCACTileTest01(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1560,7 +1560,7 @@ static int SCACTileTest02(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1593,7 +1593,7 @@ static int SCACTileTest03(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1630,7 +1630,7 @@ static int SCACTileTest04(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
Expand Down Expand Up @@ -1664,7 +1664,7 @@ static int SCACTileTest05(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
Expand Down Expand Up @@ -1698,7 +1698,7 @@ static int SCACTileTest06(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

MpmAddPatternCS(&mpm_ctx, (uint8_t *)"abcd", 4, 0, 0, 0, 0, 0);
Expand Down Expand Up @@ -1730,7 +1730,7 @@ static int SCACTileTest07(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* should match 30 times */
Expand Down Expand Up @@ -1775,7 +1775,7 @@ static int SCACTileTest08(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1807,7 +1807,7 @@ static int SCACTileTest09(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1839,7 +1839,7 @@ static int SCACTileTest10(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1876,7 +1876,7 @@ static int SCACTileTest11(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

if (MpmAddPatternCS(&mpm_ctx, (uint8_t *)"he", 2, 0, 0, 1, 0, 0) == -1)
Expand Down Expand Up @@ -1923,7 +1923,7 @@ static int SCACTileTest12(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1958,7 +1958,7 @@ static int SCACTileTest13(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -1992,7 +1992,7 @@ static int SCACTileTest14(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -2026,7 +2026,7 @@ static int SCACTileTest15(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -2060,7 +2060,7 @@ static int SCACTileTest16(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -2094,7 +2094,7 @@ static int SCACTileTest17(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -2128,7 +2128,7 @@ static int SCACTileTest18(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -2162,7 +2162,7 @@ static int SCACTileTest19(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 */
Expand Down Expand Up @@ -2196,7 +2196,7 @@ static int SCACTileTest20(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 */
Expand Down Expand Up @@ -2230,7 +2230,7 @@ static int SCACTileTest21(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 */
Expand Down Expand Up @@ -2262,7 +2262,7 @@ static int SCACTileTest22(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 match */
Expand Down Expand Up @@ -2297,7 +2297,7 @@ static int SCACTileTest23(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 */
Expand Down Expand Up @@ -2329,7 +2329,7 @@ static int SCACTileTest24(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 1 */
Expand Down Expand Up @@ -2361,7 +2361,7 @@ static int SCACTileTest25(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

MpmAddPatternCI(&mpm_ctx, (uint8_t *)"ABCD", 4, 0, 0, 0, 0, 0);
Expand Down Expand Up @@ -2395,7 +2395,7 @@ static int SCACTileTest26(void)

memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

MpmAddPatternCI(&mpm_ctx, (uint8_t *)"Works", 5, 0, 0, 0, 0, 0);
Expand Down Expand Up @@ -2428,7 +2428,7 @@ static int SCACTileTest27(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 0 match */
Expand Down Expand Up @@ -2461,7 +2461,7 @@ static int SCACTileTest28(void)

memset(&mpm_ctx, 0, sizeof(MpmCtx));
memset(&mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
MpmInitCtx(&mpm_ctx, MPM_AC_TILE);
MpmInitCtx(&mpm_ctx, MPM_AC_KS);
SCACTileInitThreadCtx(&mpm_ctx, &mpm_thread_ctx);

/* 0 match */
Expand Down
6 changes: 3 additions & 3 deletions src/util-mpm-ac-tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*
*/

#ifndef __UTIL_MPM_AC_TILE__H__
#define __UTIL_MPM_AC_TILE__H__
#ifndef __UTIL_MPM_AC_KS__H__
#define __UTIL_MPM_AC_KS__H__

typedef struct SCACTilePatternList_ {
uint8_t *cs;
Expand Down Expand Up @@ -155,4 +155,4 @@ typedef struct SCACTileThreadCtx_ {

void MpmACTileRegister(void);

#endif /* __UTIL_MPM_AC_TILE__H__ */
#endif /* __UTIL_MPM_AC_KS__H__ */
4 changes: 2 additions & 2 deletions src/util-mpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ void MpmInitCtx (MpmCtx *mpm_ctx, uint16_t matcher)
#ifdef BUILD_HYPERSCAN
# define DEFAULT_MPM MPM_HS
# ifdef __tile__
# define DEFAULT_MPM_AC MPM_AC_TILE
# define DEFAULT_MPM_AC MPM_AC_KS
# else
# define DEFAULT_MPM_AC MPM_AC
# endif
#else
# ifdef __tile__
# define DEFAULT_MPM MPM_AC_TILE
# define DEFAULT_MPM MPM_AC_KS
# else
# define DEFAULT_MPM MPM_AC
# endif
Expand Down
2 changes: 1 addition & 1 deletion src/util-mpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum {
/* aho-corasick */
MPM_AC,
MPM_AC_BS,
MPM_AC_TILE,
MPM_AC_KS,
MPM_HS,
/* table size */
MPM_TABLE_SIZE,
Expand Down

0 comments on commit 3f253cb

Please sign in to comment.