From fabb33431caf0238489edd42b81ad43b3f62f8ad Mon Sep 17 00:00:00 2001 From: is Date: Thu, 2 Oct 1997 19:41:56 +0000 Subject: [PATCH] Reimplement a test for broadcast addresses advertized, which was left out when rewriting the ARP system. --- sys/net/if.c | 3 ++- sys/net/if.h | 3 ++- sys/net/if_arcsubr.c | 3 ++- sys/net/if_ethersubr.c | 3 ++- sys/net/if_fddisubr.c | 3 ++- sys/netinet/if_arp.c | 21 ++++++++++----------- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index a9bd50675c9d..1a1897139486 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.41 1997/08/29 00:57:54 thorpej Exp $ */ +/* $NetBSD: if.c,v 1.42 1997/10/02 19:41:56 is Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -132,6 +132,7 @@ if_attach(ifp) sdl->sdl_data[--namelen] = 0xff; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; + ifp->if_broadcastaddr = 0; /* reliably crash if used uninitialized */ } /* * Locate an interface based on a complete address. diff --git a/sys/net/if.h b/sys/net/if.h index d41b5fae4674..ea4caf4d2b3c 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $NetBSD: if.h,v 1.28 1997/04/08 21:29:26 chuck Exp $ */ +/* $NetBSD: if.h,v 1.29 1997/10/02 19:41:57 is Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -145,6 +145,7 @@ struct ifnet { /* and the entries */ int ifq_drops; } if_snd; /* output queue */ struct sockaddr_dl *if_sadl; /* pointer to our sockaddr_dl */ + u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ }; #define if_mtu if_data.ifi_mtu #define if_type if_data.ifi_type diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index afa5ac3e66d9..f958ccc32f27 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arcsubr.c,v 1.15 1997/03/23 01:22:35 is Exp $ */ +/* $NetBSD: if_arcsubr.c,v 1.16 1997/10/02 19:41:58 is Exp $ */ /* * Copyright (c) 1994, 1995 Ignatios Souvatzis @@ -648,4 +648,5 @@ arc_ifattach(ifp, lla) sdl->sdl_alen = ifp->if_addrlen; bcopy((caddr_t)&lla, LLADDR(sdl), ifp->if_addrlen); } + ifp->if_broadcastaddr = &arcbroadcastaddr; } diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index c5f2b73e0447..8c1a437a7b4c 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.25 1997/04/03 18:48:28 christos Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.26 1997/10/02 19:41:59 is Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -648,6 +648,7 @@ ether_ifattach(ifp, lla) bcopy((caddr_t)lla, LLADDR(sdl), ifp->if_addrlen); } LIST_INIT(&((struct ethercom *)ifp)->ec_multiaddrs); + ifp->if_broadcastaddr = etherbroadcastaddr; } u_char ether_ipmulticast_min[6] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 }; diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 565cc32e714a..e529d1407039 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fddisubr.c,v 1.14 1997/04/03 21:07:42 christos Exp $ */ +/* $NetBSD: if_fddisubr.c,v 1.15 1997/10/02 19:42:00 is Exp $ */ /* * Copyright (c) 1995, 1996 @@ -772,6 +772,7 @@ fddi_ifattach(ifp) sdl->sdl_alen = ifp->if_addrlen; bcopy(lla, LLADDR(sdl), ifp->if_addrlen); } + ifp->if_broadcastaddr = fddibroadcastaddr; #else for (ifa = ifp->if_addrlist; ifa != NULL; ifa = ifa->ifa_next) if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && diff --git a/sys/netinet/if_arp.c b/sys/netinet/if_arp.c index b2209c4cce13..92169b21424c 100644 --- a/sys/netinet/if_arp.c +++ b/sys/netinet/if_arp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.40 1997/08/29 16:02:41 gwr Exp $ */ +/* $NetBSD: if_arp.c,v 1.41 1997/10/02 19:42:02 is Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1993 @@ -506,16 +506,15 @@ in_arpinput(m) if (!bcmp((caddr_t)ar_sha(ah), LLADDR(ifp->if_sadl), ifp->if_data.ifi_addrlen)) goto out; /* it's from me, ignore it. */ -/* - * XXX - * if (!bcmp((caddr_t)ar_sha(ah), (caddr_t)etherbroadcastaddr, - * sizeof (ea->arp_sha))) { - * log(LOG_ERR, - * "arp: ether address is broadcast for IP address %x!\n", - * ntohl(isaddr.s_addr)); - * goto out; - * } - */ + + if (!bcmp((caddr_t)ar_sha(ah), (caddr_t)ifp->if_broadcastaddr, + ifp->if_data.ifi_addrlen)) { + log(LOG_ERR, + "%s: arp: link address is broadcast for IP address %x!\n", + ifp->if_xname, ntohl(isaddr.s_addr)); + goto out; + } + if (in_hosteq(isaddr, myaddr)) { log(LOG_ERR, "duplicate IP address %08x sent from link address %s\n",