summaryrefslogtreecommitdiff
path: root/accel-pppd/ipv6/dhcpv6.c
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2018-01-13 01:47:27 +0500
committerVladislav Grishenko <themiron@mail.ru>2018-01-13 02:08:09 +0500
commitabaa43a307fa7a790dd34034c5fd8013dbd0488c (patch)
treed884d23c46fffc52247bce87781a9f8656a1ff82 /accel-pppd/ipv6/dhcpv6.c
parentbd2c6c801707b05541edbfc050bcd2930785321e (diff)
downloadaccel-ppp-abaa43a307fa7a790dd34034c5fd8013dbd0488c.tar.gz
accel-ppp-abaa43a307fa7a790dd34034c5fd8013dbd0488c.zip
ipv6: dhcpv6: route all PD via one linklocal gateway
Diffstat (limited to 'accel-pppd/ipv6/dhcpv6.c')
-rw-r--r--accel-pppd/ipv6/dhcpv6.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/accel-pppd/ipv6/dhcpv6.c b/accel-pppd/ipv6/dhcpv6.c
index 2442b1a9..22273428 100644
--- a/accel-pppd/ipv6/dhcpv6.c
+++ b/accel-pppd/ipv6/dhcpv6.c
@@ -169,7 +169,6 @@ static void ev_ses_finished(struct ap_session *ses)
static void insert_dp_routes(struct ap_session *ses, struct dhcpv6_pd *pd)
{
- struct ipv6db_addr_t *a;
struct ipv6db_addr_t *p;
struct in6_rtmsg rt6;
char str1[INET6_ADDRSTRLEN];
@@ -180,37 +179,27 @@ static void insert_dp_routes(struct ap_session *ses, struct dhcpv6_pd *pd)
rt6.rtmsg_ifindex = ses->ifindex;
rt6.rtmsg_flags = RTF_UP;
+ if (conf_route_via_gw) {
+ rt6.rtmsg_flags |= RTF_GATEWAY;
+ rt6.rtmsg_gateway.s6_addr32[0] = htonl(0xfe800000);
+ memcpy(rt6.rtmsg_gateway.s6_addr + 8, &ses->ipv6->peer_intf_id, 8);
+ }
+
list_for_each_entry(p, &ses->ipv6_dp->prefix_list, entry) {
memcpy(&rt6.rtmsg_dst, &p->addr, sizeof(p->addr));
rt6.rtmsg_dst_len = p->prefix_len;
- rt6.rtmsg_metric = 1;
-
- if (conf_route_via_gw) {
- rt6.rtmsg_flags |= RTF_GATEWAY;
- list_for_each_entry(a, &ses->ipv6->addr_list, entry) {
- build_ip6_addr(a, ses->ipv6->peer_intf_id, &rt6.rtmsg_gateway);
- if (net->sock6_ioctl(SIOCADDRT, &rt6)) {
- err = errno;
- inet_ntop(AF_INET6, &p->addr, str1, sizeof(str1));
- inet_ntop(AF_INET6, &rt6.rtmsg_gateway, str2, sizeof(str2));
- log_ppp_error("dhcpv6: route add %s/%i via %s: %s\n", str1, p->prefix_len, str2, strerror(err));
- } else if (conf_verbose) {
- inet_ntop(AF_INET6, &p->addr, str1, sizeof(str1));
- inet_ntop(AF_INET6, &rt6.rtmsg_gateway, str2, sizeof(str2));
- log_ppp_info2("dhcpv6: route add %s/%i via %s\n", str1, p->prefix_len, str2);
- }
- rt6.rtmsg_metric++;
- }
- } else {
- if (net->sock6_ioctl(SIOCADDRT, &rt6)) {
- err = errno;
- inet_ntop(AF_INET6, &p->addr, str1, sizeof(str1));
- log_ppp_error("dhcpv6: route add %s/%i: %s\n",
- str1, p->prefix_len, strerror(err));
- } else if (conf_verbose) {
- inet_ntop(AF_INET6, &p->addr, str1, sizeof(str1));
- log_ppp_info2("dhcpv6: route add %s/%i\n", str1, p->prefix_len);
- }
+
+ if (net->sock6_ioctl(SIOCADDRT, &rt6)) {
+ err = errno;
+ inet_ntop(AF_INET6, &p->addr, str1, sizeof(str1));
+ inet_ntop(AF_INET6, &rt6.rtmsg_gateway, str2, sizeof(str2));
+ log_ppp_error("dhcpv6: route add %s/%i%s%s: %s\n", str1, p->prefix_len,
+ conf_route_via_gw ? " via " : "", str2, strerror(err));
+ } else if (conf_verbose) {
+ inet_ntop(AF_INET6, &p->addr, str1, sizeof(str1));
+ inet_ntop(AF_INET6, &rt6.rtmsg_gateway, str2, sizeof(str2));
+ log_ppp_info2("dhcpv6: route add %s/%i%s%s\n", str1, p->prefix_len,
+ conf_route_via_gw ? " via " : "", str2);
}
}