diff options
| author | zhuzhenjun <[email protected]> | 2023-10-23 09:54:02 +0800 |
|---|---|---|
| committer | zhuzhenjun <[email protected]> | 2023-10-23 09:54:02 +0800 |
| commit | 7a5b2e9f072649a13b7b800420a2bb23e34cbbfc (patch) | |
| tree | 2f161fa3e8a2e59f6609fc92e3807d5fdda18d3c /src/osfp.c | |
| parent | c0cfa2e61df7b74e8f033bf484f3beda432baa01 (diff) | |
score_db: support hash prefilter
Diffstat (limited to 'src/osfp.c')
| -rw-r--r-- | src/osfp.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -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); |
