| 2149 | } |
| 2150 | |
| 2151 | static void |
| 2152 | pfsync_bulk_update(void *arg) |
| 2153 | { |
| 2154 | struct pfsync_softc *sc = arg; |
| 2155 | struct pf_state *s; |
| 2156 | int i, sent = 0; |
| 2157 | |
| 2158 | PFSYNC_BLOCK_ASSERT(sc); |
| 2159 | CURVNET_SET(sc->sc_ifp->if_vnet); |
| 2160 | |
| 2161 | /* |
| 2162 | * Start with last state from previous invocation. |
| 2163 | * It may had gone, in this case start from the |
| 2164 | * hash slot. |
| 2165 | */ |
| 2166 | s = pf_find_state_byid(sc->sc_bulk_stateid, sc->sc_bulk_creatorid); |
| 2167 | |
| 2168 | if (s != NULL) |
| 2169 | i = PF_IDHASH(s); |
| 2170 | else |
| 2171 | i = sc->sc_bulk_hashid; |
| 2172 | |
| 2173 | for (; i <= pf_hashmask; i++) { |
| 2174 | struct pf_idhash *ih = &V_pf_idhash[i]; |
| 2175 | |
| 2176 | if (s != NULL) |
| 2177 | PF_HASHROW_ASSERT(ih); |
| 2178 | else { |
| 2179 | PF_HASHROW_LOCK(ih); |
| 2180 | s = LIST_FIRST(&ih->states); |
| 2181 | } |
| 2182 | |
| 2183 | for (; s; s = LIST_NEXT(s, entry)) { |
| 2184 | if (s->sync_state == PFSYNC_S_NONE && |
| 2185 | s->timeout < PFTM_MAX && |
| 2186 | s->pfsync_time <= sc->sc_ureq_received) { |
| 2187 | if (pfsync_update_state_req(s)) { |
| 2188 | /* We've filled a packet. */ |
| 2189 | sc->sc_bulk_hashid = i; |
| 2190 | sc->sc_bulk_stateid = s->id; |
| 2191 | sc->sc_bulk_creatorid = s->creatorid; |
| 2192 | PF_HASHROW_UNLOCK(ih); |
| 2193 | callout_reset(&sc->sc_bulk_tmo, 1, |
| 2194 | pfsync_bulk_update, sc); |
| 2195 | goto full; |
| 2196 | } |
| 2197 | sent++; |
| 2198 | } |
| 2199 | } |
| 2200 | PF_HASHROW_UNLOCK(ih); |
| 2201 | } |
| 2202 | |
| 2203 | /* We're done. */ |
| 2204 | pfsync_bulk_status(PFSYNC_BUS_END); |
| 2205 | full: |
| 2206 | CURVNET_RESTORE(); |
| 2207 | } |
| 2208 |
nothing calls this directly
no test coverage detected