diff options
author | Guy Harris <gharris@sonic.net> | 2022-04-13 16:16:08 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-04-13 16:16:08 -0700 |
commit | 17a48ca162de1a6d40a3b767eb318c2899666eb4 (patch) | |
tree | 16b52d679c344d107f7a0aae37ab089a87468d8e /pcap-linux.c | |
parent | 0035db9167474bfdfc4164e3aff3846b356e6d16 (diff) |
linux: reserve space for DLT_LINUX_SLL2 on all cooked captures.
Don't just do it if we're using DLT_LINUX_SLL2 up front; that can be
changed by the software using libpcap at any point.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r-- | pcap-linux.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index 6b09c798..8dbf89bc 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -2891,22 +2891,22 @@ create_ring(pcap_t *handle, int *status) tp_reserve = VLAN_TAG_LEN; /* - * If we're using DLT_LINUX_SLL2, reserve space for a - * DLT_LINUX_SLL2 header. + * If we're capturing in cooked mode, reserve space for + * a DLT_LINUX_SLL2 header; we don't know yet whether + * we'll be using DLT_LINUX_SLL or DLT_LINUX_SLL2, as + * that can be changed on an open device, so we reserve + * space for the larger of the two. * * XXX - we assume that the kernel is still adding - * 16 bytes of extra space; that happens to - * correspond to SLL_HDR_LEN (whether intentionally - * or not - the kernel code has a raw "16" in - * the expression), so we subtract SLL_HDR_LEN - * from SLL2_HDR_LEN to get the additional space - * needed. That also means we don't bother reserving - * any additional space if we're using DLT_LINUX_SLL. + * 16 bytes of extra space, so we subtract 16 from + * SLL2_HDR_LEN to get the additional space needed. + * (Are they doing that for DLT_LINUX_SLL, the link- + * layer header for which is 16 bytes?) * - * XXX - should we use TPACKET_ALIGN(SLL2_HDR_LEN - SLL_HDR_LEN)? + * XXX - should we use TPACKET_ALIGN(SLL2_HDR_LEN - 16)? */ - if (handle->linktype == DLT_LINUX_SLL2) - tp_reserve += SLL2_HDR_LEN - SLL_HDR_LEN; + if (handlep->cooked) + tp_reserve += SLL2_HDR_LEN - 16; /* * Try to request that amount of reserve space. |