iwconfig lost the last letter of essid when using r818x driver

Bug #98926 reported by Qishuai Liu
This bug report is a duplicate of:  Bug #74672: ESSID gets truncated. Edit Remove
4
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Incomplete
Undecided
Unassigned
linux-source-2.6.20 (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

I have a rtl8180-based wireless pcmcia card. After I upgraded to feisty, I found that iwconfig cannot set the essid correctly. It lost the last letter. Let's see the example:

lqs@lqs-laptop:~$ sudo iwconfig wlan0 essid private
lqs@lqs-laptop:~$ iwconfig wlan0
wlan0 802.11b ESSID:"privat"
          Mode:Managed Frequency:2.432 GHz Access Point: Not-Associated
          Bit Rate=11 Mb/s
          Retry:on Fragment thr:off
          Power Management:off
          Link Quality:34/100 Signal level:-111 dBm Noise level:-190 dBm
          Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
          Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lqs@lqs-laptop:~$ sudo iwconfig wlan0 essid privatee
lqs@lqs-laptop:~$ iwconfig wlan0
wlan0 802.11b linked ESSID:"private"
          Mode:Managed Frequency:2.457 GHz Access Point: 00:90:00:18:03:25
          Bit Rate=11 Mb/s
          Retry:on Fragment thr:off
          Power Management:off
          Link Quality=73/100 Signal level=-111 dBm Noise level=-229 dBm
          Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
          Tx excessive retries:0 Invalid misc:0 Missed beacon:0

lqs@lqs-laptop:~$ uname -a
Linux lqs-laptop 2.6.20-13-generic #2 SMP Sun Mar 25 00:21:25 UTC 2007 i686 GNU/Linux

I have to connect to "privatee" if I actually want to connect to "private".
This only happened with a rtl8180-based card, using r818x driver. It doesn't happen with another cards, such as atheros cards.

The nm-applet also cannot set it correctly.

Tim Gardner (timg-tpi)
Changed in linux-source-2.6.20:
assignee: nobody → ubuntu-kernel-team
status: Unconfirmed → Confirmed
Revision history for this message
20after4 (twentyafterfour) wrote :

You are not alone. I am experiencing the exact same issue with Feisty Fawn Beta (With updates applied bringing it to nearly-released status)

The card is a PCMCIA "Generic" re-branded device from wal-mart. It is detected as :

PCI Device: Realtek Semiconductor Co., Ltd. RTL8180L 802.11b MAC (rev 20)
Subsystem: Linksys unknown device 0019

The r818x driver works ok but auto-configuration sure doesn't! As long as I put an extra random digit on the end of the essid (or provide the router's mac address via iwconfig) then I can establish a network connection immediately. I'm not sure if this is a problem with iwconfig or the device driver but it seems more likely to be the device or the r818x kernel module.

Revision history for this message
Qishuai Liu (lqs) wrote :

In the Ubuntu version of the kernel source, the line 358 of ubuntu/net/rtl_ieee80211/rtl_ieee80211_softmac_wx.c, has the following code:

        if (wrqu->essid.flags && wrqu->essid.length) {
                len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;

                strncpy(ieee->current_network.ssid, extra, len);
                ieee->current_network.ssid_len = len;
                ieee->ssid_set = 1;
        }

I think the wrqu->essid.length should not minus one.

Anyone who can check it?

Revision history for this message
Roland (rolandonlinux) wrote :

Searching on IW_ESSID_MAX_SIZE across wlan drivers
shows many different ways to determine the length of the ESS-ID.
This could be simpler.

I'd suggest determine the length of the ESS string in a way that
works for both the old and the new version of wireless extensions,
by double checking if the last character is a \0 byte.

In the meantime, users should just enter a dummy character at
the end of the ESS in /etc/network/interfaces or the network config tool.

linux-source-2.6.20/ubuntu/wireless/acx/ioctl.c :

                if (dwrq->length > IW_ESSID_MAX_SIZE+1) {
                        result = -E2BIG;
                        goto end_unlock;
                }

                if (len > sizeof(adev->essid))
                        len = sizeof(adev->essid);
                memcpy(adev->essid, extra, len-1);
                adev->essid[len-1] = '\0';
                /* Paranoia: just in case there is a '\0'... */
                adev->essid_len = strlen(adev->essid);

at76/at76c503.c :

                memcpy(scan.essid, dev->essid, IW_ESSID_MAX_SIZE);
                scan.essid_size = dev->essid_size;

ipw3945/ipw3945.c :

#if WIRELESS_EXT > 20
#define IW_ESSID_FIX 0
#else
#define IW_ESSID_FIX 1
...
#endif

                length = wrqu->essid.length - IW_ESSID_FIX;

iwlwifi/base.c :

        essid_len = min(essid_len, (u8) IW_ESSID_MAX_SIZE);
        while (essid_len--) {
                if (*s == '\0') {
                        *d++ = '\\';
                        *d++ = '0';
                        s++;
                } else {
                        *d++ = *s++;
                }
        }
        *d = '\0';

        ...

                priv->direct_ssid_len = (u8)
                    min((u8) len, (u8) IW_ESSID_MAX_SIZE);
                memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len);

Revision history for this message
Launchpad Janitor (janitor) wrote : This bug is now reported against the 'linux' package

Beginning with the Hardy Heron 8.04 development cycle, all open Ubuntu kernel bugs need to be reported against the "linux" kernel package. We are automatically migrating this bug to the new "linux" package. However, development has already began for the upcoming Intrepid Ibex 8.10 release. It would be helpful if you could test the upcoming release and verify if this is still an issue - http://www.ubuntu.com/testing . If the issue still exists, please update this report by changing the Status of the "linux" task from "Incomplete" to "New". We appreciate your patience and understanding as we make this transition. Thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote : Kernel team bugs

Per a decision made by the Ubuntu Kernel Team, bugs will longer be assigned to the ubuntu-kernel-team in Launchpad as part of the bug triage process. The ubuntu-kernel-team is being unassigned from this bug report. Refer to https://wiki.ubuntu.com/KernelTeamBugPolicies for more information. Thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.