[systemd-devel] [PATCH] sd-dhcp: check for udp packets

Tom Gundersen teg at jklm.no
Sun Mar 30 11:51:47 PDT 2014


On Sun, Mar 30, 2014 at 7:09 PM, Umut Tezduyar Lindskog
<umut.tezduyar at axis.com> wrote:
> Do not try to parse ICMP packets
> ---
>  src/libsystemd-network/dhcp-packet.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/libsystemd-network/dhcp-packet.c b/src/libsystemd-network/dhcp-packet.c
> index bed942f..f4a6227 100644
> --- a/src/libsystemd-network/dhcp-packet.c
> +++ b/src/libsystemd-network/dhcp-packet.c
> @@ -157,6 +157,11 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum) {
>
>          /* UDP */
>
> +        if (packet->ip.protocol != IPPROTO_UDP) {
> +                log_dhcp_client(client, "ignoring packet: packet is not UDP");
> +                return -EINVAL;
> +        }
> +
>          if (len < DHCP_IP_UDP_SIZE) {
>                  log_dhcp_client(client, "ignoring packet: packet (%zu bytes) "
>                                  " smaller than IP+UDP header (%u bytes)", len,

Thanks, this makes a lot of sense. I pushed this and made a few other
tweaks to the parsing function. FWIW, I intend to drop most of the
logging messages from this function once things have matured a bit,
but for now they are useful to help debugging.

Cheers,

Tom


More information about the systemd-devel mailing list