diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-10-23 11:12:57 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-10-23 11:12:57 +0400 |
commit | d30d6a5f2605aee09137e75f471cc511c3e0d961 (patch) | |
tree | 9502f3cb7f8589fbd93525002581f3da7739df1c /accel-pppd/ppp | |
parent | 1497887f794b1a770c0e01a2ef3030e4229213dc (diff) | |
download | accel-ppp-d30d6a5f2605aee09137e75f471cc511c3e0d961.tar.gz accel-ppp-d30d6a5f2605aee09137e75f471cc511c3e0d961.zip |
ppp: rename interface back when put it into unit cache
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r-- | accel-pppd/ppp/ppp.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c index 6329b89c..91c4aa7d 100644 --- a/accel-pppd/ppp/ppp.c +++ b/accel-pppd/ppp/ppp.c @@ -162,17 +162,18 @@ int __export establish_ppp(struct ppp_t *ppp) ppp->chan_hnd.read = ppp_chan_read; ppp->unit_hnd.fd = ppp->unit_fd; ppp->unit_hnd.read = ppp_unit_read; - triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->chan_hnd); - triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->unit_hnd); - - triton_md_enable_handler(&ppp->chan_hnd, MD_MODE_READ); - triton_md_enable_handler(&ppp->unit_hnd, MD_MODE_READ); log_ppp_debug("ppp established\n"); if (ap_session_starting(&ppp->ses)) goto exit_close_unit; + triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->chan_hnd); + triton_md_register_handler(ppp->ses.ctrl->ctx, &ppp->unit_hnd); + + triton_md_enable_handler(&ppp->chan_hnd, MD_MODE_READ); + triton_md_enable_handler(&ppp->unit_hnd, MD_MODE_READ); + start_first_layer(ppp); return 0; @@ -197,6 +198,17 @@ static void destablish_ppp(struct ppp_t *ppp) triton_md_unregister_handler(&ppp->chan_hnd, 1); if (conf_unit_cache) { + struct ifreq ifr; + + sprintf(ifr.ifr_newname, "ppp%i", ppp->ses.unit_idx); + if (strcmp(ifr.ifr_newname, ppp->ses.ifname)) { + strncpy(ifr.ifr_name, ppp->ses.ifname, IFNAMSIZ); + if (ioctl(sock_fd, SIOCSIFNAME, &ifr)) { + triton_md_unregister_handler(&ppp->unit_hnd, 1); + goto skip; + } + } + triton_md_unregister_handler(&ppp->unit_hnd, 0); uc = mempool_alloc(uc_pool); uc->fd = ppp->unit_fd; @@ -210,6 +222,7 @@ static void destablish_ppp(struct ppp_t *ppp) } else triton_md_unregister_handler(&ppp->unit_hnd, 1); +skip: close(ppp->fd); ppp->fd = -1; ppp->chan_fd = -1; |