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

Function reset_d

freebsd/net/bpf.c:1294–1320  ·  view source on GitHub ↗

* Reset a descriptor by flushing its packet buffer and clearing the receive * and drop counts. This is doable for kernel-only buffers, but with * zero-copy buffers, we can't write to (or rotate) buffers that are * currently owned by userspace. It would be nice if we could encapsulate * this logic in the buffer code rather than here. */

Source from the content-addressed store, hash-verified

1292 * this logic in the buffer code rather than here.
1293 */
1294static void
1295reset_d(struct bpf_d *d)
1296{
1297
1298 BPFD_LOCK_ASSERT(d);
1299
1300 while (d->bd_hbuf_in_use)
1301 mtx_sleep(&d->bd_hbuf_in_use, &d->bd_lock, PRINET,
1302 "bd_hbuf", 0);
1303 if ((d->bd_hbuf != NULL) &&
1304 (d->bd_bufmode != BPF_BUFMODE_ZBUF || bpf_canfreebuf(d))) {
1305 /* Free the hold buffer. */
1306 d->bd_fbuf = d->bd_hbuf;
1307 d->bd_hbuf = NULL;
1308 d->bd_hlen = 0;
1309 bpf_buf_reclaimed(d);
1310 }
1311 if (bpf_canwritebuf(d))
1312 d->bd_slen = 0;
1313 counter_u64_zero(d->bd_rcount);
1314 counter_u64_zero(d->bd_dcount);
1315 counter_u64_zero(d->bd_fcount);
1316 counter_u64_zero(d->bd_wcount);
1317 counter_u64_zero(d->bd_wfcount);
1318 counter_u64_zero(d->bd_wdcount);
1319 counter_u64_zero(d->bd_zcopy);
1320}
1321
1322/*
1323 * FIONREAD Check for read packet available.

Callers 4

bpf_attachdFunction · 0.85
bpfioctlFunction · 0.85
bpf_setfFunction · 0.85
bpf_setifFunction · 0.85

Calls 4

bpf_canfreebufFunction · 0.85
bpf_buf_reclaimedFunction · 0.85
bpf_canwritebufFunction · 0.85
counter_u64_zeroFunction · 0.85

Tested by

no test coverage detected