Bug 264253 - hyperv: ifconfig media autoselect on FreeBSD 13.0 displays error: ifconfig: SIOCSIFMEDIA (media): Operation not supported
Summary: hyperv: ifconfig media autoselect on FreeBSD 13.0 displays error: ifconfig: S...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords: needs-qa, regression
Depends on:
Blocks:
 
Reported: 2022-05-26 10:21 UTC by Prakash Shiva
Modified: 2024-04-07 21:06 UTC (History)
5 users (show)

See Also:
koobs: maintainer-feedback? (whu)
koobs: mfc-stable13?
koobs: mfc-stable12?


Attachments
dmesg.boot log (4.70 KB, text/plain)
2022-05-27 08:36 UTC, Prakash Shiva
no flags Details
Azure-var-run-dmesg (37.38 KB, text/plain)
2022-06-16 04:05 UTC, Prakash Shiva
no flags Details
Patch to resolve this issue (433 bytes, patch)
2022-06-23 04:57 UTC, Prakash Shiva
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Prakash Shiva 2022-05-26 10:21:08 UTC
FreeBSD 13.0 HyperV VM: 
  when I type this command "ifconfig nic0 media autoselect" I see following "error: ifconfig: SIOCSIFMEDIA (media): Operation not supported".

FreeBSD 10.4 HyperV Vm:
  Running same command does not throw this error on the same hyperV host. 

HyperV host NIC card: Intel X550-TX 10Gig


==========================
FreeBSD 10.4 log:
==========================
bsd-10.4# ifconfig hn0 media autoselect
bsd-10.4# uname -r
10.4-RELEASE
bsd-10.4# ifconfig -mvvvv hn0
hn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8051b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,LRO,LINKSTATE>
	capabilities=48071b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,TSO6,LRO,LINKSTATE,TXCSUM_IPV6>
	ether 00:15:5d:01:0a:3c
	hwaddr 00:15:5d:01:0a:3c
	inet 192.168.1.41 netmask 0xffffffe0 broadcast 192.168.1.63 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (10Gbase-T <full-duplex>)
	status: active
	supported media:
		media autoselect
bsd-10.4# dmesg |grep hn
hn0: <Hyper-V Network Interface> on vmbus0
hn0: Ethernet address: 00:15:5d:01:0a:3c
hn1: <Hyper-V Network Interface> on vmbus0
hn0: link state changed to UP
hn1: Ethernet address: 00:15:5d:01:0a:3d
hn2: <Hyper-V Network Interface> on vmbus0
hn1: link state changed to UP
hn2: Ethernet address: 00:15:5d:01:0a:3e
hn2: link state changed to UP


==========================
FreeBSD 13.0 log:
==========================
bsd-13.0:~ # dmesg |grep hn
hn0: <Hyper-V Network Interface> on vmbus0
hn0: Ethernet address: 00:15:5d:01:0a:58
hn1: <Hyper-V Network Interface> on vmbus0
hn0: link state changed to UP
hn1: Ethernet address: 00:15:5d:01:0a:59
hn1: link state changed to UP
root@freebsd:~ # uname -a
FreeBSD freebsd 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
bsd-13.0:~ # ifconfig -mvvvv hn0
hn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8051b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,LRO,LINKSTATE>
	capabilities=48071b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,TSO6,LRO,LINKSTATE,TXCSUM_IPV6>
	ether 00:15:5d:01:0a:58
	inet6 fe80::215:5dff:fe01:a58%hn0 prefixlen 64 scopeid 0x2
	inet 192.168.1.36 netmask 0xffffffe0 broadcast 192.168.1.33
	media: Ethernet autoselect (10Gbase-T <full-duplex>)
	status: active
	supported media:
		media autoselect
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
bsd-13.0:~ # ifconfig hn0 media autoselect
ifconfig: SIOCSIFMEDIA (media): Operation not supported
bsd-13.0:~ #
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2022-05-26 23:56:01 UTC
@Reporter Could you include additional information please:

- uname -a output
- /var/run/dmesg.boot output (as an attachment)
- pciconf -lv output (as an attachment)

Thanks!
Comment 2 Prakash Shiva 2022-05-27 08:36:58 UTC
Created attachment 234256 [details]
dmesg.boot log

log of /var/run/dmesg.boot
Comment 3 Prakash Shiva 2022-05-27 08:39:11 UTC
root@freebsd:~ # uname -a
FreeBSD freebsd 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
root@freebsd:~ #

pciconf is not working in hyperV VMs. I fired up BSD 13.0 and 13.1. pciconf did not work on both.

=============
pciconf log:
=============
root@freebsd:~ # pciconf -lv
root@freebsd:~ # pciconf 
usage: pciconf -l [-BbcevV] [device]
       pciconf -a device
       pciconf -r [-b | -h] device addr[:addr2]
       pciconf -w [-b | -h] device addr value
       pciconf -D [-b | -h | -x] device bar [start [count]]
