summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2002-07-01 11:14:39 +0000
committerbrian <brian@cvs.openbsd.org>2002-07-01 11:14:39 +0000
commitd5cf9668782ed199afd0865ce6eb8f02882617cc (patch)
treea0be7fc7d5c4bb91138b7a7adbd221883bcb07df /usr.sbin
parentda4f9f16ff7bdd9ece620e95136642d0448325b0 (diff)
Fix a FreeBSD specific latency problem.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ppp/ether.c127
1 files changed, 68 insertions, 59 deletions
diff --git a/usr.sbin/ppp/ppp/ether.c b/usr.sbin/ppp/ppp/ether.c
index 12a5fc083b0..bf1d9702106 100644
--- a/usr.sbin/ppp/ppp/ether.c
+++ b/usr.sbin/ppp/ppp/ether.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: ether.c,v 1.16 2002/05/16 01:13:39 brian Exp $
+ * $OpenBSD: ether.c,v 1.17 2002/07/01 11:14:38 brian Exp $
*/
#include <sys/param.h>
@@ -221,7 +221,7 @@ ether_MessageIn(struct etherdevice *dev)
struct timeval t;
fd_set *r;
u_long slot;
- int ret;
+ int asciilen, ret;
if (dev->cs < 0)
return;
@@ -230,72 +230,81 @@ ether_MessageIn(struct etherdevice *dev)
log_Printf(LogERROR, "DoLoop: Cannot create fd_set\n");
return;
}
- zerofdset(r);
- FD_SET(dev->cs, r);
- t.tv_sec = t.tv_usec = 0;
- ret = select(dev->cs + 1, r, NULL, NULL, &t);
- free(r);
-
- if (ret <= 0)
- return;
- if (NgRecvMsg(dev->cs, rep, sizeof msgbuf, NULL) <= 0)
- return;
-
- if (rep->header.version != NG_VERSION) {
- log_Printf(LogWARN, "%ld: Unexpected netgraph version, expected %ld\n",
- (long)rep->header.version, (long)NG_VERSION);
- return;
- }
+ while (1) {
+ zerofdset(r);
+ FD_SET(dev->cs, r);
+ t.tv_sec = t.tv_usec = 0;
+ ret = select(dev->cs + 1, r, NULL, NULL, &t);
- if (rep->header.typecookie != NGM_PPPOE_COOKIE) {
- log_Printf(LogWARN, "%ld: Unexpected netgraph cookie, expected %ld\n",
- (long)rep->header.typecookie, (long)NGM_PPPOE_COOKIE);
- return;
- }
+ if (ret <= 0)
+ break;
- switch (rep->header.cmd) {
- case NGM_PPPOE_SET_FLAG: msg = "SET_FLAG"; break;
- case NGM_PPPOE_CONNECT: msg = "CONNECT"; break;
- case NGM_PPPOE_LISTEN: msg = "LISTEN"; break;
- case NGM_PPPOE_OFFER: msg = "OFFER"; break;
- case NGM_PPPOE_SUCCESS: msg = "SUCCESS"; break;
- case NGM_PPPOE_FAIL: msg = "FAIL"; break;
- case NGM_PPPOE_CLOSE: msg = "CLOSE"; break;
- case NGM_PPPOE_GET_STATUS: msg = "GET_STATUS"; break;
- case NGM_PPPOE_ACNAME:
- msg = "ACNAME";
- if (setenv("ACNAME", sts->hook, 1) != 0)
- log_Printf(LogWARN, "setenv: cannot set ACNAME=%s: %m", sts->hook);
+ if (NgRecvMsg(dev->cs, rep, sizeof msgbuf, NULL) <= 0)
break;
- case NGM_PPPOE_SESSIONID:
- msg = "SESSIONID";
- snprintf(sessionid, sizeof sessionid, "%04x", *(u_int16_t *)sts);
- if (setenv("SESSIONID", sessionid, 1) != 0)
- syslog(LOG_WARNING, "setenv: cannot set SESSIONID=%s: %m",
- sessionid);
- /* Use this in preference to our interface index */
- slot = strtoul(sessionid, &end, 16);
- if (end != sessionid && *end == '\0')
- dev->slot = slot;
+
+ if (rep->header.version != NG_VERSION) {
+ log_Printf(LogWARN, "%ld: Unexpected netgraph version, expected %ld\n",
+ (long)rep->header.version, (long)NG_VERSION);
break;
- default:
- snprintf(unknown, sizeof unknown, "<%d>", (int)rep->header.cmd);
- msg = unknown;
+ }
+
+ if (rep->header.typecookie != NGM_PPPOE_COOKIE) {
+ log_Printf(LogWARN, "%ld: Unexpected netgraph cookie, expected %ld\n",
+ (long)rep->header.typecookie, (long)NGM_PPPOE_COOKIE);
break;
- }
+ }
- log_Printf(LogPHASE, "Received NGM_PPPOE_%s (hook \"%s\")\n", msg, sts->hook);
+ asciilen = 0;
+ switch (rep->header.cmd) {
+ case NGM_PPPOE_SET_FLAG: msg = "SET_FLAG"; break;
+ case NGM_PPPOE_CONNECT: msg = "CONNECT"; break;
+ case NGM_PPPOE_LISTEN: msg = "LISTEN"; break;
+ case NGM_PPPOE_OFFER: msg = "OFFER"; break;
+ case NGM_PPPOE_SUCCESS: msg = "SUCCESS"; break;
+ case NGM_PPPOE_FAIL: msg = "FAIL"; break;
+ case NGM_PPPOE_CLOSE: msg = "CLOSE"; break;
+ case NGM_PPPOE_GET_STATUS: msg = "GET_STATUS"; break;
+ case NGM_PPPOE_ACNAME:
+ msg = "ACNAME";
+ if (setenv("ACNAME", sts->hook, 1) != 0)
+ log_Printf(LogWARN, "setenv: cannot set ACNAME=%s: %m", sts->hook);
+ asciilen = rep->header.arglen;
+ break;
+ case NGM_PPPOE_SESSIONID:
+ msg = "SESSIONID";
+ snprintf(sessionid, sizeof sessionid, "%04x", *(u_int16_t *)sts);
+ if (setenv("SESSIONID", sessionid, 1) != 0)
+ syslog(LOG_WARNING, "setenv: cannot set SESSIONID=%s: %m",
+ sessionid);
+ /* Use this in preference to our interface index */
+ slot = strtoul(sessionid, &end, 16);
+ if (end != sessionid && *end == '\0')
+ dev->slot = slot;
+ break;
+ default:
+ snprintf(unknown, sizeof unknown, "<%d>", (int)rep->header.cmd);
+ msg = unknown;
+ break;
+ }
- switch (rep->header.cmd) {
- case NGM_PPPOE_SUCCESS:
- dev->connected = CARRIER_OK;
- break;
- case NGM_PPPOE_FAIL:
- case NGM_PPPOE_CLOSE:
- dev->connected = CARRIER_LOST;
- break;
+ if (asciilen)
+ log_Printf(LogPHASE, "Received NGM_PPPOE_%s (hook \"%.*s\")\n",
+ msg, asciilen, sts->hook);
+ else
+ log_Printf(LogPHASE, "Received NGM_PPPOE_%s\n", msg);
+
+ switch (rep->header.cmd) {
+ case NGM_PPPOE_SUCCESS:
+ dev->connected = CARRIER_OK;
+ break;
+ case NGM_PPPOE_FAIL:
+ case NGM_PPPOE_CLOSE:
+ dev->connected = CARRIER_LOST;
+ break;
+ }
}
+ free(r);
}
static int