|
|
| version 1.1, 2022/06/22 13:01:55 | version 1.3, 2022/07/11 12:58:58 |
|---|---|
| Line 24 struct cfg_sync fws_cfg; | Line 24 struct cfg_sync fws_cfg; |
| //static struct sysctl_oid *fws_sysctl_oid, *fws_sysctl_dir; | //static struct sysctl_oid *fws_sysctl_oid, *fws_sysctl_dir; |
| struct task fws_sndpkt_task; | struct task fws_sndpkt_task; |
| struct taskqueue *fws_tq; | |
| struct mtx fws_mtx_c, fws_mtx_e; | |
| fwsync_sndpkt_t fwsync_sndpkt; | |
| SYSCTL_NODE(_net_inet_ip, IFT_FWSYNC, fwsync, CTLFLAG_RW, 0, "IPFW Sync - Sync firewall states"); | SYSCTL_NODE(_net_inet_ip, IFT_FWSYNC, fwsync, CTLFLAG_RW, 0, "IPFW Sync - Sync firewall states"); |
| SYSCTL_INT(_net_inet_ip_fwsync, OID_AUTO, debug, CTLFLAG_RW, &fwsync_debug, 0, "Debug driver"); | SYSCTL_INT(_net_inet_ip_fwsync, OID_AUTO, debug, CTLFLAG_RW, &fwsync_debug, 0, "Debug driver"); |
| Line 31 SYSCTL_INT(_net_inet_ip_fwsync, OID_AUTO, debug, CTLFL | Line 34 SYSCTL_INT(_net_inet_ip_fwsync, OID_AUTO, debug, CTLFL |
| static int | static int |
| fws_fini(void *arg) | fws_fini(void *arg) |
| { | { |
| struct fws_sndpkt *p; | |
| DTRACE(); | DTRACE(); |
| if (!fwsync_hooked) | if (!fwsync_hooked) |
| Line 44 fws_fini(void *arg) | Line 49 fws_fini(void *arg) |
| IPFW_DEL_SOPT_HANDLER(1, soc); | IPFW_DEL_SOPT_HANDLER(1, soc); |
| if (fws_tq) | |
| taskqueue_free(fws_tq); | |
| mtx_lock(&fws_mtx_c); | |
| while (!TAILQ_EMPTY(&fwsync_sndpkt)) { | |
| p = TAILQ_FIRST(&fwsync_sndpkt); | |
| TAILQ_REMOVE(&fwsync_sndpkt, p, sp_next); | |
| free(p, M_FWSYNC); | |
| } | |
| mtx_unlock(&fws_mtx_c); | |
| mtx_destroy(&fws_mtx_c); | |
| mtx_destroy(&fws_mtx_e); | |
| fwsync_hooked = 0; | fwsync_hooked = 0; |
| /* sysctl context */ | /* sysctl context */ |
| Line 72 fws_init(void *arg) | Line 91 fws_init(void *arg) |
| return 0; | return 0; |
| memset(&fws_cfg, 0, sizeof fws_cfg); | memset(&fws_cfg, 0, sizeof fws_cfg); |
| memset(&fws_ctx, 0, sizeof fws_ctx); | |
| TAILQ_INIT(&fwsync_sndpkt); | |
| /* mutexes */ | |
| mtx_init(&fws_mtx_e, "fwsync mtx edge", NULL, MTX_DEF); | |
| mtx_init(&fws_mtx_c, "fwsync mtx collector", NULL, MTX_DEF); | |
| /* taskqueue */ | |
| TASK_INIT(&fws_sndpkt_task, 0, fwsync_sndpkt_handler, &fwsync_sndpkt); | |
| fws_tq = taskqueue_create("fwsync_tq", M_NOWAIT, taskqueue_thread_enqueue, &fws_tq); | |
| if (!fws_tq) { | |
| printf("Failed to allocate fwsync task queue\n"); | |
| mtx_destroy(&fws_mtx_c); | |
| mtx_destroy(&fws_mtx_e); | |
| return ENOMEM; | |
| } else | |
| taskqueue_start_threads(&fws_tq, 1, PI_NET, "fwsync tq"); | |
| /* sysctl context */ | /* sysctl context */ |
| sysctl_ctx_init(&fwsync_sysctl_ctx); | sysctl_ctx_init(&fwsync_sysctl_ctx); |
| IPFW_ADD_SOPT_HANDLER(1, soc); | IPFW_ADD_SOPT_HANDLER(1, soc); |
| memset(&fws_ctx, 0, sizeof fws_ctx); | |
| fwsync_hooked = 1; | fwsync_hooked = 1; |
| uprintf("Loaded ELWIX %s driver version %d ...\n", DRV_NAME, DRV_VERSION); | uprintf("Loaded ELWIX %s driver version %d ...\n", DRV_NAME, DRV_VERSION); |