1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4# Check FDB default-remote handling across "ip link set".
5
6check_remotes()
7{
8	local what=$1; shift
9	local N=$(bridge fdb sh dev vx | grep 00:00:00:00:00:00 | wc -l)
10
11	echo -ne "expected two remotes after $what\t"
12	if [[ $N != 2 ]]; then
13		echo "[FAIL]"
14		EXIT_STATUS=1
15	else
16		echo "[ OK ]"
17	fi
18}
19
20ip link add name vx up type vxlan id 2000 dstport 4789
21bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.20 self permanent
22bridge fdb ap dev vx 00:00:00:00:00:00 dst 192.0.2.30 self permanent
23check_remotes "fdb append"
24
25ip link set dev vx type vxlan remote 192.0.2.30
26check_remotes "link set"
27
28ip link del dev vx
29exit $EXIT_STATUS
30