diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2017-12-25 17:55:52 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2017-12-25 17:55:52 +0300 |
commit | cd9bb5cfe3afec23ef62f2aa2ed82e6dd04a32f9 (patch) | |
tree | 2750ae03b9db866569571aa353fc4a699c64ed28 | |
parent | 2369a4f0049e91dc62914693bea104b3fc54f557 (diff) | |
download | accel-ppp-xebd-cd9bb5cfe3afec23ef62f2aa2ed82e6dd04a32f9.tar.gz accel-ppp-xebd-cd9bb5cfe3afec23ef62f2aa2ed82e6dd04a32f9.zip |
ipv6pool: added gw-ip6-address option and special handling for /128 prefixes
If pool specified with /128 prefix length, then initialize intf_id by gw_ip6_address and peer_intf_id by generated pool address.
-rw-r--r-- | accel-pppd/accel-ppp.conf | 1 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 2 | ||||
-rw-r--r-- | accel-pppd/extra/ipv6pool.c | 24 |
3 files changed, 23 insertions, 4 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 1da9dc3..edab749 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -262,6 +262,7 @@ burst=3 timeout=60 [ipv6-pool] +#gw-ip6-address=fc00:0:1::1 fc00:0:1::/48,64 delegate=fc00:1::/36,48 diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index c69c5ed..ce4550d 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -873,6 +873,8 @@ fc00:0:1:ffff::/64 .BI "delegate=" ipv6prefix/mask,prefix_len Specifies range of prefixes to delegate to clients through DHCPv6 prefix delegation (rfc3633). Format is same as described above. +.BI "gw-ip6-address=" ipv6address +Specifies gateway address (used only for /128 prefixes) .SH [connlimit] .br This module limits connection rate from single source. diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c index 6887ea3..6fa5cc5 100644 --- a/accel-pppd/extra/ipv6pool.c +++ b/accel-pppd/extra/ipv6pool.c @@ -32,6 +32,7 @@ static LIST_HEAD(ippool); static LIST_HEAD(dppool); static spinlock_t pool_lock; static struct ipdb_t ipdb; +static struct in6_addr conf_gw_addr; static void in6_addr_add(struct in6_addr *res, const struct in6_addr *arg) { @@ -182,18 +183,30 @@ err: static struct ipv6db_item_t *get_ip(struct ap_session *ses) { struct ippool_item_t *it; + struct ipv6db_addr_t *a; spin_lock(&pool_lock); if (!list_empty(&ippool)) { it = list_entry(ippool.next, typeof(*it), entry); list_del(&it->entry); - it->it.intf_id = 0; - it->it.peer_intf_id = 0; } else it = NULL; spin_unlock(&pool_lock); - return it ? &it->it : NULL; + if (it) { + a = list_entry(it->it.addr_list.next, typeof(*a), entry); + if (a->prefix_len == 128) { + memcpy(&it->it.intf_id, conf_gw_addr.s6_addr + 8, 8); + memcpy(&it->it.peer_intf_id, a->addr.s6_addr + 8, 8); + } else { + it->it.intf_id = 0; + it->it.peer_intf_id = 0; + } + + return &it->it; + } + + return NULL; } static void put_ip(struct ap_session *ses, struct ipv6db_item_t *it) @@ -247,7 +260,10 @@ static void ippool_init(void) return; list_for_each_entry(opt, &s->items, entry) { - if (!strcmp(opt->name, "delegate")) + if (!strcmp(opt->name, "gw-ip6-address")) { + if (inet_pton(AF_INET6, opt->val, &conf_gw_addr) == 0) + log_error("ipv6_pool: failed to parse gw-ip6-address\n"); + } else if (!strcmp(opt->name, "delegate")) add_prefix(1, opt->val); else add_prefix(0, opt->name); |