git: 31016aa0be6d - main - ifconfig: fix 'ifconfig -l ether'
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Aug 2023 17:33:20 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=31016aa0be6dbf7556a91dda14cfe1ff0dcf933b
commit 31016aa0be6dbf7556a91dda14cfe1ff0dcf933b
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-08-25 17:31:26 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-08-25 17:31:26 +0000
ifconfig: fix 'ifconfig -l ether'
When matching interfaces for being Ethernet, use same trick that
the link module does - pass if_type through convert_iftype().
That restores historicaly behaviour of listing lagg(4) ports.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D41585
---
sbin/ifconfig/af_link.c | 11 -----------
sbin/ifconfig/ifconfig.h | 2 ++
sbin/ifconfig/ifconfig_netlink.c | 15 ++++++++++++++-
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c
index 17de87539d9a..2a53daeb7d01 100644
--- a/sbin/ifconfig/af_link.c
+++ b/sbin/ifconfig/af_link.c
@@ -165,17 +165,6 @@ pcp:
}
#else
-static uint8_t
-convert_iftype(uint8_t iftype)
-{
- switch (iftype) {
- case IFT_IEEE8023ADLAG:
- return (IFT_ETHER);
- case IFT_INFINIBANDLAG:
- return (IFT_INFINIBAND);
- }
- return (iftype);
-}
static void
link_status_nl(if_ctx *ctx, if_link_t *link, if_addr_t *ifa __unused)
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
index 80e6b9bc2289..3303c4894ba7 100644
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -38,6 +38,7 @@
#include <libifconfig.h>
#include <stdbool.h>
+#include <net/if_types.h>
#define __constructor __attribute__((constructor))
@@ -279,6 +280,7 @@ struct afswtch *af_getbyfamily(int af);
void af_other_status(if_ctx *ctx);
void print_ifstatus(if_ctx *ctx);
void print_metric(if_ctx *ctx);
+ifType convert_iftype(ifType iftype);
/* Netlink-related functions */
void list_interfaces_nl(struct ifconfig_args *args);
diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c
index 76dd99307f31..c3e8cd413409 100644
--- a/sbin/ifconfig/ifconfig_netlink.c
+++ b/sbin/ifconfig/ifconfig_netlink.c
@@ -224,6 +224,19 @@ if_nametoindex_nl(struct snl_state *ss, const char *ifname)
return (link.ifi_index);
}
+ifType
+convert_iftype(ifType iftype)
+{
+ switch (iftype) {
+ case IFT_IEEE8023ADLAG:
+ return (IFT_ETHER);
+ case IFT_INFINIBANDLAG:
+ return (IFT_INFINIBAND);
+ default:
+ return (iftype);
+ }
+}
+
static void
prepare_ifaddrs(struct snl_state *ss, struct ifmap *ifmap)
{
@@ -282,7 +295,7 @@ match_iface(struct ifconfig_args *args, struct iface *iface)
struct sockaddr_dl sdl = {
.sdl_len = sizeof(struct sockaddr_dl),
.sdl_family = AF_LINK,
- .sdl_type = link->ifi_type,
+ .sdl_type = convert_iftype(link->ifi_type),
.sdl_alen = NLA_DATA_LEN(link->ifla_address),
};
return (match_ether(&sdl));