Bug 213237 - [ndis][patch] ndis wireless ieee80211 communication failure
Summary: [ndis][patch] ndis wireless ieee80211 communication failure
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.0-RC1
Hardware: i386 Any
: --- Affects Only Me
Assignee: Gleb Smirnoff
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2016-10-06 06:19 UTC by ota
Modified: 2017-06-08 22:14 UTC (History)
5 users (show)

See Also:


Attachments
Add ifp pointer check (8.83 KB, patch)
2017-05-15 03:09 UTC, ota
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ota 2016-10-06 06:19:50 UTC
Bug introduced in 11-0-RELEASE.

I have eMachines eM250-1915 and it is Broadcom based wireless NIC.  I have used it with NDIS driver until 10.2-RELEASE.  After upgrading to 11.0 and re-creating NDIS kernel module, it no longer works.

kldload mentions about ndis0 but ifconfig does not show driver become available like below on 11.0.

% kldload /boot/modules/bcmwl5_sys.ko
ndis0: <Broadcom 802.11g Network Adapter> mem 0x57100000-0x57103fff irq 16 at device 0.0 on pci1
ndis0: NDIS API version: 5.1
% ifconfig
alc0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c3198<VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MCAST,WOL_MAGIC,VLAN_HWTSO,LINKSTATE>
        ether 70:5a:b6:16:82:6e
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
        inet 127.0.0.1 netmask 0xff000000 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
        groups: lo
Comment 1 Andriy Voskoboinyk freebsd_committer freebsd_triage 2016-11-06 13:58:07 UTC
sysctl net.wlan.devices ?
Comment 2 ota 2016-11-28 09:07:55 UTC
(In reply to Andriy Voskoboinyk from comment #1)

$ sysctl net.wlan.devices
net.wlan.devices: ndis0
Comment 3 ota 2016-11-28 09:10:44 UTC
It looks rev 286410 (due to compile error, I tested with 286416) is when a problem started.
With rev 286416, kldload crashes the system.

With 11.0-RELEASE, kernel doesn't crash but ndis does not function.
Comment 4 ota 2016-11-28 09:19:09 UTC
On 11.0-RELEASE, I also see pci-one error as following today. ndis print is the same as last time.  I reran ndisgen and tried.

$ kldload ./bcmwl5_sys3.ko
pci1: <network> at device 0.0 (no driver attached)
ndis0: <Broadcom 802.11g Network Adapter> mem 0x57100000-0x57103fff irq 16 at device 0.0 on pci1
ndis0: NDIS API version: 5.1

I had booted 10.2-RELEASE and ndis didn't have issues.
Comment 5 ota 2016-11-28 09:26:04 UTC
11.0-RELEASE output, typed by hand.

$ pciconf -lv
...
ndis@pci0:1:0:0:    class=0x028000 card=0xe01b105b chip=0x431514e4 rev=0x01 hdr=0x00
    vendor  = 'Broadcom Corporation'
    device  = 'BCM4312 802.11b/g LP-PHY'
    class   = netowork
Comment 6 ota 2016-12-29 17:11:33 UTC
https://svnweb.freebsd.org/base?view=revision&revision=286410 was the trigger.

Per comment, "ndis, ... were not tested. ...But the ndis driver is complex, and it is likely to be broken with this commit."

NDIS causes kernel panic with ssid is specified.  When ssid isn't specified, "list scan" works.
Comment 7 ota 2017-05-15 03:09:25 UTC
Created attachment 182606 [details]
Add ifp pointer check

ifnet *ifp pointer became a member of a union.
direct pointer access to ifp resulted in incompatible structure in net80211 mode.
Thus, I added flag check and adjusted few of callbacks.

This is tested on 11.0-REELASE.

For longer term solution, I think it is best to split ifnet and ieee80211 handling.
However, I tried with less changes to minimize impact and ease branch merge for this.
Comment 8 Marius Strobl freebsd_committer freebsd_triage 2017-05-21 20:55:44 UTC
Assign to glebius@, who committed r286410.
Comment 9 commit-hook freebsd_committer freebsd_triage 2017-05-22 20:00:29 UTC
A commit references this bug:

Author: glebius
Date: Mon May 22 20:00:02 UTC 2017
New revision: 318677
URL: https://svnweb.freebsd.org/changeset/base/318677

Log:
  Fix regression in ndis(4) after r286410. This adds a bunch of checks for
  whether this is a Ethernet or 802.11 device and does proper dereferencing.

  PR:		213237
  Submitted by:	<ota j.email.ne.jp>
  MFC after:	2 weeks

Changes:
  head/sys/compat/ndis/kern_ndis.c
  head/sys/compat/ndis/subr_ndis.c
  head/sys/dev/if_ndis/if_ndis.c
  head/sys/dev/if_ndis/if_ndisvar.h
Comment 10 ota 2017-05-26 02:39:54 UTC
I tested my laptop with NDIS with the latest 12-CURRENT and confirmed working.
Comment 11 commit-hook freebsd_committer freebsd_triage 2017-06-08 22:13:12 UTC
A commit references this bug:

Author: glebius
Date: Thu Jun  8 22:12:10 UTC 2017
New revision: 319726
URL: https://svnweb.freebsd.org/changeset/base/319726

Log:
  MFC r318677:
    Fix regression in ndis(4) after r286410. This adds a bunch of checks for
    whether this is a Ethernet or 802.11 device and does proper dereferencing.

    PR:		213237
    Submitted by:	<ota j.email.ne.jp>
    Approved by:	re (marius)

Changes:
_U  stable/11/
  stable/11/sys/compat/ndis/kern_ndis.c
  stable/11/sys/compat/ndis/subr_ndis.c
  stable/11/sys/dev/if_ndis/if_ndis.c
  stable/11/sys/dev/if_ndis/if_ndisvar.h