Latest routed from Vern Schryver. This is supposed to fix

Andrey's rtquery problem.

Submitted by:	Vernon J. Schryver <vjs@mica.denver.sgi.com>
This commit is contained in:
Garrett Wollman 1996-12-17 21:07:05 +00:00
parent 71965874ee
commit 337e72d0e5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/SGI/dist_v_2_21/; revision=20606
svn path=/vendor/SGI/vjs_961217/; revision=20608; tag=vendor/SGI/vjs_961217
8 changed files with 69 additions and 68 deletions

View File

@ -36,7 +36,7 @@
*/ */
#ifndef __NetBSD__ #ifndef __NetBSD__
#ident "$Revision: 1.19 $" #ident "$Revision: 1.21 $"
#endif #endif
/* Definitions for RIPv2 routing process. /* Definitions for RIPv2 routing process.
@ -77,6 +77,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <syslog.h> #include <syslog.h>
#include <time.h> #include <time.h>
#include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -95,10 +96,6 @@
#define RIPVERSION RIPv2 #define RIPVERSION RIPv2
#include <protocols/routed.h> #include <protocols/routed.h>
#ifdef sgi
#define USE_PASSIFNAME
#endif
/* Type of an IP address. /* Type of an IP address.
* Some systems do not like to pass structures, so do not use in_addr. * Some systems do not like to pass structures, so do not use in_addr.

View File

@ -36,7 +36,7 @@ static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$"; static char rcsid[] = "$NetBSD$";
#endif #endif
#ident "$Revision: 1.21 $" #ident "$Revision: 1.22 $"
#include "defs.h" #include "defs.h"
#include "pathnames.h" #include "pathnames.h"
@ -60,7 +60,7 @@ struct interface *remote_if; /* remote interfaces */
/* hash for physical interface names. /* hash for physical interface names.
* Assume there are never more 100 or 200 real interfaces, and that * Assume there are never more 100 or 200 real interfaces, and that
* aliases put on the end of the hash chains. * aliases are put on the end of the hash chains.
*/ */
#define NHASH_LEN 97 #define NHASH_LEN 97
struct interface *nhash[NHASH_LEN]; struct interface *nhash[NHASH_LEN];
@ -71,11 +71,14 @@ int foundloopback; /* valid flag for loopaddr */
naddr loopaddr; /* our address on loopback */ naddr loopaddr; /* our address on loopback */
struct timeval ifinit_timer; struct timeval ifinit_timer;
static struct timeval last_ifinit;
int have_ripv1_out; /* have a RIPv1 interface */ int have_ripv1_out; /* have a RIPv1 interface */
int have_ripv1_in; int have_ripv1_in;
/* Link a new interface into the lists and hash tables.
*/
void void
if_link(struct interface *ifp) if_link(struct interface *ifp)
{ {
@ -117,6 +120,7 @@ if_link(struct interface *ifp)
i += *p; i += *p;
hifp = &nhash[i % NHASH_LEN]; hifp = &nhash[i % NHASH_LEN];
if (ifp->int_state & IS_ALIAS) { if (ifp->int_state & IS_ALIAS) {
/* put aliases on the end of the hash chain */
while (*hifp != 0) while (*hifp != 0)
hifp = &(*hifp)->int_nhash; hifp = &(*hifp)->int_nhash;
} }
@ -176,19 +180,32 @@ ifwithname(char *name, /* "ec0" or whatever */
int i; int i;
char *p; char *p;
for (i = 0, p = name; *p != '\0'; p++) for (;;) {
i += *p; for (i = 0, p = name; *p != '\0'; p++)
for (ifp = nhash[i % NHASH_LEN]; ifp != 0; ifp = ifp->int_nhash) { i += *p;
/* If the network address is not specified, ifp = nhash[i % NHASH_LEN];
* ignore any alias interfaces. Otherwise, look
* for the interface with the target name and address. while (ifp != 0) {
/* If the network address is not specified,
* ignore any alias interfaces. Otherwise, look
* for the interface with the target name and address.
*/
if (!strcmp(ifp->int_name, name)
&& ((addr == 0 && !(ifp->int_state & IS_ALIAS))
|| (ifp->int_addr == addr)))
return ifp;
ifp = ifp->int_nhash;
}
/* If there is no known interface, maybe there is a
* new interface. So just once look for new interfaces.
*/ */
if (!strcmp(ifp->int_name, name) if (last_ifinit.tv_sec == now.tv_sec
&& ((addr == 0 && !(ifp->int_state & IS_ALIAS)) && last_ifinit.tv_usec == now.tv_usec)
|| (ifp->int_addr == addr))) return 0;
return ifp; ifinit();
} }
return 0;
} }
@ -214,7 +231,6 @@ struct interface *
iflookup(naddr addr) iflookup(naddr addr)
{ {
struct interface *ifp, *maybe; struct interface *ifp, *maybe;
static struct timeval retried;
maybe = 0; maybe = 0;
for (;;) { for (;;) {
@ -239,15 +255,14 @@ iflookup(naddr addr)
} }
if (maybe != 0 if (maybe != 0
|| (retried.tv_sec == now.tv_sec || (last_ifinit.tv_sec == now.tv_sec
&& retried.tv_usec == now.tv_usec)) && last_ifinit.tv_usec == now.tv_usec))
return maybe; return maybe;
/* If there is no known interface, maybe there is a /* If there is no known interface, maybe there is a
* new interface. So just once look for new interfaces. * new interface. So just once look for new interfaces.
*/ */
ifinit(); ifinit();
retried = now;
} }
} }
@ -654,6 +669,7 @@ ifinit(void)
#endif #endif
last_ifinit = now;
ifinit_timer.tv_sec = now.tv_sec + (supplier ifinit_timer.tv_sec = now.tv_sec + (supplier
? CHECK_ACT_INTERVAL ? CHECK_ACT_INTERVAL
: CHECK_QUIET_INTERVAL); : CHECK_QUIET_INTERVAL);

