aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1996-12-17 21:07:05 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1996-12-17 21:07:05 +0000
commit337e72d0e59a6e844679b70ddb1df6f93f7fcbfe (patch)
treef53ec81502ac44b44c86ac510cf893890e08e026
parent71965874ee69f5093d3dc664d26fa81eadf09523 (diff)
downloadsrc-337e72d0e59a6e844679b70ddb1df6f93f7fcbfe.tar.gz
src-337e72d0e59a6e844679b70ddb1df6f93f7fcbfe.zip
Latest routed from Vern Schryver. This is supposed to fixvendor/SGI/vjs_961217
Andrey's rtquery problem. Submitted by: Vernon J. Schryver <vjs@mica.denver.sgi.com>
Notes
Notes: svn path=/vendor/SGI/dist_v_2_21/; revision=20606 svn path=/vendor/SGI/vjs_961217/; revision=20608; tag=vendor/SGI/vjs_961217
-rw-r--r--sbin/routed/defs.h7
-rw-r--r--sbin/routed/if.c50
-rw-r--r--sbin/routed/input.c34
-rw-r--r--sbin/routed/md5.c4
-rw-r--r--sbin/routed/rdisc.c30
-rw-r--r--sbin/routed/rtquery/md5.c4
-rw-r--r--sbin/routed/rtquery/rtquery.c6
-rw-r--r--sbin/routed/trace.c2
8 files changed, 69 insertions, 68 deletions
diff --git a/sbin/routed/defs.h b/sbin/routed/defs.h
index 3e52ab7db603..9e70add9fe85 100644
--- a/sbin/routed/defs.h
+++ b/sbin/routed/defs.h
@@ -36,7 +36,7 @@
*/
#ifndef __NetBSD__
-#ident "$Revision: 1.19 $"
+#ident "$Revision: 1.21 $"
#endif
/* Definitions for RIPv2 routing process.
@@ -77,6 +77,7 @@
#include <stdarg.h>
#include <syslog.h>
#include <time.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -95,10 +96,6 @@
#define RIPVERSION RIPv2
#include <protocols/routed.h>
-#ifdef sgi
-#define USE_PASSIFNAME
-#endif
-
/* Type of an IP address.
* Some systems do not like to pass structures, so do not use in_addr.
diff --git a/sbin/routed/if.c b/sbin/routed/if.c
index 8a42344bd8ae..860c07537ac7 100644
--- a/sbin/routed/if.c
+++ b/sbin/routed/if.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)if.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.21 $"
+#ident "$Revision: 1.22 $"
#include "defs.h"
#include "pathnames.h"
@@ -60,7 +60,7 @@ struct interface *remote_if; /* remote interfaces */
/* hash for physical interface names.
* 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
struct interface *nhash[NHASH_LEN];
@@ -71,11 +71,14 @@ int foundloopback; /* valid flag for loopaddr */
naddr loopaddr; /* our address on loopback */
struct timeval ifinit_timer;
+static struct timeval last_ifinit;
int have_ripv1_out; /* have a RIPv1 interface */
int have_ripv1_in;
+/* Link a new interface into the lists and hash tables.
+ */
void
if_link(struct interface *ifp)
{
@@ -117,6 +120,7 @@ if_link(struct interface *ifp)
i += *p;
hifp = &nhash[i % NHASH_LEN];
if (ifp->int_state & IS_ALIAS) {
+ /* put aliases on the end of the hash chain */
while (*hifp != 0)
hifp = &(*hifp)->int_nhash;
}
@@ -176,19 +180,32 @@ ifwithname(char *name, /* "ec0" or whatever */
int i;
char *p;
- for (i = 0, p = name; *p != '\0'; p++)
- i += *p;
- for (ifp = nhash[i % NHASH_LEN]; ifp != 0; ifp = ifp->int_nhash) {
- /* If the network address is not specified,
- * ignore any alias interfaces. Otherwise, look
- * for the interface with the target name and address.
+ for (;;) {
+ for (i = 0, p = name; *p != '\0'; p++)
+ i += *p;
+ ifp = nhash[i % NHASH_LEN];
+
+ 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)
- && ((addr == 0 && !(ifp->int_state & IS_ALIAS))
- || (ifp->int_addr == addr)))
- return ifp;
+ if (last_ifinit.tv_sec == now.tv_sec
+ && last_ifinit.tv_usec == now.tv_usec)
+ return 0;
+ ifinit();
}
- return 0;
}
@@ -214,7 +231,6 @@ struct interface *
iflookup(naddr addr)
{
struct interface *ifp, *maybe;
- static struct timeval retried;
maybe = 0;
for (;;) {
@@ -239,15 +255,14 @@ iflookup(naddr addr)
}
if (maybe != 0
- || (retried.tv_sec == now.tv_sec
- && retried.tv_usec == now.tv_usec))
+ || (last_ifinit.tv_sec == now.tv_sec
+ && last_ifinit.tv_usec == now.tv_usec))
return maybe;
/* If there is no known interface, maybe there is a
* new interface. So just once look for new interfaces.
*/
ifinit();
- retried = now;
}
}
@@ -654,6 +669,7 @@ ifinit(void)
#endif
+ last_ifinit = now;
ifinit_timer.tv_sec = now.tv_sec + (supplier
? CHECK_ACT_INTERVAL
: CHECK_QUIET_INTERVAL);
diff --git a/sbin/routed/input.c b/sbin/routed/input.c
index fb5dbf57f231..100bd3df0c4f 100644
--- a/sbin/routed/input.c
+++ b/sbin/routed/input.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.19 $"
+#ident "$Revision: 1.20 $"
#include "defs.h"
@@ -103,26 +103,20 @@ read_rip(int sock,
if (aifp == 0) {
aifp = ifwithname(inbuf.ifname, 0);
if (aifp == 0) {
- /* maybe it is a new interface */
- ifinit();
- aifp = ifwithname(inbuf.ifname, 0);
- if (aifp == 0) {
- msglim(&bad_name, from.sin_addr.s_addr,
- "impossible interface name"
- " %.*s", IFNAMSIZ,
- inbuf.ifname);
- }
- }
-
- /* 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)))
+ msglim(&bad_name, from.sin_addr.s_addr,
+ "impossible interface name %.*s",
+ IFNAMSIZ, inbuf.ifname);
+ } else 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))) {
+ /* If it came via the wrong interface, do not
+ * trust it.
+ */
aifp = 0;
+ }
}
#else
aifp = iflookup(from.sin_addr.s_addr);
diff --git a/sbin/routed/md5.c b/sbin/routed/md5.c
index c24aa5ad7503..dc52a8fdc96e 100644
--- a/sbin/routed/md5.c
+++ b/sbin/routed/md5.c
@@ -22,10 +22,10 @@
* documentation and/or software.
*/
-#ident "$Revision: 1.3 $"
+#ident "$Revision: 1.4 $"
-#ifdef sgi
#include <strings.h>
+#ifdef sgi
#include <bstring.h>
#endif
#include <sys/types.h>
diff --git a/sbin/routed/rdisc.c b/sbin/routed/rdisc.c
index 1e9f42d17b03..bccb3d9374dd 100644
--- a/sbin/routed/rdisc.c
+++ b/sbin/routed/rdisc.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)rdisc.c 8.1 (Berkeley) x/y/95";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.19 $"
+#ident "$Revision: 1.20 $"
#include "defs.h"
#include <netinet/in_systm.h>
@@ -916,10 +916,12 @@ void
read_d(void)
{
static struct msg_limit bad_asize, bad_len;
+#ifdef USE_PASSIFNAME
+ static struct msg_limit bad_name;
+#endif
struct sockaddr_in from;
int n, fromlen, cc, hlen;
struct {
-#undef USE_PASSIFNAME /* it is too bad it does not work on raw sockets */
#ifdef USE_PASSIFNAME
char ifname[IFNAMSIZ];
#endif
@@ -961,16 +963,10 @@ read_d(void)
#ifdef USE_PASSIFNAME
ifp = ifwithname(buf.ifname, 0);
- if (ifp == 0) {
- /* maybe it is a new interface */
- ifinit();
- ifp = ifwithname(buf.ifname, 0);
- if (ifp == 0) {
- msglim(&bad_name, from.sin_addr.s_addr,
- "impossible rdisc if_ name %.*s",
- IFNAMSIZ, buf.ifname);
- }
- }
+ if (ifp == 0)
+ msglim(&bad_name, from.sin_addr.s_addr,
+ "impossible rdisc if_ name %.*s",
+ IFNAMSIZ, buf.ifname);
#else
/* If we could tell the interface on which a packet from
* address 0 arrived, we could deal with such solicitations.
@@ -978,15 +974,13 @@ read_d(void)
ifp = ((from.sin_addr.s_addr == 0)
? 0 : iflookup(from.sin_addr.s_addr));
#endif
- ifp = ck_icmp("Recv",
- from.sin_addr.s_addr, ifp,
- buf.pkt.ip.ip_dst.s_addr,
- p, cc);
+ ifp = ck_icmp("Recv", from.sin_addr.s_addr, ifp,
+ buf.pkt.ip.ip_dst.s_addr, p, cc);
if (ifp == 0)
continue;
if (ifwithaddr(from.sin_addr.s_addr, 0, 0)) {
- trace_pkt(" discard our own Router Discovery"
- " message");
+ trace_pkt(" "
+ "discard our own Router Discovery message");
continue;
}
diff --git a/sbin/routed/rtquery/md5.c b/sbin/routed/rtquery/md5.c
index c24aa5ad7503..dc52a8fdc96e 100644
--- a/sbin/routed/rtquery/md5.c
+++ b/sbin/routed/rtquery/md5.c
@@ -22,10 +22,10 @@
* documentation and/or software.
*/
-#ident "$Revision: 1.3 $"
+#ident "$Revision: 1.4 $"
-#ifdef sgi
#include <strings.h>
+#ifdef sgi
#include <bstring.h>
#endif
#include <sys/types.h>
diff --git a/sbin/routed/rtquery/rtquery.c b/sbin/routed/rtquery/rtquery.c
index 5417d06c73ee..82e768c0b235 100644
--- a/sbin/routed/rtquery/rtquery.c
+++ b/sbin/routed/rtquery/rtquery.c
@@ -40,7 +40,7 @@ static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.10 $"
+#ident "$Revision: 1.11 $"
#include <sys/param.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);
-int
+void
main(int argc,
char *argv[])
{
@@ -255,7 +255,7 @@ main(int argc,
if ((not_trace && trace) || argc == 0) {
usage: fprintf(stderr, "%s: [-np1v] [-r tgt_rt] [-w wtime]"
" [-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",
pgmname);
exit(1);
diff --git a/sbin/routed/trace.c b/sbin/routed/trace.c
index a171ce86dad9..28c65f3f136d 100644
--- a/sbin/routed/trace.c
+++ b/sbin/routed/trace.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.16 $"
+#ident "$Revision: 1.17 $"
#define RIPCMDS
#include "defs.h"