--- fwsync/driver/fwsync_workers.c 2022/08/13 18:16:39 1.11 +++ fwsync/driver/fwsync_workers.c 2022/08/18 12:34:00 1.15 @@ -272,3 +272,37 @@ fwsync_state_sync(const void *arg, const void *extdata free(pkt, M_FWSYNC); return 0; } + +int +fwsync_alias_sync(const void *arg, const void *extdata) +{ + struct fws_sndpkt *pkt; + const struct cfg_nat *t = arg; + + DTRACE(); + + mtx_lock(&fws_mtx_n); + pkt = TAILQ_FIRST(&fwsync_natpkt); + if (pkt) + TAILQ_REMOVE(&fwsync_natpkt, pkt, sp_next); + mtx_unlock(&fws_mtx_n); + + if (!pkt) /* update queue is empty */ + return 0; + + if (!(fws_cfg.cfg.on & CFG_SYNC_EDGE)) { + free(pkt, M_FWSYNC); + return EAGAIN; + } + + printf("%s: pkt=%p t=%p\n", __func__, pkt, t->if_name); + + LIBALIAS_LOCK(t->lib); + AddLink(t->lib, pkt->sp_proto.fws_saddr, pkt->sp_proto.fws_daddr, pkt->sp_proto.fws_aaddr, + pkt->sp_proto.fws_sport, pkt->sp_proto.fws_dport, pkt->sp_proto.fws_aport, + pkt->sp_proto.fws_linktype | LINK_SYNC_MASK); + LIBALIAS_UNLOCK(t->lib); + + free(pkt, M_FWSYNC); + return 0; +}