diff options
author | Thomas Huth <thuth@redhat.com> | 2015-12-22 11:08:43 +0100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2015-12-23 13:01:41 +1100 |
commit | 749c50b84b83a9b96b8cbac64b192dc31147f351 (patch) | |
tree | fd523f555108365be59932f64356244f262e5f4d /clients | |
parent | 33c9899c7769d3bc4a37a107abf4dafb75de6b5c (diff) | |
download | SLOF-749c50b84b83a9b96b8cbac64b192dc31147f351.zip SLOF-749c50b84b83a9b96b8cbac64b192dc31147f351.tar.gz SLOF-749c50b84b83a9b96b8cbac64b192dc31147f351.tar.bz2 |
net-snk: Get rid of junk at the end of sent DHCPv6 packets
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@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'clients')
-rw-r--r-- | clients/net-snk/app/netlib/dhcpv6.c | 8 | ||||
-rw-r--r-- | 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..9b70f22 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; 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; }; |