--- fwsync/driver/fwsync_workers.c 2022/08/10 00:03:50 1.9 +++ fwsync/driver/fwsync_workers.c 2022/08/11 21:59:05 1.10 @@ -5,26 +5,6 @@ #include "fwsync.h" -static int -fwsync_add_state_4(struct ipfw_flow_id *fid, u_int ruleid, u_short rulenum, - u_short kidx, u_char cmdtype) -{ - struct ip_fw *rule = NULL; - - DTRACE(); - - return ipfw_dyn_install_sync_state(fid, rule, ruleid, rulenum, kidx, cmdtype); -} - -static int -fwsync_add_state_6(struct ipfw_flow_id *fid, u_int ruleid, u_short rulenum, - u_short kidx, u_char cmdtype) -{ - DTRACE(); - - return 0; -} - int fwsync_add_state(const struct fws_proto *pkt) { @@ -228,6 +208,9 @@ fwsync_state_sync(const void *arg, const void *extdata { struct fws_sndpkt *pkt; struct ipfw_flow_id fid; + struct ip_fw *rule; + int f_pos; + struct ip_fw_chain *chain = &V_layer3_chain; DTRACE(); @@ -266,12 +249,11 @@ fwsync_state_sync(const void *arg, const void *extdata return EINVAL; } - if (pkt->sp_proto.fws_addrtype == 4) - fwsync_add_state_4(&fid, pkt->sp_proto.fws_ruleid, pkt->sp_proto.fws_rulenum, - pkt->sp_proto.fws_kidx, pkt->sp_proto.fws_cmdtype); - else if (pkt->sp_proto.fws_addrtype == 6) - fwsync_add_state_6(&fid, pkt->sp_proto.fws_ruleid, pkt->sp_proto.fws_rulenum, - pkt->sp_proto.fws_kidx, pkt->sp_proto.fws_cmdtype); + f_pos = ipfw_find_rule(chain, pkt->sp_proto.fws_ruleid, pkt->sp_proto.fws_rulenum); + rule = chain->map[f_pos]; + ipfw_dyn_install_sync_state(&fid, rule, + pkt->sp_proto.fws_ruleid, pkt->sp_proto.fws_rulenum, + pkt->sp_proto.fws_kidx, pkt->sp_proto.fws_cmdtype); free(pkt, M_FWSYNC); return 0;