Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netpfil/pf/if_pfsync.c
Show First 20 Lines • Show All 1,503 Lines • ▼ Show 20 Lines | |||||
pfsync_sendout(int schedswi) | pfsync_sendout(int schedswi) | ||||
{ | { | ||||
struct pfsync_softc *sc = V_pfsyncif; | struct pfsync_softc *sc = V_pfsyncif; | ||||
struct ifnet *ifp = sc->sc_ifp; | struct ifnet *ifp = sc->sc_ifp; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
struct ip *ip; | struct ip *ip; | ||||
struct pfsync_header *ph; | struct pfsync_header *ph; | ||||
struct pfsync_subheader *subh; | struct pfsync_subheader *subh; | ||||
struct pf_state *st; | struct pf_state *st, *st_next; | ||||
struct pfsync_upd_req_item *ur; | struct pfsync_upd_req_item *ur; | ||||
int offset; | int offset; | ||||
int q, count = 0; | int q, count = 0; | ||||
KASSERT(sc != NULL, ("%s: null sc", __func__)); | KASSERT(sc != NULL, ("%s: null sc", __func__)); | ||||
KASSERT(sc->sc_len > PFSYNC_MINPKT, | KASSERT(sc->sc_len > PFSYNC_MINPKT, | ||||
("%s: sc_len %zu", __func__, sc->sc_len)); | ("%s: sc_len %zu", __func__, sc->sc_len)); | ||||
PFSYNC_LOCK_ASSERT(sc); | PFSYNC_LOCK_ASSERT(sc); | ||||
Show All 33 Lines | pfsync_sendout(int schedswi) | ||||
for (q = 0; q < PFSYNC_S_COUNT; q++) { | for (q = 0; q < PFSYNC_S_COUNT; q++) { | ||||
if (TAILQ_EMPTY(&sc->sc_qs[q])) | if (TAILQ_EMPTY(&sc->sc_qs[q])) | ||||
continue; | continue; | ||||
subh = (struct pfsync_subheader *)(m->m_data + offset); | subh = (struct pfsync_subheader *)(m->m_data + offset); | ||||
offset += sizeof(*subh); | offset += sizeof(*subh); | ||||
count = 0; | count = 0; | ||||
TAILQ_FOREACH(st, &sc->sc_qs[q], sync_list) { | TAILQ_FOREACH_SAFE(st, &sc->sc_qs[q], sync_list, st_next) { | ||||
KASSERT(st->sync_state == q, | KASSERT(st->sync_state == q, | ||||
("%s: st->sync_state == q", | ("%s: st->sync_state == q", | ||||
__func__)); | __func__)); | ||||
/* | /* | ||||
* XXXGL: some of write methods do unlocked reads | * XXXGL: some of write methods do unlocked reads | ||||
* of state data :( | * of state data :( | ||||
*/ | */ | ||||
pfsync_qs[q].write(st, m->m_data + offset); | pfsync_qs[q].write(st, m->m_data + offset); | ||||
▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | if (st->sync_state != PFSYNC_S_NONE) | ||||
pfsync_q_del(st); | pfsync_q_del(st); | ||||
PFSYNC_UNLOCK(sc); | PFSYNC_UNLOCK(sc); | ||||
return; | return; | ||||
} | } | ||||
if (sc->sc_len == PFSYNC_MINPKT) | if (sc->sc_len == PFSYNC_MINPKT) | ||||
callout_reset(&sc->sc_tmo, 1 * hz, pfsync_timeout, V_pfsyncif); | callout_reset(&sc->sc_tmo, 1 * hz, pfsync_timeout, V_pfsyncif); | ||||
pf_ref_state(st); | |||||
switch (st->sync_state) { | switch (st->sync_state) { | ||||
case PFSYNC_S_INS: | case PFSYNC_S_INS: | ||||
/* We never got to tell the world so just forget about it. */ | /* We never got to tell the world so just forget about it. */ | ||||
pfsync_q_del(st); | pfsync_q_del(st); | ||||
break; | break; | ||||
case PFSYNC_S_UPD_C: | case PFSYNC_S_UPD_C: | ||||
case PFSYNC_S_UPD: | case PFSYNC_S_UPD: | ||||
case PFSYNC_S_IACK: | case PFSYNC_S_IACK: | ||||
pfsync_q_del(st); | pfsync_q_del(st); | ||||
/* FALLTHROUGH to putting it on the del list */ | /* FALLTHROUGH to putting it on the del list */ | ||||
case PFSYNC_S_NONE: | case PFSYNC_S_NONE: | ||||
pfsync_q_ins(st, PFSYNC_S_DEL); | pfsync_q_ins(st, PFSYNC_S_DEL); | ||||
break; | break; | ||||
default: | default: | ||||
panic("%s: unexpected sync state %d", __func__, st->sync_state); | panic("%s: unexpected sync state %d", __func__, st->sync_state); | ||||
} | } | ||||
pf_release_state(st); | |||||
PFSYNC_UNLOCK(sc); | PFSYNC_UNLOCK(sc); | ||||
} | } | ||||
static void | static void | ||||
pfsync_clear_states(u_int32_t creatorid, const char *ifname) | pfsync_clear_states(u_int32_t creatorid, const char *ifname) | ||||
{ | { | ||||
struct pfsync_softc *sc = V_pfsyncif; | struct pfsync_softc *sc = V_pfsyncif; | ||||
struct { | struct { | ||||
▲ Show 20 Lines • Show All 459 Lines • Show Last 20 Lines |