Cleanup loopback interface support.

Reviewed by:	wollman
This commit is contained in:
Paul Traina 1995-04-26 18:10:58 +00:00
parent ef6304d8c6
commit f5fea3ddc9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8090
9 changed files with 47 additions and 41 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
* $Id: if.h,v 1.15 1994/12/30 06:46:21 davidg Exp $
* $Id: if.h,v 1.16 1995/03/16 18:14:24 bde Exp $
*/
#ifndef _NET_IF_H_
@ -350,7 +350,7 @@ struct ifconf {
(ifa)->ifa_refcnt--;
extern struct ifnet *ifnet;
extern struct ifnet loif;
extern struct ifnet loif[];
void ether_ifattach __P((struct ifnet *));
void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));

View File

@ -31,12 +31,14 @@
* SUCH DAMAGE.
*
* @(#)if_loop.c 8.1 (Berkeley) 6/10/93
* $Id: if_loop.c,v 1.7 1995/03/04 04:28:50 davidg Exp $
* $Id: if_loop.c,v 1.8 1995/03/20 19:20:41 wollman Exp $
*/
/*
* Loopback interface driver for protocol testing and timing.
*/
#include "loop.h"
#if NLOOP > 0
#include <sys/param.h>
#include <sys/systm.h>
@ -79,26 +81,31 @@
#define LOMTU 16384
#endif
struct ifnet loif;
struct ifnet loif[NLOOP];
/* ARGSUSED */
void
loopattach(void)
{
register struct ifnet *ifp = &loif;
register struct ifnet *ifp;
register int i = 0;
ifp->if_name = "lo";
ifp->if_mtu = LOMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
ifp->if_ioctl = loioctl;
ifp->if_output = looutput;
ifp->if_type = IFT_LOOP;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
if_attach(ifp);
for (ifp = loif; i < NLOOP; ifp++) {
ifp->if_name = "lo";
ifp->if_next = NULL;
ifp->if_unit = i++;
ifp->if_mtu = LOMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
ifp->if_ioctl = loioctl;
ifp->if_output = looutput;
ifp->if_type = IFT_LOOP;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
if_attach(ifp);
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int));
bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int));
#endif
}
}
PSEUDO_SET(loopattach, if_loop);
@ -117,7 +124,7 @@ looutput(ifp, m, dst, rt)
panic("looutput no HDR");
ifp->if_lastchange = time;
#if NBPFILTER > 0
if (loif.if_bpf) {
if (ifp->if_bpf) {
/*
* We need to prepend the address family as
* a four byte field. Cons up a dummy header
@ -132,7 +139,7 @@ looutput(ifp, m, dst, rt)
m0.m_len = 4;
m0.m_data = (char *)&af;
bpf_mtap(loif.if_bpf, &m0);
bpf_mtap(ifp->if_bpf, &m0);
}
#endif
m->m_pkthdr.rcvif = ifp;
@ -251,3 +258,4 @@ loioctl(ifp, cmd, data)
}
return (error);
}
#endif /* NLOOP > 0 */

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_x25subr.c 8.1 (Berkeley) 6/10/93
* $Id: if_x25subr.c,v 1.3 1994/12/13 22:32:12 wollman Exp $
* $Id: if_x25subr.c,v 1.4 1995/02/15 06:29:47 jkh Exp $
*/
#include <sys/param.h>
@ -74,7 +74,6 @@ int tp_incoming();
#include <netiso/iso_var.h>
#endif
extern struct ifnet loif;
struct llinfo_x25 llinfo_x25 = {&llinfo_x25, &llinfo_x25};
#ifndef _offsetof
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ether.c 8.1 (Berkeley) 6/10/93
* $Id: if_ether.c,v 1.12 1995/03/16 17:32:26 wollman Exp $
* $Id: if_ether.c,v 1.13 1995/03/16 18:14:49 bde Exp $
*/
/*
@ -216,7 +216,7 @@ arp_rtrequest(req, rt, sa)
Bcopy(((struct arpcom *)rt->rt_ifp)->ac_enaddr,
LLADDR(SDL(gate)), SDL(gate)->sdl_alen = 6);
if (useloopback)
rt->rt_ifp = &loif;
rt->rt_ifp = loif;
}
break;

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)igmp.c 8.1 (Berkeley) 7/19/93
* $Id: igmp.c,v 1.7 1995/02/16 00:27:41 wollman Exp $
* $Id: igmp.c,v 1.8 1995/03/16 18:14:49 bde Exp $
*/
/*
@ -212,7 +212,7 @@ igmp_input(m, iphlen)
case IGMP_HOST_MEMBERSHIP_QUERY:
++igmpstat.igps_rcv_queries;
if (ifp == &loif)
if (ifp->if_flags & IFF_LOOPBACK)
break;
if (igmp->igmp_code == 0) {
@ -348,7 +348,7 @@ igmp_input(m, iphlen)
case IGMP_HOST_MEMBERSHIP_REPORT:
++igmpstat.igps_rcv_reports;
if (ifp == &loif)
if (ifp->if_flags & IFF_LOOPBACK)
break;
if (!IN_MULTICAST(ntohl(igmp->igmp_group.s_addr)) ||
@ -410,7 +410,7 @@ igmp_input(m, iphlen)
*/
++igmpstat.igps_rcv_reports;
if (ifp == &loif)
if (ifp->if_flags & IFF_LOOPBACK)
break;
if (!IN_MULTICAST(ntohl(igmp->igmp_group.s_addr)) ||
@ -474,7 +474,7 @@ igmp_joingroup(inm)
inm->inm_state = IGMP_IDLE_MEMBER;
if (inm->inm_addr.s_addr == igmp_all_hosts_group ||
inm->inm_ifp == &loif)
inm->inm_ifp->if_flags & IFF_LOOPBACK)
inm->inm_timer = 0;
else {
igmp_sendpkt(inm,fill_rti(inm));
@ -497,7 +497,7 @@ igmp_leavegroup(inm)
case IGMP_DELAYING_MEMBER:
case IGMP_IDLE_MEMBER:
if (!(inm->inm_addr.s_addr == igmp_all_hosts_group ||
inm->inm_ifp == &loif))
inm->inm_ifp->if_flags & IFF_LOOPBACK))
if (inm->inm_rti->type != IGMP_OLD_ROUTER)
igmp_sendleave(inm);
break;
@ -587,7 +587,7 @@ igmp_sendpkt(inm, type)
return;
}
m->m_pkthdr.rcvif = &loif;
m->m_pkthdr.rcvif = loif;
m->m_pkthdr.len = sizeof(struct ip) + IGMP_MINLEN;
MH_ALIGN(m, IGMP_MINLEN + sizeof(struct ip));
m->m_data += sizeof(struct ip);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in.c 8.2 (Berkeley) 11/15/93
* $Id: in.c,v 1.11 1995/03/23 18:14:40 wollman Exp $
* $Id: in.c,v 1.12 1995/04/25 19:50:20 wollman Exp $
*/
#include <sys/param.h>
@ -259,7 +259,7 @@ in_control(so, cmd, data, ifp)
ia->ia_broadaddr.sin_family = AF_INET;
}
ia->ia_ifp = ifp;
if (ifp != &loif)
if (!(ifp->if_flags & IFF_LOOPBACK))
in_interfaces++;
}
break;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_output.c 8.3 (Berkeley) 1/21/94
* $Id: ip_output.c,v 1.15 1995/03/20 18:31:51 wollman Exp $
* $Id: ip_output.c,v 1.16 1995/04/09 01:29:22 davidg Exp $
*/
#include <sys/param.h>
@ -259,7 +259,7 @@ ip_output(m0, opt, ro, flags, imo)
* loop back a copy if this host actually belongs to the
* destination group on the loopback interface.
*/
if (ip->ip_ttl == 0 || ifp == &loif) {
if (ip->ip_ttl == 0 || ifp->if_flags & IFF_LOOPBACK) {
m_freem(m);
goto done;
}
@ -1124,7 +1124,8 @@ ip_freemoptions(imo)
* Routine called from ip_output() to loop back a copy of an IP multicast
* packet to the input queue of a specified interface. Note that this
* calls the output routine of the loopback "driver", but with an interface
* pointer that might NOT be &loif -- easier than replicating that code here.
* pointer that might NOT be a loopback interface -- evil, but easier than
* replicating that code here.
*/
static void
ip_mloopback(ifp, m, dst)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_eon.c 8.1 (Berkeley) 6/10/93
* $Id$
* $Id: if_eon.c,v 1.2 1994/08/02 07:50:23 davidg Exp $
*/
/***********************************************************
@ -61,7 +61,7 @@ SOFTWARE.
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
*/
/*
* $Header: /home/ncvs/src/sys/netiso/if_eon.c,v 1.1.1.1 1994/05/24 10:07:13 rgrimes Exp $
* $Header: /home/ncvs/src/sys/netiso/if_eon.c,v 1.2 1994/08/02 07:50:23 davidg Exp $
* $Source: /home/ncvs/src/sys/netiso/if_eon.c,v $
*
* EON rfc
@ -108,7 +108,6 @@ SOFTWARE.
#include <netiso/eonvar.h>
extern struct timeval time;
extern struct ifnet loif;
#define EOK 0
@ -286,7 +285,7 @@ register struct sockaddr *gate;
case RTM_ADD:
case RTM_RESOLVE:
rt->rt_rmx.rmx_mtu = loif.if_mtu; /* unless better below */
rt->rt_rmx.rmx_mtu = loif->if_mtu; /* unless better below */
R_Malloc(el, struct eon_llinfo *, sizeof(*el));
rt->rt_llinfo = (caddr_t)el;
if (el == 0)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)iso.c 8.2 (Berkeley) 11/15/93
* $Id$
* $Id: iso.c,v 1.2 1994/08/02 07:50:26 davidg Exp $
*/
/***********************************************************
@ -61,7 +61,7 @@ SOFTWARE.
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
*/
/*
* $Header: /home/ncvs/src/sys/netiso/iso.c,v 1.1.1.1 1994/05/24 10:07:13 rgrimes Exp $
* $Header: /home/ncvs/src/sys/netiso/iso.c,v 1.2 1994/08/02 07:50:26 davidg Exp $
* $Source: /home/ncvs/src/sys/netiso/iso.c,v $
*
* iso.c: miscellaneous routines to support the iso address family
@ -93,7 +93,6 @@ SOFTWARE.
#ifdef ISO
int iso_interfaces = 0; /* number of external interfaces */
extern struct ifnet loif; /* loopback interface */
int ether_output();
void llc_rtrequest();
@ -480,7 +479,7 @@ iso_control(so, cmd, data, ifp)
ia->ia_ifa.ifa_netmask
= (struct sockaddr *)&ia->ia_sockmask;
ia->ia_ifp = ifp;
if (ifp != &loif)
if (!(ifp->if_flags & IFF_LOOPBACK))
iso_interfaces++;
}
break;