aboutsummaryrefslogtreecommitdiff
path: root/sbin
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
commita105b819c88bd562864ea91096e968fb20c55b82 (patch)
treea9a60eecd4dc3b282d12f4f353246354a9446342 /sbin
parentb4ccb10ee321041fe9f2d2e01e3287760e0af8a8 (diff)
parent337e72d0e59a6e844679b70ddb1df6f93f7fcbfe (diff)
downloadsrc-a105b819c88bd562864ea91096e968fb20c55b82.tar.gz
src-a105b819c88bd562864ea91096e968fb20c55b82.zip
This commit was generated by cvs2svn to compensate for changes in r20606,
which included commits to RCS files with non-trunk default branches.
Notes
Notes: svn path=/head/; revision=20607
Diffstat (limited to 'sbin')
-rw-r--r--sbin/routed/if.c50
-rw-r--r--sbin/routed/input.c34
-rw-r--r--sbin/routed/rdisc.c30
-rw-r--r--sbin/routed/trace.c2
4 files changed, 60 insertions, 56 deletions
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/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/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"