root@freebsd:~ # pciconf -l
root@freebsd:~ # pciconf -lv
root@freebsd:~ #
Comment 4 Prakash Shiva 2022-06-16 04:05:55 UTC
Created attachment 234716 [details]
Azure-var-run-dmesg

Issue is seen in Azure Freebsd 13.0 as well. Please find the log below:

azureuser@pshiva-bare-13:~ $ uname -a
FreeBSD pshiva-bare-13 13.0-RELEASE-p7 FreeBSD 13.0-RELEASE-p7 #0 releng/13.0-n244776-e5733e6d904: Tue Feb 15 04:09:03 UTC 2022     root@build-13-0:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
azureuser@pshiva-bare-13:~ $ ifconfig hn0 media autoselect
ifconfig: SIOCSIFMEDIA (media): Operation not permitted
azureuser@pshiva-bare-13:~ $
azureuser@pshiva-bare-13:~ $ pciconf -lv
hostb0@pci0:0:0:0:	class=0x060000 rev=0x03 hdr=0x00 vendor=0x8086 device=0x7192 subvendor=0x0000 subdevice=0x0000
    vendor     = 'Intel Corporation'
    device     = '440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled)'
    class      = bridge
    subclass   = HOST-PCI
isab0@pci0:0:7:0:	class=0x060100 rev=0x01 hdr=0x00 vendor=0x8086 device=0x7110 subvendor=0x1414 subdevice=0x0000
    vendor     = 'Intel Corporation'
    device     = '82371AB/EB/MB PIIX4 ISA'
    class      = bridge
    subclass   = PCI-ISA
atapci0@pci0:0:7:1:	class=0x010180 rev=0x01 hdr=0x00 vendor=0x8086 device=0x7111 subvendor=0x0000 subdevice=0x0000
    vendor     = 'Intel Corporation'
    device     = '82371AB/EB/MB PIIX4 IDE'
    class      = mass storage
    subclass   = ATA
none0@pci0:0:7:3:	class=0x068000 rev=0x02 hdr=0x00 vendor=0x8086 device=0x7113 subvendor=0x0000 subdevice=0x0000
    vendor     = 'Intel Corporation'
    device     = '82371AB/EB/MB PIIX4 ACPI'
    class      = bridge
vgapci0@pci0:0:8:0:	class=0x030000 rev=0x00 hdr=0x00 vendor=0x1414 device=0x5353 subvendor=0x0000 subdevice=0x0000
    vendor     = 'Microsoft Corporation'
    device     = 'Hyper-V virtual VGA'
    class      = display
    subclass   = VGA
azureuser@pshiva-bare-13:~ $
Comment 5 Prakash Shiva 2022-06-23 04:57:56 UTC
Created attachment 234879 [details]
Patch to resolve this issue

Without patch:
root@share-bare13:~ # ifconfig hn0 media autoselect
ifconfig: SIOCSIFMEDIA (media): Operation not supported
root@share-bare13:~ # 

With patch:
root@share-bare13:~ # ifconfig hn0 media autoselect
root@share-bare13:~ #
Comment 6 Mark Peek freebsd_committer freebsd_triage 2024-03-02 21:14:02 UTC
I see the same error across 10.4, 13.0, and 15-current

10.4
====
# uname -a
FreeBSD fbsd10 10.4-RELEASE FreeBSD 10.4-RELEASE #0 r324094: Fri Sep 29 01:45:44 UTC 2017     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
# ifconfig -mv hn0
hn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8051b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,LRO,LINKSTATE>
	capabilities=48071b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,TSO6,LRO,LINKSTATE,TXCSUM_IPV6>
	ether 00:15:5d:0a:28:00
	hwaddr 00:15:5d:0a:28:00
	inet6 fe80::215:5dff:fe0a:2800%hn0 prefixlen 64 scopeid 0x2
	inet6 2601:601:4000:c4de:215:5dff:fe0a:2800 prefixlen 64 autoconf
	inet6 fd50:d9bc:e952:6040:215:5dff:fe0a:2800 prefixlen 64 detached autoconf
	inet 10.1.10.215 netmask 0xffffff00 broadcast 10.1.10.255
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
	media: Ethernet autoselect (10Gbase-T <full-duplex>)
	status: active
	supported media:
		media autoselect
# ifconfig hn0 media autoselect
ifconfig: SIOCSIFMEDIA (media): Operation not supported

13.0
====
# uname -a
FreeBSD bsd13 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
# ifconfig -mv hn0
hn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8051b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,LRO,LINKSTATE>
	capabilities=48071b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,TSO6,LRO,LINKSTATE,TXCSUM_IPV6>
	ether 00:15:5d:0a:28:01
	inet 10.1.10.139 netmask 0xffffff00 broadcast 10.1.10.255
	media: Ethernet autoselect (10Gbase-T <full-duplex>)
	status: active
	supported media:
		media autoselect
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
# ifconfig hn0 media autoselect
ifconfig: SIOCSIFMEDIA (media): Operation not supported

