From e0cca4344f70b9c9e23e3c6a7e17c8e93c765184 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Mon, 11 Jul 2016 09:47:04 +0300 Subject: implemented support for network namespace This is done using radius attribute NAS-Port-Id. The new format of this attribute is NAS-Port-Id=[ns/][name]. Namespaces must be created malually by "ip netns add ..." command --- accel-pppd/ctrl/ipoe/ipoe.c | 4 ++-- accel-pppd/ctrl/l2tp/l2tp.c | 3 ++- accel-pppd/ctrl/pppoe/pppoe.c | 9 +++++---- accel-pppd/ctrl/pppoe/pppoe.h | 2 +- accel-pppd/ctrl/pptp/pptp.c | 6 +++++- 5 files changed, 15 insertions(+), 9 deletions(-) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index c7db14aa..84f8ad7c 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -203,7 +203,7 @@ static void ipoe_serv_timeout(struct triton_timer_t *t); static void ipoe_ctx_switch(struct triton_context_t *ctx, void *arg) { - net = &def_net; + net = def_net; log_switch(ctx, arg); } @@ -3263,7 +3263,7 @@ static void load_config(void) if (!s) return; - net = &def_net; + net = def_net; opt = conf_get_opt("ipoe", "username"); if (opt) { diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 76c679c7..5d9041fa 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -255,7 +255,8 @@ static inline int nsnr_cmp(uint16_t ns, uint16_t nr) static void l2tp_ctx_switch(struct triton_context_t *ctx, void *arg) { - net = &def_net; + struct ap_session *s = arg; + net = s->net; log_switch(ctx, arg); } diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index 242f7e07..4536040d 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -264,7 +264,7 @@ static int pppoe_rad_send_accounting_request(struct rad_plugin_t *rad, struct ra static void pppoe_conn_ctx_switch(struct triton_context_t *ctx, void *arg) { struct pppoe_conn_t *conn = arg; - net = conn->serv->net; + net = conn->ppp.ses.net; log_switch(ctx, &conn->ppp.ses); } @@ -400,6 +400,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui ppp_init(&conn->ppp); + conn->ppp.ses.net = serv->net; conn->ppp.ses.ctrl = &conn->ctrl; conn->ppp.ses.chan_name = conn->ctrl.calling_station_id; @@ -1266,7 +1267,7 @@ static void pppoe_serv_timeout(struct triton_timer_t *t) pppoe_server_free(serv); } -static int parse_server(const char *opt, int *padi_limit, const struct ap_net **net) +static int parse_server(const char *opt, int *padi_limit, struct ap_net **net) { char *ptr, *endptr; char name[64]; @@ -1374,7 +1375,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli, struct pppoe_serv_t *serv; struct ifreq ifr; int padi_limit = conf_padi_limit; - const struct ap_net *net = &def_net; + struct ap_net *net = def_net; if (parse_server(opt, &padi_limit, &net)) { if (cli) @@ -1462,7 +1463,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli, goto out_err; } - if (parent_ifindex == -1 && net == &def_net) + if (parent_ifindex == -1 && net == def_net) vid = iplink_vlan_get_vid(ifr.ifr_ifindex, &parent_ifindex); serv->ctx.close = pppoe_serv_close; diff --git a/accel-pppd/ctrl/pppoe/pppoe.h b/accel-pppd/ctrl/pppoe/pppoe.h index aac169ed..75e0eed9 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.h +++ b/accel-pppd/ctrl/pppoe/pppoe.h @@ -70,7 +70,7 @@ struct pppoe_serv_t struct triton_context_t ctx; struct rb_node node; - const struct ap_net *net; + struct ap_net *net; int disc_sock; uint8_t hwaddr[ETH_ALEN]; diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index ec20586f..4aba5767 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -75,7 +75,11 @@ static void ppp_finished(struct ap_session *); static void pptp_ctx_switch(struct triton_context_t *ctx, void *arg) { - net = &def_net; + if (arg) { + struct ap_session *s = arg; + net = s->net; + } else + net = def_net; log_switch(ctx, arg); } -- cgit v1.2.3