summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorFrançois Cachereul <f.cachereul@alphalink.fr>2015-01-27 12:06:58 +0100
committerDmitry Kozlov <xeb@mail.ru>2015-02-20 11:21:41 +0300
commit44d70d146370ba2bb88ab0c8d2fad60deca696ab (patch)
tree913e1444dfa35ad1a847e137fda5d56b696fb2f7 /accel-pppd
parentbb92e3829330860b75ce6a5882bf10930da9ba52 (diff)
downloadaccel-ppp-44d70d146370ba2bb88ab0c8d2fad60deca696ab.tar.gz
accel-ppp-44d70d146370ba2bb88ab0c8d2fad60deca696ab.zip
ppp: set mtu and mru after unit creation
In the following patch PPP unit will be created after MRU negotation. Signed-off-by: François Cachereul <f.cachereul@alphalink.fr>
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/ppp/lcp_opt_mru.c13
-rw-r--r--accel-pppd/ppp/ppp.c12
-rw-r--r--accel-pppd/ppp/ppp.h3
3 files changed, 18 insertions, 10 deletions
diff --git a/accel-pppd/ppp/lcp_opt_mru.c b/accel-pppd/ppp/lcp_opt_mru.c
index c9443312..9a288171 100644
--- a/accel-pppd/ppp/lcp_opt_mru.c
+++ b/accel-pppd/ppp/lcp_opt_mru.c
@@ -111,27 +111,20 @@ static int mru_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui
return LCP_OPT_NAK;
mru_opt->mtu = ntohs(opt16->val);
+ lcp->ppp->mtu = mru_opt->mtu;
+
return LCP_OPT_ACK;
}
static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, uint8_t *ptr)
{
struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt), opt);
- struct ifreq ifr = {
- .ifr_mtu = mru_opt->mtu,
- };
-
- strcpy(ifr.ifr_name, lcp->ppp->ses.ifname);
if (ioctl(lcp->ppp->chan_fd, PPPIOCSMRU, &mru_opt->mru) &&
errno != EIO && errno != ENOTTY)
log_ppp_error("lcp:mru: failed to set channel MRU: %s\n", strerror(errno));
- if (ioctl(lcp->ppp->unit_fd, PPPIOCSMRU, &mru_opt->mru))
- log_ppp_error("lcp:mru: failed to set MRU: %s\n", strerror(errno));
-
- if (ioctl(sock_fd, SIOCSIFMTU, &ifr))
- log_ppp_error("lcp:mru: failed to set MTU: %s\n", strerror(errno));
+ lcp->ppp->mru = mru_opt->mru;
return 0;
}
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c
index 9772b846..2bc0ab38 100644
--- a/accel-pppd/ppp/ppp.c
+++ b/accel-pppd/ppp/ppp.c
@@ -77,6 +77,7 @@ void __export ppp_init(struct ppp_t *ppp)
int __export establish_ppp(struct ppp_t *ppp)
{
struct pppunit_cache *uc = NULL;
+ struct ifreq ifr;
if (ap_shutdown)
return -1;
@@ -149,6 +150,17 @@ int __export establish_ppp(struct ppp_t *ppp)
log_ppp_info1("connect: %s <--> %s(%s)\n", ppp->ses.ifname, ppp->ses.ctrl->name, ppp->ses.chan_name);
+ ifr.ifr_mtu = ppp->mtu;
+ strcpy(ifr.ifr_name, ppp->ses.ifname);
+ if (ioctl(sock_fd, SIOCSIFMTU, &ifr)) {
+ log_ppp_error("failed to set MTU: %s\n", strerror(errno));
+ goto exit_close_unit;
+ }
+ if (ioctl(ppp->unit_fd, PPPIOCSMRU, &ppp->mru)) {
+ log_ppp_error("failed to set MRU: %s\n", strerror(errno));
+ goto exit_close_unit;
+ }
+
init_layers(ppp);
if (list_empty(&ppp->layers)) {
diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h
index 73fe4229..759e114a 100644
--- a/accel-pppd/ppp/ppp.h
+++ b/accel-pppd/ppp/ppp.h
@@ -51,6 +51,9 @@ struct ppp_t
int chan_idx;
+ int mtu;
+ int mru;
+
void *buf;
int buf_size;