15-current
==========
# uname -a
FreeBSD FreeBSD-current 15.0-CURRENT FreeBSD 15.0-CURRENT #0 main-n268454-9097284b98be: Thu Feb 22 03:00:34 UTC 2024     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
# ifconfig -mv hn0
hn0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
	options=8051b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,LRO,LINKSTATE>
	capabilities=48071b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,TSO6,LRO,LINKSTATE,TXCSUM_IPV6>
	ether 00:15:5d:0a:28:02
	inet 10.1.10.125 netmask 0xffffff00 broadcast 10.1.10.255
	inet6 fe80::215:5dff:fe0a:2802%hn0 prefixlen 64 scopeid 0x2
	inet6 2601:601:4000:c4de:215:5dff:fe0a:2802 prefixlen 64 autoconf pltime 14400 vltime 86400
	inet6 fd50:d9bc:e952:6040:215:5dff:fe0a:2802 prefixlen 64 detached autoconf pltime 1800 vltime 1800
	media: Ethernet autoselect (10Gbase-T <full-duplex>)
	status: active
	supported media:
		media autoselect
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
	drivername: hn0
# ifconfig hn0 media autoselect
ifconfig: SIOCSIFMEDIA (media): Operation not supported


This is not surprising since the hn_ifmedia_upd() callback is the same and returns EOPNOTSUPP. The code for 10.4 is here:
https://github.com/freebsd/freebsd-src/blob/releng/10.4/sys/dev/hyperv/netvsc/if_hn.c#L1008

Since the only media supported is autoselect, it seems reasonable to just return 0 from hn_ifmedia_upd() instead of EOPNOTSUPP. Patched on 15-current, this results in no error for "autoselect" and will error for unregistered media types.

# ifconfig hn0 media autoselect
# ifconfig hn0 media 100baseT
ifconfig: SIOCSIFMEDIA (media): Device not configured

An early review D4611 did have hn_ifmedia_upd() return 0 but was abandoned. A subsequent review D4852 has this function returning EOPNOTSUPP.

Allowing selection of the current (and only) registered media type seems reasonable rather than throwing an error. I'm going to try contacting a couple of the contributors to the reviews to see if they agree.
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-03-14 00:11:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=63a7c4be4ad524629292eee659d6542f1c5e9c21

commit 63a7c4be4ad524629292eee659d6542f1c5e9c21
Author:     Mark Peek <mp@FreeBSD.org>
AuthorDate: 2024-03-13 23:53:07 +0000
Commit:     Mark Peek <mp@FreeBSD.org>
CommitDate: 2024-03-14 00:05:19 +0000

    hyperv/hn: Don't return error when setting media to autoselect

    Setting media to autoselect would always return EOPNOTSUPP.
    As autoselect is the only valid media, this change now returns
    success instead.

    PR:             264253
    Reported by:    Prakash Shiva <prakashs0234@gmail.com>
    Reviewed by:    Dexuan Cui <decui microsoft com>, whu
    Approved by:    whu
    MFC after:      2 weeks

 sys/dev/hyperv/netvsc/if_hn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-03-31 16:56:22 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a1f89082dcb591886acc22c5503a2d5a82b267d9

commit a1f89082dcb591886acc22c5503a2d5a82b267d9
Author:     Mark Peek <mp@FreeBSD.org>
AuthorDate: 2024-03-13 23:53:07 +0000
Commit:     Mark Peek <mp@FreeBSD.org>
CommitDate: 2024-03-31 16:51:02 +0000

    hyperv/hn: Don't return error when setting media to autoselect

    Setting media to autoselect would always return EOPNOTSUPP.
    As autoselect is the only valid media, this change now returns
    success instead.

    PR:             264253
    Reported by:    Prakash Shiva <prakashs0234@gmail.com>
    Reviewed by:    Dexuan Cui <decui microsoft com>, whu
    Approved by:    whu
    MFC after:      2 weeks

    (cherry picked from commit 63a7c4be4ad524629292eee659d6542f1c5e9c21)

 sys/dev/hyperv/netvsc/if_hn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-03-31 16:57:25 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a26e93052a3897bb55301954dff7e40547d7f291

commit a26e93052a3897bb55301954dff7e40547d7f291
Author:     Mark Peek <mp@FreeBSD.org>
AuthorDate: 2024-03-13 23:53:07 +0000
Commit:     Mark Peek <mp@FreeBSD.org>
CommitDate: 2024-03-31 16:49:01 +0000

    hyperv/hn: Don't return error when setting media to autoselect

    Setting media to autoselect would always return EOPNOTSUPP.
    As autoselect is the only valid media, this change now returns
    success instead.

    PR:             264253
    Reported by:    Prakash Shiva <prakashs0234@gmail.com>
    Reviewed by:    Dexuan Cui <decui microsoft com>, whu
    Approved by:    whu
    MFC after:      2 weeks

    (cherry picked from commit 63a7c4be4ad524629292eee659d6542f1c5e9c21)

 sys/dev/hyperv/netvsc/if_hn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)