Bug 181006 - [run] [patch] mbuf leak in run(4) driver
Summary: [run] [patch] mbuf leak in run(4) driver
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-03 21:20 UTC by Joao Cabral
Modified: 2014-02-06 22:44 UTC (History)
0 users

See Also:


Attachments
file.diff (677 bytes, patch)
2013-08-03 21:20 UTC, Joao Cabral
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joao Cabral 2013-08-03 21:20:00 UTC
When running a Ralink RT3070/3020/2870 based USB WiFi adapter with FreeBSD current on a Raspberry Pi, the output of "netstat -nr" kept reporting an increasing number of mbufs up to (a few thousands) a point where the adapter would disconnect from the WiFi network and never reconnect again, at which point only a reboot would solve the problem. 

The adapter reports as: 

Aug  2 23:21:10 witch kernel: run0: MAC/BBP RT3070 (rev 0x0201), RF RT3020 (MIMO
 1T1R), address 00:23:28:01:89:a2
Aug  2 23:21:11 witch kernel: wlan0: Ethernet address: 00:23:28:01:89:a2
Aug  2 23:21:12 witch kernel: run0: firmware RT2870 ver. 0.236 loaded

Setting sysctl hw.usb.run.debug=1 caused a lot of error messages, mainly such as: 

Aug  3 03:05:01 witch kernel: run_bulk_rx_callback: bad DMA length 60329
Aug  3 03:05:02 witch kernel: run_bulk_rx_callback: bad DMA length 21348 > 2600
Aug  3 03:05:02 witch kernel: run_bulk_rx_callback: bad DMA length 2787
Aug  3 03:05:02 witch kernel: run_bulk_rx_callback: bad DMA length 26261
Aug  3 03:05:02 witch kernel: run_bulk_rx_callback: bad DMA length 55261

Which suggest alignment problems.

Fix: A friend suggested the following patch to base/head/sys/dev/usb/wlan/if_run.c which seems to have solved the problem of the increasing number of mbufs and hence the leak. Mbufs are now stable. 

This does not however solve the problem of misalignment observed on the Raspberry Pi/arm causing the error messages to be triggered. 
How-To-Repeat: 
Plugin a run(4) adapter to an arm based FreeBSD and let it flow traffic... see the mbufs increasing up to the point where the adapter disconnects and no longer recovers.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-08-04 00:59:08 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 Joao Cabral 2013-08-04 09:49:19 UTC
Sorry, just a couple of mistakes/corrections:

1. Where it reads "netstat -nr" should read "netstat -m".

2. It might not be an alignment problem at all, but just a display/check =
problem in the driver.

---

But the patch seems to have fixed the issue and the network hasn't =
hanged since and the mbufs are now stable:=20

jcnc@witch ~]$ netstat -m
2/268/270 mbufs in use (current/cache/total)
2/132/134/31744 mbuf clusters in use (current/cache/total/max)
2/126 mbuf+clusters out of packet secondary zone in use (current/cache)
1/8/9/15872 4k (page size) jumbo clusters in use =
(current/cache/total/max)
0/0/0/4702 9k jumbo clusters in use (current/cache/total/max)
0/0/0/2645 16k jumbo clusters in use (current/cache/total/max)
8K/363K/371K bytes allocated to network (current/cache/total)
0/0/0 requests for mbufs denied (mbufs/clusters/mbuf+clusters)
0/0/0 requests for mbufs delayed (mbufs/clusters/mbuf+clusters)
0/0/0 requests for jumbo clusters delayed (4k/9k/16k)
0/0/0 requests for jumbo clusters denied (4k/9k/16k)
0/4/4608 sfbufs in use (current/peak/max)
0 requests for sfbufs denied
0 requests for sfbufs delayed
0 requests for I/O initiated by sendfile
0 calls to protocol drain routines
Comment 3 Christian Brueffer freebsd_committer freebsd_triage 2014-02-06 22:42:02 UTC
State Changed
From-To: open->closed

This was fixed in HEAD with r257435 and merged back to 9-STABLE in r259457. 
Thanks for the report!