Skip to content

Commit a326f6a

Browse files
author
CKI KWF Bot
committed
Merge: selftests: stable backport for 10.1 phase 2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1044 JIRA: https://issues.redhat.com/browse/RHEL-96617 No fixes, just add some helper functions for testing lib. Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> Signed-off-by: Hangbin Liu <haliu@redhat.com> --- <small>Created 2025-06-13 06:04 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12334433&issuetype=1&priority=4&summary=backporter+webhook+issue&components=kernel-workflow+/+backporter)</small> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: Phil Sutter <psutter@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 07b7390 + 7fc0cc4 commit a326f6a

File tree

7 files changed

+168
-111
lines changed

7 files changed

+168
-111
lines changed

tools/testing/selftests/drivers/net/bonding/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TEST_PROGS := \
1010
mode-2-recovery-updelay.sh \
1111
bond_options.sh \
1212
bond-eth-type-change.sh \
13-
bond_macvlan.sh
13+
bond_macvlan_ipvlan.sh
1414

1515
TEST_FILES := \
1616
lag_lib.sh \

tools/testing/selftests/drivers/net/bonding/bond_macvlan.sh

Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Test macvlan/ipvlan over bond
5+
6+
lib_dir=$(dirname "$0")
7+
source ${lib_dir}/bond_topo_2d1c.sh
8+
9+
xvlan1_ns="xvlan1-$(mktemp -u XXXXXX)"
10+
xvlan2_ns="xvlan2-$(mktemp -u XXXXXX)"
11+
xvlan1_ip4="192.0.2.11"
12+
xvlan1_ip6="2001:db8::11"
13+
xvlan2_ip4="192.0.2.12"
14+
xvlan2_ip6="2001:db8::12"
15+
16+
cleanup()
17+
{
18+
client_destroy
19+
server_destroy
20+
gateway_destroy
21+
22+
ip netns del ${xvlan1_ns}
23+
ip netns del ${xvlan2_ns}
24+
}
25+
26+
check_connection()
27+
{
28+
local ns=${1}
29+
local target=${2}
30+
local message=${3}
31+
RET=0
32+
33+
ip netns exec ${ns} ping ${target} -c 4 -i 0.1 &>/dev/null
34+
check_err $? "ping failed"
35+
log_test "${bond_mode}/${xvlan_type}_${xvlan_mode}: ${message}"
36+
}
37+
38+
xvlan_over_bond()
39+
{
40+
local param="$1"
41+
local xvlan_type="$2"
42+
local xvlan_mode="$3"
43+
RET=0
44+
45+
# setup new bond mode
46+
bond_reset "${param}"
47+
48+
ip -n ${s_ns} link add link bond0 name ${xvlan_type}0 type ${xvlan_type} mode ${xvlan_mode}
49+
ip -n ${s_ns} link set ${xvlan_type}0 netns ${xvlan1_ns}
50+
ip -n ${xvlan1_ns} link set dev ${xvlan_type}0 up
51+
ip -n ${xvlan1_ns} addr add ${xvlan1_ip4}/24 dev ${xvlan_type}0
52+
ip -n ${xvlan1_ns} addr add ${xvlan1_ip6}/24 dev ${xvlan_type}0
53+
54+
ip -n ${s_ns} link add link bond0 name ${xvlan_type}0 type ${xvlan_type} mode ${xvlan_mode}
55+
ip -n ${s_ns} link set ${xvlan_type}0 netns ${xvlan2_ns}
56+
ip -n ${xvlan2_ns} link set dev ${xvlan_type}0 up
57+
ip -n ${xvlan2_ns} addr add ${xvlan2_ip4}/24 dev ${xvlan_type}0
58+
ip -n ${xvlan2_ns} addr add ${xvlan2_ip6}/24 dev ${xvlan_type}0
59+
60+
sleep 2
61+
62+
check_connection "${c_ns}" "${s_ip4}" "IPv4: client->server"
63+
check_connection "${c_ns}" "${s_ip6}" "IPv6: client->server"
64+
check_connection "${c_ns}" "${xvlan1_ip4}" "IPv4: client->${xvlan_type}_1"
65+
check_connection "${c_ns}" "${xvlan1_ip6}" "IPv6: client->${xvlan_type}_1"
66+
check_connection "${c_ns}" "${xvlan2_ip4}" "IPv4: client->${xvlan_type}_2"
67+
check_connection "${c_ns}" "${xvlan2_ip6}" "IPv6: client->${xvlan_type}_2"
68+
check_connection "${xvlan1_ns}" "${xvlan2_ip4}" "IPv4: ${xvlan_type}_1->${xvlan_type}_2"
69+
check_connection "${xvlan1_ns}" "${xvlan2_ip6}" "IPv6: ${xvlan_type}_1->${xvlan_type}_2"
70+
71+
check_connection "${s_ns}" "${c_ip4}" "IPv4: server->client"
72+
check_connection "${s_ns}" "${c_ip6}" "IPv6: server->client"
73+
check_connection "${xvlan1_ns}" "${c_ip4}" "IPv4: ${xvlan_type}_1->client"
74+
check_connection "${xvlan1_ns}" "${c_ip6}" "IPv6: ${xvlan_type}_1->client"
75+
check_connection "${xvlan2_ns}" "${c_ip4}" "IPv4: ${xvlan_type}_2->client"
76+
check_connection "${xvlan2_ns}" "${c_ip6}" "IPv6: ${xvlan_type}_2->client"
77+
check_connection "${xvlan2_ns}" "${xvlan1_ip4}" "IPv4: ${xvlan_type}_2->${xvlan_type}_1"
78+
check_connection "${xvlan2_ns}" "${xvlan1_ip6}" "IPv6: ${xvlan_type}_2->${xvlan_type}_1"
79+
80+
ip -n ${c_ns} neigh flush dev eth0
81+
}
82+
83+
trap cleanup EXIT
84+
85+
setup_prepare
86+
ip netns add ${xvlan1_ns}
87+
ip netns add ${xvlan2_ns}
88+
89+
bond_modes="active-backup balance-tlb balance-alb"
90+
91+
for bond_mode in ${bond_modes}; do
92+
xvlan_over_bond "mode ${bond_mode}" macvlan bridge
93+
xvlan_over_bond "mode ${bond_mode}" ipvlan l2
94+
done
95+
96+
exit $EXIT_STATUS

