]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
initrt should really take dhcpcd_ctx as an argument.
authorRoy Marples <roy@marples.name>
Thu, 12 May 2016 10:45:21 +0000 (10:45 +0000)
committerRoy Marples <roy@marples.name>
Thu, 12 May 2016 10:45:21 +0000 (10:45 +0000)
dhcp.c
dhcp6.c
if-bsd.c
if-linux.c
if.h
ipv4.c
ipv4ll.c
ipv6.c
ipv6nd.c

diff --git a/dhcp.c b/dhcp.c
index 21c1c7109e76166900128d549456457b7dce6fb1..2a87cfba9c5882ae72b96570e02c27870cf60aa7 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -3290,7 +3290,7 @@ dhcp_init(struct interface *ifp)
                state->raw_fd = -1;
 
                /* Now is a good time to find IPv4 routes */
-               if_initrt(ifp);
+               if_initrt(ifp->ctx);
        }
 
        state->state = DHS_INIT;
diff --git a/dhcp6.c b/dhcp6.c
index 239350c3709dc3fc3b2c074bbfa2976f7815b598..352e7ef8d1cbd69c29b785aa1d1d02bb30edceb1 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -2524,7 +2524,7 @@ dhcp6_delegate_prefix(struct interface *ifp)
                if (k && !carrier_warned) {
                        ifd_state = D6_STATE(ifd);
                        ipv6_addaddrs(&ifd_state->addrs);
-                       if_initrt6(ifd);
+                       if_initrt(ifd->ctx);
                        ipv6_buildroutes(ifd->ctx);
                        dhcp6_script_try_run(ifd, 1);
                }
@@ -2591,7 +2591,7 @@ dhcp6_find_delegates(struct interface *ifp)
                state = D6_STATE(ifp);
                state->state = DH6S_DELEGATED;
                ipv6_addaddrs(&state->addrs);
-               if_initrt6(ifp);
+               if_initrt6(ifp->ctx);
                ipv6_buildroutes(ifp->ctx);
                dhcp6_script_try_run(ifp, 1);
        }
@@ -3092,7 +3092,7 @@ recv:
                else if (state->expire == 0)
                        logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
                            "%s: will expire", ifp->name);
-               if_initrt6(ifp);
+               if_initrt6(ifp->ctx);
                ipv6_buildroutes(ifp->ctx);
                dhcp6_writelease(ifp);
                dhcp6_delegate_prefix(ifp);
index 249fa4e36e25aac373f466ded5af1db11cd9f028..dd033f6748a6e9eae5e65ec7594aecd5d87580e5 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -772,7 +772,7 @@ if_route(unsigned char cmd, const struct rt *rt)
 }
 
 int
-if_initrt(struct interface *ifp)
+if_initrt(struct dhcpcd_ctx *ctx) 
 {
        struct rt_msghdr *rtm;
        int mib[6];
@@ -780,7 +780,7 @@ if_initrt(struct interface *ifp)
        char *buf, *p, *end;
        struct rt rt;
 
-       ipv4_freerts(ifp->ctx->ipv4_kroutes);
+       ipv4_freerts(ctx->ipv4_kroutes);
 
        mib[0] = CTL_NET;
        mib[1] = PF_ROUTE;
@@ -803,8 +803,8 @@ if_initrt(struct interface *ifp)
        end = buf + needed;
        for (p = buf; p < end; p += rtm->rtm_msglen) {
                rtm = (void *)p;
-               if (if_copyrt(ifp->ctx, &rt, rtm) == 0)
-                       ipv4_handlert(ifp->ctx, RTM_ADD, &rt, 1);
+               if (if_copyrt(ctx, &rt, rtm) == 0)
+                       ipv4_handlert(ctx, RTM_ADD, &rt, 1);
        }
        free(buf);
        return 0;
@@ -1139,7 +1139,7 @@ if_route6(unsigned char cmd, const struct rt6 *rt)
 }
 
 int
