udhcpc[6]: initialize entire sockaddr_ll
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 29 Sep 2017 12:09:02 +0000 (14:09 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 29 Sep 2017 12:22:43 +0000 (14:22 +0200)
I see random field values like sll_hatype=0x267 when I strace.
They seem to not matter, but just in case they sometimes do,
let's at least have deterministic values (via memset(0)).

function                                             old     new   delta
change_listen_mode                                   308     322     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/d6_dhcpc.c
networking/udhcp/d6_packet.c
networking/udhcp/dhcpc.c
networking/udhcp/packet.c

index 714555fa8f3f451d9fff288a0a067a40271695f3..d4bb3507b70828a6034da513f7f04d628b5e0fe3 100644 (file)
@@ -881,9 +881,14 @@ static int d6_raw_socket(int ifindex)
        fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
        log2("got raw socket fd %d", fd);
 
+       memset(&sock, 0, sizeof(sock)); /* let's be deterministic */
        sock.sll_family = AF_PACKET;
        sock.sll_protocol = htons(ETH_P_IPV6);
        sock.sll_ifindex = ifindex;
+       /*sock.sll_hatype = ARPHRD_???;*/
+       /*sock.sll_pkttype = PACKET_???;*/
+       /*sock.sll_halen = ???;*/
+       /*sock.sll_addr[8] = ???;*/
        xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
 
 #if 0
index 79a0ac8a867463bf43eaab3cc21f03a57d98c427..a0656c1dab54989cef71cac161e7f4fcb9bb4a97 100644 (file)
@@ -75,6 +75,8 @@ int FAST_FUNC d6_send_raw_packet(
        dest_sll.sll_family = AF_PACKET;
        dest_sll.sll_protocol = htons(ETH_P_IPV6);
        dest_sll.sll_ifindex = ifindex;
+       /*dest_sll.sll_hatype = ARPHRD_???;*/
+       /*dest_sll.sll_pkttype = PACKET_???;*/
        dest_sll.sll_halen = 6;
        memcpy(dest_sll.sll_addr, dest_arp, 6);
 
index 99d91bf70bd31918590c4a19d6d88542cafdec64..6c74996ef65a06a9196f28eb5f539569670fef2f 100644 (file)
@@ -1010,9 +1010,14 @@ static int udhcp_raw_socket(int ifindex)
         */
        log2("got raw socket fd");
 
+       memset(&sock, 0, sizeof(sock)); /* let's be deterministic */
        sock.sll_family = AF_PACKET;
        sock.sll_protocol = htons(ETH_P_IP);
        sock.sll_ifindex = ifindex;
+       /*sock.sll_hatype = ARPHRD_???;*/
+       /*sock.sll_pkttype = PACKET_???;*/
+       /*sock.sll_halen = ???;*/
+       /*sock.sll_addr[8] = ???;*/
        xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
 
 #if 0 /* Several users reported breakage when BPF filter is used */
index 9e1b46d2f71efbb7f295b3593f40d60d80772ec8..44d9ceec76743ed9a8849bc9f20a119a69b31c9c 100644 (file)
@@ -129,6 +129,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
        dest_sll.sll_family = AF_PACKET;
        dest_sll.sll_protocol = htons(ETH_P_IP);
        dest_sll.sll_ifindex = ifindex;
+       /*dest_sll.sll_hatype = ARPHRD_???;*/
+       /*dest_sll.sll_pkttype = PACKET_???;*/
        dest_sll.sll_halen = 6;
        memcpy(dest_sll.sll_addr, dest_arp, 6);