From: Roy Marples Date: Wed, 12 Mar 2014 15:39:53 +0000 (+0000) Subject: Remove notion of hoplimit from DHCPv6 X-Git-Tag: v6.3.2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b826c088b70e5f7b9d4a778c9e279eefe2fcc1d9;p=thirdparty%2Fdhcpcd.git Remove notion of hoplimit from DHCPv6 --- diff --git a/dhcp6.c b/dhcp6.c index 853cf7d5..b89cfd31 100644 --- 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 32b5cdb7..1f321f5b 100644 --- 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); diff --git a/ipv6nd.c b/ipv6nd.c index d60e0979..c03f9a0b 100644 --- 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");