-if_initrt6(struct interface *ifp)
+if_initrt6(struct dhcpcd_ctx *ctx)
 {
        struct rt_msghdr *rtm;
        int mib[6];
@@ -1147,7 +1147,7 @@ if_initrt6(struct interface *ifp)
        char *buf, *p, *end;
        struct rt6 rt;
 
-       ipv6_freerts(&ifp->ctx->ipv6->kroutes);
+       ipv6_freerts(&ctx->ipv6->kroutes);
 
        mib[0] = CTL_NET;
        mib[1] = PF_ROUTE;
@@ -1170,8 +1170,8 @@ if_initrt6(struct interface *ifp)
        end = buf + needed;
        for (p = buf; p < end; p += rtm->rtm_msglen) {
                rtm = (void *)p;
-               if (if_copyrt6(ifp->ctx, &rt, rtm) == 0)
-                       ipv6_handlert(ifp->ctx, RTM_ADD, &rt);
+               if (if_copyrt6(ctx, &rt, rtm) == 0)
+                       ipv6_handlert(ctx, RTM_ADD, &rt);
        }
        free(buf);
        return 0;
index 973544ac6c6e0524997410d753128d0c15381589..040ebf9022fc2f4fd21aa87f292adc419a88eb2b 100644 (file)
@@ -1474,11 +1474,11 @@ _if_initrt(struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
 }
 
 int
-if_initrt(struct interface *ifp)
+if_initrt(struct dhcpcd_ctx *ctx)
 {
        struct nlmr nlm;
 
-       ipv4_freerts(ifp->ctx->ipv4_kroutes);
+       ipv4_freerts(ctx->ipv4_kroutes);
 
        memset(&nlm, 0, sizeof(nlm));
        nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
@@ -1487,10 +1487,8 @@ if_initrt(struct interface *ifp)
        nlm.hdr.nlmsg_flags |= NLM_F_REQUEST;
        nlm.rt.rtm_family = AF_INET;
        nlm.rt.rtm_table = RT_TABLE_MAIN;
-       add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index);
 
-       return send_netlink(ifp->ctx, ifp,
-           NETLINK_ROUTE, &nlm.hdr, &_if_initrt);
+       return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, &_if_initrt);
 }
 
 int
@@ -1648,11 +1646,11 @@ _if_initrt6(struct dhcpcd_ctx *ctx, __unused struct interface *ifp,
 }
 
 int
-if_initrt6(struct interface *ifp)
+if_initrt6(struct dhcpcd_ctx *ctx)
 {
        struct nlmr nlm;
 
-       ipv6_freerts(&ifp->ctx->ipv6->kroutes);
+       ipv6_freerts(&ctx->ipv6->kroutes);
 
        memset(&nlm, 0, sizeof(nlm));
        nlm.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
@@ -1661,10 +1659,8 @@ if_initrt6(struct interface *ifp)
        nlm.hdr.nlmsg_flags |= NLM_F_REQUEST;
        nlm.rt.rtm_family = AF_INET6;
        nlm.rt.rtm_table = RT_TABLE_MAIN;
-       add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, ifp->index);
 
-       return send_netlink(ifp->ctx, ifp,
-           NETLINK_ROUTE, &nlm.hdr, &_if_initrt6);
+       return send_netlink(ctx, NULL, NETLINK_ROUTE, &nlm.hdr, &_if_initrt6);
 }
 
 int
