diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c index dd09838b5d8b..a23c245f7fe6 100644 --- a/sbin/ifconfig/carp.c +++ b/sbin/ifconfig/carp.c @@ -1,256 +1,252 @@ /* from $OpenBSD: ifconfig.c,v 1.82 2003/10/19 05:43:35 mcbride Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Michael Shalayeff. All rights reserved. * Copyright (c) 2003 Ryan McBride. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ifconfig.h" static const char *carp_states[] = { CARP_STATES }; static void setcarp_callback(if_ctx *, void *); static int carpr_vhid = -1; static int carpr_advskew = -1; static int carpr_advbase = -1; static int carpr_state = -1; static struct in_addr carp_addr; static struct in6_addr carp_addr6; static unsigned char const *carpr_key; static void carp_status(if_ctx *ctx) { struct ifconfig_carp carpr[CARP_MAXVHID]; char addr_buf[NI_MAXHOST]; if (ifconfig_carp_get_info(lifh, ctx->ifname, carpr, CARP_MAXVHID) == -1) return; for (size_t i = 0; i < carpr[0].carpr_count; i++) { printf("\tcarp: %s vhid %d advbase %d advskew %d", carp_states[carpr[i].carpr_state], carpr[i].carpr_vhid, carpr[i].carpr_advbase, carpr[i].carpr_advskew); if (ctx->args->printkeys && carpr[i].carpr_key[0] != '\0') printf(" key \"%s\"\n", carpr[i].carpr_key); else printf("\n"); inet_ntop(AF_INET6, &carpr[i].carpr_addr6, addr_buf, sizeof(addr_buf)); printf("\t peer %s peer6 %s\n", inet_ntoa(carpr[i].carpr_addr), addr_buf); } } static void setcarp_vhid(if_ctx *ctx, const char *val, int dummy __unused) { const struct afswtch *afp = ctx->afp; carpr_vhid = atoi(val); if (carpr_vhid <= 0 || carpr_vhid > CARP_MAXVHID) errx(1, "vhid must be greater than 0 and less than %u", CARP_MAXVHID); if (afp->af_setvhid == NULL) errx(1, "%s doesn't support carp(4)", afp->af_name); afp->af_setvhid(carpr_vhid); callback_register(setcarp_callback, NULL); } static void setcarp_callback(if_ctx *ctx, void *arg __unused) { struct ifconfig_carp carpr = { }; if (ifconfig_carp_get_vhid(lifh, ctx->ifname, &carpr, carpr_vhid) == -1) { if (ifconfig_err_errno(lifh) != ENOENT) return; } carpr.carpr_vhid = carpr_vhid; if (carpr_key != NULL) /* XXX Should hash the password into the key here? */ strlcpy(carpr.carpr_key, carpr_key, CARP_KEY_LEN); if (carpr_advskew > -1) carpr.carpr_advskew = carpr_advskew; if (carpr_advbase > -1) carpr.carpr_advbase = carpr_advbase; if (carpr_state > -1) carpr.carpr_state = carpr_state; if (carp_addr.s_addr != INADDR_ANY) carpr.carpr_addr = carp_addr; if (! IN6_IS_ADDR_UNSPECIFIED(&carp_addr6)) memcpy(&carpr.carpr_addr6, &carp_addr6, sizeof(carp_addr6)); if (ifconfig_carp_set_info(lifh, ctx->ifname, &carpr)) err(1, "SIOCSVH"); } static void setcarp_passwd(if_ctx *ctx __unused, const char *val, int dummy __unused) { if (carpr_vhid == -1) errx(1, "passwd requires vhid"); carpr_key = val; } static void setcarp_advskew(if_ctx *ctx __unused, const char *val, int dummy __unused) { if (carpr_vhid == -1) errx(1, "advskew requires vhid"); carpr_advskew = atoi(val); } static void setcarp_advbase(if_ctx *ctx __unused, const char *val, int dummy __unused) { if (carpr_vhid == -1) errx(1, "advbase requires vhid"); carpr_advbase = atoi(val); } static void setcarp_state(if_ctx *ctx __unused, const char *val, int dummy __unused) { int i; if (carpr_vhid == -1) errx(1, "state requires vhid"); for (i = 0; i <= CARP_MAXSTATE; i++) if (strcasecmp(carp_states[i], val) == 0) { carpr_state = i; return; } errx(1, "unknown state"); } static void setcarp_peer(if_ctx *ctx __unused, const char *val, int dummy __unused) { carp_addr.s_addr = inet_addr(val); } static void setcarp_mcast(if_ctx *ctx __unused, const char *val __unused, int dummy __unused) { carp_addr.s_addr = htonl(INADDR_CARP_GROUP); } static void setcarp_peer6(if_ctx *ctx __unused, const char *val, int dummy __unused) { struct addrinfo hints, *res; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; hints.ai_flags = AI_NUMERICHOST; if (getaddrinfo(val, NULL, &hints, &res) != 0) errx(1, "Invalid IPv6 address %s", val); memcpy(&carp_addr6, &(satosin6(res->ai_addr))->sin6_addr, sizeof(carp_addr6)); freeaddrinfo(res); } static void setcarp_mcast6(if_ctx *ctx __unused, const char *val __unused, int dummy __unused) { bzero(&carp_addr6, sizeof(carp_addr6)); carp_addr6.s6_addr[0] = 0xff; carp_addr6.s6_addr[1] = 0x02; carp_addr6.s6_addr[15] = 0x12; } static struct cmd carp_cmds[] = { DEF_CMD_ARG("advbase", setcarp_advbase), DEF_CMD_ARG("advskew", setcarp_advskew), DEF_CMD_ARG("pass", setcarp_passwd), DEF_CMD_ARG("vhid", setcarp_vhid), DEF_CMD_ARG("state", setcarp_state), DEF_CMD_ARG("peer", setcarp_peer), DEF_CMD("mcast", 0, setcarp_mcast), DEF_CMD_ARG("peer6", setcarp_peer6), DEF_CMD("mcast6", 0, setcarp_mcast6), }; static struct afswtch af_carp = { .af_name = "af_carp", .af_af = AF_UNSPEC, .af_other_status = carp_status, }; static __constructor void carp_ctor(void) { - /* Default to multicast. */ - setcarp_mcast(NULL, NULL, 0); - setcarp_mcast6(NULL, NULL, 0); - for (size_t i = 0; i < nitems(carp_cmds); i++) cmd_register(&carp_cmds[i]); af_register(&af_carp); } diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh index d0e10bc2c085..8cea2f4cbf1b 100755 --- a/tests/sys/netinet/carp.sh +++ b/tests/sys/netinet/carp.sh @@ -1,484 +1,487 @@ # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2020 Kristof Provost # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. . $(atf_get_srcdir)/../common/vnet.subr is_master() { jail=$1 itf=$2 jexec ${jail} ifconfig ${itf} | grep carp | grep MASTER } wait_for_carp() { jail1=$1 itf1=$2 jail2=$3 itf2=$4 while [ -z "$(is_master ${jail1} ${itf1})" ] && [ -z "$(is_master ${jail2} ${itf2})" ]; do sleep 1 done if [ -n "$(is_master ${jail1} ${itf1})" ] && [ -n "$(is_master ${jail2} ${itf2})" ]; then atf_fail "Both jails are master" fi } carp_init() { if ! kldstat -q -m carp; then atf_skip "This test requires carp" fi vnet_init } atf_test_case "basic_v4" "cleanup" basic_v4_head() { atf_set descr 'Basic CARP test (IPv4)' atf_set require.user root } basic_v4_body() { carp_init vnet_init_bridge bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_basic_v4_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_basic_v4_two ${epair_one}b vnet_mkjail carp_basic_v4_three ${epair_two}b jexec carp_basic_v4_one ifconfig ${bridge} 192.0.2.4/29 up jexec carp_basic_v4_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_basic_v4_one ifconfig ${epair_one}a up jexec carp_basic_v4_one ifconfig ${epair_two}a up jexec carp_basic_v4_two ifconfig ${epair_one}b 192.0.2.202/29 up jexec carp_basic_v4_two ifconfig ${epair_one}b add vhid 1 192.0.2.1/29 jexec carp_basic_v4_three ifconfig ${epair_two}b 192.0.2.203/29 up jexec carp_basic_v4_three ifconfig ${epair_two}b add vhid 1 \ 192.0.2.1/29 wait_for_carp carp_basic_v4_two ${epair_one}b \ carp_basic_v4_three ${epair_two}b atf_check -s exit:0 -o ignore jexec carp_basic_v4_one \ ping -c 3 192.0.2.1 } basic_v4_cleanup() { vnet_cleanup } atf_test_case "unicast_v4" "cleanup" unicast_v4_head() { atf_set descr 'Unicast CARP test (IPv4)' atf_set require.user root } unicast_v4_body() { carp_init vnet_init_bridge bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_uni_v4_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_uni_v4_two ${epair_one}b vnet_mkjail carp_uni_v4_three ${epair_two}b jexec carp_uni_v4_one ifconfig ${bridge} 192.0.2.4/29 up jexec carp_uni_v4_one sysctl net.inet.ip.forwarding=1 jexec carp_uni_v4_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_uni_v4_one ifconfig ${epair_one}a up jexec carp_uni_v4_one ifconfig ${epair_two}a up jexec carp_uni_v4_one ifconfig ${bridge} inet alias 198.51.100.1/25 jexec carp_uni_v4_one ifconfig ${bridge} inet alias 198.51.100.129/25 jexec carp_uni_v4_two ifconfig ${epair_one}b 198.51.100.2/25 up jexec carp_uni_v4_two route add default 198.51.100.1 jexec carp_uni_v4_two ifconfig ${epair_one}b add vhid 1 \ peer 198.51.100.130 192.0.2.1/29 jexec carp_uni_v4_three ifconfig ${epair_two}b 198.51.100.130/25 up jexec carp_uni_v4_three route add default 198.51.100.129 jexec carp_uni_v4_three ifconfig ${epair_two}b add vhid 1 \ peer 198.51.100.2 192.0.2.1/29 # Sanity check atf_check -s exit:0 -o ignore jexec carp_uni_v4_two \ ping -c 1 198.51.100.130 wait_for_carp carp_uni_v4_two ${epair_one}b \ carp_uni_v4_three ${epair_two}b atf_check -s exit:0 -o ignore jexec carp_uni_v4_one \ ping -c 3 192.0.2.1 - jexec carp_uni_v4_two ifconfig - jexec carp_uni_v4_three ifconfig + # Check that we remain in unicast when tweaking settings + atf_check -s exit:0 -o ignore \ + jexec carp_uni_v4_two ifconfig ${epair_one}b vhid 1 advskew 2 + atf_check -s exit:0 -o match:"peer 198.51.100.130" \ + jexec carp_uni_v4_two ifconfig ${epair_one}b } unicast_v4_cleanup() { vnet_cleanup } atf_test_case "basic_v6" "cleanup" basic_v6_head() { atf_set descr 'Basic CARP test (IPv6)' atf_set require.user root } basic_v6_body() { carp_init vnet_init_bridge bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_basic_v6_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_basic_v6_two ${epair_one}b vnet_mkjail carp_basic_v6_three ${epair_two}b jexec carp_basic_v6_one ifconfig ${bridge} inet6 2001:db8::0:4/64 up \ no_dad jexec carp_basic_v6_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_basic_v6_one ifconfig ${epair_one}a up jexec carp_basic_v6_one ifconfig ${epair_two}a up jexec carp_basic_v6_two ifconfig ${epair_one}b inet6 \ 2001:db8::1:2/64 up no_dad jexec carp_basic_v6_two ifconfig ${epair_one}b inet6 add vhid 1 \ 2001:db8::0:1/64 jexec carp_basic_v6_three ifconfig ${epair_two}b inet6 2001:db8::1:3/64 up no_dad jexec carp_basic_v6_three ifconfig ${epair_two}b inet6 add vhid 1 \ 2001:db8::0:1/64 wait_for_carp carp_basic_v6_two ${epair_one}b \ carp_basic_v6_three ${epair_two}b atf_check -s exit:0 -o ignore jexec carp_basic_v6_one \ ping -6 -c 3 2001:db8::0:1 } basic_v6_cleanup() { vnet_cleanup } atf_test_case "unicast_v6" "cleanup" unicast_v6_head() { atf_set descr 'Unicast CARP test (IPv6)' atf_set require.user root } unicast_v6_body() { carp_init vnet_init_bridge bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_uni_v6_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_uni_v6_two ${epair_one}b vnet_mkjail carp_uni_v6_three ${epair_two}b jexec carp_uni_v6_one sysctl net.inet6.ip6.forwarding=1 jexec carp_uni_v6_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_uni_v6_one ifconfig ${epair_one}a up jexec carp_uni_v6_one ifconfig ${epair_two}a up jexec carp_uni_v6_one ifconfig ${bridge} inet6 2001:db8::0:4/64 up \ no_dad jexec carp_uni_v6_one ifconfig ${bridge} inet6 alias 2001:db8:1::1/64 \ no_dad up jexec carp_uni_v6_one ifconfig ${bridge} inet6 alias 2001:db8:2::1/64 \ no_dad up jexec carp_uni_v6_two ifconfig ${epair_one}b inet6 2001:db8:1::2/64 \ no_dad up jexec carp_uni_v6_two route -6 add default 2001:db8:1::1 jexec carp_uni_v6_two ifconfig ${epair_one}b inet6 add vhid 1 \ peer6 2001:db8:2::2 \ 2001:db8::0:1/64 jexec carp_uni_v6_three ifconfig ${epair_two}b inet6 2001:db8:2::2/64 \ no_dad up jexec carp_uni_v6_three route -6 add default 2001:db8:2::1 jexec carp_uni_v6_three ifconfig ${epair_two}b inet6 add vhid 1 \ peer6 2001:db8:1::2 \ 2001:db8::0:1/64 # Sanity check atf_check -s exit:0 -o ignore jexec carp_uni_v6_two \ ping -6 -c 1 2001:db8:2::2 wait_for_carp carp_uni_v6_two ${epair_one}b \ carp_uni_v6_three ${epair_two}b atf_check -s exit:0 -o ignore jexec carp_uni_v6_one \ ping -6 -c 3 2001:db8::0:1 } unicast_v6_cleanup() { vnet_cleanup } atf_test_case "unicast_ll_v6" "cleanup" unicast_ll_v6_head() { atf_set descr 'Unicast CARP test (IPv6, link-local)' atf_set require.user root } unicast_ll_v6_body() { carp_init vnet_init_bridge j=carp_uni_ll_v6 bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail ${j}_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail ${j}_two ${epair_one}b vnet_mkjail ${j}_three ${epair_two}b jexec ${j}_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec ${j}_one ifconfig ${epair_one}a up jexec ${j}_one ifconfig ${epair_two}a up jexec ${j}_one ifconfig ${bridge} inet6 2001:db8::0:4/64 up \ no_dad jexec ${j}_one ifconfig ${bridge} inet6 alias 2001:db8:1::1/64 \ no_dad up jexec ${j}_two ifconfig ${epair_one}b inet6 2001:db8:1::2/64 \ no_dad up jexec ${j}_three ifconfig ${epair_two}b inet6 2001:db8:1::3/64 \ no_dad up ll_one=$(jexec ${j}_two ifconfig ${epair_one}b | awk "/ .*%${epair_one}b.* / { print \$2 }" | cut -d % -f 1) ll_two=$(jexec ${j}_three ifconfig ${epair_two}b | awk "/ .*%${epair_two}b.* / { print \$2 }" | cut -d % -f 1) jexec ${j}_two ifconfig ${epair_one}b inet6 add vhid 1 \ peer6 ${ll_two} \ 2001:db8::0:1/64 jexec ${j}_three ifconfig ${epair_two}b inet6 add vhid 1 \ peer6 ${ll_one} \ 2001:db8::0:1/64 # Sanity check atf_check -s exit:0 -o ignore jexec ${j}_two \ ping -6 -c 1 2001:db8:1::3 wait_for_carp ${j}_two ${epair_one}b \ ${j}_three ${epair_two}b atf_check -s exit:0 -o ignore jexec ${j}_one \ ping -6 -c 3 2001:db8::0:1 } unicast_ll_v6_cleanup() { vnet_cleanup } atf_test_case "negative_demotion" "cleanup" negative_demotion_head() { atf_set descr 'Test PR #259528' atf_set require.user root } negative_demotion_body() { carp_init epair=$(vnet_mkepair) vnet_mkjail one ${epair}a jexec one sysctl net.inet.carp.preempt=1 jexec one ifconfig ${epair}a 192.0.2.1/24 up jexec one ifconfig ${epair}a add vhid 1 192.0.2.254/24 \ advskew 0 pass foobar vnet_mkjail two ${epair}b jexec two sysctl net.inet.carp.preempt=1 jexec two ifconfig ${epair}b 192.0.2.2/24 up jexec two ifconfig ${epair}b add vhid 1 192.0.2.254/24 \ advskew 100 pass foobar # Allow things to settle wait_for_carp one ${epair}a two ${epair}b if is_master one ${epair}a && is_master two ${epair}b then atf_fail "Two masters!" fi jexec one sysctl net.inet.carp.demotion=-1 sleep 3 if is_master one ${epair}a && is_master two ${epair}b then atf_fail "Two masters!" fi } negative_demotion_cleanup() { vnet_cleanup } atf_test_case "nd6_ns_source_mac" "cleanup" nd6_ns_source_mac_head() { atf_set descr 'CARP ndp neighbor solicitation MAC source test (IPv6)' atf_set require.user root } nd6_ns_source_mac_body() { carp_init vnet_init_bridge bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_ndp_v6_bridge ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_ndp_v6_master ${epair_one}b vnet_mkjail carp_ndp_v6_slave ${epair_two}b jexec carp_ndp_v6_bridge ifconfig ${bridge} inet6 2001:db8::0:4/64 up \ no_dad jexec carp_ndp_v6_bridge ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_ndp_v6_bridge ifconfig ${epair_one}a up jexec carp_ndp_v6_bridge ifconfig ${epair_two}a up jexec carp_ndp_v6_master ifconfig ${epair_one}b inet6 \ 2001:db8::1:2/64 up no_dad jexec carp_ndp_v6_master ifconfig ${epair_one}b inet6 add vhid 1 \ advskew 0 2001:db8::0:1/64 jexec carp_ndp_v6_slave ifconfig ${epair_two}b inet6 \ 2001:db8::1:3/64 up no_dad jexec carp_ndp_v6_slave ifconfig ${epair_two}b inet6 add vhid 1 \ advskew 100 2001:db8::0:1/64 wait_for_carp carp_ndp_v6_master ${epair_one}b \ carp_ndp_v6_slave ${epair_two}b # carp_ndp_v6_master is MASTER # trigger a NS from the virtual IP from the BACKUP atf_check -s exit:2 -o ignore jexec carp_ndp_v6_slave \ ping -6 -c 3 -S 2001:db8::0:1 2001:db8::0:4 # trigger a NS from the virtual IP from the MASTER, # this ping should work atf_check -s exit:0 -o ignore jexec carp_ndp_v6_master \ ping -6 -c 3 -S 2001:db8::0:1 2001:db8::0:4 # ndp entry should be for the virtual mac atf_check -o match:'2001:db8::1 +00:00:5e:00:01:01' \ jexec carp_ndp_v6_bridge ndp -an } nd6_ns_source_mac_cleanup() { vnet_cleanup } atf_test_case "switch" "cleanup" switch_head() { atf_set descr 'Switch between master and backup' atf_set require.user root } switch_body() { carp_init epair=$(vnet_mkepair) ifconfig ${epair}a up ifconfig ${epair}a vhid 1 advskew 100 192.0.2.1/24 ifconfig ${epair}a vhid 1 state backup ifconfig ${epair}a vhid 1 state master } switch_cleanup() { vnet_cleanup } atf_init_test_cases() { atf_add_test_case "basic_v4" atf_add_test_case "unicast_v4" atf_add_test_case "basic_v6" atf_add_test_case "unicast_v6" atf_add_test_case "unicast_ll_v6" atf_add_test_case "negative_demotion" atf_add_test_case "nd6_ns_source_mac" atf_add_test_case "switch" }