Don't send/recieve packets when the interface is down.

This commit is contained in:
Hidetoshi Shimokawa 2002-10-23 15:16:37 +00:00
parent 08675def10
commit 3983050934
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105804

View File

@ -459,6 +459,11 @@ tunoutput(
return (EHOSTDOWN);
}
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
m_freem (m0);
return (EHOSTDOWN);
}
/* BPF write needs to be handled specially */
if (dst->sa_family == AF_UNSPEC) {
dst->sa_family = *(mtod(m0, int *));
@ -707,6 +712,10 @@ tunwrite(dev_t dev, struct uio *uio, int flag)
TUNDEBUG("%s%d: tunwrite\n", ifp->if_name, ifp->if_unit);
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
/* ignore silently */
return (0);
if (uio->uio_resid == 0)
return (0);