diff --git a/if.h b/if.h
index f174ee4ce8a39c2826dda0301a2045718039e924..de9b2d9fa4b800f59f1e5df5387e98659efa2b8e 100644 (file)
--- a/if.h
+++ b/if.h
@@ -155,7 +155,7 @@ int if_address(const struct interface *,
 int if_addrflags(const struct in_addr *, const struct interface *);
 
 int if_route(unsigned char, const struct rt *rt);
-int if_initrt(struct interface *);
+int if_initrt(struct dhcpcd_ctx *);
 #endif
 
 #ifdef INET6
@@ -176,7 +176,7 @@ int if_addrflags6(const struct in6_addr *, const struct interface *);
 int if_getlifetime6(struct ipv6_addr *);
 
 int if_route6(unsigned char, const struct rt6 *rt);
-int if_initrt6(struct interface *);
+int if_initrt6(struct dhcpcd_ctx *);
 #else
 #define if_checkipv6(a, b, c) (-1)
 #endif
diff --git a/ipv4.c b/ipv4.c
index 600e41f91164af8ddc2d0b06d79c7d8f7aa2c7d5..38d7e592ae08d9bfd2d78f838de2f934d921955a 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -1205,7 +1205,7 @@ ipv4_applyaddr(void *arg)
        /* Find any freshly added routes, such as the subnet route.
         * We do this because we cannot rely on recieving the kernel
         * notification right now via our link socket. */
-       if_initrt(ifp);
+       if_initrt(ifp->ctx);
        ipv4_buildroutes(ifp->ctx);
        /* Announce the address */
        if (ifo->options & DHCPCD_ARP) {
index e3d17ff37794aca1582512ba1650bcc7acb38165..5d8dc1f40ef362b9911ebe4ac46b48150fe7e4c7 100644 (file)
--- a/ipv4ll.c
+++ b/ipv4ll.c
@@ -202,7 +202,7 @@ test:
                return;
        }
        timespecclear(&state->defend);
-       if_initrt(ifp);
+       if_initrt(ifp->ctx);
        ipv4_buildroutes(ifp->ctx);
        arp_announce(astate);
        script_runreason(ifp, "IPV4LL");
@@ -476,12 +476,11 @@ ipv4ll_handlert(struct dhcpcd_ctx *ctx, __unused int cmd, const struct rt *rt)
 
        /* If any interface is running IPv4LL, rebuild our routing table. */
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {
-               if (IPV4LL_STATE_RUNNING(ifp))
+               if (IPV4LL_STATE_RUNNING(ifp)) {
+                       if_initrt(ifp->ctx);
+                       ipv4_buildroutes(ifp->ctx);
                        break;
-       }
-       if (ifp != NULL) {
-               if_initrt(ifp);
-               ipv4_buildroutes(ctx);
+               }
        }
 
        return 0;
diff --git a/ipv6.c b/ipv6.c
index d539cdb1902e24395045635247e64aacf04d6f83..f87a1f6010f09622668c6687f16dd85b6184522f 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -1450,7 +1450,7 @@ ipv6_startstatic(struct interface *ifp)
        ia->prefix_pltime = ND6_INFINITE_LIFETIME;
        ia->dadcallback = ipv6_staticdadcallback;
        ipv6_addaddr(ia, NULL);
-       if_initrt6(ifp);
+       if_initrt6(ifp->ctx);
        ipv6_buildroutes(ifp->ctx);
        if (run_script)
                script_runreason(ifp, "STATIC6");
@@ -1473,7 +1473,7 @@ ipv6_start(struct interface *ifp)
        }
 
        /* Load existing routes */
-       if_initrt6(ifp);
+       if_initrt6(ifp->ctx);
        if (!IN6_IS_ADDR_UNSPECIFIED(&ifp->options->req_addr6))
                ipv6_buildroutes(ifp->ctx);
        return 0;
@@ -1494,7 +1494,7 @@ ipv6_freedrop(struct interface *ifp, int drop)
        ipv6_freedrop_addrs(&state->addrs, drop ? 2 : 0, NULL);
        if (drop) {
                if (ifp->ctx->ipv6 != NULL) {
-                       if_initrt6(ifp);
+                       if_initrt6(ifp->ctx);
                        ipv6_buildroutes(ifp->ctx);
                }
        } else {
index a1fe6e0f116c41c1465206bdc6127f5956f15607..35da0136ec33138f06688a2fc91dfac96cea8d72 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -1099,7 +1099,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *dctx, struct interface *ifp,
        /* Find any freshly added routes, such as the subnet route.
         * We do this because we cannot rely on recieving the kernel
         * notification right now via our link socket. */
-       if_initrt6(ifp);
+       if_initrt6(ifp->ctx);
 
        ipv6_buildroutes(ifp->ctx);
        if (ipv6nd_scriptrun(rap))