Return to BSD News archive
Xref: sserve comp.os.386bsd.development:694 comp.os.386bsd.misc:318
Path: sserve!newshost.anu.edu.au!munnari.oz.au!goanna!escargot!otto!davidb
From: davidb@otto.bf.rmit.oz.au (David Burren [Athos])
Newsgroups: comp.os.386bsd.development,comp.os.386bsd.misc
Subject: Multiple loopback interfaces [patch]
Message-ID: <davidb.736697638@otto>
Date: 6 May 93 14:13:58 GMT
Organization: Royal Melbourne Institute of Technology
Lines: 94
NNTP-Posting-Host: otto.bf.rmit.oz.au
In testing some networking protocols, and playing with configurations
where I wanted to have a single network interface (hardware) respond
to more than one IP address, I've found it very useful to have multiple
loopback interfaces defined.
With the following patch to /sys/net/if_loop.c, the loop.h file in
the kernel's compile directory is actually used.
Thus to define two loopbacks (lo0 and lo1) the kernel config file
just needs a line such as:
psuedo-device loop 2
I have been using this for a while, initially on 386bsd0.1 and
Ultrix 4.x (which unfortunately required a binary hack) and now on
NetBSD-0.8.
Hopefully others will find this useful also..
__
David Burren
davidb@otto.bf.rmit.oz.au (guest acct)
+61-3-634-3635
*** if_loop.c Sun May 2 21:18:42 1993
--- if_loop.c.orig Sun May 2 20:47:56 1993
***************
*** 45,52 ****
#include "ioctl.h"
#include "protosw.h"
- #include "loop.h"
-
#include "../net/if.h"
#include "../net/if_types.h"
#include "../net/netisr.h"
--- 45,50 ----
***************
*** 80,110 ****
#define LOMTU (1024+512)
! struct ifnet loif[NLOOP];
int looutput(), loioctl();
loattach()
{
! register int i;
! register struct ifnet *ifp;
! for (i = 0; i < NLOOP; i++)
! {
! ifp = &loif[i];
! ifp->if_unit = i;
! ifp->if_name = "lo";
! ifp->if_mtu = LOMTU;
! ifp->if_flags = IFF_LOOPBACK;
! 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(&lo_bpf, ifp, DLT_NULL, sizeof(u_int));
#endif
- }
}
looutput(ifp, m, dst, rt)
--- 78,102 ----
#define LOMTU (1024+512)
! struct ifnet loif;
int looutput(), loioctl();
loattach()
{
! register struct ifnet *ifp = &loif;
! ifp->if_name = "lo";
! ifp->if_mtu = LOMTU;
! ifp->if_flags = IFF_LOOPBACK;
! 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(&lo_bpf, ifp, DLT_NULL, sizeof(u_int));
#endif
}
looutput(ifp, m, dst, rt)