* 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. */
| 1292 | * this logic in the buffer code rather than here. |
| 1293 | */ |
| 1294 | static void |
| 1295 | reset_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. |
no test coverage detected