]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
bpf: don't check caplen == datalen
authorRoy Marples <roy@marples.name>
Tue, 4 Apr 2017 08:45:27 +0000 (09:45 +0100)
committerRoy Marples <roy@marples.name>
Tue, 4 Apr 2017 08:45:27 +0000 (09:45 +0100)
Some drivers return FCS at the end of the payload to BPF.
AFAIK, we have no way of knowing this in userland.
We can guess that FCS is there because the BPF filter trims the
DHCP payload to the Frame and IP lengths, but equally the data
could be anything.

As such removing the check that caplen == datalen makes sense.

src/bpf.c

index 46c5db388b1837e86fc3a1d2b18248d9e23eda49..d7cb3616569170b65009e161cc0d964136ff1670 100644 (file)
--- a/src/bpf.c
+++ b/src/bpf.c
@@ -222,8 +222,6 @@ bpf_read(struct interface *ifp, int fd, void *data, size_t len, int *flags)
                bytes = -1;
                memcpy(&packet, state->buffer + state->buffer_pos,
                    sizeof(packet));
-               if (packet.bh_caplen != packet.bh_datalen)
-                       goto next; /* Incomplete packet, drop. */
                if (state->buffer_pos + packet.bh_caplen + packet.bh_hdrlen >
                    state->buffer_len)
                        goto next; /* Packet beyond buffer, drop. */