Subject: kern/37286: Memory leak with Ral(4)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <maillistthom@gmail.com>
List: netbsd-bugs
Date: 11/06/2007 08:35:01
>Number:         37286
>Category:       kern
>Synopsis:       Memory leak with Ral(4)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 06 08:35:00 +0000 2007
>Originator:     Thomas Galliano
>Release:        NetBSD 4.0 RC1
>Organization:
>Environment:
NetBSD prune 4.0_RC1 NetBSD 4.0_RC1 (CUSTOM_DEBUG) #1: Tue Oct  9 21:50:10 CEST 2007 root@prune:/usr/obj/sys/arch/i386/compile/CUSTOM_DEBUG i386

$ cat /usr/src/sys/arch/i386/conf/CUSTOM_DEBUG
include "arch/i386/conf/GENERIC"

options         KMEMSTATS
options         DEBUG
options         DIAGNOSTIC
options         MBUFTRACE



>Description:
I got a leak when I use my wifi ralink card.

Here is my hardware :

ral0 at pci0 dev 6 function 0: Ralink Technologies RT2561S 802.11b/g (rev. 0x00)
ral0: interrupting at ioapic0 pin 17 (irq 10)
ral0: 802.11 address 00:19:db:0b:44:6f
ral0: MAC/BBP RT2561C, RF RT2527
ral0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ral0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
ral0 at pci0 dev 6 function 0: Ralink Technologies RT2561S 802.11b/g (rev. 0x00)
ral0: interrupting at ioapic0 pin 17 (irq 10)
ral0: 802.11 address 00:19:db:0b:44:6f
ral0: MAC/BBP RT2561C, RF RT2527
ral0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ral0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps

The AP configuration (I tried with no encryption, same problem)

ral0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2290
        ssid myBSDap apbridge nwkey *****
        powersave off
        bssid 00:19:db:0b:44:6f chan 2
        address: 00:19:db:0b:44:6f
        media: IEEE802.11 autoselect mode 11g hostap
        status: active
        inet 192.168.1.254 netmask 0xffffff00 broadcast 192.168.1.255


After heavy trafic for exemple ftp or torrent the connection fail and become anavalaible. Then when I try to use un cable connection there is no more mbuf.

I tried to identify the issue. I made an netstat -mssv.
ral tx increase slowly at the beginning then very fast before crash

            rtk0 rx            inuse             0          0          0
                               claims      5171098        700        700
                               releases    5171098        700        700
            rtk0 tx            inuse            89          0          0
                               claims     23177322    7723921    7716919
                               releases   23177233    7723921    7716919
           epic0 rx            inuse             0          0          0
                               claims       665450     665450     665450
                               releases     665450     665450     665450
           epic0 tx            inuse             0          0          0
                               claims       443503     350399     346960
                               releases     443503     350399     346960
            ral0 rx            inuse             0          0          0
                               claims      8109320    8109320    8109320
                               releases    8109320    8109320    8109320
            ral0 tx            inuse        258910        886        886
                               claims      5628982    1152933    1148503
                               releases    5370072    1152047    1147617


Then I reboot

            rtk0 rx            inuse             0          0          0
                               claims         2223         64         64
                               releases       2223         64         64
            rtk0 tx            inuse             0          0          0
                               claims         2658        490        490
                               releases       2658        490        490
           epic0 rx            inuse             0          0          0
                               claims         1250       1250       1250
                               releases       1250       1250       1250
           epic0 tx            inuse             0          0          0
                               claims         1021        406        406
                               releases       1021        406        406
            ral0 rx            inuse             0          0          0
                               claims          479        479        479
                               releases        479        479        479
            ral0 tx            inuse             0          0          0
                               claims         1586       1056       1056
                               releases       1586       1056       1056

>How-To-Repeat:
Put an AP wifi with Ral card and a ftpd (Netbsd).
You don't necessary need encryption
Connect to the AP(WinXP Client) and make a ftp connection.
Upload ~3 hours.
The connection become impossible. When I try connecting with cable I got anavalaible mbuf.

>Fix: