| 1173 | } |
| 1174 | |
| 1175 | static int |
| 1176 | pfsync_in_bus(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count) |
| 1177 | { |
| 1178 | struct pfsync_softc *sc = V_pfsyncif; |
| 1179 | struct pfsync_bus *bus; |
| 1180 | struct mbuf *mp; |
| 1181 | int len = count * sizeof(*bus); |
| 1182 | int offp; |
| 1183 | |
| 1184 | PFSYNC_BLOCK(sc); |
| 1185 | |
| 1186 | /* If we're not waiting for a bulk update, who cares. */ |
| 1187 | if (sc->sc_ureq_sent == 0) { |
| 1188 | PFSYNC_BUNLOCK(sc); |
| 1189 | return (len); |
| 1190 | } |
| 1191 | |
| 1192 | mp = m_pulldown(m, offset, len, &offp); |
| 1193 | if (mp == NULL) { |
| 1194 | PFSYNC_BUNLOCK(sc); |
| 1195 | V_pfsyncstats.pfsyncs_badlen++; |
| 1196 | return (-1); |
| 1197 | } |
| 1198 | bus = (struct pfsync_bus *)(mp->m_data + offp); |
| 1199 | |
| 1200 | switch (bus->status) { |
| 1201 | case PFSYNC_BUS_START: |
| 1202 | callout_reset(&sc->sc_bulkfail_tmo, 4 * hz + |
| 1203 | V_pf_limits[PF_LIMIT_STATES].limit / |
| 1204 | ((sc->sc_ifp->if_mtu - PFSYNC_MINPKT) / |
| 1205 | sizeof(struct pfsync_state)), |
| 1206 | pfsync_bulk_fail, sc); |
| 1207 | if (V_pf_status.debug >= PF_DEBUG_MISC) |
| 1208 | printf("pfsync: received bulk update start\n"); |
| 1209 | break; |
| 1210 | |
| 1211 | case PFSYNC_BUS_END: |
| 1212 | if (time_uptime - ntohl(bus->endtime) >= |
| 1213 | sc->sc_ureq_sent) { |
| 1214 | /* that's it, we're happy */ |
| 1215 | sc->sc_ureq_sent = 0; |
| 1216 | sc->sc_bulk_tries = 0; |
| 1217 | callout_stop(&sc->sc_bulkfail_tmo); |
| 1218 | if (!(sc->sc_flags & PFSYNCF_OK) && carp_demote_adj_p) |
| 1219 | (*carp_demote_adj_p)(-V_pfsync_carp_adj, |
| 1220 | "pfsync bulk done"); |
| 1221 | sc->sc_flags |= PFSYNCF_OK; |
| 1222 | if (V_pf_status.debug >= PF_DEBUG_MISC) |
| 1223 | printf("pfsync: received valid " |
| 1224 | "bulk update end\n"); |
| 1225 | } else { |
| 1226 | if (V_pf_status.debug >= PF_DEBUG_MISC) |
| 1227 | printf("pfsync: received invalid " |
| 1228 | "bulk update end: bad timestamp\n"); |
| 1229 | } |
| 1230 | break; |
| 1231 | } |
| 1232 | PFSYNC_BUNLOCK(sc); |
nothing calls this directly
no test coverage detected