]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
BSD: SIOCSRTRFLUSH_IN6 and SIOCSPFXFLUSH_IN6 require in6_ifreq
authorRoy Marples <roy@marples.name>
Sun, 16 Dec 2018 08:56:06 +0000 (08:56 +0000)
committerRoy Marples <roy@marples.name>
Sun, 16 Dec 2018 08:56:06 +0000 (08:56 +0000)
and not a character array of the interface name.
This only worked previously because the first member of in6_ifreq
is the interface name.

src/if-bsd.c

index b1d65a8864ab8b7afbe397923381b9d891d0aec4..fbb30bb4f536e0b5a67e255561afc983706774eb 100644 (file)
@@ -1507,13 +1507,14 @@ if_setup_inet6(const struct interface *ifp)
         * and prefixes so the kernel does not expire prefixes
         * and default routes we are trying to own. */
        if (ifp->options->options & DHCPCD_IPV6RS) {
-               char ifname[IFNAMSIZ + 8];
+               struct in6_ifreq ifr;
 
-               strlcpy(ifname, ifp->name, sizeof(ifname));
-               if (ioctl(s, SIOCSRTRFLUSH_IN6, (void *)&ifname) == -1 &&
+               memset(&ifr, 0, sizeof(ifr));
+               strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name));
+               if (ioctl(s, SIOCSRTRFLUSH_IN6, &ifr) == -1 &&
                    errno != ENOTSUP)
                        logwarn("SIOCSRTRFLUSH_IN6");
-               if (ioctl(s, SIOCSPFXFLUSH_IN6, (void *)&ifname) == -1 &&
+               if (ioctl(s, SIOCSPFXFLUSH_IN6, &ifr) == -1 &&
                    errno != ENOTSUP)
                        logwarn("SIOCSPFXFLUSH_IN6");
        }