tools/testing/selftests/drivers/net/bonding/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CONFIG_BRIDGE=y
33
CONFIG_DUMMY=y
44
CONFIG_IPV6=y
55
CONFIG_MACVLAN=y
6+
CONFIG_IPVLAN=y
67
CONFIG_NET_ACT_GACT=y
78
CONFIG_NET_CLS_FLOWER=y
89
CONFIG_NET_SCH_INGRESS=y

tools/testing/selftests/net/fdb_notify.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_dup_vxlan_self()
4949
{
5050
ip_link_add br up type bridge vlan_filtering 1
5151
ip_link_add vx up type vxlan id 2000 dstport 4789
52-
ip_link_master vx br
52+
ip_link_set_master vx br
5353

5454
do_test_dup add "vxlan" dev vx self dst 192.0.2.1
5555
do_test_dup del "vxlan" dev vx self dst 192.0.2.1
@@ -59,7 +59,7 @@ test_dup_vxlan_master()
5959
{
6060
ip_link_add br up type bridge vlan_filtering 1
6161
ip_link_add vx up type vxlan id 2000 dstport 4789
62-
ip_link_master vx br
62+
ip_link_set_master vx br
6363

6464
do_test_dup add "vxlan master" dev vx master
6565
do_test_dup del "vxlan master" dev vx master
@@ -79,7 +79,7 @@ test_dup_macvlan_master()
7979
ip_link_add br up type bridge vlan_filtering 1
8080
ip_link_add dd up type dummy
8181
ip_link_add mv up link dd type macvlan mode passthru
82-
ip_link_master mv br
82+
ip_link_set_master mv br
8383

8484
do_test_dup add "macvlan master" dev mv self
8585
do_test_dup del "macvlan master" dev mv self

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,13 +936,6 @@ packets_rate()
936936
echo $(((t1 - t0) / interval))
937937
}
938938

939-
mac_get()
940-
{
941-
local if_name=$1
942-
943-
ip -j link show dev $if_name | jq -r '.[]["address"]'
944-
}
945-
946939
ether_addr_to_u64()
947940
{
948941
local addr="$1"

tools/testing/selftests/net/lib.sh

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,13 @@ xfail_on_veth()
437437
fi
438438
}
439439

440+
mac_get()
441+
{
442+
local if_name=$1
443+
444+
ip -j link show dev $if_name | jq -r '.[]["address"]'
445+
}
446+
440447
kill_process()
441448
{
442449
local pid=$1; shift
@@ -453,11 +460,70 @@ ip_link_add()
453460
defer ip link del dev "$name"
454461
}
455462

456-
ip_link_master()
463+
ip_link_set_master()
457464
{
458465
local member=$1; shift
459466
local master=$1; shift
460467

461468
ip link set dev "$member" master "$master"
462469
defer ip link set dev "$member" nomaster
463470
}
471+
472+
ip_link_set_addr()
473+
{
474+
local name=$1; shift
475+
local addr=$1; shift
476+
477+
local old_addr=$(mac_get "$name")
478+
ip link set dev "$name" address "$addr"
479+
defer ip link set dev "$name" address "$old_addr"
480+
}
481+
482+
ip_link_is_up()
483+
{
484+
local name=$1; shift
485+
486+
local state=$(ip -j link show "$name" |
487+
jq -r '(.[].flags[] | select(. == "UP")) // "DOWN"')
488+
[[ $state == "UP" ]]
489+
}
490+
491+
ip_link_set_up()
492+
{
493+
local name=$1; shift
494+
495+
if ! ip_link_is_up "$name"; then
496+
ip link set dev "$name" up
497+
defer ip link set dev "$name" down
498+
fi
499+
}
500+
501+
ip_link_set_down()
502+
{
503+
local name=$1; shift
504+
505+
if ip_link_is_up "$name"; then
506+
ip link set dev "$name" down
507+
defer ip link set dev "$name" up
508+
fi
509+
}
510+
511+
ip_addr_add()
512+
{
513+
local name=$1; shift
514+
515+
ip addr add dev "$name" "$@"
516+
defer ip addr del dev "$name" "$@"
517+
}
518+
519+
ip_route_add()
520+
{
521+
ip route add "$@"
522+
defer ip route del "$@"
523+
}
524+
525+
bridge_vlan_add()
526+
{
527+
bridge vlan add "$@"
528+
defer bridge vlan del "$@"
529+
}

0 commit comments

Comments
 (0)