Skip to content

Commit

Permalink
libsystemd-network: do not split messages in half
Browse files Browse the repository at this point in the history
This makes grepping for the messages unnecessarily painful.
  • Loading branch information
keszybz committed Apr 29, 2022
1 parent 2d14ec9 commit 9a94baa
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/libsystemd-network/dhcp-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,12 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui
hdrlen = packet->ip.ihl * 4;
if (hdrlen < 20)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"ignoring packet: IPv4 IHL (%zu bytes) "
"smaller than minimum (20 bytes)",
"ignoring packet: IPv4 IHL (%zu bytes) smaller than minimum (20 bytes)",
hdrlen);

if (len < hdrlen)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"ignoring packet: packet (%zu bytes) "
"smaller than expected (%zu) by IP header",
"ignoring packet: packet (%zu bytes) smaller than expected (%zu) by IP header",
len, hdrlen);

/* UDP */
Expand All @@ -162,14 +160,12 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui

if (len < hdrlen + be16toh(packet->udp.len))
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"ignoring packet: packet (%zu bytes) "
"smaller than expected (%zu) by UDP header",
"ignoring packet: packet (%zu bytes) smaller than expected (%zu) by UDP header",
len, hdrlen + be16toh(packet->udp.len));

if (be16toh(packet->udp.dest) != port)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"ignoring packet: to port %u, which "
"is not the DHCP client port (%u)",
"ignoring packet: to port %u, which is not the DHCP client port (%u)",
be16toh(packet->udp.dest), port);

/* checksums - computing these is relatively expensive, so only do it
Expand Down

0 comments on commit 9a94baa

Please sign in to comment.