From 029134c1e9aaa1439dbbf3d421e43d701d60d1b6 Mon Sep 17 00:00:00 2001 From: Fengyan Mu Date: Wed, 8 Nov 2023 22:46:03 +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 Signed-off-by: Fengyan Mu --- ...ce-and-related-display-of-vf-address.patch | 199 ++++++++++++++++++ iproute.spec | 13 +- 2 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch diff --git a/feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch b/feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch new file mode 100644 index 0000000..d4bd24d --- /dev/null +++ b/feature-iproute2-supports-to-parse-UB-device-and-related-display-of-vf-address.patch @@ -0,0 +1,199 @@ +From fc8d86356ef55fc4716e9bfb643592c1e1aef9a6 Mon Sep 17 00:00:00 2001 +From: Fengyan Mu +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 +Signed-off-by: Fengyan Mu +--- + 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 <> $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 + diff --git a/iproute.spec b/iproute.spec index 6b27e29..3320bf3 100644 --- a/iproute.spec +++ b/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 +* Sat Nov 25 2023 mufengyan - 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 - 1:5.15.0-14 - Type:bugfix - ID:NA -- Gitee