Module Name: src Committed By: martin Date: Tue Apr 10 11:48:29 UTC 2018
Modified Files: src/sys/net [netbsd-8]: if_bridge.c src/tests/net/if_bridge [netbsd-8]: t_rtable.sh Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #727): tests/net/if_bridge/t_rtable.sh: revision 1.2 sys/net/if_bridge.c: revision 1.149 Fix bridge_rtdelete It removes a rtable entry that belongs to a specified interface, however, its original behavior was to delete all belonging entries. Restore the original behavior. Add a test case for bridge_rtdelete To generate a diff of this commit: cvs rdiff -u -r1.134.6.7 -r1.134.6.8 src/sys/net/if_bridge.c cvs rdiff -u -r1.1 -r1.1.8.1 src/tests/net/if_bridge/t_rtable.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_bridge.c diff -u src/sys/net/if_bridge.c:1.134.6.7 src/sys/net/if_bridge.c:1.134.6.8 --- src/sys/net/if_bridge.c:1.134.6.7 Mon Feb 26 00:41:13 2018 +++ src/sys/net/if_bridge.c Tue Apr 10 11:48:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bridge.c,v 1.134.6.7 2018/02/26 00:41:13 snj Exp $ */ +/* $NetBSD: if_bridge.c,v 1.134.6.8 2018/04/10 11:48:29 martin Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.134.6.7 2018/02/26 00:41:13 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.134.6.8 2018/04/10 11:48:29 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_bridge_ipf.h" @@ -2299,6 +2299,8 @@ bridge_rtdelete(struct bridge_softc *sc, { struct bridge_rtnode *brt; + /* XXX pserialize_perform for each entry is slow */ +again: BRIDGE_RT_LOCK(sc); LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) { if (brt->brt_ifp == ifp) @@ -2313,6 +2315,8 @@ bridge_rtdelete(struct bridge_softc *sc, BRIDGE_RT_UNLOCK(sc); bridge_rtnode_destroy(brt); + + goto again; } /* Index: src/tests/net/if_bridge/t_rtable.sh diff -u src/tests/net/if_bridge/t_rtable.sh:1.1 src/tests/net/if_bridge/t_rtable.sh:1.1.8.1 --- src/tests/net/if_bridge/t_rtable.sh:1.1 Sat Mar 11 04:24:52 2017 +++ src/tests/net/if_bridge/t_rtable.sh Tue Apr 10 11:48:28 2018 @@ -1,4 +1,4 @@ -# $NetBSD: t_rtable.sh,v 1.1 2017/03/11 04:24:52 ozaki-r Exp $ +# $NetBSD: t_rtable.sh,v 1.1.8.1 2018/04/10 11:48:28 martin Exp $ # # Copyright (c) 2017 Internet Initiative Japan Inc. # All rights reserved. @@ -342,6 +342,76 @@ bridge_rtable_maxaddr_cleanup() } +atf_test_case bridge_rtable_delete_member cleanup +bridge_rtable_delete_member_head() +{ + + atf_set "descr" "Tests belonging rtable entries are removed on deleting an interface" + atf_set "require.progs" "rump_server" +} + +bridge_rtable_delete_member_body() +{ + local addr10= addr30= addr11= addr31= + local n= + + setup + setup_bridge + + # Add extra interfaces and addresses + export RUMP_SERVER=$SOCK1 + rump_server_add_iface $SOCK1 shmif1 bus1 + atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24 + atf_check -s exit:0 rump.ifconfig -w 10 + + export RUMP_SERVER=$SOCK3 + rump_server_add_iface $SOCK3 shmif1 bus2 + atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.12/24 + atf_check -s exit:0 rump.ifconfig -w 10 + + # Get MAC addresses of the endpoints. + addr10=$(get_macaddr $SOCK1 shmif0) + addr30=$(get_macaddr $SOCK3 shmif0) + addr11=$(get_macaddr $SOCK1 shmif1) + addr31=$(get_macaddr $SOCK3 shmif1) + + # Make the bridge learn the MAC addresses of the endpoints. + export RUMP_SERVER=$SOCK1 + atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 10.0.0.12 + export RUMP_SERVER=$SOCK3 + atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 10.0.0.11 + + export RUMP_SERVER=$SOCK2 + export LD_PRELOAD=/usr/lib/librumphijack.so + $DEBUG && /sbin/brconfig bridge0 + atf_check -s exit:0 -o match:"$addr10 shmif0" /sbin/brconfig bridge0 + atf_check -s exit:0 -o match:"$addr11 shmif0" /sbin/brconfig bridge0 + atf_check -s exit:0 -o match:"$addr30 shmif1" /sbin/brconfig bridge0 + atf_check -s exit:0 -o match:"$addr31 shmif1" /sbin/brconfig bridge0 + + atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 delete shmif0 + atf_check -s exit:0 -o not-match:"$addr10 shmif0" /sbin/brconfig bridge0 + atf_check -s exit:0 -o not-match:"$addr11 shmif0" /sbin/brconfig bridge0 + atf_check -s exit:0 -o match:"$addr30 shmif1" /sbin/brconfig bridge0 + atf_check -s exit:0 -o match:"$addr31 shmif1" /sbin/brconfig bridge0 + + atf_check -s exit:0 -o ignore /sbin/brconfig bridge0 delete shmif1 + atf_check -s exit:0 -o not-match:"$addr10 shmif0" /sbin/brconfig bridge0 + atf_check -s exit:0 -o not-match:"$addr11 shmif0" /sbin/brconfig bridge0 + atf_check -s exit:0 -o not-match:"$addr30 shmif1" /sbin/brconfig bridge0 + atf_check -s exit:0 -o not-match:"$addr31 shmif1" /sbin/brconfig bridge0 + + rump_server_destroy_ifaces +} + +bridge_rtable_delete_member_cleanup() +{ + + $DEBUG && dump + cleanup +} + + atf_init_test_cases() { @@ -349,5 +419,6 @@ atf_init_test_cases() atf_add_test_case bridge_rtable_flush atf_add_test_case bridge_rtable_timeout atf_add_test_case bridge_rtable_maxaddr + atf_add_test_case bridge_rtable_delete_member # TODO: brconfig static/flushall/discover/learn }