avoid fd_set overrun. sync w/kame
This commit is contained in:
parent
ac03214470
commit
f78cc67c13
|
@ -1,5 +1,5 @@
|
||||||
.\" $NetBSD: route6d.8,v 1.9 2002/06/02 14:56:47 wiz Exp $
|
.\" $NetBSD: route6d.8,v 1.10 2002/06/07 16:45:30 itojun Exp $
|
||||||
.\" $KAME: route6d.8,v 1.8 2000/05/31 17:00:09 itojun Exp $
|
.\" $KAME: route6d.8,v 1.11 2002/06/02 15:00:30 itojun Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1996 WIDE Project. All rights reserved.
|
.\" Copyright (c) 1996 WIDE Project. All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
.Nd RIP6 routing daemon
|
.Nd RIP6 routing daemon
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm route6d
|
.Nm route6d
|
||||||
.Op Fl adDhlqsS
|
.Op Fl adDhlnqsS
|
||||||
.Bk -words
|
.Bk -words
|
||||||
.Op Fl R Ar routelog
|
.Op Fl R Ar routelog
|
||||||
.Ek
|
.Ek
|
||||||
|
@ -146,6 +146,9 @@ For example, with
|
||||||
will accept the default route and routes in the 6bone test address range,
|
will accept the default route and routes in the 6bone test address range,
|
||||||
but no others.
|
but no others.
|
||||||
.\"
|
.\"
|
||||||
|
.It Fl n
|
||||||
|
Do not update the kernel routing table.
|
||||||
|
.\"
|
||||||
.It Fl N Ar if1[,if2...]
|
.It Fl N Ar if1[,if2...]
|
||||||
Do not listen to, or advertise, route from/to interfaces specified by
|
Do not listen to, or advertise, route from/to interfaces specified by
|
||||||
.Ar if1,[if2...] .
|
.Ar if1,[if2...] .
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* $NetBSD: route6d.c,v 1.33 2002/05/29 23:11:13 itojun Exp $ */
|
/* $NetBSD: route6d.c,v 1.34 2002/06/07 16:45:30 itojun Exp $ */
|
||||||
/* $KAME: route6d.c,v 1.83 2002/05/29 23:07:33 itojun Exp $ */
|
/* $KAME: route6d.c,v 1.85 2002/06/07 16:39:41 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: route6d.c,v 1.33 2002/05/29 23:11:13 itojun Exp $");
|
__RCSID("$NetBSD: route6d.c,v 1.34 2002/06/07 16:45:30 itojun Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -140,7 +140,9 @@ int nifc; /* number of valid ifc's */
|
||||||
struct ifc **index2ifc;
|
struct ifc **index2ifc;
|
||||||
int nindex2ifc;
|
int nindex2ifc;
|
||||||
struct ifc *loopifcp = NULL; /* pointing to loopback */
|
struct ifc *loopifcp = NULL; /* pointing to loopback */
|
||||||
fd_set sockvec; /* vector to select() for receiving */
|
fd_set *sockvecp; /* vector to select() for receiving */
|
||||||
|
fd_set *recvecp;
|
||||||
|
int fdmasks;
|
||||||
int rtsock; /* the routing socket */
|
int rtsock; /* the routing socket */
|
||||||
int ripsock; /* socket to send/receive RIP datagram */
|
int ripsock; /* socket to send/receive RIP datagram */
|
||||||
int maxfd; /* maximum fd for select() */
|
int maxfd; /* maximum fd for select() */
|
||||||
|
@ -430,8 +432,6 @@ main(argc, argv)
|
||||||
sigemptyset(&mask);
|
sigemptyset(&mask);
|
||||||
sigaddset(&mask, SIGALRM);
|
sigaddset(&mask, SIGALRM);
|
||||||
while (1) {
|
while (1) {
|
||||||
fd_set recvec;
|
|
||||||
|
|
||||||
if (seenalrm) {
|
if (seenalrm) {
|
||||||
ripalarm();
|
ripalarm();
|
||||||
seenalrm = 0;
|
seenalrm = 0;
|
||||||
|
@ -448,8 +448,8 @@ main(argc, argv)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_COPY(&sockvec, &recvec);
|
memcpy(recvecp, sockvecp, fdmasks);
|
||||||
switch (select(maxfd + 1, &recvec, 0, 0, 0)) {
|
switch (select(maxfd + 1, recvecp, 0, 0, 0)) {
|
||||||
case -1:
|
case -1:
|
||||||
if (errno != EINTR) {
|
if (errno != EINTR) {
|
||||||
fatal("select");
|
fatal("select");
|
||||||
|
@ -459,12 +459,12 @@ main(argc, argv)
|
||||||
case 0:
|
case 0:
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
if (FD_ISSET(ripsock, &recvec)) {
|
if (FD_ISSET(ripsock, recvecp)) {
|
||||||
sigprocmask(SIG_BLOCK, &mask, &omask);
|
sigprocmask(SIG_BLOCK, &mask, &omask);
|
||||||
riprecv();
|
riprecv();
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
}
|
}
|
||||||
if (FD_ISSET(rtsock, &recvec)) {
|
if (FD_ISSET(rtsock, recvecp)) {
|
||||||
sigprocmask(SIG_BLOCK, &mask, &omask);
|
sigprocmask(SIG_BLOCK, &mask, &omask);
|
||||||
rtrecv();
|
rtrecv();
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
|
@ -642,12 +642,6 @@ init()
|
||||||
}
|
}
|
||||||
memcpy(&ripsin, res->ai_addr, res->ai_addrlen);
|
memcpy(&ripsin, res->ai_addr, res->ai_addrlen);
|
||||||
|
|
||||||
#ifdef FD_ZERO
|
|
||||||
FD_ZERO(&sockvec);
|
|
||||||
#else
|
|
||||||
memset(&sockvec, 0, sizeof(sockvec));
|
|
||||||
#endif
|
|
||||||
FD_SET(ripsock, &sockvec);
|
|
||||||
maxfd = ripsock;
|
maxfd = ripsock;
|
||||||
|
|
||||||
if (nflag == 0) {
|
if (nflag == 0) {
|
||||||
|
@ -655,11 +649,24 @@ init()
|
||||||
fatal("route socket");
|
fatal("route socket");
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
}
|
}
|
||||||
FD_SET(rtsock, &sockvec);
|
|
||||||
if (rtsock > maxfd)
|
if (rtsock > maxfd)
|
||||||
maxfd = rtsock;
|
maxfd = rtsock;
|
||||||
} else
|
} else
|
||||||
rtsock = -1; /*just for safety */
|
rtsock = -1; /*just for safety */
|
||||||
|
|
||||||
|
fdmasks = howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask);
|
||||||
|
if ((sockvecp = malloc(fdmasks)) == NULL) {
|
||||||
|
fatal("malloc");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
if ((recvecp = malloc(fdmasks)) == NULL) {
|
||||||
|
fatal("malloc");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
memset(sockvecp, 0, fdmasks);
|
||||||
|
FD_SET(ripsock, sockvecp);
|
||||||
|
if (rtsock >= 0)
|
||||||
|
FD_SET(rtsock, sockvecp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RIPSIZE(n) \
|
#define RIPSIZE(n) \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: route6d.h,v 1.6 2001/02/07 13:46:04 itojun Exp $ */
|
/* $NetBSD: route6d.h,v 1.7 2002/06/07 16:45:30 itojun Exp $ */
|
||||||
/* $KAME: route6d.h,v 1.4 2001/01/15 03:50:54 inoue Exp $ */
|
/* $KAME: route6d.h,v 1.4 2001/01/15 03:50:54 inoue Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -35,7 +35,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ROUTE6D_DUMP "/var/run/route6d_dump"
|
#define ROUTE6D_DUMP "/var/run/route6d_dump"
|
||||||
#define ROUTE6D_PID "/var/run/route6d.pid"
|
|
||||||
|
|
||||||
#define RIP6_VERSION 1
|
#define RIP6_VERSION 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue