MpmCtx *mpm_ctx = NULL;
if (p->proto == IPPROTO_TCP) {
- mpm_ctx = sgh->mpm_proto_tcp_ctx;
+ if (p->flowflags & FLOW_PKT_TOSERVER)
+ mpm_ctx = sgh->mpm_proto_tcp_ctx_ts;
+ else
+ mpm_ctx = sgh->mpm_proto_tcp_ctx_tc;
} else if (p->proto == IPPROTO_UDP) {
- mpm_ctx = sgh->mpm_proto_udp_ctx;
+ if (p->flowflags & FLOW_PKT_TOSERVER)
+ mpm_ctx = sgh->mpm_proto_udp_ctx_ts;
+ else
+ mpm_ctx = sgh->mpm_proto_udp_ctx_tc;
} else {
mpm_ctx = sgh->mpm_proto_other_ctx;
}
MpmInitCtx(sh->mpm_hscd_ctx_ts, de_ctx->mpm_matcher, -1);
MpmInitCtx(sh->mpm_hscd_ctx_tc, de_ctx->mpm_matcher, -1);
#else
- MpmInitCtx(sh->mpm_hscd_ctx_ts, de_ctx->mpm_matcher, de_ctx->cuda_rc_mod_handle, 0);
- MpmInitCtx(sh->mpm_hscd_ctx_tc, de_ctx->mpm_matcher, de_ctx->cuda_rc_mod_handle, 1);
+ MpmInitCtx(sh->mpm_hscd_ctx_ts, de_ctx->mpm_matcher, de_ctx->cuda_rc_mod_handle);
+ MpmInitCtx(sh->mpm_hscd_ctx_tc, de_ctx->mpm_matcher, de_ctx->cuda_rc_mod_handle);
#endif
}
static inline uint32_t B2gCudaInitHash(B2gCudaPattern *p)
{
- uint32_t hash = p->len * p->cs[0];
+ uint32_t hash = p->len * p->original_pat[0];
if (p->len > 1)
- hash += p->cs[1];
+ hash += p->original_pat[1];
return (hash % INIT_HASH_SIZE);
}
}
static inline B2gCudaPattern *B2gCudaInitHashLookup(B2gCudaCtx *ctx, uint8_t *pat,
- uint16_t patlen, char flags)
+ uint16_t patlen, char flags,
+ uint32_t pid)
{
uint32_t hash = B2gCudaInitHashRaw(pat, patlen);
B2gCudaPattern *t = ctx->init_hash[hash];
for ( ; t != NULL; t = t->next) {
- if (B2gCudaCmpPattern(t, pat, patlen, flags) == 1)
+ //if (B2gCudaCmpPattern(t, pat, patlen, flags) == 1)
+ if (t->flags == flags && t->id == pid)
return t;
}
return 0;
/* get a memory piece */
- B2gCudaPattern *p = B2gCudaInitHashLookup(ctx, pat, patlen, flags);
+ B2gCudaPattern *p = B2gCudaInitHashLookup(ctx, pat, patlen, flags, pid);
if (p == NULL) {
SCLogDebug("allocing new pattern");
p->flags = flags;
p->id = pid;
+ p->original_pat = SCMalloc(patlen);
+ if (p->original_pat == NULL)
+ goto error;
+ mpm_ctx->memory_cnt++;
+ mpm_ctx->memory_size += patlen;
+ memcpy(p->original_pat, pat, patlen);
+
/* setup the case insensitive part of the pattern */
p->ci = SCMalloc(patlen);
if (p->ci == NULL)
printf("Max search words reached\n");
exit(1);
}
+
mpm_ctx->pattern_cnt++;
if (mpm_ctx->maxlen < patlen) mpm_ctx->maxlen = patlen;
{
B2gCudaCtx *ctx = (B2gCudaCtx *)mpm_ctx->ctx;
+ if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) {
+ SCLogDebug("no patterns supplied to this mpm_ctx");
+ return 0;
+ }
+
/* alloc the pattern array */
ctx->parray = (B2gCudaPattern **)SCMalloc(mpm_ctx->pattern_cnt *
sizeof(B2gCudaPattern *));
void B2gCudaInitCtx(MpmCtx *mpm_ctx, int module_handle)
{
- SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx);
+ if (mpm_ctx->ctx != NULL)
+ return;
- BUG_ON(mpm_ctx->ctx != NULL);
+ SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx);
mpm_ctx->ctx = SCMalloc(sizeof(B2gCudaCtx));
if (mpm_ctx->ctx == NULL)
uint8_t *ci;
struct B2gCudaPattern_ *next;
uint32_t id;
+ uint8_t *original_pat;
} B2gCudaPattern;
typedef struct B2gCudaHashItem_ {
TAILQ_FOREACH(seq_node, &cuda_node->head, next) {
if (strcasecmp(seq_node->val, "mpm") == 0) {
packet_buffer_limit = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "packet_buffer_limit");
+ (seq_node->head.tqh_first, "packet-buffer-limit");
packet_size_limit = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "packet_size_limit");
+ (seq_node->head.tqh_first, "packet-size-limit");
packet_buffers = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "packet_buffers");
+ (seq_node->head.tqh_first, "packet-buffers");
batching_timeout = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "batching_timeout");
+ (seq_node->head.tqh_first, "batching-timeout");
page_locked = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "page_locked");
+ (seq_node->head.tqh_first, "page-locked");
device_id = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "device_id");
+ (seq_node->head.tqh_first, "device-id");
cuda_streams = ConfNodeLookupChildValue
- (seq_node->head.tqh_first, "cuda_streams");
+ (seq_node->head.tqh_first, "cuda-streams");
/* packet_buffer_size */
if (packet_buffer_limit == NULL || strcasecmp(packet_buffer_limit, "") == 0) {