[SLOF] [PATCH 7/7] net-snk: Get rid of junk at the end of sent DHCPv6 packets

Stefan Berger stefanb at linux.vnet.ibm.com
Tue Dec 22 03:05:57 AEDT 2015


On 12/17/2015 03:18 PM, Thomas Huth wrote:
> Wireshark reports bad FCS values and trailing zeros for SLOF's
> DHCPv6 packets. This happens due to two bugs. First, the length
> given to send_ipv6() contained sizeof(struct ethhdr) - but
> adding that length is the responsibility of the send_ipv6()
> function itself, the upper layers must not add this length yet.
> Second, struct option_request was defined with 5 options, but
> the code only uses 3 options instead. So when the code uses
> sizeof(struct dhcp_message_header) (which contains the struct
> option_request), there were additional unused bytes appended
> to the message.
>
> Signed-off-by: Thomas Huth <thuth at redhat.com>
> ---
>   clients/net-snk/app/netlib/dhcpv6.c | 8 +++-----
>   clients/net-snk/app/netlib/dhcpv6.h | 4 +++-
>   2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/clients/net-snk/app/netlib/dhcpv6.c b/clients/net-snk/app/netlib/dhcpv6.c
> index 05e9fcd..1a4ce6d 100644
> --- a/clients/net-snk/app/netlib/dhcpv6.c
> +++ b/clients/net-snk/app/netlib/dhcpv6.c
> @@ -70,16 +70,14 @@ send_info_request(int fd)
>   	dhcph->option.el_time.length = 2;
>   	dhcph->option.el_time.time = 0x190; /* 4000 ms */
>   	dhcph->option.option_request_option.code = DHCPV6_OPTION_ORO;
> -	dhcph->option.option_request_option.length= 6;
> +	dhcph->option.option_request_option.length= DHCPV6_OPTREQUEST_NUMOPTS * 2;

nit: space before '=' ?

>   	dhcph->option.option_request_option.option_code[0] = DHCPV6_OPTION_DNS_SERVERS;
>   	dhcph->option.option_request_option.option_code[1] = DHCPV6_OPTION_DOMAIN_LIST;
>   	dhcph->option.option_request_option.option_code[2] = DHCPV6_OPTION_BOOT_URL;
>   
> -
>   	send_ipv6(fd, ether_packet + sizeof(struct ethhdr),
> -	         sizeof(struct ethhdr)+ sizeof(struct ip6hdr)
> -		 + sizeof(struct udphdr)
> -	         + sizeof( struct dhcp_message_header) );
> +		  sizeof(struct ip6hdr) + sizeof(struct udphdr)
> +		  + sizeof(struct dhcp_message_header));
>   }
>   
>   static int32_t
> diff --git a/clients/net-snk/app/netlib/dhcpv6.h b/clients/net-snk/app/netlib/dhcpv6.h
> index dcda9b1..404706e 100644
> --- a/clients/net-snk/app/netlib/dhcpv6.h
> +++ b/clients/net-snk/app/netlib/dhcpv6.h
> @@ -103,6 +103,8 @@ struct server_identifier {
>   	uint8_t mac[6];
>   };
>   
> +#define DHCPV6_OPTREQUEST_NUMOPTS 3
> +
>   struct dhcp_info_request {
>   	struct client_identifier client_id;
>   	struct elapsed_time {
> @@ -113,7 +115,7 @@ struct dhcp_info_request {
>   	struct option_request {
>   		uint16_t code;
>   		uint16_t length;
> -		uint16_t option_code[5];
> +		uint16_t option_code[DHCPV6_OPTREQUEST_NUMOPTS];
>   	} option_request_option;
>   };
>   

Rest looks good.
    Stefan



More information about the SLOF mailing list