summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2024-10-16 11:12:32 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2024-10-16 11:12:32 +0000
commit3fd4bd169476536c35b35bc8909aa053ca2f6921 (patch)
tree3b7e8ddb7c112b16e32957ddc65a3bebc5f11191 /sys/net
parent5c34a43079c63e29de474d12232db914b4abedf3 (diff)
cut tun_init() out, it does pointless work.
tun_init turns interface/stack config into a set of flags that tun(4) keeps in tun_softc sc_flags, but never uses. ok miod@ kn@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_tun.c62
1 files changed, 3 insertions, 59 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 577b018c65f..bd11b2b28e5 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.242 2024/10/16 11:03:55 dlg Exp $ */
+/* $OpenBSD: if_tun.c,v 1.243 2024/10/16 11:12:31 dlg Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -123,7 +123,6 @@ int tap_clone_create(struct if_clone *, int);
int tun_create(struct if_clone *, int, int);
int tun_clone_destroy(struct ifnet *);
void tun_wakeup(struct tun_softc *);
-int tun_init(struct tun_softc *);
void tun_start(struct ifnet *);
int filt_tunread(struct knote *, long);
int filt_tunwrite(struct knote *, long);
@@ -523,61 +522,6 @@ tun_dev_close(dev_t dev, struct proc *p)
return (error);
}
-int
-tun_init(struct tun_softc *sc)
-{
- struct ifnet *ifp = &sc->sc_if;
- struct ifaddr *ifa;
-
- TUNDEBUG(("%s: tun_init\n", ifp->if_xname));
-
- ifp->if_flags |= IFF_UP | IFF_RUNNING;
-
- sc->sc_flags &= ~(TUN_IASET|TUN_DSTADDR|TUN_BRDADDR);
- TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
- if (ifa->ifa_addr->sa_family == AF_INET) {
- struct sockaddr_in *sin;
-
- sin = satosin(ifa->ifa_addr);
- if (sin && sin->sin_addr.s_addr)
- sc->sc_flags |= TUN_IASET;
-
- if (ifp->if_flags & IFF_POINTOPOINT) {
- sin = satosin(ifa->ifa_dstaddr);
- if (sin && sin->sin_addr.s_addr)
- sc->sc_flags |= TUN_DSTADDR;
- } else
- sc->sc_flags &= ~TUN_DSTADDR;
-
- if (ifp->if_flags & IFF_BROADCAST) {
- sin = satosin(ifa->ifa_broadaddr);
- if (sin && sin->sin_addr.s_addr)
- sc->sc_flags |= TUN_BRDADDR;
- } else
- sc->sc_flags &= ~TUN_BRDADDR;
- }
-#ifdef INET6
- if (ifa->ifa_addr->sa_family == AF_INET6) {
- struct sockaddr_in6 *sin6;
-
- sin6 = satosin6(ifa->ifa_addr);
- if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
- sc->sc_flags |= TUN_IASET;
-
- if (ifp->if_flags & IFF_POINTOPOINT) {
- sin6 = satosin6(ifa->ifa_dstaddr);
- if (sin6 &&
- !IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
- sc->sc_flags |= TUN_DSTADDR;
- } else
- sc->sc_flags &= ~TUN_DSTADDR;
- }
-#endif /* INET6 */
- }
-
- return (0);
-}
-
/*
* Process an ioctl request.
*/
@@ -590,8 +534,8 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
switch (cmd) {
case SIOCSIFADDR:
- tun_init(sc);
- break;
+ SET(ifp->if_flags, IFF_UP);
+ /* FALLTHROUGH */
case SIOCSIFFLAGS:
if (ISSET(ifp->if_flags, IFF_UP))
SET(ifp->if_flags, IFF_RUNNING);