Skip to content

Commit

Permalink
sockd: Don't require that dhcp4 packets originate from port 67.
Browse files Browse the repository at this point in the history
The RFC requires that clients receive on port UDP 68 and send
to servers at UDP 67, but it doesn't make further mandates.

So, although most servers and clients originate packets from 67 or 68,
it isn't required and thus the check here is too strict.
  • Loading branch information
niklata committed Aug 2, 2023
1 parent 6cd4876 commit c1a2f78
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sockd.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@ static int create_raw_listen_socket(bool *using_bpf)
BPF_STMT(BPF_RET + BPF_K, 0),
// Packet is UDP. Advance X past the IP header.
BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 0),
// Verify that the UDP client and server ports match that of the
// IANA-assigned DHCP ports.
BPF_STMT(BPF_LD + BPF_W + BPF_IND, 0),
// Verify that the UDP client port matches that of the
// IANA-assigned DHCP port; RFCs do not require the origin
// port to correspond to the DHCP_SERVER_PORT.
BPF_STMT(BPF_LD + BPF_H + BPF_IND, 2),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K,
(DHCP_SERVER_PORT << 16) + DHCP_CLIENT_PORT, 1, 0),
DHCP_CLIENT_PORT, 1, 0),
BPF_STMT(BPF_RET + BPF_K, 0),
// Get the UDP length field and store it in X.
BPF_STMT(BPF_LD + BPF_H + BPF_IND, 4),
Expand Down

0 comments on commit c1a2f78

Please sign in to comment.