--- fwsync/driver/fwsync.c 2022/08/04 00:24:39 1.7 +++ fwsync/driver/fwsync.c 2022/08/10 00:03:49 1.8 @@ -33,6 +33,7 @@ fwsync_edge_proc(void *arg) if (m_length(m, NULL) != sizeof(struct fws_proto)) { printf("FWSync packet length=%d isn't match expected %lu\n", m_length(m, NULL), sizeof(struct fws_proto)); + m_freem(m); return; } @@ -47,8 +48,10 @@ fwsync_edge_proc(void *arg) break; default: printf("FWSync packet was discarded due to wrong version\n"); - return; + break; } + + m_freem(m); } } @@ -168,6 +171,7 @@ fwsync_destroy(struct ip_fw_chain *ch, ip_fw3_opheader if (fws_ctx.config & CTX_EDGE_ONLINE) { callout_drain(&fws_co); + ipfw_unregister_state_sync(); soshutdown(fws_ctx.sockz[CFG_SYNC_ADDR_EDGE], SHUT_RD); soclose(fws_ctx.sockz[CFG_SYNC_ADDR_EDGE]); } @@ -178,6 +182,8 @@ fwsync_destroy(struct ip_fw_chain *ch, ip_fw3_opheader ipfw_unregister_alias_hook(); } + taskqueue_drain(fws_tq, &fws_sndpkt_task); + fws_cfg.cfg.on &= ~CFG_SYNC_COLLECTOR; fws_cfg.cfg.collector = 0; fws_cfg.cfg.addrs = 0; @@ -264,9 +270,13 @@ fwsync_start(struct ip_fw_chain *ch, ip_fw3_opheader * if ((*n & CFG_SYNC_EDGE) && (fws_ctx.config & CTX_EDGE_READY)) { fws_cfg.cfg.on |= CFG_SYNC_EDGE; - fws_ctx.config |= CTX_EDGE_ONLINE; callout_reset(&fws_co, hz, fwsync_edge_proc, NULL); + + if (!(fws_ctx.config & CTX_EDGE_ONLINE)) + ipfw_register_state_sync(fwsync_state_sync); + + fws_ctx.config |= CTX_EDGE_ONLINE; } if ((*n & CFG_SYNC_COLLECTOR) && (fws_ctx.config & CTX_COLLECTOR_1_READY)) { @@ -321,6 +331,8 @@ fwsync_stop(struct ip_fw_chain *ch, ip_fw3_opheader *o fws_ctx.config &= ~CTX_EDGE_ONLINE; callout_drain(&fws_co); + + ipfw_unregister_state_sync(); } if ((*n & CFG_SYNC_COLLECTOR) && (fws_ctx.config & CTX_COLLECTOR_2_ONLINE)) @@ -334,6 +346,8 @@ fwsync_stop(struct ip_fw_chain *ch, ip_fw3_opheader *o ipfw_unregister_state_hook(); ipfw_unregister_alias_hook(); + + taskqueue_drain(fws_tq, &fws_sndpkt_task); } return 0;