View File

@ -36,7 +36,7 @@ static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$"; static char rcsid[] = "$NetBSD$";
#endif #endif
#ident "$Revision: 1.19 $" #ident "$Revision: 1.20 $"
#include "defs.h" #include "defs.h"
@ -103,26 +103,20 @@ read_rip(int sock,
if (aifp == 0) { if (aifp == 0) {
aifp = ifwithname(inbuf.ifname, 0); aifp = ifwithname(inbuf.ifname, 0);
if (aifp == 0) { if (aifp == 0) {
/* maybe it is a new interface */ msglim(&bad_name, from.sin_addr.s_addr,
ifinit(); "impossible interface name %.*s",
aifp = ifwithname(inbuf.ifname, 0); IFNAMSIZ, inbuf.ifname);
if (aifp == 0) { } else if (((aifp->int_if_flags & IFF_POINTOPOINT)
msglim(&bad_name, from.sin_addr.s_addr, && aifp->int_dstaddr!=from.sin_addr.s_addr)
"impossible interface name" || (!(aifp->int_if_flags & IFF_POINTOPOINT)
" %.*s", IFNAMSIZ, && !on_net(from.sin_addr.s_addr,
inbuf.ifname); aifp->int_net,
} aifp->int_mask))) {
} /* If it came via the wrong interface, do not
* trust it.
/* If it came via the wrong interface, do not */
* trust it.
*/
if (((aifp->int_if_flags & IFF_POINTOPOINT)
&& aifp->int_dstaddr != from.sin_addr.s_addr)
|| (!(aifp->int_if_flags & IFF_POINTOPOINT)
&& !on_net(from.sin_addr.s_addr,
aifp->int_net, aifp->int_mask)))
aifp = 0; aifp = 0;
}
} }
#else #else
aifp = iflookup(from.sin_addr.s_addr); aifp = iflookup(from.sin_addr.s_addr);

View File

@ -22,10 +22,10 @@
* documentation and/or software. * documentation and/or software.
*/ */
#ident "$Revision: 1.3 $" #ident "$Revision: 1.4 $"
#ifdef sgi
#include <strings.h> #include <strings.h>
#ifdef sgi
#include <bstring.h> #include <bstring.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>

View File

@ -36,7 +36,7 @@ static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$"; static char rcsid[] = "$NetBSD$";
#endif #endif
#ident "$Revision: 1.19 $" #ident "$Revision: 1.20 $"
#include "defs.h" #include "defs.h"
#include <netinet/in_systm.h> #include <netinet/in_systm.h>
@ -916,10 +916,12 @@ void
read_d(void) read_d(void)
{ {
static struct msg_limit bad_asize, bad_len; static struct msg_limit bad_asize, bad_len;
#ifdef USE_PASSIFNAME
static struct msg_limit bad_name;
#endif
struct sockaddr_in from; struct sockaddr_in from;
int n, fromlen, cc, hlen; int n, fromlen, cc, hlen;
struct { struct {
#undef USE_PASSIFNAME /* it is too bad it does not work on raw sockets */
#ifdef USE_PASSIFNAME #ifdef USE_PASSIFNAME
char ifname[IFNAMSIZ]; char ifname[IFNAMSIZ];
#endif #endif
@ -961,16 +963,10 @@ read_d(void)
#ifdef USE_PASSIFNAME #ifdef USE_PASSIFNAME
ifp = ifwithname(buf.ifname, 0); ifp = ifwithname(buf.ifname, 0);
if (ifp == 0) { if (ifp == 0)
/* maybe it is a new interface */ msglim(&bad_name, from.sin_addr.s_addr,
ifinit(); "impossible rdisc if_ name %.*s",
ifp = ifwithname(buf.ifname, 0); IFNAMSIZ, buf.ifname);
if (ifp == 0) {
msglim(&bad_name, from.sin_addr.s_addr,
"impossible rdisc if_ name %.*s",
IFNAMSIZ, buf.ifname);
}
}
#else #else
/* If we could tell the interface on which a packet from /* If we could tell the interface on which a packet from
* address 0 arrived, we could deal with such solicitations. * address 0 arrived, we could deal with such solicitations.
@ -978,15 +974,13 @@ read_d(void)
ifp = ((from.sin_addr.s_addr == 0) ifp = ((from.sin_addr.s_addr == 0)
? 0 : iflookup(from.sin_addr.s_addr)); ? 0 : iflookup(from.sin_addr.s_addr));
#endif #endif
ifp = ck_icmp("Recv", ifp = ck_icmp("Recv", from.sin_addr.s_addr, ifp,
from.sin_addr.s_addr, ifp, buf.pkt.ip.ip_dst.s_addr, p, cc);
buf.pkt.ip.ip_dst.s_addr,
p, cc);
if (ifp == 0) if (ifp == 0)
continue; continue;
if (ifwithaddr(from.sin_addr.s_addr, 0, 0)) { if (ifwithaddr(from.sin_addr.s_addr, 0, 0)) {
trace_pkt(" discard our own Router Discovery" trace_pkt(" "
" message"); "discard our own Router Discovery message");
continue; continue;
} }

View File

@ -22,10 +22,10 @@
* documentation and/or software. * documentation and/or software.
*/ */
#ident "$Revision: 1.3 $" #ident "$Revision: 1.4 $"
#ifdef sgi
#include <strings.h> #include <strings.h>
#ifdef sgi
#include <bstring.h> #include <bstring.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>

View File

@ -40,7 +40,7 @@ static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$"; static char rcsid[] = "$NetBSD$";
#endif #endif
#ident "$Revision: 1.10 $" #ident "$Revision: 1.11 $"
#include <sys/param.h> #include <sys/param.h>
#include <sys/protosw.h> #include <sys/protosw.h>
@ -117,7 +117,7 @@ static u_int std_mask(u_int);
static int parse_quote(char **, char *, char *, char *, int); static int parse_quote(char **, char *, char *, char *, int);
int void
main(int argc, main(int argc,
char *argv[]) char *argv[])
{ {
@ -255,7 +255,7 @@ main(int argc,
if ((not_trace && trace) || argc == 0) { if ((not_trace && trace) || argc == 0) {
usage: fprintf(stderr, "%s: [-np1v] [-r tgt_rt] [-w wtime]" usage: fprintf(stderr, "%s: [-np1v] [-r tgt_rt] [-w wtime]"
" [-a type=passwd] host1 [host2 ...]\n" " [-a type=passwd] host1 [host2 ...]\n"
"or\t-t {on=filename|more|off|on=dump/../table}" "or\t-t {on=filename|more|off|dump}"
" host1 [host2 ...]\n", " host1 [host2 ...]\n",
pgmname); pgmname);
exit(1); exit(1);

View File

@ -36,7 +36,7 @@ static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$"; static char rcsid[] = "$NetBSD$";
#endif #endif
#ident "$Revision: 1.16 $" #ident "$Revision: 1.17 $"
#define RIPCMDS #define RIPCMDS
#include "defs.h" #include "defs.h"