summaryrefslogtreecommitdiffstats
path: root/ipv6nd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-03-12 15:59:19 +0000
committerRoy Marples <roy@marples.name>2014-03-12 15:59:19 +0000
commitcc43133914bde9c93ef92a6a01545992cfd471b7 (patch)
tree2a6d8fbda12fbca0a176ac982c94377f63825a61 /ipv6nd.c
parentb826c088b70e5f7b9d4a778c9e279eefe2fcc1d9 (diff)
downloaddhcpcd-cc43133914bde9c93ef92a6a01545992cfd471b7.tar.xz
Set hoplimit by IPV6_MULTICAST_HOPS intead of each time we send.
Diffstat (limited to 'ipv6nd.c')
-rw-r--r--ipv6nd.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/ipv6nd.c b/ipv6nd.c
index c03f9a0b..a755fe87 100644
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -184,6 +184,12 @@ ipv6nd_open(struct dhcpcd_ctx *dctx)
}
#endif
+ /* RFC4861 4.1 */
+ on = 255;
+ if (setsockopt(ctx->nd_fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ &on, sizeof(on)) == -1)
+ goto eexit;
+
on = 1;
if (setsockopt(ctx->nd_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
&on, sizeof(on)) == -1)
@@ -247,7 +253,6 @@ ipv6nd_sendrsprobe(void *arg)
struct sockaddr_in6 dst;
struct cmsghdr *cm;
struct in6_pktinfo pi;
- int hoplimit = 255; /* RFC4861 4.1 */
if (ipv6_linklocal(ifp) == NULL) {
syslog(LOG_DEBUG,
@@ -273,8 +278,6 @@ 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);
@@ -287,15 +290,6 @@ ipv6nd_sendrsprobe(void *arg)
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;
- cm->cmsg_level = IPPROTO_IPV6;
- cm->cmsg_type = IPV6_HOPLIMIT;
- cm->cmsg_len = CMSG_LEN(sizeof(hoplimit));
- memcpy(CMSG_DATA(cm), &hoplimit, sizeof(hoplimit));
-
syslog(LOG_DEBUG, "%s: sending Router Solicitation", ifp->name);
if (sendmsg(ctx->nd_fd, &ctx->sndhdr, 0) == -1) {
syslog(LOG_ERR, "%s: %s: sendmsg: %m", ifp->name, __func__);
@@ -1247,7 +1241,6 @@ ipv6nd_proberouter(void *arg)
struct sockaddr_in6 dst;
struct cmsghdr *cm;
struct in6_pktinfo pi;
- int hoplimit = 255; /* RFC4861 4.1 */
struct timeval tv, rtv;
struct ipv6_ctx *ctx;
@@ -1287,8 +1280,6 @@ 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);
@@ -1301,15 +1292,6 @@ ipv6nd_proberouter(void *arg)
pi.ipi6_ifindex = rap->iface->index;
memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
- /* Hop limit */
- cm = CMSG_NXTHDR(&ctx->sndhdr, cm);
- if (cm == NULL) /* unlikely */
- return;
- cm->cmsg_level = IPPROTO_IPV6;
- cm->cmsg_type = IPV6_HOPLIMIT;
- cm->cmsg_len = CMSG_LEN(sizeof(hoplimit));
- memcpy(CMSG_DATA(cm), &hoplimit, sizeof(hoplimit));
-
#ifdef DEBUG_NS
syslog(LOG_INFO, "%s: sending IPv6 NS for %s",
rap->iface->name, rap->sfrom);