Discussion:
[patch] wlan-udev.sh possible empty variable
Tormod Volden
2007-05-19 09:39:32 UTC
Permalink
Hi,
In wlan-udev.sh the WLAN_WEXT variable is possibly used uninitialized
in an "if" statement:
if [ $WLAN_WEXT = 1 ]; then
which then breaks since it becomes :
if [ = 1 ]; then

Either add quotes,
if [ "$WLAN_WEXT" = 1 ]; then

or use the attached patch which makes sure WLAN_WEXT has a value.

Best regards,
Tormod
Richard Kennedy
2007-05-19 11:28:36 UTC
Permalink
Post by Tormod Volden
Hi,
In wlan-udev.sh the WLAN_WEXT variable is possibly used uninitialized
if [ $WLAN_WEXT = 1 ]; then
if [ = 1 ]; then
Either add quotes,
if [ "$WLAN_WEXT" = 1 ]; then
or use the attached patch which makes sure WLAN_WEXT has a value.
Best regards,
Tormod
Hi Tormod,

Yes that was a bit sloppy on my part, but are you really seeing this
problem occur ?

If so then maybe there's a race between the creation of the /sys module
parameter and the running of the script. but that seems really broken
and I can't think of a way to fix it other than just delay and hope.

I guess though if the sys module parameter isn't there the card might
have gone away -- so the script should just exit at that point anyway.

Cheers
Richard
Tormod Volden
2007-05-19 13:08:09 UTC
Permalink
Post by Richard Kennedy
Yes that was a bit sloppy on my part, but are you really seeing this
problem occur ?
If so then maybe there's a race between the creation of the /sys module
parameter and the running of the script. but that seems really broken
and I can't think of a way to fix it other than just delay and hope.
I guess though if the sys module parameter isn't there the card might
have gone away -- so the script should just exit at that point anyway.
Hi Richard,
No, I haven't seen this yet, but in some distributions like Ubuntu,
the prism2/p80211 modules are shipped with the kernel packages
independently from the linux-wlan-ng package. This makes it possible
to run a new linux-wlan-ng package with your script, but on an old
kernel which doesn't have your wireless extensions.
My patch makes this more robust, and I would need it to backport Gutsy
linux-wlan-ng to Feisty (without patching the kernel!). I prefer
fixing this upstream rather than having another tweak in Ubuntu or
Debian.

Thanks again for the wireless extensions!
Cheers,
Tormod
Richard Kennedy
2007-05-19 15:07:02 UTC
Permalink
Post by Tormod Volden
Hi Richard,
No, I haven't seen this yet, but in some distributions like Ubuntu,
the prism2/p80211 modules are shipped with the kernel packages
independently from the linux-wlan-ng package. This makes it possible
to run a new linux-wlan-ng package with your script, but on an old
kernel which doesn't have your wireless extensions.
My patch makes this more robust, and I would need it to backport Gutsy
linux-wlan-ng to Feisty (without patching the kernel!). I prefer
fixing this upstream rather than having another tweak in Ubuntu or
Debian.
Thanks again for the wireless extensions!
Cheers,
Tormod
Tormod,

I'm glad that you haven't seen this :)

In practice you shouldn't have a problem though, because that module
parameter has been in the driver for a long time.

But, you are right we should do something if that file test fails.
maybe something like this ?

if [ -f $WEXT_PARAM ]; then
WLAN_WEXT=`cat $WEXT_PARAM`
else
echo "wext module parameter not found! card removed ?"
exit 1
fi

Cheers
Richard
Tormod Volden
2007-05-19 16:20:55 UTC
Permalink
Post by Richard Kennedy
I'm glad that you haven't seen this :)
In practice you shouldn't have a problem though, because that module
parameter has been in the driver for a long time.
But, you are right we should do something if that file test fails.
maybe something like this ?
if [ -f $WEXT_PARAM ]; then
WLAN_WEXT=`cat $WEXT_PARAM`
else
echo "wext module parameter not found! card removed ?"
exit 1
fi
Cheers
Richard
I mistakenly thought this was a relative new parameter, which it is
not. So it's no practical issue at all :) But I think, if your script
is careful enough to check for WEXT_PARAM it should also not bail out
in error if it doesn't exist, in order to be consistent in terms of
coding.

I don't think the WEXT_PARAM should be used to check for the existence
of the card either. Can't we just ignore it, like my (ok, practically
useless) patch does?

Tormod
Richard Kennedy
2007-05-20 11:23:07 UTC
Permalink
Post by Tormod Volden
Post by Richard Kennedy
I'm glad that you haven't seen this :)
In practice you shouldn't have a problem though, because that module
parameter has been in the driver for a long time.
But, you are right we should do something if that file test fails.
maybe something like this ?
if [ -f $WEXT_PARAM ]; then
WLAN_WEXT=`cat $WEXT_PARAM`
else
echo "wext module parameter not found! card removed ?"
exit 1
fi
Cheers
Richard
I mistakenly thought this was a relative new parameter, which it is
not. So it's no practical issue at all :) But I think, if your script
is careful enough to check for WEXT_PARAM it should also not bail out
in error if it doesn't exist, in order to be consistent in terms of
coding.
I don't think the WEXT_PARAM should be used to check for the existence
of the card either. Can't we just ignore it, like my (ok, practically
useless) patch does?
Tormod
No really if the /sys module parameter isn't there we are in serious
trouble.

WEXT_PARAM=/sys/module/p80211/parameters/wlan_wext_write

which is an entry in the virtual sysfs.
This can only be missing if the module has gone away. On any normal
kernel config, I can only imagine this happening if udev was slow in
running our script, maybe due to a heavily loaded system, and the card
got pulled before the script got scheduled. It seems really unlikely to
happen but _is_ going to be fatal -- the script is going to fail
somewhere so we might as well bail out as soon as we detect a problem.

Cheers
Richard

Loading...