diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 1998-07-12 04:34:43 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 1998-07-12 04:34:43 +0000 |
commit | fbaa2f1fb45d7e38444bc8ff2bb5245cf4b3562a (patch) | |
tree | 82dd292d9ddf8c4df0cf99213db8c41dd7750c77 /usr.sbin | |
parent | 2609ab695c6066d1c2c7b58b9664a62179d36a75 (diff) |
Implement demand_drop() for demand mode pppd; try to avoid mbuf
exhaustion while setting up a connection.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pppd/demand.c | 32 | ||||
-rw-r--r-- | usr.sbin/pppd/main.c | 8 | ||||
-rw-r--r-- | usr.sbin/pppd/pppd.h | 3 |
3 files changed, 35 insertions, 8 deletions
diff --git a/usr.sbin/pppd/demand.c b/usr.sbin/pppd/demand.c index f72e61ecc09..2f5de37bf33 100644 --- a/usr.sbin/pppd/demand.c +++ b/usr.sbin/pppd/demand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: demand.c,v 1.5 1998/01/17 20:30:21 millert Exp $ */ +/* $OpenBSD: demand.c,v 1.6 1998/07/12 04:34:39 angelos Exp $ */ /* * demand.c - Support routines for demand-dialling. @@ -23,7 +23,7 @@ #if 0 static char rcsid[] = "Id: demand.c,v 1.7 1997/11/27 06:08:26 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: demand.c,v 1.5 1998/01/17 20:30:21 millert Exp $"; +static char rcsid[] = "$OpenBSD: demand.c,v 1.6 1998/07/12 04:34:39 angelos Exp $"; #endif #endif @@ -153,6 +153,34 @@ demand_discard() } /* + * demand_drop - set each network protocol to discard packets + * without an error. + */ +void +demand_drop() +{ + struct packet *pkt, *nextpkt; + int i; + struct protent *protp; + + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (protp->enabled_flag && protp->demand_conf != NULL) + sifnpmode(0, protp->protocol & ~0x8000, NPMODE_DROP); + get_loop_output(); + + /* discard all saved packets */ + for (pkt = pend_q; pkt != NULL; pkt = nextpkt) { + nextpkt = pkt->next; + free(pkt); + } + pend_q = NULL; + framelen = 0; + flush_flag = 0; + escape_flag = 0; + fcs = PPP_INITFCS; +} + +/* * demand_unblock - set each enabled network protocol to pass packets. */ void diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c index 6581629e795..7e1356b8d72 100644 --- a/usr.sbin/pppd/main.c +++ b/usr.sbin/pppd/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.24 1998/07/10 08:06:45 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.25 1998/07/12 04:34:41 angelos Exp $ */ /* * main.c - Point-to-Point Protocol main module @@ -23,7 +23,7 @@ #if 0 static char rcsid[] = "Id: main.c,v 1.49 1998/05/05 05:24:17 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.24 1998/07/10 08:06:45 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.25 1998/07/12 04:34:41 angelos Exp $"; #endif #endif @@ -414,7 +414,7 @@ main(argc, argv) /* * Now we want to bring up the link. */ - demand_block(); + demand_discard(); syslog(LOG_INFO, "Starting link"); } @@ -589,8 +589,6 @@ main(argc, argv) if (!persist) die(1); - if (demand) - demand_discard(); if (holdoff > 0 && need_holdoff) { phase = PHASE_HOLDOFF; TIMEOUT(holdoff_end, NULL, holdoff); diff --git a/usr.sbin/pppd/pppd.h b/usr.sbin/pppd/pppd.h index a3f530d6f01..dc7bba871cd 100644 --- a/usr.sbin/pppd/pppd.h +++ b/usr.sbin/pppd/pppd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pppd.h,v 1.9 1998/05/08 04:52:32 millert Exp $ */ +/* $OpenBSD: pppd.h,v 1.10 1998/07/12 04:34:42 angelos Exp $ */ /* * pppd.h - PPP daemon global declarations. @@ -235,6 +235,7 @@ void check_access __P((FILE *, char *)); /* Procedures exported from demand.c */ void demand_conf __P((void)); /* config interface(s) for demand-dial */ void demand_block __P((void)); /* set all NPs to queue up packets */ +void demand_drop __P((void)); /* set all NPs to drop packets */ void demand_unblock __P((void)); /* set all NPs to pass packets */ void demand_discard __P((void)); /* set all NPs to discard packets */ void demand_rexmit __P((int)); /* retransmit saved frames for an NP */ |