net80211/ifconfig: print hardware device name for wlan interfaces

Add IEEE80211_IOC_IC_NAME to query the ic_name field and in ifconfig
to print the parent interface again. This functionality was lost
around r287197. It helps in case of multiple wlan interfaces and
multiple underlying hardware devices to keep track which wlan
interface belongs to which physical device.

Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Reviewed by:	adrian, Idwer Vollering
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D25832
This commit is contained in:
Bjoern A. Zeeb 2020-08-07 12:24:23 +00:00
parent 4323354324
commit 7d1d4407f5
4 changed files with 44 additions and 1 deletions

View File

@ -4779,6 +4779,23 @@ getid(int s, int ix, void *data, size_t len, int *plen, int mesh)
return 0;
}
static int
getdevicename(int s, void *data, size_t len, int *plen)
{
struct ieee80211req ireq;
(void) memset(&ireq, 0, sizeof(ireq));
(void) strlcpy(ireq.i_name, name, sizeof(ireq.i_name));
ireq.i_type = IEEE80211_IOC_IC_NAME;
ireq.i_val = -1;
ireq.i_data = data;
ireq.i_len = len;
if (ioctl(s, SIOCG80211, &ireq) < 0)
return (-1);
*plen = ireq.i_len;
return (0);
}
static void
ieee80211_status(int s)
{
@ -5503,6 +5520,12 @@ ieee80211_status(int s)
}
LINE_BREAK();
if (getdevicename(s, data, sizeof(data), &len) < 0)
return;
LINE_CHECK("parent interface: %s", data);
LINE_BREAK();
}
static int

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 10, 2009
.Dd August 7, 2020
.Dt NET80211 4
.Os
.Sh NAME
@ -393,6 +393,16 @@ Valid values are:
and
.Dv IEEE80211_HWMP_ROOTMODE_RANN
(send broadcast Root Announcement (RANN) frames).
.It Dv IEEE80211_IOC_IC_NAME
Return the underlying hardware
.Xr device 9
name in the buffer pointed to by
.Va i_data
and the name length including terminating NUL character in
.Va i_len .
If the buffer length is too small to hold the full name
.Er EINVAL
will be returned.
.It Dv IEEE80211_IOC_INACTIVITY
Return whether or not the system handles inactivity processing in
.Va i_val .

View File

@ -785,6 +785,13 @@ ieee80211_ioctl_get80211(struct ieee80211vap *vap, u_long cmd,
int error = 0;
switch (ireq->i_type) {
case IEEE80211_IOC_IC_NAME:
len = strlen(ic->ic_name) + 1;
if (len > ireq->i_len)
return (EINVAL);
ireq->i_len = len;
error = copyout(ic->ic_name, ireq->i_data, ireq->i_len);
break;
case IEEE80211_IOC_SSID:
switch (vap->iv_state) {
case IEEE80211_S_INIT:

View File

@ -743,6 +743,9 @@ struct ieee80211req {
#define IEEE80211_IOC_QUIET_OFFSET 207 /* Quiet Offset */
#define IEEE80211_IOC_QUIET_DUR 208 /* Quiet Duration */
#define IEEE80211_IOC_QUIET_COUNT 209 /* Quiet Count */
#define IEEE80211_IOC_IC_NAME 210 /* HW device name. */
/*
* Parameters for controlling a scan requested with
* IEEE80211_IOC_SCAN_REQ.