MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pfsync_request_update

Function pfsync_request_update

freebsd/netpfil/pf/if_pfsync.c:1932–1971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1930}
1931
1932static void
1933pfsync_request_update(u_int32_t creatorid, u_int64_t id)
1934{
1935 struct pfsync_softc *sc = V_pfsyncif;
1936 struct pfsync_bucket *b = &sc->sc_buckets[0];
1937 struct pfsync_upd_req_item *item;
1938 size_t nlen = sizeof(struct pfsync_upd_req);
1939
1940 PFSYNC_BUCKET_LOCK_ASSERT(b);
1941
1942 /*
1943 * This code does a bit to prevent multiple update requests for the
1944 * same state being generated. It searches current subheader queue,
1945 * but it doesn't lookup into queue of already packed datagrams.
1946 */
1947 TAILQ_FOREACH(item, &b->b_upd_req_list, ur_entry)
1948 if (item->ur_msg.id == id &&
1949 item->ur_msg.creatorid == creatorid)
1950 return;
1951
1952 item = malloc(sizeof(*item), M_PFSYNC, M_NOWAIT);
1953 if (item == NULL)
1954 return; /* XXX stats */
1955
1956 item->ur_msg.id = id;
1957 item->ur_msg.creatorid = creatorid;
1958
1959 if (TAILQ_EMPTY(&b->b_upd_req_list))
1960 nlen += sizeof(struct pfsync_subheader);
1961
1962 if (b->b_len + nlen > sc->sc_ifp->if_mtu) {
1963 pfsync_sendout(1, 0);
1964
1965 nlen = sizeof(struct pfsync_subheader) +
1966 sizeof(struct pfsync_upd_req);
1967 }
1968
1969 TAILQ_INSERT_TAIL(&b->b_upd_req_list, item, ur_entry);
1970 b->b_len += nlen;
1971}
1972
1973static bool
1974pfsync_update_state_req(struct pf_state *st)

Callers 3

pfsync_in_upd_cFunction · 0.85
pfsyncioctlFunction · 0.85
pfsync_bulk_failFunction · 0.85

Calls 2

mallocFunction · 0.85
pfsync_sendoutFunction · 0.85

Tested by

no test coverage detected