Add SIOCG80211ZSTATS to atomically get/clear 802.11 statistics.

Protect SIOCG80211STATS with splnet()/splx() so that it takes a
"snapshot" of the 802.11 statistics, which is superfluous if
ieee80211_ioctl is always called at splnet()....
This commit is contained in:
dyoung 2004-12-20 23:03:39 +00:00
parent f7e41a32b4
commit 8fff1555a5
2 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_ioctl.c,v 1.16 2004/07/23 08:31:39 mycroft Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.17 2004/12/20 23:03:39 dyoung Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@ -35,7 +35,7 @@
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.13 2004/03/30 22:57:57 sam Exp $");
#else
__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.16 2004/07/23 08:31:39 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.17 2004/12/20 23:03:39 dyoung Exp $");
#endif
/*
@ -1110,7 +1110,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
struct ieee80211com *ic = (void *)ifp;
struct ifreq *ifr = (struct ifreq *)data;
int i, error = 0;
int i, error = 0, s;
struct ieee80211_nwid nwid;
struct ieee80211_nwkey *nwkey;
struct ieee80211_power *power;
@ -1342,9 +1342,14 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
error = ieee80211_cfgset(ifp, cmd, data);
break;
case SIOCG80211ZSTATS:
case SIOCG80211STATS:
ifr = (struct ifreq *)data;
s = splnet();
copyout(&ic->ic_stats, ifr->ifr_data, sizeof (ic->ic_stats));
if (cmd == SIOCG80211ZSTATS)
(void)memset(&ic->ic_stats, 0, sizeof(ic->ic_stats));
splx(s);
break;
case SIOCSIFMTU:
ifr = (struct ifreq *)data;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_ioctl.h,v 1.7 2004/04/30 22:51:04 dyoung Exp $ */
/* $NetBSD: ieee80211_ioctl.h,v 1.8 2004/12/20 23:03:39 dyoung Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@ -203,6 +203,7 @@ struct ieee80211_bssid {
#define SIOCG80211BSSID _IOWR('i', 241, struct ieee80211_bssid)
#define SIOCG80211STATS _IOWR('i', 242, struct ifreq)
#define SIOCG80211ZSTATS _IOWR('i', 243, struct ifreq)
#endif
#endif /* _NET80211_IEEE80211_IOCTL_H_ */