Hi Geliang,
On 17/03/2024 01:58, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> The address that needs to change flags can only be identified by an address
> ID in change_endpoint() helper. This patch adds another helper named
> change_address(), its 2nd parameter is an IP address.
>
> Usage:
> Address ID - change_endpoint $ns id $id $flags
> IP address - change_address $ns $addr $flags
>
> Use this new helper in pm_netlink.sh to replace all 'pm_nl_ctl set'
> commands.
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> tools/testing/selftests/net/mptcp/mptcp_lib.sh | 13 +++++++++++++
> tools/testing/selftests/net/mptcp/pm_netlink.sh | 4 ++--
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index d83a67922b17..e26ef67e4ef1 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -588,3 +588,16 @@ mptcp_lib_pm_nl_get_endpoint() {
> ip netns exec "${ns}" ./pm_nl_ctl get "${id}"
> fi
> }
> +
> +mptcp_lib_pm_nl_change_address() {
Same here, if it is only used in pm_netlink.sh, keep it there, with a
shorter name, and without ns:
change_address 10.0.1.1 backup
no?
> + local ns=${1}
> + local addr=${2}
> + local flags=${3}
> +
> + if mptcp_lib_is_ip_mptcp; then
> + # shellcheck disable=SC2086 # blanks in flags, no double quote
> + ip -n "${ns}" mptcp endpoint change "${addr}" ${flags//","/" "}
It looks like this helper is only used with 'backup' or 'nobackup' flag,
you can then use "${flags}" without the "disable=SC2086", no?
> + else
> + ip netns exec "${ns}" ./pm_nl_ctl set "${addr}" flags "${flags}"
> + fi
> +}
(...)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.