fixes from <brad@fcr.com> who claims it now works correctly
This commit is contained in:
parent
e5c1d566ef
commit
946453260a
@ -11,7 +11,7 @@
|
|||||||
* UCL. This driver is based much more on read/write/select mode of
|
* UCL. This driver is based much more on read/write/select mode of
|
||||||
* operation though.
|
* 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"
|
#include "tun.h"
|
||||||
@ -165,8 +165,14 @@ tunclose(dev, flag)
|
|||||||
s = splimp();
|
s = splimp();
|
||||||
if_down(ifp);
|
if_down(ifp);
|
||||||
if (ifp->if_flags & IFF_RUNNING) {
|
if (ifp->if_flags & IFF_RUNNING) {
|
||||||
rtinit(ifp->if_addrlist, (int)RTM_DELETE,
|
/* find internet addresses and delete routes */
|
||||||
tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
|
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);
|
splx(s);
|
||||||
}
|
}
|
||||||
@ -189,17 +195,18 @@ tuninit(unit)
|
|||||||
|
|
||||||
ifp->if_flags |= IFF_UP | IFF_RUNNING;
|
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)
|
||||||
struct sockaddr_in *si;
|
if (ifa->ifa_addr->sa_family == AF_INET) {
|
||||||
|
struct sockaddr_in *si;
|
||||||
|
|
||||||
si = (struct sockaddr_in *)ifa->ifa_addr;
|
si = (struct sockaddr_in *)ifa->ifa_addr;
|
||||||
if (si && si->sin_addr.s_addr)
|
if (si && si->sin_addr.s_addr)
|
||||||
tp->tun_flags |= TUN_IASET;
|
tp->tun_flags |= TUN_IASET;
|
||||||
|
|
||||||
si = (struct sockaddr_in *)ifa->ifa_dstaddr;
|
si = (struct sockaddr_in *)ifa->ifa_dstaddr;
|
||||||
if (si && si->sin_addr.s_addr)
|
if (si && si->sin_addr.s_addr)
|
||||||
tp->tun_flags |= TUN_DSTADDR;
|
tp->tun_flags |= TUN_DSTADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -221,11 +228,13 @@ tunioctl(ifp, cmd, data, flag)
|
|||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case SIOCSIFADDR:
|
case SIOCSIFADDR:
|
||||||
tuninit(ifp->if_unit);
|
tuninit(ifp->if_unit);
|
||||||
|
TUNDEBUG("%s%d: address set\n",
|
||||||
|
ifp->if_name, ifp->if_unit);
|
||||||
break;
|
break;
|
||||||
case SIOCSIFDSTADDR:
|
case SIOCSIFDSTADDR:
|
||||||
tp->tun_flags |= TUN_DSTADDR;
|
tuninit(ifp->if_unit);
|
||||||
TUNDEBUG("%s%d: destination address set\n", ifp->if_name,
|
TUNDEBUG("%s%d: destination address set\n",
|
||||||
ifp->if_unit);
|
ifp->if_name, ifp->if_unit);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* operation though.
|
* operation though.
|
||||||
*
|
*
|
||||||
* from: $Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp
|
* 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_
|
#ifndef _NET_IF_TUN_H_
|
||||||
@ -25,10 +25,12 @@ struct tun_softc {
|
|||||||
#define TUN_RCOLL 0x0004
|
#define TUN_RCOLL 0x0004
|
||||||
#define TUN_IASET 0x0008
|
#define TUN_IASET 0x0008
|
||||||
#define TUN_DSTADDR 0x0010
|
#define TUN_DSTADDR 0x0010
|
||||||
#define TUN_READY 0x0020
|
|
||||||
#define TUN_RWAIT 0x0040
|
#define TUN_RWAIT 0x0040
|
||||||
#define TUN_ASYNC 0x0080
|
#define TUN_ASYNC 0x0080
|
||||||
#define TUN_NBIO 0x0100
|
#define TUN_NBIO 0x0100
|
||||||
|
|
||||||
|
#define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET)
|
||||||
|
|
||||||
struct ifnet tun_if; /* the interface */
|
struct ifnet tun_if; /* the interface */
|
||||||
int tun_pgrp; /* the process group - if any */
|
int tun_pgrp; /* the process group - if any */
|
||||||
struct selinfo tun_rsel; /* read select */
|
struct selinfo tun_rsel; /* read select */
|
||||||
|
Loading…
Reference in New Issue
Block a user