diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-07-24 22:11:33 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-07-24 22:11:33 +0400 |
commit | 768ad4d4f1930ffe1630e82789cd58191b651a64 (patch) | |
tree | 7db7adff9a766e5f936d9a7e68aebe5edea92d0b /accel-pppd/ipv6/nd.c | |
parent | cddc20689a17a1b30d491cd2021f911a669f6dbc (diff) | |
download | accel-ppp-xebd-768ad4d4f1930ffe1630e82789cd58191b651a64.tar.gz accel-ppp-xebd-768ad4d4f1930ffe1630e82789cd58191b651a64.zip |
radius: exit from active interim request when termination event occures
Diffstat (limited to 'accel-pppd/ipv6/nd.c')
-rw-r--r-- | accel-pppd/ipv6/nd.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/accel-pppd/ipv6/nd.c b/accel-pppd/ipv6/nd.c index 67a4a0f..669840a 100644 --- a/accel-pppd/ipv6/nd.c +++ b/accel-pppd/ipv6/nd.c @@ -256,7 +256,6 @@ static int ipv6_nd_start(struct ap_session *ses) { int sock; struct icmp6_filter filter; - struct sockaddr_in6 addr; struct ipv6_mreq mreq; int val; struct ipv6_nd_handler_t *h; @@ -268,17 +267,9 @@ static int ipv6_nd_start(struct ap_session *ses) return -1; } - fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC); - - memset(&addr, 0, sizeof(addr)); - addr.sin6_family = AF_INET6; - addr.sin6_addr.s6_addr32[0] = htons(0xfe80); - *(uint64_t *)(addr.sin6_addr.s6_addr + 8) = ses->ipv6->intf_id; - addr.sin6_scope_id = ses->ifindex; - - if (bind(sock, (struct sockaddr *)&addr, sizeof(addr))) { - close(sock); - return 1; + if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, ses->ifname, strlen(ses->ifname))) { + log_ppp_error("ipv6_nd: setsockopt(SO_BINDTODEVICE): %s\n", strerror(errno)); + goto out_err; } val = 2; @@ -322,6 +313,7 @@ static int ipv6_nd_start(struct ap_session *ses) goto out_err; } + fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC); fcntl(sock, F_SETFL, O_NONBLOCK); h = _malloc(sizeof(*h)); @@ -358,19 +350,19 @@ static struct ipv6_nd_handler_t *find_pd(struct ap_session *ses) return NULL; } -static void ipv6_nd_start_later(struct ap_session *ses) -{ - while (ipv6_nd_start(ses) == 1) - sched_yield(); -} - static void ev_ses_started(struct ap_session *ses) { + struct ipv6db_addr_t *a; + if (!ses->ipv6) return; - if (ipv6_nd_start(ses) == 1) - triton_context_call(triton_context_self(), (triton_event_func)ipv6_nd_start_later, ses); + list_for_each_entry(a, &ses->ipv6->addr_list, entry) { + if (a->prefix_len == 64) { + ipv6_nd_start(ses); + break; + } + } } static void ev_ses_finishing(struct ap_session *ses) |