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>
This commit is contained in:
parent
33c9899c77
commit
749c50b84b
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue