diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-06-05 14:24:31 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-06-05 14:27:57 +0400 |
commit | fa315a7a7584f6f4954888c010e3cc84c2b33330 (patch) | |
tree | 778396449f9e19c52d8b83e7fabdb1c37706e16f /accel-pppd/ppp/ipcp_opt_ipaddr.c | |
parent | 6f01783f2b67cd0b82805240f2aeea9a39606d65 (diff) | |
download | accel-ppp-fa315a7a7584f6f4954888c010e3cc84c2b33330.tar.gz accel-ppp-fa315a7a7584f6f4954888c010e3cc84c2b33330.zip |
ppp: implemented unit cache
If enabled accel-pppd will not destroy interface immediately after corresponding session is terminated, instead interface will be brought down and placed to cache for later use for new sessions.
It should reduce kernel interface creation/deletion rate lack and increase responsibility of daemon
Diffstat (limited to 'accel-pppd/ppp/ipcp_opt_ipaddr.c')
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_ipaddr.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c index 14557440..e965f5c2 100644 --- a/accel-pppd/ppp/ipcp_opt_ipaddr.c +++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c @@ -58,8 +58,10 @@ static void ipaddr_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt) { struct ipaddr_option_t *ipaddr_opt = container_of(opt, typeof(*ipaddr_opt), opt); - if (ipcp->ppp->ipv4) + if (ipcp->ppp->ipv4) { ipdb_put_ipv4(ipcp->ppp, ipcp->ppp->ipv4); + ipcp->ppp->ipv4 = NULL; + } _free(ipaddr_opt); } @@ -137,8 +139,6 @@ static int ipaddr_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o { struct ipaddr_option_t *ipaddr_opt = container_of(opt, typeof(*ipaddr_opt), opt); struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; - struct ifreq ifr; - struct sockaddr_in addr; int r; if (!ipcp->ppp->ipv4) { @@ -152,31 +152,10 @@ static int ipaddr_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o if (ipcp->ppp->ipv4->peer_addr == opt32->val) { ipcp->delay_ack = ccp_ipcp_started(ipcp->ppp); - goto ack; + return IPCP_OPT_ACK; } return IPCP_OPT_NAK; - -ack: - memset(&ifr, 0, sizeof(ifr)); - memset(&addr, 0, sizeof(addr)); - - strcpy(ifr.ifr_name, ipcp->ppp->ifname); - - addr.sin_family = AF_INET; - addr.sin_addr.s_addr = ipcp->ppp->ipv4->addr; - memcpy(&ifr.ifr_addr,&addr,sizeof(addr)); - - if (ioctl(sock_fd, SIOCSIFADDR, &ifr)) - log_ppp_error("ipcp: failed to set PA address: %s\n", strerror(errno)); - - addr.sin_addr.s_addr = ipcp->ppp->ipv4->peer_addr; - memcpy(&ifr.ifr_dstaddr,&addr,sizeof(addr)); - - if (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr)) - log_ppp_error("ipcp: failed to set remote PA address: %s\n", strerror(errno)); - - return IPCP_OPT_ACK; } static void ipaddr_print(void (*print)(const char *fmt,...),struct ipcp_option_t *opt, uint8_t *ptr) |