MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pf_setup_pfsync_matching

Function pf_setup_pfsync_matching

freebsd/netpfil/pf/pf_ioctl.c:1087–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1085}
1086
1087static int
1088pf_setup_pfsync_matching(struct pf_kruleset *rs)
1089{
1090 MD5_CTX ctx;
1091 struct pf_krule *rule;
1092 int rs_cnt;
1093 u_int8_t digest[PF_MD5_DIGEST_LENGTH];
1094
1095 MD5Init(&ctx);
1096 for (rs_cnt = 0; rs_cnt < PF_RULESET_MAX; rs_cnt++) {
1097 /* XXX PF_RULESET_SCRUB as well? */
1098 if (rs_cnt == PF_RULESET_SCRUB)
1099 continue;
1100
1101 if (rs->rules[rs_cnt].inactive.ptr_array)
1102 free(rs->rules[rs_cnt].inactive.ptr_array, M_TEMP);
1103 rs->rules[rs_cnt].inactive.ptr_array = NULL;
1104
1105 if (rs->rules[rs_cnt].inactive.rcount) {
1106 rs->rules[rs_cnt].inactive.ptr_array =
1107 malloc(sizeof(caddr_t) *
1108 rs->rules[rs_cnt].inactive.rcount,
1109 M_TEMP, M_NOWAIT);
1110
1111 if (!rs->rules[rs_cnt].inactive.ptr_array)
1112 return (ENOMEM);
1113 }
1114
1115 TAILQ_FOREACH(rule, rs->rules[rs_cnt].inactive.ptr,
1116 entries) {
1117 pf_hash_rule(&ctx, rule);
1118 (rs->rules[rs_cnt].inactive.ptr_array)[rule->nr] = rule;
1119 }
1120 }
1121
1122 MD5Final(digest, &ctx);
1123 memcpy(V_pf_status.pf_chksum, digest, sizeof(V_pf_status.pf_chksum));
1124 return (0);
1125}
1126
1127static int
1128pf_addr_setup(struct pf_kruleset *ruleset, struct pf_addr_wrap *addr,

Callers 1

pf_commit_rulesFunction · 0.85

Calls 6

MD5InitFunction · 0.85
mallocFunction · 0.85
pf_hash_ruleFunction · 0.85
MD5FinalFunction · 0.85
freeFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected