diff options
author | Vladislav Grishenko <themiron@mail.ru> | 2020-01-11 01:57:14 +0500 |
---|---|---|
committer | Vladislav Grishenko <themiron@mail.ru> | 2020-01-11 01:57:14 +0500 |
commit | f532c72d0cb33b16b9794d83a46969538bdf2596 (patch) | |
tree | bcfab735d95546e9992aafb3303e360893a9a140 /accel-pppd | |
parent | 70952034ecaf0ecb732052d6837f7a4c084ba7bc (diff) | |
download | accel-ppp-f532c72d0cb33b16b9794d83a46969538bdf2596.tar.gz accel-ppp-f532c72d0cb33b16b9794d83a46969538bdf2596.zip |
ipv6pool: add per-proto ipv6-pool and ipv6-pool-delegate options
also, disable ipv6 pools via chap-secrets, need to find another
syntax for it, may be with comments.
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/accel-ppp.conf | 8 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 16 | ||||
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 25 | ||||
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 8 | ||||
-rw-r--r-- | accel-pppd/ctrl/pptp/pptp.c | 8 | ||||
-rw-r--r-- | accel-pppd/ctrl/sstp/sstp.c | 8 | ||||
-rw-r--r-- | accel-pppd/extra/chap-secrets.c | 8 | ||||
-rw-r--r-- | accel-pppd/extra/ipv6pool.c | 8 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 2 | ||||
-rw-r--r-- | accel-pppd/session.c | 6 |
10 files changed, 85 insertions, 12 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index e9fe77c8..a54731c0 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -83,6 +83,8 @@ called-sid=mac #tr101=1 #padi-limit=0 #ip-pool=pppoe +#ipv6-pool=pppoe +#ipv6-pool-delegate=pppoe #ifname=pppoe%d #sid-uppercase=0 #vlan-mon=eth0,10-200 @@ -106,6 +108,8 @@ verbose=1 #dataseq=allow #reorder-timeout=0 #ip-pool=l2tp +#ipv6-pool=l2tp +#ipv6-pool-delegate=l2tp #ifname=l2tp%d [sstp] @@ -127,6 +131,8 @@ verbose=1 #timeout=60 #hello-interval=60 #ip-pool=sstp +#ipv6-pool=sstp +#ipv6-pool-delegate=sstp #ifname=sstp%d [ipoe] @@ -170,6 +176,8 @@ start=dhcpv4 #vlan-timeout=60 #vlan-name=%I.%N #ip-pool=ipoe +#ipv6-pool=ipoe +#ipv6-pool-delegate=ipoe #idle-timeout=0 #session-timeout=0 #soft-terminate=0 diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 45f66b73..b1504a2f 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -119,6 +119,8 @@ static int conf_arp; static int conf_ipv6; static uint32_t conf_src; static const char *conf_ip_pool; +static const char *conf_ipv6_pool; +static const char *conf_dpv6_pool; static const char *conf_l4_redirect_pool; //static int conf_dhcpv6; static int conf_username; @@ -1366,6 +1368,10 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s if (conf_ip_pool) ses->ses.ipv4_pool_name = _strdup(conf_ip_pool); + if (conf_ipv6_pool) + ses->ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (conf_dpv6_pool) + ses->ses.dpv6_pool_name = _strdup(conf_dpv6_pool); triton_context_register(&ses->ctx, &ses->ses); @@ -2073,6 +2079,10 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc if (conf_ip_pool) ses->ses.ipv4_pool_name = _strdup(conf_ip_pool); + if (conf_ipv6_pool) + ses->ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (conf_dpv6_pool) + ses->ses.dpv6_pool_name = _strdup(conf_dpv6_pool); ses->ctrl.dont_ifcfg = 1; @@ -2118,6 +2128,10 @@ static void ipoe_session_create_auto(struct ipoe_serv *serv) if (conf_ip_pool) ses->ses.ipv4_pool_name = _strdup(conf_ip_pool); + if (conf_ipv6_pool) + ses->ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (conf_dpv6_pool) + ses->ses.dpv6_pool_name = _strdup(conf_dpv6_pool); ses->ctrl.dont_ifcfg = 1; @@ -3915,6 +3929,8 @@ static void load_config(void) conf_offer_timeout = 10; conf_ip_pool = conf_get_opt("ipoe", "ip-pool"); + conf_ipv6_pool = conf_get_opt("ipoe", "ipv6-pool"); + conf_dpv6_pool = conf_get_opt("ipoe", "ipv6-pool-delegate"); conf_l4_redirect_pool = conf_get_opt("ipoe", "l4-redirect-ip-pool"); conf_vlan_name = conf_get_opt("ipoe", "vlan-name"); diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 6c108487..0d1ca21a 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -94,6 +94,8 @@ static int conf_mppe = MPPE_UNSET; static int conf_dataseq = L2TP_DATASEQ_ALLOW; static int conf_reorder_timeout = 0; static const char *conf_ip_pool; +static const char *conf_ipv6_pool; +static const char *conf_dpv6_pool; static const char *conf_ifname; static unsigned int stat_conn_starting; @@ -1791,12 +1793,23 @@ static int l2tp_session_start_data_channel(struct l2tp_sess_t *sess) if (conf_ip_pool) { sess->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool); if (sess->ppp.ses.ipv4_pool_name == NULL) { + err_pool: log_session(log_error, sess, "impossible to start data channel:" - " allocation of IPv4 pool name failed\n"); + " allocation of pool name failed\n"); goto err; } } + if (conf_ipv6_pool) { + sess->ppp.ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (sess->ppp.ses.ipv6_pool_name == NULL) + goto err_pool; + } + if (conf_dpv6_pool) { + sess->ppp.ses.dpv6_pool_name = _strdup(conf_dpv6_pool); + if (sess->ppp.ses.dpv6_pool_name == NULL) + goto err_pool; + } if (conf_ifname) sess->ppp.ses.ifname_rename = _strdup(conf_ifname); @@ -1836,6 +1849,14 @@ err: _free(sess->ppp.ses.ipv4_pool_name); sess->ppp.ses.ipv4_pool_name = NULL; } + if (sess->ppp.ses.ipv6_pool_name) { + _free(sess->ppp.ses.ipv6_pool_name); + sess->ppp.ses.ipv6_pool_name = NULL; + } + if (sess->ppp.ses.dpv6_pool_name) { + _free(sess->ppp.ses.dpv6_pool_name); + sess->ppp.ses.dpv6_pool_name = NULL; + } if (sess->ctrl.called_station_id) { _free(sess->ctrl.called_station_id); sess->ctrl.called_station_id = NULL; @@ -4938,6 +4959,8 @@ static void load_config(void) } conf_ip_pool = conf_get_opt("l2tp", "ip-pool"); + conf_ipv6_pool = conf_get_opt("l2tp", "ipv6-pool"); + conf_dpv6_pool = conf_get_opt("l2tp", "ipv6-pool-delegate"); conf_ifname = conf_get_opt("l2tp", "ifname"); switch (iprange_check_activation()) { diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index 12b54004..120e161f 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -98,6 +98,8 @@ int conf_padi_limit = 0; int conf_mppe = MPPE_UNSET; int conf_sid_uppercase = 0; static const char *conf_ip_pool; +static const char *conf_ipv6_pool; +static const char *conf_dpv6_pool; static const char *conf_ifname; enum {CSID_MAC, CSID_IFNAME, CSID_IFNAME_MAC}; static int conf_called_sid; @@ -408,6 +410,10 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui if (conf_ip_pool) conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool); + if (conf_ipv6_pool) + conn->ppp.ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (conf_dpv6_pool) + conn->ppp.ses.dpv6_pool_name = _strdup(conf_dpv6_pool); if (conf_ifname) conn->ppp.ses.ifname_rename = _strdup(conf_ifname); @@ -2014,6 +2020,8 @@ static void load_config(void) } conf_ip_pool = conf_get_opt("pppoe", "ip-pool"); + conf_ipv6_pool = conf_get_opt("pppoe", "ipv6-pool"); + conf_dpv6_pool = conf_get_opt("pppoe", "ipv6-pool-delegate"); conf_ifname = conf_get_opt("pppoe", "ifname"); conf_called_sid = CSID_MAC; diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index 081e9216..1161da5a 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -63,6 +63,8 @@ static int conf_echo_failure = 3; static int conf_verbose = 0; static int conf_mppe = MPPE_UNSET; static const char *conf_ip_pool; +static const char *conf_ipv6_pool; +static const char *conf_dpv6_pool; static const char *conf_ifname; static mempool_t conn_pool; @@ -713,6 +715,10 @@ static int pptp_connect(struct triton_md_handler_t *h) if (conf_ip_pool) conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool); + if (conf_ipv6_pool) + conn->ppp.ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (conf_dpv6_pool) + conn->ppp.ses.dpv6_pool_name = _strdup(conf_dpv6_pool); if (conf_ifname) conn->ppp.ses.ifname_rename = _strdup(conf_ifname); @@ -802,6 +808,8 @@ static void load_config(void) } conf_ip_pool = conf_get_opt("pptp", "ip-pool"); + conf_ipv6_pool = conf_get_opt("pptp", "ipv6-pool"); + conf_dpv6_pool = conf_get_opt("pptp", "ipv6-pool-delegate"); conf_ifname = conf_get_opt("pptp", "ifname"); switch (iprange_check_activation()) { diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c index 62e574c7..5bf8fd82 100644 --- a/accel-pppd/ctrl/sstp/sstp.c +++ b/accel-pppd/ctrl/sstp/sstp.c @@ -159,6 +159,8 @@ static int conf_hello_interval = SSTP_HELLO_TIMEOUT; static int conf_verbose = 0; static int conf_ppp_max_mtu = 1452; static const char *conf_ip_pool; +static const char *conf_ipv6_pool; +static const char *conf_dpv6_pool; static const char *conf_ifname; static int conf_proxyproto = 0; @@ -2276,6 +2278,10 @@ static int sstp_connect(struct triton_md_handler_t *h) conn->ppp.ses.chan_name = _strdup(addr_buf); if (conf_ip_pool) conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool); + if (conf_ipv6_pool) + conn->ppp.ses.ipv6_pool_name = _strdup(conf_ipv6_pool); + if (conf_dpv6_pool) + conn->ppp.ses.dpv6_pool_name = _strdup(conf_dpv6_pool); if (conf_ifname) conn->ppp.ses.ifname_rename = _strdup(conf_ifname); @@ -2693,6 +2699,8 @@ static void load_config(void) conf_ppp_max_mtu = atoi(opt); conf_ip_pool = conf_get_opt("sstp", "ip-pool"); + conf_ipv6_pool = conf_get_opt("sstp", "ipv6-pool"); + conf_dpv6_pool = conf_get_opt("sstp", "ipv6-pool-delegate"); conf_ifname = conf_get_opt("sstp", "ifname"); ipmode = (serv.addr.u.sa.sa_family == AF_INET && !conf_proxyproto) ? diff --git a/accel-pppd/extra/chap-secrets.c b/accel-pppd/extra/chap-secrets.c index 2d8593c9..0fadc9cb 100644 --- a/accel-pppd/extra/chap-secrets.c +++ b/accel-pppd/extra/chap-secrets.c @@ -313,12 +313,14 @@ static struct ipv4db_item_t *get_ip(struct ap_session *ses) if (ses->ipv4_pool_name) _free(ses->ipv4_pool_name); ses->ipv4_pool_name = _strdup(pd->pool); +/* TODO: wrong to use same pool name, but there's no other syntax if (ses->ipv6_pool_name) _free(ses->ipv6_pool_name); ses->ipv6_pool_name = _strdup(pd->pool); - if (ses->ipv6_dppool_name) - _free(ses->ipv6_dppool_name); - ses->ipv6_dppool_name = _strdup(pd->pool); + if (ses->dpv6_pool_name) + _free(ses->dpv6_pool_name); + ses->dpv6_pool_name = _strdup(pd->pool); +*/ return NULL; } else if (!pd->ip.peer_addr) return NULL; diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c index f00dbcfa..a2cf30df 100644 --- a/accel-pppd/extra/ipv6pool.c +++ b/accel-pppd/extra/ipv6pool.c @@ -302,7 +302,7 @@ static struct ipv6db_prefix_t *get_dp(struct ap_session *ses) struct ippool_t *pool; if (ses->ipv6_pool_name) - pool = find_pool(IPPOOL_PREFIX, ses->ipv6_dppool_name, 0); + pool = find_pool(IPPOOL_PREFIX, ses->dpv6_pool_name, 0); else pool = def_dppool; @@ -356,9 +356,9 @@ static void ev_radius_access_accept(struct ev_radius_t *ev) continue; if (conf_dppool_attr && conf_dppool_attr == attr->attr->id) { - if (ses->ipv6_dppool_name) - _free(ses->ipv6_dppool_name); - ses->ipv6_dppool_name = _strdup(attr->val.string); + if (ses->dpv6_pool_name) + _free(ses->dpv6_pool_name); + ses->dpv6_pool_name = _strdup(attr->val.string); } else if (conf_ippool_attr && conf_ippool_attr == attr->attr->id) { if (ses->ipv6_pool_name) diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index cf49e32b..6a6b9504 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -84,7 +84,7 @@ struct ap_session struct ipv6db_prefix_t *ipv6_dp; char *ipv4_pool_name; char *ipv6_pool_name; - char *ipv6_dppool_name; + char *dpv6_pool_name; struct ap_net *net; const struct ap_ctrl *ctrl; diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 8326ffa7..81247d18 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -239,9 +239,9 @@ void __export ap_session_finished(struct ap_session *ses) ses->ipv6_pool_name = NULL; } - if (ses->ipv6_dppool_name) { - _free(ses->ipv6_dppool_name); - ses->ipv6_dppool_name = NULL; + if (ses->dpv6_pool_name) { + _free(ses->dpv6_pool_name); + ses->dpv6_pool_name = NULL; } if (ses->ifname_rename) { |