[PATCH] udhcpc6 source address is null, should be link-local address

Mathias Krüger math.krueger at gmail.com
Fri Aug 16 15:12:06 UTC 2013


Hi,

there is an open bug (issue 6194
https://bugs.busybox.net/show_bug.cgi?id=6194 ) for udhcpc6 client

IETF RFC 3315, section 16, says:
"The client MUST use a link-local address assigned to the interface for which
it is requesting configuration information as the source address in the header
of the IP datagram."

udhcpc6 is sending DHCPv6 datagrams using a null source address

This is the patch I made:

diff d6_dhcpc.c ~/udhcp/d6_dhcpc.c
36,37d35
< #include <net/if.h>
< #include <ifaddrs.h>
93,123d90
< static int d6_get_lladdr(const char *interface, uint8_t *ip6)
< {
<       struct sockaddr_in6 *our_ip6;
<       struct ifaddrs *ifap, *ife;
<
<       if (ip6) {
<               if(getifaddrs(&ifap)<0)
<               {
<                       return -1;
<               }
<               for(ife = ifap; ife; ife = ife->ifa_next)
<               {
<                       if (0 != strcmp(interface, ife->ifa_name))
<                               continue;
<                       if (ife->ifa_addr == NULL)
<                               continue;
<                       if ((ife->ifa_addr->sa_family == AF_INET6))
<                       {
<                               our_ip6 = ((struct sockaddr_in6
*)ife->ifa_addr);
<                               if
(IN6_IS_ADDR_LINKLOCAL(&(our_ip6->sin6_addr)))
<                               {
<                                       memcpy(ip6,
our_ip6->sin6_addr.s6_addr, 16);
<                                       break;
<                               }
<                       }
<               }
<       }
<
<       return 0;
< }
<
346c313
<               /*src*/ (struct in6_addr*)client6_data.lladdr, CLIENT_PORT,
---
>               /*src*/ NULL, CLIENT_PORT,
1029,1034d995
<       if (d6_get_lladdr(client_config.interface,
<                       client6_data.lladdr)
<       ) {
<               return 1;
<       }
<
1137,1141d1097
<                       if (d6_get_lladdr(client_config.interface,
<                                       client6_data.lladdr)
<                       ) {
<                               goto ret0; /* no lladdr? */
<                       }


diff d6_common.h ~/udhcp/d6_common.h
90d89
<     uint8_t lladdr[16];

Regards,
Mathias


More information about the busybox mailing list