Fix sysctl support in Linux 2.6.24

Linux 2.6.24 introduces a sysctl checker that disallows using arbitrary
ctl_name values for sysctl entries.  The entries with non-standard
values should set ctl_name to CTL_UNNUMBERED.

On the other hand, using consistent non-zero ctl_name values is required
for older kernels (tested on Linux 2.4.33.3 from Slackware 11).

Thus the solution is to use CTL_UNNUMBERED on Linux 2.6.24+ and the
original values in the older kernels.  Move CTL_AUTO and DEV_ATH to
include/compat.h and define them correspondingly.

When copying sysctl entries, check procname for being non-zero, since
ctl_name is zero (CTL_UNNUMBERED) on Linux 2.6.24 and newer.

For the same reason, don't use ctl_name to distinguish entries in
ath_sysctl_template, use extra2 instead.


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2814 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
proski 2007-10-31 05:39:41 +00:00
parent be0769dcae
commit 120d309bc3
6 changed files with 60 additions and 61 deletions

View File

@ -9403,7 +9403,7 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
if (write) {
ret = ATH_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos);
if (ret == 0) {
switch (ctl->ctl_name) {
switch ((long)ctl->extra2) {
case ATH_SLOTTIME:
if (val > 0) {
if (!ath_hal_setslottime(ah, val))
@ -9515,7 +9515,7 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
}
}
} else {
switch (ctl->ctl_name) {
switch ((long)ctl->extra2) {
case ATH_SLOTTIME:
val = ath_hal_getslottime(ah);
break;
@ -9581,92 +9581,106 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl, write, filp, buffer, lenp, ppos)
static int mincalibrate = 1; /* once a second */
static int maxint = 0x7fffffff; /* 32-bit big */
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
static const ctl_table ath_sysctl_template[] = {
{ .ctl_name = ATH_SLOTTIME,
{ .ctl_name = CTL_AUTO,
.procname = "slottime",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_SLOTTIME,
},
{ .ctl_name = ATH_ACKTIMEOUT,
{ .ctl_name = CTL_AUTO,
.procname = "acktimeout",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_ACKTIMEOUT,
},
{ .ctl_name = ATH_CTSTIMEOUT,
{ .ctl_name = CTL_AUTO,
.procname = "ctstimeout",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_CTSTIMEOUT,
},
{ .ctl_name = ATH_SOFTLED,
{ .ctl_name = CTL_AUTO,
.procname = "softled",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_SOFTLED,
},
{ .ctl_name = ATH_LEDPIN,
{ .ctl_name = CTL_AUTO,
.procname = "ledpin",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_LEDPIN,
},
{ .ctl_name = ATH_COUNTRYCODE,
{ .ctl_name = CTL_AUTO,
.procname = "countrycode",
.mode = 0444,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_COUNTRYCODE,
},
{ .ctl_name = ATH_REGDOMAIN,
{ .ctl_name = CTL_AUTO,
.procname = "regdomain",
.mode = 0444,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_REGDOMAIN,
},
#ifdef AR_DEBUG
{ .ctl_name = ATH_DEBUG,
{ .ctl_name = CTL_AUTO,
.procname = "debug",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_DEBUG,
},
#endif
{ .ctl_name = ATH_TXANTENNA,
{ .ctl_name = CTL_AUTO,
.procname = "txantenna",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_TXANTENNA,
},
{ .ctl_name = ATH_RXANTENNA,
{ .ctl_name = CTL_AUTO,
.procname = "rxantenna",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_RXANTENNA,
},
{ .ctl_name = ATH_DIVERSITY,
{ .ctl_name = CTL_AUTO,
.procname = "diversity",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_DIVERSITY,
},
{ .ctl_name = ATH_TXINTRPERIOD,
{ .ctl_name = CTL_AUTO,
.procname = "txintrperiod",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_TXINTRPERIOD,
},
{ .ctl_name = ATH_FFTXQMIN,
{ .ctl_name = CTL_AUTO,
.procname = "fftxqmin",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_FFTXQMIN,
},
#ifdef ATH_SUPERG_XR
{ .ctl_name = ATH_XR_POLL_PERIOD,
{ .ctl_name = CTL_AUTO,
.procname = "xrpollperiod",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_XR_POLL_PERIOD,
},
{ .ctl_name = ATH_XR_POLL_COUNT,
{ .ctl_name = CTL_AUTO,
.procname = "xrpollcount",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_XR_POLL_COUNT,
},
#endif
{ .ctl_name = ATH_ACKRATE,
{ .ctl_name = CTL_AUTO,
.procname = "ackrate",
.mode = 0644,
.proc_handler = ath_sysctl_halparam
.proc_handler = ath_sysctl_halparam,
.extra2 = (void *)ATH_ACKRATE,
},
{ 0 }
};
@ -9715,7 +9729,7 @@ ath_dynamic_sysctl_register(struct ath_softc *sc)
sizeof(ath_sysctl_template));
/* add in dynamic data references */
for (i = 4; sc->sc_sysctls[i].ctl_name; i++)
for (i = 4; sc->sc_sysctls[i].procname; i++)
if (sc->sc_sysctls[i].extra1 == NULL)
sc->sc_sysctls[i].extra1 = sc;
@ -9806,10 +9820,6 @@ ath_announce(struct net_device *dev)
* Static (i.e. global) sysctls. Note that the HAL sysctls
* are located under ours by sharing the setting for DEV_ATH.
*/
enum {
DEV_ATH = 9, /* XXX known by HAL */
};
static ctl_table ath_static_sysctls[] = {
#ifdef AR_DEBUG
{ .ctl_name = CTL_AUTO,

View File

@ -453,12 +453,6 @@ ath_hal_memcmp(const void *a, const void *b, size_t n)
}
EXPORT_SYMBOL(ath_hal_memcmp);
enum {
DEV_ATH = 9, /* XXX must match driver */
};
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
static ctl_table ath_hal_sysctls[] = {
#ifdef AH_DEBUG
{ .ctl_name = CTL_AUTO,

View File

@ -485,14 +485,9 @@ static int minrateinterval = 500; /* 500ms */
static int maxint = 0x7fffffff; /* 32-bit big */
static int min_threshold = 1;
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
/*
* Static (i.e. global) sysctls.
*/
enum {
DEV_ATH = 9, /* XXX known by many */
};
static ctl_table ath_rate_static_sysctls[] = {
{ .ctl_name = CTL_AUTO,

View File

@ -434,15 +434,9 @@ static int maxpercent = 100; /* 100% */
static int minpercent = 0; /* 0% */
static int maxint = 0x7fffffff; /* 32-bit big */
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
/*
* Static (i.e. global) sysctls.
*/
enum {
DEV_ATH = 9, /* XXX known by many */
};
static ctl_table ath_rate_static_sysctls[] = {
{ .ctl_name = CTL_AUTO,
.procname = "interval",

View File

@ -154,6 +154,14 @@ static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
do { (_skb)->mac.raw = (_skb)->data; } while(0)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
#define CTL_AUTO -2
#define DEV_ATH 9
#else
#define CTL_AUTO CTL_UNNUMBERED
#define DEV_ATH CTL_UNNUMBERED
#endif
#endif /* __KERNEL__ */
#endif /* _ATH_COMPAT_H_ */

View File

@ -670,8 +670,6 @@ IEEE80211_SYSCTL_DECL(ieee80211_sysctl_monitor_crc_errors, ctl, write, filp, buf
return ret;
}
#define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */
static const ctl_table ieee80211_sysctl_template[] = {
#ifdef IEEE80211_DEBUG
{ .ctl_name = CTL_AUTO,
@ -776,7 +774,7 @@ ieee80211_virtfs_latevattach(struct ieee80211vap *vap)
sizeof(ieee80211_sysctl_template));
/* add in dynamic data references */
for (i = 4; vap->iv_sysctls[i].ctl_name; i++)
for (i = 4; vap->iv_sysctls[i].procname; i++)
if (vap->iv_sysctls[i].extra1 == NULL)
vap->iv_sysctls[i].extra1 = vap;