Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/if_pfsync.c
Show First 20 Lines • Show All 1,541 Lines • ▼ Show 20 Lines | pfsync_sendout(int schedswi) | ||||
ip_fillid(ip); | ip_fillid(ip); | ||||
/* build the pfsync header */ | /* build the pfsync header */ | ||||
ph = (struct pfsync_header *)(m->m_data + offset); | ph = (struct pfsync_header *)(m->m_data + offset); | ||||
bzero(ph, sizeof(*ph)); | bzero(ph, sizeof(*ph)); | ||||
offset += sizeof(*ph); | offset += sizeof(*ph); | ||||
ph->version = PFSYNC_VERSION; | ph->version = PFSYNC_VERSION; | ||||
ph->revision = PFSYNC_REVISION; | |||||
ph->len = htons(sc->sc_len - sizeof(*ip)); | ph->len = htons(sc->sc_len - sizeof(*ip)); | ||||
bcopy(V_pf_status.pf_chksum, ph->pfcksum, PF_MD5_DIGEST_LENGTH); | bcopy(V_pf_status.pf_chksum, ph->pfcksum, PF_MD5_DIGEST_LENGTH); | ||||
/* walk the queues */ | /* walk the queues */ | ||||
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; | ||||
Show All 14 Lines | TAILQ_FOREACH_SAFE(st, &sc->sc_qs[q], sync_list, st_next) { | ||||
st->sync_state = PFSYNC_S_NONE; | st->sync_state = PFSYNC_S_NONE; | ||||
pf_release_state(st); | pf_release_state(st); | ||||
count++; | count++; | ||||
} | } | ||||
TAILQ_INIT(&sc->sc_qs[q]); | TAILQ_INIT(&sc->sc_qs[q]); | ||||
bzero(subh, sizeof(*subh)); | bzero(subh, sizeof(*subh)); | ||||
subh->action = pfsync_qs[q].action; | subh->action = pfsync_qs[q].action; | ||||
subh->size = pfsync_qs[q].len >> 1; | |||||
subh->count = htons(count); | subh->count = htons(count); | ||||
V_pfsyncstats.pfsyncs_oacts[pfsync_qs[q].action] += count; | V_pfsyncstats.pfsyncs_oacts[pfsync_qs[q].action] += count; | ||||
} | } | ||||
if (!TAILQ_EMPTY(&sc->sc_upd_req_list)) { | if (!TAILQ_EMPTY(&sc->sc_upd_req_list)) { | ||||
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; | ||||
while ((ur = TAILQ_FIRST(&sc->sc_upd_req_list)) != NULL) { | while ((ur = TAILQ_FIRST(&sc->sc_upd_req_list)) != NULL) { | ||||
TAILQ_REMOVE(&sc->sc_upd_req_list, ur, ur_entry); | TAILQ_REMOVE(&sc->sc_upd_req_list, ur, ur_entry); | ||||
bcopy(&ur->ur_msg, m->m_data + offset, | bcopy(&ur->ur_msg, m->m_data + offset, | ||||
sizeof(ur->ur_msg)); | sizeof(ur->ur_msg)); | ||||
offset += sizeof(ur->ur_msg); | offset += sizeof(ur->ur_msg); | ||||
free(ur, M_PFSYNC); | free(ur, M_PFSYNC); | ||||
count++; | count++; | ||||
} | } | ||||
bzero(subh, sizeof(*subh)); | bzero(subh, sizeof(*subh)); | ||||
subh->action = PFSYNC_ACT_UPD_REQ; | subh->action = PFSYNC_ACT_UPD_REQ; | ||||
subh->size = sizeof(ur->ur_msg) >> 1; | |||||
subh->count = htons(count); | subh->count = htons(count); | ||||
V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_UPD_REQ] += count; | V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_UPD_REQ] += count; | ||||
} | } | ||||
/* has someone built a custom region for us to add? */ | /* has someone built a custom region for us to add? */ | ||||
if (sc->sc_plus != NULL) { | if (sc->sc_plus != NULL) { | ||||
bcopy(sc->sc_plus, m->m_data + offset, sc->sc_pluslen); | bcopy(sc->sc_plus, m->m_data + offset, sc->sc_pluslen); | ||||
offset += sc->sc_pluslen; | offset += sc->sc_pluslen; | ||||
sc->sc_plus = NULL; | sc->sc_plus = NULL; | ||||
} | } | ||||
subh = (struct pfsync_subheader *)(m->m_data + offset); | subh = (struct pfsync_subheader *)(m->m_data + offset); | ||||
offset += sizeof(*subh); | offset += sizeof(*subh); | ||||
bzero(subh, sizeof(*subh)); | bzero(subh, sizeof(*subh)); | ||||
subh->action = PFSYNC_ACT_EOF; | subh->action = PFSYNC_ACT_EOF; | ||||
subh->size = 0; | |||||
subh->count = htons(1); | subh->count = htons(1); | ||||
V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_EOF]++; | V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_EOF]++; | ||||
/* we're done, let's put it on the wire */ | /* we're done, let's put it on the wire */ | ||||
if (ifp->if_bpf) { | if (ifp->if_bpf) { | ||||
m->m_data += sizeof(*ip); | m->m_data += sizeof(*ip); | ||||
m->m_len = m->m_pkthdr.len = sc->sc_len - sizeof(*ip); | m->m_len = m->m_pkthdr.len = sc->sc_len - sizeof(*ip); | ||||
BPF_MTAP(ifp, m); | BPF_MTAP(ifp, m); | ||||
▲ Show 20 Lines • Show All 806 Lines • Show Last 20 Lines |