summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2001-04-27 22:20:22 +0000
committerfenner <fenner@FreeBSD.org>2001-04-27 22:20:22 +0000
commit65d40dd90a422bc664875beb90dea98e35f749b8 (patch)
tree76e4774448857048ee9f846b251309d681aa2e3c /sys/net/if.c
parent0b059bcc425cfc51d0f0b21504e5799c4d743f7a (diff)
downloadFreeBSD-src-65d40dd90a422bc664875beb90dea98e35f749b8.zip
FreeBSD-src-65d40dd90a422bc664875beb90dea98e35f749b8.tar.gz
Better handling of ioctl(SIOCSIFFLAGS) failing in ifpromisc():
- Don't print the "promiscuous mode (enabled|disabled)" on failure - Restore the reference count on failure
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 3e0cf0e..f98d85e 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1016,8 +1016,9 @@ ifpromisc(ifp, pswitch)
{
struct ifreq ifr;
int error;
- int oldflags;
+ int oldflags, oldpcount;
+ oldpcount = ifp->if_pcount;
oldflags = ifp->if_flags;
if (pswitch) {
/*
@@ -1029,21 +1030,22 @@ ifpromisc(ifp, pswitch)
if (ifp->if_pcount++ != 0)
return (0);
ifp->if_flags |= IFF_PROMISC;
- log(LOG_INFO, "%s%d: promiscuous mode enabled\n",
- ifp->if_name, ifp->if_unit);
} else {
if (--ifp->if_pcount > 0)
return (0);
ifp->if_flags &= ~IFF_PROMISC;
- log(LOG_INFO, "%s%d: promiscuous mode disabled\n",
- ifp->if_name, ifp->if_unit);
}
ifr.ifr_flags = ifp->if_flags;
error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
- if (error == 0)
+ if (error == 0) {
+ log(LOG_INFO, "%s%d: promiscuous mode %s\n",
+ ifp->if_name, ifp->if_unit,
+ (ifp->if_flags & IFF_PROMISC) ? "enabled" : "disabled");
rt_ifmsg(ifp);
- else
+ } else {
+ ifp->if_pcount = oldpcount;
ifp->if_flags = oldflags;
+ }
return error;
}
OpenPOWER on IntegriCloud