summaryrefslogtreecommitdiffstats
path: root/freebsd/sbin/ifconfig
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-21 09:39:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:40 +0200
commit2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783 (patch)
treebd7bad558534db4a1f400bc38a2c9aa7ea4f411e /freebsd/sbin/ifconfig
parentUpdate to FreeBSD head 2018-02-01 (diff)
downloadrtems-libbsd-2df56dbd60bb5d925d2ce0ddbdefdbe6107ea783.tar.bz2
Update to FreeBSD head 2018-04-01
Git mirror commit 8dfb1ccc26d1cea7e2529303003ff61f9f1784c4. Update #3472.
Diffstat (limited to 'freebsd/sbin/ifconfig')
-rw-r--r--freebsd/sbin/ifconfig/af_link.c138
-rw-r--r--freebsd/sbin/ifconfig/ifconfig.c28
-rw-r--r--freebsd/sbin/ifconfig/ifieee80211.c2
3 files changed, 98 insertions, 70 deletions
diff --git a/freebsd/sbin/ifconfig/af_link.c b/freebsd/sbin/ifconfig/af_link.c
index c08a19fc..61a071ef 100644
--- a/freebsd/sbin/ifconfig/af_link.c
+++ b/freebsd/sbin/ifconfig/af_link.c
@@ -72,78 +72,78 @@ static void
link_status(int s __unused, const struct ifaddrs *ifa)
{
/* XXX no const 'cuz LLADDR is defined wrong */
- struct sockaddr_dl *sdl = (struct sockaddr_dl *) ifa->ifa_addr;
+ struct sockaddr_dl *sdl;
char *ether_format, *format_char;
-
- if (sdl != NULL && sdl->sdl_alen > 0) {
- if ((sdl->sdl_type == IFT_ETHER ||
- sdl->sdl_type == IFT_L2VLAN ||
- sdl->sdl_type == IFT_BRIDGE) &&
- sdl->sdl_alen == ETHER_ADDR_LEN) {
- ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl));
- if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
- for (format_char = strchr(ether_format, ':');
- format_char != NULL;
- format_char = strchr(ether_format, ':'))
- *format_char = '-';
- }
- printf("\tether %s\n", ether_format);
- } else {
- int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
-
- printf("\tlladdr %s\n", link_ntoa(sdl) + n);
- }
- /* Best-effort (i.e. failures are silent) to get original
- * hardware address, as read by NIC driver at attach time. Only
- * applies to Ethernet NICs (IFT_ETHER). However, laggX
- * interfaces claim to be IFT_ETHER, and re-type their component
- * Ethernet NICs as IFT_IEEE8023ADLAG. So, check for both. If
- * the MAC is zeroed, then it's actually a lagg.
- */
- if ((sdl->sdl_type == IFT_ETHER ||
- sdl->sdl_type == IFT_IEEE8023ADLAG) &&
- sdl->sdl_alen == ETHER_ADDR_LEN) {
- struct ifreq ifr;
- int sock_hw;
- int rc;
- static const u_char laggaddr[6] = {0};
-
- strncpy(ifr.ifr_name, ifa->ifa_name,
- sizeof(ifr.ifr_name));
- memcpy(&ifr.ifr_addr, ifa->ifa_addr,
- sizeof(ifa->ifa_addr->sa_len));
- ifr.ifr_addr.sa_family = AF_LOCAL;
- if ((sock_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
- warn("socket(AF_LOCAL,SOCK_DGRAM)");
- return;
- }
- rc = ioctl(sock_hw, SIOCGHWADDR, &ifr);
- close(sock_hw);
- if (rc != 0) {
- return;
- }
-
- /*
- * If this is definitely a lagg device or the hwaddr
- * matches the link addr, don't bother.
- */
- if (memcmp(ifr.ifr_addr.sa_data, laggaddr,
- sdl->sdl_alen) == 0 ||
- memcmp(ifr.ifr_addr.sa_data, LLADDR(sdl),
- sdl->sdl_alen) == 0) {
- return;
- }
- ether_format = ether_ntoa((const struct ether_addr *)
- &ifr.ifr_addr.sa_data);
- if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
- for (format_char = strchr(ether_format, ':');
- format_char != NULL;
- format_char = strchr(ether_format, ':'))
- *format_char = '-';
- }
- printf("\thwaddr %s\n", ether_format);
+ struct ifreq ifr;
+ int n, rc, sock_hw;
+ static const u_char laggaddr[6] = {0};
+
+ sdl = (struct sockaddr_dl *) ifa->ifa_addr;
+ if (sdl == NULL || sdl->sdl_alen == 0)
+ return;
+
+ if ((sdl->sdl_type == IFT_ETHER || sdl->sdl_type == IFT_L2VLAN ||
+ sdl->sdl_type == IFT_BRIDGE) && sdl->sdl_alen == ETHER_ADDR_LEN) {
+ ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl));
+ if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
+ for (format_char = strchr(ether_format, ':');
+ format_char != NULL;
+ format_char = strchr(ether_format, ':'))
+ *format_char = '-';
}
+ printf("\tether %s\n", ether_format);
+ } else {
+ n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
+ printf("\tlladdr %s\n", link_ntoa(sdl) + n);
}
+
+ /*
+ * Best-effort (i.e. failures are silent) to get original
+ * hardware address, as read by NIC driver at attach time. Only
+ * applies to Ethernet NICs (IFT_ETHER). However, laggX
+ * interfaces claim to be IFT_ETHER, and re-type their component
+ * Ethernet NICs as IFT_IEEE8023ADLAG. So, check for both. If
+ * the MAC is zeroed, then it's actually a lagg.
+ */
+ if ((sdl->sdl_type != IFT_ETHER &&
+ sdl->sdl_type != IFT_IEEE8023ADLAG) ||
+ sdl->sdl_alen != ETHER_ADDR_LEN)
+ return;
+
+ strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
+ memcpy(&ifr.ifr_addr, ifa->ifa_addr, sizeof(ifa->ifa_addr->sa_len));
+ ifr.ifr_addr.sa_family = AF_LOCAL;
+ if ((sock_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
+ warn("socket(AF_LOCAL,SOCK_DGRAM)");
+ return;
+ }
+ rc = ioctl(sock_hw, SIOCGHWADDR, &ifr);
+ close(sock_hw);
+ if (rc != 0)
+ return;
+
+ /*
+ * If this is definitely a lagg device or the hwaddr
+ * matches the link addr, don't bother.
+ */
+ if (memcmp(ifr.ifr_addr.sa_data, laggaddr, sdl->sdl_alen) == 0 ||
+ memcmp(ifr.ifr_addr.sa_data, LLADDR(sdl), sdl->sdl_alen) == 0)
+ goto pcp;
+
+ ether_format = ether_ntoa((const struct ether_addr *)
+ &ifr.ifr_addr.sa_data);
+ if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
+ for (format_char = strchr(ether_format, ':');
+ format_char != NULL;
+ format_char = strchr(ether_format, ':'))
+ *format_char = '-';
+ }
+ printf("\thwaddr %s\n", ether_format);
+
+pcp:
+ if (ioctl(s, SIOCGLANPCP, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_lan_pcp != IFNET_PCP_NONE)
+ printf("\tpcp %d\n", ifr.ifr_lan_pcp);
}
static void
diff --git a/freebsd/sbin/ifconfig/ifconfig.c b/freebsd/sbin/ifconfig/ifconfig.c
index 410c4849..e625e42b 100644
--- a/freebsd/sbin/ifconfig/ifconfig.c
+++ b/freebsd/sbin/ifconfig/ifconfig.c
@@ -1161,6 +1161,32 @@ setifmtu(const char *val, int dummy __unused, int s,
}
static void
+setifpcp(const char *val, int arg __unused, int s, const struct afswtch *afp)
+{
+ u_long ul;
+ char *endp;
+
+ ul = strtoul(val, &endp, 0);
+ if (*endp != '\0')
+ errx(1, "invalid value for pcp");
+ if (ul > 7)
+ errx(1, "value for pcp out of range");
+ ifr.ifr_lan_pcp = ul;
+ if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
+ err(1, "SIOCSLANPCP");
+}
+
+static void
+disableifpcp(const char *val, int arg __unused, int s,
+ const struct afswtch *afp)
+{
+
+ ifr.ifr_lan_pcp = IFNET_PCP_NONE;
+ if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
+ err(1, "SIOCSLANPCP");
+}
+
+static void
setifname(const char *val, int dummy __unused, int s,
const struct afswtch *afp)
{
@@ -1523,6 +1549,8 @@ static struct cmd basic_cmds[] = {
DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap),
DEF_CMD("netcons", IFCAP_NETCONS, setifcap),
DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
+ DEF_CMD_ARG("pcp", setifpcp),
+ DEF_CMD("-pcp", 0, disableifpcp),
DEF_CMD("polling", IFCAP_POLLING, setifcap),
DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
DEF_CMD("tso6", IFCAP_TSO6, setifcap),
diff --git a/freebsd/sbin/ifconfig/ifieee80211.c b/freebsd/sbin/ifconfig/ifieee80211.c
index c3139e2c..8faeca23 100644
--- a/freebsd/sbin/ifconfig/ifieee80211.c
+++ b/freebsd/sbin/ifconfig/ifieee80211.c
@@ -3519,7 +3519,7 @@ list_scan(int s)
getchaninfo(s);
- ssidmax = verbose ? IEEE80211_NWID_LEN : 14;
+ ssidmax = verbose ? IEEE80211_NWID_LEN : 32;
printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n"
, ssidmax, ssidmax, "SSID/MESH ID"
, "BSSID"