!189 [feature]iproute2 supports to parse the new device and related display of vf address
From: @mufengyan Reviewed-by: @sunsuwan Signed-off-by: @sunsuwan
This commit is contained in:
commit
02329b6615
@ -0,0 +1,199 @@
|
||||
From fc8d86356ef55fc4716e9bfb643592c1e1aef9a6 Mon Sep 17 00:00:00 2001
|
||||
From: Fengyan Mu <mufengyan@hisilicon.com>
|
||||
Date: Sat, 25 Nov 2023 12:10:29 +0800
|
||||
Subject: [PATCH] [feature]iproute2 supports to parse UB device and related
|
||||
display of vf address
|
||||
|
||||
tool inclusion
|
||||
category: feature
|
||||
bugzilla: https://gitee.com/src-openeuler/iproute/issues/I8EZGI
|
||||
CVE: NA
|
||||
|
||||
-----------------------------------------------------
|
||||
|
||||
This patch adds ARPHRD_UB for iproute2 and support name parse for it.
|
||||
The pf in the ub does not manage the addresses of VFs and the address
|
||||
information of the VF cannot be obtained.
|
||||
This patch deletes the display of vf address information in the pf.
|
||||
|
||||
Signed-off-by: Junxin Chen <chenjunxin1@huawei.com>
|
||||
Signed-off-by: Fengyan Mu <mufengyan@hisilicon.com>
|
||||
---
|
||||
configure | 23 +++++++++++++
|
||||
include/uapi/linux/if_arp.h | 4 +++
|
||||
ip/ipaddress.c | 68 ++++++++++++++++++++++++++-----------
|
||||
lib/ll_types.c | 3 ++
|
||||
4 files changed, 79 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 7f4f3bd..094582b 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -265,6 +265,17 @@ check_elf()
|
||||
fi
|
||||
}
|
||||
|
||||
+check_support_ub()
|
||||
+{
|
||||
+ if [ "$SUPPORT_UB" = on ]; then
|
||||
+ echo "yes"
|
||||
+ echo 'CFLAGS += -DSUPPORT_UB' >> $CONFIG
|
||||
+ else
|
||||
+ echo "no"
|
||||
+ return
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
have_libbpf_basic()
|
||||
{
|
||||
cat >$TMPDIR/libbpf_test.c <<EOF
|
||||
@@ -490,6 +501,9 @@ Usage: $0 [OPTIONS]
|
||||
--libbpf_force Enable/disable libbpf by force. Available options:
|
||||
on: require link against libbpf, quit config if no libbpf support
|
||||
off: disable libbpf probing
|
||||
+ --support_ub Enable supportting to parse ub device. Available options:
|
||||
+ on: enable supportting ub
|
||||
+ off: disable supportting ub
|
||||
-h | --help Show this usage info
|
||||
EOF
|
||||
exit $1
|
||||
@@ -513,6 +527,12 @@ else
|
||||
fi
|
||||
LIBBPF_FORCE=$2
|
||||
shift 2 ;;
|
||||
+ --support_ub)
|
||||
+ if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then
|
||||
+ usage 1
|
||||
+ fi
|
||||
+ SUPPORT_UB=$2
|
||||
+ shift 2 ;;
|
||||
-h | --help)
|
||||
usage 0 ;;
|
||||
"")
|
||||
@@ -578,6 +598,9 @@ check_strlcpy
|
||||
echo -n "libcap support: "
|
||||
check_cap
|
||||
|
||||
+echo -n "support parse ub device: "
|
||||
+check_support_ub
|
||||
+
|
||||
echo >> $CONFIG
|
||||
echo "%.o: %.c" >> $CONFIG
|
||||
echo ' $(QUIET_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -c -o $@ $<' >> $CONFIG
|
||||
diff --git a/include/uapi/linux/if_arp.h b/include/uapi/linux/if_arp.h
|
||||
index 12d06bb..b7111a5 100644
|
||||
--- a/include/uapi/linux/if_arp.h
|
||||
+++ b/include/uapi/linux/if_arp.h
|
||||
@@ -43,6 +43,10 @@
|
||||
#define ARPHRD_EUI64 27 /* EUI-64 */
|
||||
#define ARPHRD_INFINIBAND 32 /* InfiniBand */
|
||||
|
||||
+#ifdef SUPPORT_UB
|
||||
+#define ARPHRD_UB 38 /* Unified bus */
|
||||
+#endif
|
||||
+
|
||||
/* Dummy types for non ARP hardware */
|
||||
#define ARPHRD_SLIP 256
|
||||
#define ARPHRD_CSLIP 257
|
||||
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
|
||||
index 85534aa..463b8fd 100644
|
||||
--- a/ip/ipaddress.c
|
||||
+++ b/ip/ipaddress.c
|
||||
@@ -374,31 +374,61 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
|
||||
"link_type",
|
||||
" link/%s ",
|
||||
ll_type_n2a(ifi->ifi_type, b1, sizeof(b1)));
|
||||
-
|
||||
- print_color_string(PRINT_ANY, COLOR_MAC,
|
||||
- "address", "%s",
|
||||
- ll_addr_n2a((unsigned char *) &vf_mac->mac,
|
||||
- ifi->ifi_type == ARPHRD_ETHER ?
|
||||
- ETH_ALEN : INFINIBAND_ALEN,
|
||||
- ifi->ifi_type,
|
||||
- b1, sizeof(b1)));
|
||||
-
|
||||
- if (vf[IFLA_VF_BROADCAST]) {
|
||||
- if (ifi->ifi_flags&IFF_POINTOPOINT) {
|
||||
- print_string(PRINT_FP, NULL, " peer ", NULL);
|
||||
- print_bool(PRINT_JSON,
|
||||
- "link_pointtopoint", NULL, true);
|
||||
- } else
|
||||
- print_string(PRINT_FP, NULL, " brd ", NULL);
|
||||
-
|
||||
+#ifdef SUPPORT_UB
|
||||
+ if (ifi->ifi_type == ARPHRD_UB) {
|
||||
+ print_string(PRINT_FP, NULL, "pointtopoint", NULL);
|
||||
+ } else {
|
||||
print_color_string(PRINT_ANY, COLOR_MAC,
|
||||
- "broadcast", "%s",
|
||||
- ll_addr_n2a((unsigned char *) &vf_broadcast->broadcast,
|
||||
+ "address", "%s",
|
||||
+ ll_addr_n2a((unsigned char *) &vf_mac->mac,
|
||||
ifi->ifi_type == ARPHRD_ETHER ?
|
||||
ETH_ALEN : INFINIBAND_ALEN,
|
||||
ifi->ifi_type,
|
||||
b1, sizeof(b1)));
|
||||
+
|
||||
+ if (vf[IFLA_VF_BROADCAST]) {
|
||||
+ if (ifi->ifi_flags&IFF_POINTOPOINT) {
|
||||
+ print_string(PRINT_FP, NULL, " peer ", NULL);
|
||||
+ print_bool(PRINT_JSON,
|
||||
+ "link_pointtopoint", NULL, true);
|
||||
+ } else
|
||||
+ print_string(PRINT_FP, NULL, " brd ", NULL);
|
||||
+
|
||||
+ print_color_string(PRINT_ANY, COLOR_MAC,
|
||||
+ "broadcast", "%s",
|
||||
+ ll_addr_n2a((unsigned char *) &vf_broadcast->broadcast,
|
||||
+ ifi->ifi_type == ARPHRD_ETHER ?
|
||||
+ ETH_ALEN : INFINIBAND_ALEN,
|
||||
+ ifi->ifi_type,
|
||||
+ b1, sizeof(b1)));
|
||||
+ }
|
||||
}
|
||||
+#else
|
||||
+ print_color_string(PRINT_ANY, COLOR_MAC,
|
||||
+ "address", "%s",
|
||||
+ ll_addr_n2a((unsigned char *) &vf_mac->mac,
|
||||
+ ifi->ifi_type == ARPHRD_ETHER ?
|
||||
+ ETH_ALEN : INFINIBAND_ALEN,
|
||||
+ ifi->ifi_type,
|
||||
+ b1, sizeof(b1)));
|
||||
+
|
||||
+ if (vf[IFLA_VF_BROADCAST]) {
|
||||
+ if (ifi->ifi_flags&IFF_POINTOPOINT) {
|
||||
+ print_string(PRINT_FP, NULL, " peer ", NULL);
|
||||
+ print_bool(PRINT_JSON,
|
||||
+ "link_pointtopoint", NULL, true);
|
||||
+ } else
|
||||
+ print_string(PRINT_FP, NULL, " brd ", NULL);
|
||||
+
|
||||
+ print_color_string(PRINT_ANY, COLOR_MAC,
|
||||
+ "broadcast", "%s",
|
||||
+ ll_addr_n2a((unsigned char *) &vf_broadcast->broadcast,
|
||||
+ ifi->ifi_type == ARPHRD_ETHER ?
|
||||
+ ETH_ALEN : INFINIBAND_ALEN,
|
||||
+ ifi->ifi_type,
|
||||
+ b1, sizeof(b1)));
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
if (vf[IFLA_VF_VLAN_LIST]) {
|
||||
struct rtattr *i, *vfvlanlist = vf[IFLA_VF_VLAN_LIST];
|
||||
diff --git a/lib/ll_types.c b/lib/ll_types.c
|
||||
index 49da15d..2dc8140 100644
|
||||
--- a/lib/ll_types.c
|
||||
+++ b/lib/ll_types.c
|
||||
@@ -106,6 +106,9 @@ __PF(CAIF, caif)
|
||||
__PF(IP6GRE, gre6)
|
||||
__PF(NETLINK, netlink)
|
||||
__PF(6LOWPAN, 6lowpan)
|
||||
+#ifdef SUPPORT_UB
|
||||
+__PF(UB, ub)
|
||||
+#endif
|
||||
|
||||
__PF(NONE, none)
|
||||
__PF(VOID,void)
|
||||
--
|
||||
2.33.0
|
||||
|
||||
13
iproute.spec
13
iproute.spec
@ -2,7 +2,7 @@
|
||||
Name: iproute
|
||||
Version: 5.15.0
|
||||
Epoch: 1
|
||||
Release: 14
|
||||
Release: 15
|
||||
Summary: Linux network configuration utilities
|
||||
License: GPLv2+ and Public Domain
|
||||
URL: https://kernel.org/pub/linux/utils/net/iproute2/
|
||||
@ -47,6 +47,7 @@ Patch6030: backport-rt_names-check-for-malloc-failure.patch
|
||||
|
||||
Patch9000: feature-iproute-add-support-for-ipvlan-l2e-mode.patch
|
||||
Patch9001: bugfix-iproute2-cancel-some-test-cases.patch
|
||||
Patch9002: feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch
|
||||
|
||||
BuildRequires: gcc bison elfutils-libelf-devel flex iptables-devel
|
||||
BuildRequires: libmnl-devel libselinux-devel pkgconfig libbpf-devel sudo make
|
||||
@ -79,7 +80,7 @@ Header files for iprout2
|
||||
%build
|
||||
export LIBDIR='%{_libdir}'
|
||||
export IPT_LIB_DIR='/%{_lib}/xtables'
|
||||
%configure
|
||||
%configure --support_ub on
|
||||
%make_build
|
||||
|
||||
%check
|
||||
@ -122,6 +123,14 @@ install -m 0644 lib/libnetlink.a %{buildroot}%{_libdir}/libnetlink.a
|
||||
%{_mandir}/*
|
||||
|
||||
%changelog
|
||||
* Thu May 30 2024 mufengyan <mufengyan@hisilicon.com> - 1:5.15.0-15
|
||||
- Type:feature
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:This patch adds ARPHRD_UB for iproute2 and support name
|
||||
parse for it and deletes the display of vf address
|
||||
information in the pf
|
||||
|
||||
* Thu Aug 17 2023 gaoxingwang <gaoxingwang1@huawei.com> - 1:5.15.0-14
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user