fixes from <brad@fcr.com> who claims it now works correctly

This commit is contained in:
deraadt 1994-05-03 23:02:07 +00:00
parent e5c1d566ef
commit 946453260a
2 changed files with 28 additions and 17 deletions

View File

@ -11,7 +11,7 @@
* UCL. This driver is based much more on read/write/select mode of
* operation though.
*
* $Id: if_tun.c,v 1.10 1994/02/28 07:16:10 andrew Exp $
* $Id: if_tun.c,v 1.11 1994/05/03 23:02:07 deraadt Exp $
*/
#include "tun.h"
@ -165,9 +165,15 @@ tunclose(dev, flag)
s = splimp();
if_down(ifp);
if (ifp->if_flags & IFF_RUNNING) {
rtinit(ifp->if_addrlist, (int)RTM_DELETE,
/* find internet addresses and delete routes */
register struct ifaddr *ifa;
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr->sa_family == AF_INET) {
rtinit(ifa, (int)RTM_DELETE,
tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
}
}
}
splx(s);
}
tp->tun_pgrp = 0;
@ -189,7 +195,8 @@ tuninit(unit)
ifp->if_flags |= IFF_UP | IFF_RUNNING;
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
if (ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *si;
si = (struct sockaddr_in *)ifa->ifa_addr;
@ -221,11 +228,13 @@ tunioctl(ifp, cmd, data, flag)
switch(cmd) {
case SIOCSIFADDR:
tuninit(ifp->if_unit);
TUNDEBUG("%s%d: address set\n",
ifp->if_name, ifp->if_unit);
break;
case SIOCSIFDSTADDR:
tp->tun_flags |= TUN_DSTADDR;
TUNDEBUG("%s%d: destination address set\n", ifp->if_name,
ifp->if_unit);
tuninit(ifp->if_unit);
TUNDEBUG("%s%d: destination address set\n",
ifp->if_name, ifp->if_unit);
break;
default:
error = EINVAL;

View File

@ -12,7 +12,7 @@
* operation though.
*
* from: $Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp
* $Id: if_tun.h,v 1.3 1993/12/13 14:27:01 deraadt Exp $
* $Id: if_tun.h,v 1.4 1994/05/03 23:02:09 deraadt Exp $
*/
#ifndef _NET_IF_TUN_H_
@ -25,10 +25,12 @@ struct tun_softc {
#define TUN_RCOLL 0x0004
#define TUN_IASET 0x0008
#define TUN_DSTADDR 0x0010
#define TUN_READY 0x0020
#define TUN_RWAIT 0x0040
#define TUN_ASYNC 0x0080
#define TUN_NBIO 0x0100
#define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET)
struct ifnet tun_if; /* the interface */
int tun_pgrp; /* the process group - if any */
struct selinfo tun_rsel; /* read select */