score_db: support hash prefilter

This commit is contained in:
zhuzhenjun
2023-10-23 09:54:02 +08:00
parent c0cfa2e61d
commit 7a5b2e9f07
7 changed files with 302 additions and 171 deletions

View File

@@ -43,7 +43,9 @@ static struct osfp_result *osfp_result_build(struct osfp_os_class_score *os_clas
}
}
if (likely_score < OSFP_LOWEST_SCORE_LIMIT) {
if (likely_score == OSFP_PERCENTILE) {
;
} else if (likely_score < OSFP_LOWEST_SCORE_LIMIT) {
likely_os_class = OSFP_OS_CLASS_OTHERS;
} else {
for (i = 0; i < OSFP_OS_CLASS_MAX; i++) {
@@ -183,11 +185,17 @@ struct osfp_result *osfp_ipv4_identify(struct osfp_db *db, struct iphdr* l3_hdr,
}
osfp_profile_get_cycle(c1);
ret = osfp_score_db_score(db->score_db, 0, &fp, &os_class_score);
ret = osfp_score_db_prefilter(db->score_db, &fp, &os_class_score);
osfp_profile_get_cycle(c2);
osfp_profile_counter_update(&osfp_profile_score, c2 - c1);
if (ret != 0) {
goto exit;
osfp_profile_counter_update(&osfp_profile_prefilter, c2 - c1);
if (ret <= 0) {
osfp_profile_get_cycle(c1);
ret = osfp_score_db_score(db->score_db, 0, &fp, &os_class_score);
osfp_profile_get_cycle(c2);
osfp_profile_counter_update(&osfp_profile_score, c2 - c1);
if (ret != 0) {
goto exit;
}
}
osfp_profile_get_cycle(c1);
@@ -250,9 +258,12 @@ struct osfp_result *osfp_json_identify(struct osfp_db *db, const char *json_str)
goto exit;
}
ret = osfp_score_db_score(db->score_db, 0, &fp, &os_class_score);
if (ret != 0) {
goto exit;
ret = osfp_score_db_prefilter(db->score_db, &fp, &os_class_score);
if (ret <= 0) {
ret = osfp_score_db_score(db->score_db, 0, &fp, &os_class_score);
if (ret != 0) {
goto exit;
}
}
result = osfp_result_build(&os_class_score);