]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove notion of hoplimit from DHCPv6
authorRoy Marples <roy@marples.name>
Wed, 12 Mar 2014 15:39:53 +0000 (15:39 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Mar 2014 15:39:53 +0000 (15:39 +0000)
dhcp6.c
ipv6.c
ipv6nd.c

diff --git a/dhcp6.c b/dhcp6.c
index 853cf7d5e3c260d61311a610fe2e0e5de3f28b3f..b89cfd317d56bd6d04cfe4bfafc153ef90fb0566 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -713,7 +713,6 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *))
        uint8_t neg;
        const char *broad_uni;
        const struct in6_addr alldhcp = IN6ADDR_LINKLOCAL_ALLDHCP_INIT;
-       int hoplimit = 1; /* Relay agents bump this up */
 
        memset(&dst, 0, sizeof(dst));
        dst.sin6_family = AF_INET6;
@@ -834,6 +833,7 @@ logsend:
        ctx->sndhdr.msg_name = (caddr_t)&dst;
        ctx->sndhdr.msg_iov[0].iov_base = (caddr_t)state->send;
        ctx->sndhdr.msg_iov[0].iov_len = state->send_len;
+       ctx->sndhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
 
        /* Set the outbound interface */
        cm = CMSG_FIRSTHDR(&ctx->sndhdr);
@@ -846,15 +846,6 @@ logsend:
        pi.ipi6_ifindex = ifp->index;
        memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
-       /* Hop limit */
-       cm = CMSG_NXTHDR(&ctx->sndhdr, cm);
-       if (cm == NULL) /* unlikely */
-               return -1;
-       cm->cmsg_level = IPPROTO_IPV6;
-       cm->cmsg_type = IPV6_HOPLIMIT;
-       cm->cmsg_len = CMSG_LEN(sizeof(hoplimit));
-       memcpy(CMSG_DATA(cm), &hoplimit, sizeof(hoplimit));
-
        if (sendmsg(ctx->dhcp_fd, &ctx->sndhdr, 0) == -1) {
                syslog(LOG_ERR, "%s: %s: sendmsg: %m", ifp->name, __func__);
                ifp->options->options &= ~DHCPCD_IPV6;
@@ -2023,6 +2014,7 @@ dhcp6_handledata(void *arg)
 
        dhcpcd_ctx = arg;
        ctx = dhcpcd_ctx->ipv6;
+       ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
        len = recvmsg(ctx->dhcp_fd, &ctx->rcvhdr, 0);
        if (len == -1) {
                syslog(LOG_ERR, "recvmsg: %m");
@@ -2523,11 +2515,6 @@ dhcp6_open(struct dhcpcd_ctx *dctx)
            &n, sizeof(n)) == -1)
                goto errexit;
 
-       n = 1;
-       if (setsockopt(ctx->dhcp_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
-           &n, sizeof(n)) == -1)
-               goto errexit;
-
        eloop_event_add(dctx->eloop, ctx->dhcp_fd, dhcp6_handledata, dctx);
        return 0;
 
diff --git a/ipv6.c b/ipv6.c
index 32b5cdb74cf8677aace8621566751112d5d48237..1f321f5bed1587604a27394ad9f1dc05d7fd709f 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -102,17 +102,18 @@ ipv6_init(struct dhcpcd_ctx *dhcpcd_ctx)
        }
        TAILQ_INIT(ctx->ra_routers);
 
+       // controllen is set at send/recieve
        ctx->sndhdr.msg_namelen = sizeof(struct sockaddr_in6);
        ctx->sndhdr.msg_iov = ctx->sndiov;
        ctx->sndhdr.msg_iovlen = 1;
        ctx->sndhdr.msg_control = ctx->sndbuf;
-       ctx->sndhdr.msg_controllen = sizeof(ctx->sndbuf);
+       //ctx->sndhdr.msg_controllen = sizeof(ctx->sndbuf);
        ctx->rcvhdr.msg_name = &ctx->from;
        ctx->rcvhdr.msg_namelen = sizeof(ctx->from);
        ctx->rcvhdr.msg_iov = ctx->rcviov;
        ctx->rcvhdr.msg_iovlen = 1;
        ctx->rcvhdr.msg_control = ctx->rcvbuf;
-       ctx->rcvhdr.msg_controllen = sizeof(ctx->rcvbuf);
+       //ctx->rcvhdr.msg_controllen = sizeof(ctx->rcvbuf);
        ctx->rcviov[0].iov_base = ctx->ansbuf;
        ctx->rcviov[0].iov_len = sizeof(ctx->ansbuf);
 
index d60e0979dad68e862331a16f7bb26559e8ca4c66..c03f9a0b5bcb8d4f5229ff7554dc022f8a7507fc 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -273,6 +273,8 @@ ipv6nd_sendrsprobe(void *arg)
        ctx->sndhdr.msg_name = (caddr_t)&dst;
        ctx->sndhdr.msg_iov[0].iov_base = state->rs;
        ctx->sndhdr.msg_iov[0].iov_len = state->rslen;
+       ctx->sndhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
+           CMSG_SPACE(sizeof(int));
 
        /* Set the outbound interface */
        cm = CMSG_FIRSTHDR(&ctx->sndhdr);
@@ -1285,6 +1287,8 @@ ipv6nd_proberouter(void *arg)
        ctx->sndhdr.msg_name = (caddr_t)&dst;
        ctx->sndhdr.msg_iov[0].iov_base = rap->ns;
        ctx->sndhdr.msg_iov[0].iov_len = rap->nslen;
+       ctx->sndhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
+           CMSG_SPACE(sizeof(int));
 
        /* Set the outbound interface */
        cm = CMSG_FIRSTHDR(&ctx->sndhdr);
@@ -1436,6 +1440,8 @@ ipv6nd_handledata(void *arg)
 
        dhcpcd_ctx = arg;
        ctx = dhcpcd_ctx->ipv6;
+       ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
+           CMSG_SPACE(sizeof(int));
        len = recvmsg(ctx->nd_fd, &ctx->rcvhdr, 0);
        if (len == -1) {
                syslog(LOG_ERR, "recvmsg: %m");