| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562 |
- #!/bin/bash
- # SPDX-License-Identifier: GPL-2.0
- #
- # This test is for checking VXLAN MDB functionality. The topology consists of
- # two sets of namespaces: One for the testing of IPv4 underlay and another for
- # IPv6. In both cases, both IPv4 and IPv6 overlay traffic are tested.
- #
- # Data path functionality is tested by sending traffic from one of the upper
- # namespaces and checking using ingress tc filters that the expected traffic
- # was received by one of the lower namespaces.
- #
- # +------------------------------------+ +------------------------------------+
- # | ns1_v4 | | ns1_v6 |
- # | | | |
- # | br0.10 br0.4000 br0.20 | | br0.10 br0.4000 br0.20 |
- # | + + + | | + + + |
- # | | | | | | | | | |
- # | | | | | | | | | |
- # | +---------+---------+ | | +---------+---------+ |
- # | | | | | |
- # | | | | | |
- # | + | | + |
- # | br0 | | br0 |
- # | + | | + |
- # | | | | | |
- # | | | | | |
- # | + | | + |
- # | vx0 | | vx0 |
- # | | | |
- # | | | |
- # | veth0 | | veth0 |
- # | + | | + |
- # +-----------------|------------------+ +-----------------|------------------+
- # | |
- # +-----------------|------------------+ +-----------------|------------------+
- # | + | | + |
- # | veth0 | | veth0 |
- # | | | |
- # | | | |
- # | vx0 | | vx0 |
- # | + | | + |
- # | | | | | |
- # | | | | | |
- # | + | | + |
- # | br0 | | br0 |
- # | + | | + |
- # | | | | | |
- # | | | | | |
- # | +---------+---------+ | | +---------+---------+ |
- # | | | | | | | | | |
- # | | | | | | | | | |
- # | + + + | | + + + |
- # | br0.10 br0.4000 br0.10 | | br0.10 br0.4000 br0.20 |
- # | | | |
- # | ns2_v4 | | ns2_v6 |
- # +------------------------------------+ +------------------------------------+
- source lib.sh
- ret=0
- CONTROL_PATH_TESTS="
- basic_star_g_ipv4_ipv4
- basic_star_g_ipv6_ipv4
- basic_star_g_ipv4_ipv6
- basic_star_g_ipv6_ipv6
- basic_sg_ipv4_ipv4
- basic_sg_ipv6_ipv4
- basic_sg_ipv4_ipv6
- basic_sg_ipv6_ipv6
- star_g_ipv4_ipv4
- star_g_ipv6_ipv4
- star_g_ipv4_ipv6
- star_g_ipv6_ipv6
- sg_ipv4_ipv4
- sg_ipv6_ipv4
- sg_ipv4_ipv6
- sg_ipv6_ipv6
- dump_ipv4_ipv4
- dump_ipv6_ipv4
- dump_ipv4_ipv6
- dump_ipv6_ipv6
- flush
- "
- DATA_PATH_TESTS="
- encap_params_ipv4_ipv4
- encap_params_ipv6_ipv4
- encap_params_ipv4_ipv6
- encap_params_ipv6_ipv6
- starg_exclude_ir_ipv4_ipv4
- starg_exclude_ir_ipv6_ipv4
- starg_exclude_ir_ipv4_ipv6
- starg_exclude_ir_ipv6_ipv6
- starg_include_ir_ipv4_ipv4
- starg_include_ir_ipv6_ipv4
- starg_include_ir_ipv4_ipv6
- starg_include_ir_ipv6_ipv6
- starg_exclude_p2mp_ipv4_ipv4
- starg_exclude_p2mp_ipv6_ipv4
- starg_exclude_p2mp_ipv4_ipv6
- starg_exclude_p2mp_ipv6_ipv6
- starg_include_p2mp_ipv4_ipv4
- starg_include_p2mp_ipv6_ipv4
- starg_include_p2mp_ipv4_ipv6
- starg_include_p2mp_ipv6_ipv6
- egress_vni_translation_ipv4_ipv4
- egress_vni_translation_ipv6_ipv4
- egress_vni_translation_ipv4_ipv6
- egress_vni_translation_ipv6_ipv6
- all_zeros_mdb_ipv4
- all_zeros_mdb_ipv6
- mdb_fdb_ipv4_ipv4
- mdb_fdb_ipv6_ipv4
- mdb_fdb_ipv4_ipv6
- mdb_fdb_ipv6_ipv6
- mdb_torture_ipv4_ipv4
- mdb_torture_ipv6_ipv4
- mdb_torture_ipv4_ipv6
- mdb_torture_ipv6_ipv6
- "
- # All tests in this script. Can be overridden with -t option.
- TESTS="
- $CONTROL_PATH_TESTS
- $DATA_PATH_TESTS
- "
- VERBOSE=0
- PAUSE_ON_FAIL=no
- PAUSE=no
- ################################################################################
- # Utilities
- log_test()
- {
- local rc=$1
- local expected=$2
- local msg="$3"
- if [ ${rc} -eq ${expected} ]; then
- printf "TEST: %-60s [ OK ]\n" "${msg}"
- nsuccess=$((nsuccess+1))
- else
- ret=1
- nfail=$((nfail+1))
- printf "TEST: %-60s [FAIL]\n" "${msg}"
- if [ "$VERBOSE" = "1" ]; then
- echo " rc=$rc, expected $expected"
- fi
- if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
- echo
- echo "hit enter to continue, 'q' to quit"
- read a
- [ "$a" = "q" ] && exit 1
- fi
- fi
- if [ "${PAUSE}" = "yes" ]; then
- echo
- echo "hit enter to continue, 'q' to quit"
- read a
- [ "$a" = "q" ] && exit 1
- fi
- [ "$VERBOSE" = "1" ] && echo
- }
- run_cmd()
- {
- local cmd="$1"
- local out
- local stderr="2>/dev/null"
- if [ "$VERBOSE" = "1" ]; then
- printf "COMMAND: $cmd\n"
- stderr=
- fi
- out=$(eval $cmd $stderr)
- rc=$?
- if [ "$VERBOSE" = "1" -a -n "$out" ]; then
- echo " $out"
- fi
- return $rc
- }
- tc_check_packets()
- {
- local ns=$1; shift
- local id=$1; shift
- local handle=$1; shift
- local count=$1; shift
- local pkts
- sleep 0.1
- pkts=$(tc -n $ns -j -s filter show $id \
- | jq ".[] | select(.options.handle == $handle) | \
- .options.actions[0].stats.packets")
- [[ $pkts == $count ]]
- }
- ################################################################################
- # Setup
- setup_common_ns()
- {
- local ns=$1; shift
- local local_addr=$1; shift
- ip netns exec $ns sysctl -qw net.ipv4.ip_forward=1
- ip netns exec $ns sysctl -qw net.ipv4.fib_multipath_use_neigh=1
- ip netns exec $ns sysctl -qw net.ipv4.conf.default.ignore_routes_with_linkdown=1
- ip netns exec $ns sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1
- ip netns exec $ns sysctl -qw net.ipv6.conf.all.forwarding=1
- ip netns exec $ns sysctl -qw net.ipv6.conf.default.forwarding=1
- ip netns exec $ns sysctl -qw net.ipv6.conf.default.ignore_routes_with_linkdown=1
- ip netns exec $ns sysctl -qw net.ipv6.conf.all.accept_dad=0
- ip netns exec $ns sysctl -qw net.ipv6.conf.default.accept_dad=0
- ip -n $ns link set dev lo up
- ip -n $ns address add $local_addr dev lo
- ip -n $ns link set dev veth0 up
- ip -n $ns link add name br0 up type bridge vlan_filtering 1 \
- vlan_default_pvid 0 mcast_snooping 0
- ip -n $ns link add link br0 name br0.10 up type vlan id 10
- bridge -n $ns vlan add vid 10 dev br0 self
- ip -n $ns link add link br0 name br0.20 up type vlan id 20
- bridge -n $ns vlan add vid 20 dev br0 self
- ip -n $ns link add link br0 name br0.4000 up type vlan id 4000
- bridge -n $ns vlan add vid 4000 dev br0 self
- ip -n $ns link add name vx0 up master br0 type vxlan \
- local $local_addr dstport 4789 external vnifilter
- bridge -n $ns link set dev vx0 vlan_tunnel on
- bridge -n $ns vlan add vid 10 dev vx0
- bridge -n $ns vlan add vid 10 dev vx0 tunnel_info id 10010
- bridge -n $ns vni add vni 10010 dev vx0
- bridge -n $ns vlan add vid 20 dev vx0
- bridge -n $ns vlan add vid 20 dev vx0 tunnel_info id 10020
- bridge -n $ns vni add vni 10020 dev vx0
- bridge -n $ns vlan add vid 4000 dev vx0 pvid
- bridge -n $ns vlan add vid 4000 dev vx0 tunnel_info id 14000
- bridge -n $ns vni add vni 14000 dev vx0
- }
- setup_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local local_addr1=$1; shift
- local local_addr2=$1; shift
- ip link add name veth0 type veth peer name veth1
- ip link set dev veth0 netns $ns1 name veth0
- ip link set dev veth1 netns $ns2 name veth0
- setup_common_ns $ns1 $local_addr1
- setup_common_ns $ns2 $local_addr2
- }
- setup_v4()
- {
- setup_ns ns1_v4 ns2_v4
- setup_common $ns1_v4 $ns2_v4 192.0.2.1 192.0.2.2
- ip -n $ns1_v4 address add 192.0.2.17/28 dev veth0
- ip -n $ns2_v4 address add 192.0.2.18/28 dev veth0
- ip -n $ns1_v4 route add default via 192.0.2.18
- ip -n $ns2_v4 route add default via 192.0.2.17
- }
- cleanup_v4()
- {
- cleanup_ns $ns2_v4 $ns1_v4
- }
- setup_v6()
- {
- setup_ns ns1_v6 ns2_v6
- setup_common $ns1_v6 $ns2_v6 2001:db8:1::1 2001:db8:1::2
- ip -n $ns1_v6 address add 2001:db8:2::1/64 dev veth0 nodad
- ip -n $ns2_v6 address add 2001:db8:2::2/64 dev veth0 nodad
- ip -n $ns1_v6 route add default via 2001:db8:2::2
- ip -n $ns2_v6 route add default via 2001:db8:2::1
- }
- cleanup_v6()
- {
- cleanup_ns $ns2_v6 $ns1_v6
- }
- setup()
- {
- set -e
- setup_v4
- setup_v6
- sleep 5
- set +e
- }
- cleanup()
- {
- cleanup_v6 &> /dev/null
- cleanup_v4 &> /dev/null
- }
- ################################################################################
- # Tests - Control path
- basic_common()
- {
- local ns1=$1; shift
- local grp_key=$1; shift
- local vtep_ip=$1; shift
- # Test basic control path operations common to all MDB entry types.
- # Basic add, replace and delete behavior.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- log_test $? 0 "MDB entry addition"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010"
- log_test $? 0 "MDB entry presence after addition"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- log_test $? 0 "MDB entry replacement"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010"
- log_test $? 0 "MDB entry presence after replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- log_test $? 0 "MDB entry deletion"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010"
- log_test $? 254 "MDB entry presence after deletion"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- log_test $? 255 "Non-existent MDB entry deletion"
- # Default protocol and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"proto static\""
- log_test $? 0 "MDB entry default protocol"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent proto 123 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"proto 123\""
- log_test $? 0 "MDB entry protocol replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- # Default destination port and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \" dst_port \""
- log_test $? 1 "MDB entry default destination port"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip dst_port 1234 src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"dst_port 1234\""
- log_test $? 0 "MDB entry destination port replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- # Default destination VNI and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \" vni \""
- log_test $? 1 "MDB entry default destination VNI"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip vni 1234 src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"vni 1234\""
- log_test $? 0 "MDB entry destination VNI replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- # Default outgoing interface and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \" via \""
- log_test $? 1 "MDB entry default outgoing interface"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010 via veth0"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"via veth0\""
- log_test $? 0 "MDB entry outgoing interface replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- # Common error cases.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port veth0 $grp_key permanent dst $vtep_ip src_vni 10010"
- log_test $? 255 "MDB entry with mismatch between device and port"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key temp dst $vtep_ip src_vni 10010"
- log_test $? 255 "MDB entry with temp state"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent vid 10 dst $vtep_ip src_vni 10010"
- log_test $? 255 "MDB entry with VLAN"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp 01:02:03:04:05:06 permanent dst $vtep_ip src_vni 10010"
- log_test $? 255 "MDB entry MAC address"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent"
- log_test $? 255 "MDB entry without extended parameters"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent proto 3 dst $vtep_ip src_vni 10010"
- log_test $? 255 "MDB entry with an invalid protocol"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip vni $((2 ** 24)) src_vni 10010"
- log_test $? 255 "MDB entry with an invalid destination VNI"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni $((2 ** 24))"
- log_test $? 255 "MDB entry with an invalid source VNI"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent src_vni 10010"
- log_test $? 255 "MDB entry without a remote destination IP"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010"
- log_test $? 255 "Duplicate MDB entries"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010"
- }
- basic_star_g_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local grp_key="grp 239.1.1.1"
- local vtep_ip=198.51.100.100
- echo
- echo "Control path: Basic (*, G) operations - IPv4 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_star_g_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local grp_key="grp ff0e::1"
- local vtep_ip=198.51.100.100
- echo
- echo "Control path: Basic (*, G) operations - IPv6 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_star_g_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local grp_key="grp 239.1.1.1"
- local vtep_ip=2001:db8:1000::1
- echo
- echo "Control path: Basic (*, G) operations - IPv4 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_star_g_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local grp_key="grp ff0e::1"
- local vtep_ip=2001:db8:1000::1
- echo
- echo "Control path: Basic (*, G) operations - IPv6 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_sg_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local grp_key="grp 239.1.1.1 src 192.0.2.129"
- local vtep_ip=198.51.100.100
- echo
- echo "Control path: Basic (S, G) operations - IPv4 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_sg_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local grp_key="grp ff0e::1 src 2001:db8:100::1"
- local vtep_ip=198.51.100.100
- echo
- echo "Control path: Basic (S, G) operations - IPv6 overlay / IPv4 underlay"
- echo "---------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_sg_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local grp_key="grp 239.1.1.1 src 192.0.2.129"
- local vtep_ip=2001:db8:1000::1
- echo
- echo "Control path: Basic (S, G) operations - IPv4 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- basic_sg_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local grp_key="grp ff0e::1 src 2001:db8:100::1"
- local vtep_ip=2001:db8:1000::1
- echo
- echo "Control path: Basic (S, G) operations - IPv6 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------------"
- basic_common $ns1 "$grp_key" $vtep_ip
- }
- star_g_common()
- {
- local ns1=$1; shift
- local grp=$1; shift
- local src1=$1; shift
- local src2=$1; shift
- local src3=$1; shift
- local vtep_ip=$1; shift
- local all_zeros_grp=$1; shift
- # Test control path operations specific to (*, G) entries.
- # Basic add, replace and delete behavior.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- log_test $? 0 "(*, G) MDB entry addition with source list"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010"
- log_test $? 0 "(*, G) MDB entry presence after addition"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry presence after addition"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- log_test $? 0 "(*, G) MDB entry replacement with source list"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010"
- log_test $? 0 "(*, G) MDB entry presence after replacement"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry presence after replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- log_test $? 0 "(*, G) MDB entry deletion"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010"
- log_test $? 254 "(*, G) MDB entry presence after deletion"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010"
- log_test $? 254 "(S, G) MDB entry presence after deletion"
- # Default filter mode and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep exclude"
- log_test $? 0 "(*, G) MDB entry default filter mode"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $src1 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep include"
- log_test $? 0 "(*, G) MDB entry after replacing filter mode to \"include\""
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry after replacing filter mode to \"include\""
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep blocked"
- log_test $? 1 "\"blocked\" flag after replacing filter mode to \"include\""
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep exclude"
- log_test $? 0 "(*, G) MDB entry after replacing filter mode to \"exclude\""
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grep grp $grp src $src1 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry after replacing filter mode to \"exclude\""
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep blocked"
- log_test $? 0 "\"blocked\" flag after replacing filter mode to \"exclude\""
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- # Default source list and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep source_list"
- log_test $? 1 "(*, G) MDB entry default source list"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1,$src2,$src3 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry of 1st source after replacing source list"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src2 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry of 2nd source after replacing source list"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src3 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry of 3rd source after replacing source list"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1,$src3 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry of 1st source after removing source"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src2 src_vni 10010"
- log_test $? 254 "(S, G) MDB entry of 2nd source after removing source"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src3 src_vni 10010"
- log_test $? 0 "(S, G) MDB entry of 3rd source after removing source"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- # Default protocol and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \"proto static\""
- log_test $? 0 "(*, G) MDB entry default protocol"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \"proto static\""
- log_test $? 0 "(S, G) MDB entry default protocol"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 proto bgp dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \"proto bgp\""
- log_test $? 0 "(*, G) MDB entry protocol after replacement"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \"proto bgp\""
- log_test $? 0 "(S, G) MDB entry protocol after replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- # Default destination port and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" dst_port \""
- log_test $? 1 "(*, G) MDB entry default destination port"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" dst_port \""
- log_test $? 1 "(S, G) MDB entry default destination port"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip dst_port 1234 src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" dst_port 1234 \""
- log_test $? 0 "(*, G) MDB entry destination port after replacement"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" dst_port 1234 \""
- log_test $? 0 "(S, G) MDB entry destination port after replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- # Default destination VNI and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" vni \""
- log_test $? 1 "(*, G) MDB entry default destination VNI"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" vni \""
- log_test $? 1 "(S, G) MDB entry default destination VNI"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip vni 1234 src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" vni 1234 \""
- log_test $? 0 "(*, G) MDB entry destination VNI after replacement"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" vni 1234 \""
- log_test $? 0 "(S, G) MDB entry destination VNI after replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- # Default outgoing interface and replacement.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" via \""
- log_test $? 1 "(*, G) MDB entry default outgoing interface"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" via \""
- log_test $? 1 "(S, G) MDB entry default outgoing interface"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010 via veth0"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" via veth0 \""
- log_test $? 0 "(*, G) MDB entry outgoing interface after replacement"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" via veth0 \""
- log_test $? 0 "(S, G) MDB entry outgoing interface after replacement"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010"
- # Error cases.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp permanent filter_mode exclude dst $vtep_ip src_vni 10010"
- log_test $? 255 "All-zeros group with filter mode"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp permanent source_list $src1 dst $vtep_ip src_vni 10010"
- log_test $? 255 "All-zeros group with source list"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode include dst $vtep_ip src_vni 10010"
- log_test $? 255 "(*, G) INCLUDE with an empty source list"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $grp dst $vtep_ip src_vni 10010"
- log_test $? 255 "Invalid source in source list"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent source_list $src1 dst $vtep_ip src_vni 10010"
- log_test $? 255 "Source list without filter mode"
- }
- star_g_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local grp=239.1.1.1
- local src1=192.0.2.129
- local src2=192.0.2.130
- local src3=192.0.2.131
- local vtep_ip=198.51.100.100
- local all_zeros_grp=0.0.0.0
- echo
- echo "Control path: (*, G) operations - IPv4 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------"
- star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp
- }
- star_g_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local grp=ff0e::1
- local src1=2001:db8:100::1
- local src2=2001:db8:100::2
- local src3=2001:db8:100::3
- local vtep_ip=198.51.100.100
- local all_zeros_grp=::
- echo
- echo "Control path: (*, G) operations - IPv6 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------"
- star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp
- }
- star_g_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local grp=239.1.1.1
- local src1=192.0.2.129
- local src2=192.0.2.130
- local src3=192.0.2.131
- local vtep_ip=2001:db8:1000::1
- local all_zeros_grp=0.0.0.0
- echo
- echo "Control path: (*, G) operations - IPv4 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------"
- star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp
- }
- star_g_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local grp=ff0e::1
- local src1=2001:db8:100::1
- local src2=2001:db8:100::2
- local src3=2001:db8:100::3
- local vtep_ip=2001:db8:1000::1
- local all_zeros_grp=::
- echo
- echo "Control path: (*, G) operations - IPv6 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------"
- star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp
- }
- sg_common()
- {
- local ns1=$1; shift
- local grp=$1; shift
- local src=$1; shift
- local vtep_ip=$1; shift
- local all_zeros_grp=$1; shift
- # Test control path operations specific to (S, G) entries.
- # Default filter mode.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $src permanent dst $vtep_ip src_vni 10010"
- run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src src_vni 10010 | grep include"
- log_test $? 0 "(S, G) MDB entry default filter mode"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp src $src permanent dst $vtep_ip src_vni 10010"
- # Error cases.
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $src permanent filter_mode include dst $vtep_ip src_vni 10010"
- log_test $? 255 "(S, G) with filter mode"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $src permanent source_list $src dst $vtep_ip src_vni 10010"
- log_test $? 255 "(S, G) with source list"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $grp permanent dst $vtep_ip src_vni 10010"
- log_test $? 255 "(S, G) with an invalid source list"
- run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp src $src permanent dst $vtep_ip src_vni 10010"
- log_test $? 255 "All-zeros group with source"
- }
- sg_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local grp=239.1.1.1
- local src=192.0.2.129
- local vtep_ip=198.51.100.100
- local all_zeros_grp=0.0.0.0
- echo
- echo "Control path: (S, G) operations - IPv4 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------"
- sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp
- }
- sg_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local grp=ff0e::1
- local src=2001:db8:100::1
- local vtep_ip=198.51.100.100
- local all_zeros_grp=::
- echo
- echo "Control path: (S, G) operations - IPv6 overlay / IPv4 underlay"
- echo "--------------------------------------------------------------"
- sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp
- }
- sg_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local grp=239.1.1.1
- local src=192.0.2.129
- local vtep_ip=2001:db8:1000::1
- local all_zeros_grp=0.0.0.0
- echo
- echo "Control path: (S, G) operations - IPv4 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------"
- sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp
- }
- sg_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local grp=ff0e::1
- local src=2001:db8:100::1
- local vtep_ip=2001:db8:1000::1
- local all_zeros_grp=::
- echo
- echo "Control path: (S, G) operations - IPv6 overlay / IPv6 underlay"
- echo "--------------------------------------------------------------"
- sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp
- }
- ipv4_grps_get()
- {
- local max_grps=$1; shift
- local i
- for i in $(seq 0 $((max_grps - 1))); do
- echo "239.1.1.$i"
- done
- }
- ipv6_grps_get()
- {
- local max_grps=$1; shift
- local i
- for i in $(seq 0 $((max_grps - 1))); do
- echo "ff0e::$(printf %x $i)"
- done
- }
- dump_common()
- {
- local ns1=$1; shift
- local local_addr=$1; shift
- local remote_prefix=$1; shift
- local fn=$1; shift
- local max_vxlan_devs=2
- local max_remotes=64
- local max_grps=256
- local num_entries
- local batch_file
- local grp
- local i j
- # The kernel maintains various markers for the MDB dump. Add a test for
- # large scale MDB dump to make sure that all the configured entries are
- # dumped and that the markers are used correctly.
- # Create net devices.
- for i in $(seq 1 $max_vxlan_devs); do
- ip -n $ns1 link add name vx-test${i} up type vxlan \
- local $local_addr dstport 4789 external vnifilter
- done
- # Create batch file with MDB entries.
- batch_file=$(mktemp)
- for i in $(seq 1 $max_vxlan_devs); do
- for j in $(seq 1 $max_remotes); do
- for grp in $($fn $max_grps); do
- echo "mdb add dev vx-test${i} port vx-test${i} grp $grp permanent dst ${remote_prefix}${j}" >> $batch_file
- done
- done
- done
- # Program the batch file and check for expected number of entries.
- bridge -n $ns1 -b $batch_file
- for i in $(seq 1 $max_vxlan_devs); do
- num_entries=$(bridge -n $ns1 mdb show dev vx-test${i} | grep "permanent" | wc -l)
- [[ $num_entries -eq $((max_grps * max_remotes)) ]]
- log_test $? 0 "Large scale dump - VXLAN device #$i"
- done
- rm -rf $batch_file
- }
- dump_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local local_addr=192.0.2.1
- local remote_prefix=198.51.100.
- local fn=ipv4_grps_get
- echo
- echo "Control path: Large scale MDB dump - IPv4 overlay / IPv4 underlay"
- echo "-----------------------------------------------------------------"
- dump_common $ns1 $local_addr $remote_prefix $fn
- }
- dump_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local local_addr=192.0.2.1
- local remote_prefix=198.51.100.
- local fn=ipv6_grps_get
- echo
- echo "Control path: Large scale MDB dump - IPv6 overlay / IPv4 underlay"
- echo "-----------------------------------------------------------------"
- dump_common $ns1 $local_addr $remote_prefix $fn
- }
- dump_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local local_addr=2001:db8:1::1
- local remote_prefix=2001:db8:1000::
- local fn=ipv4_grps_get
- echo
- echo "Control path: Large scale MDB dump - IPv4 overlay / IPv6 underlay"
- echo "-----------------------------------------------------------------"
- dump_common $ns1 $local_addr $remote_prefix $fn
- }
- dump_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local local_addr=2001:db8:1::1
- local remote_prefix=2001:db8:1000::
- local fn=ipv6_grps_get
- echo
- echo "Control path: Large scale MDB dump - IPv6 overlay / IPv6 underlay"
- echo "-----------------------------------------------------------------"
- dump_common $ns1 $local_addr $remote_prefix $fn
- }
- flush()
- {
- local num_entries
- echo
- echo "Control path: Flush"
- echo "-------------------"
- # Add entries with different attributes and check that they are all
- # flushed when the flush command is given with no parameters.
- # Different source VNI.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.2 permanent dst 198.51.100.1 src_vni 10011"
- # Different routing protocol.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.3 permanent proto bgp dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.4 permanent proto zebra dst 198.51.100.1 src_vni 10010"
- # Different destination IP.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.5 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.6 permanent dst 198.51.100.2 src_vni 10010"
- # Different destination port.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.7 permanent dst 198.51.100.1 dst_port 11111 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.8 permanent dst 198.51.100.1 dst_port 22222 src_vni 10010"
- # Different VNI.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.9 permanent dst 198.51.100.1 vni 10010 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.10 permanent dst 198.51.100.1 vni 10020 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- num_entries=$(bridge -n $ns1_v4 mdb show dev vx0 | wc -l)
- [[ $num_entries -eq 0 ]]
- log_test $? 0 "Flush all"
- # Check that entries are flushed when port is specified as the VXLAN
- # device and that an error is returned when port is specified as a
- # different net device.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 port vx0"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010"
- log_test $? 254 "Flush by port - matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 port veth0"
- log_test $? 255 "Flush by port - non-matching"
- # Check that when flushing by source VNI only entries programmed with
- # the specified source VNI are flushed and the rest are not.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10011"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10011"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010"
- log_test $? 254 "Flush by source VNI - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10011"
- log_test $? 0 "Flush by source VNI - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # Check that all entries are flushed when "permanent" is specified and
- # that an error is returned when "nopermanent" is specified.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 permanent"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010"
- log_test $? 254 "Flush by \"permanent\" state"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 nopermanent"
- log_test $? 255 "Flush by \"nopermanent\" state"
- # Check that when flushing by routing protocol only entries programmed
- # with the specified routing protocol are flushed and the rest are not.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent proto bgp dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent proto zebra dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 proto bgp"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"proto bgp\""
- log_test $? 1 "Flush by routing protocol - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"proto zebra\""
- log_test $? 0 "Flush by routing protocol - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # Check that when flushing by destination IP only entries programmed
- # with the specified destination IP are flushed and the rest are not.
- # IPv4.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst 198.51.100.2"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.2"
- log_test $? 1 "Flush by IPv4 destination IP - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.1"
- log_test $? 0 "Flush by IPv4 destination IP - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # IPv6.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 2001:db8:1000::1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 2001:db8:1000::2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst 2001:db8:1000::2"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 2001:db8:1000::2"
- log_test $? 1 "Flush by IPv6 destination IP - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 2001:db8:1000::1"
- log_test $? 0 "Flush by IPv6 destination IP - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # Check that when flushing by UDP destination port only entries
- # programmed with the specified port are flushed and the rest are not.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst_port 11111 dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst_port 22222 dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst_port 11111"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"dst_port 11111\""
- log_test $? 1 "Flush by UDP destination port - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"dst_port 22222\""
- log_test $? 0 "Flush by UDP destination port - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # When not specifying a UDP destination port for an entry, traffic is
- # encapsulated with the device's UDP destination port. Check that when
- # flushing by the device's UDP destination port only entries programmed
- # with this port are flushed and the rest are not.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst_port 22222 dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst_port 4789"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.1"
- log_test $? 1 "Flush by device's UDP destination port - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.2"
- log_test $? 0 "Flush by device's UDP destination port - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # Check that when flushing by destination VNI only entries programmed
- # with the specified destination VNI are flushed and the rest are not.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent vni 20010 dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent vni 20011 dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 vni 20010"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \" vni 20010\""
- log_test $? 1 "Flush by destination VNI - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \" vni 20011\""
- log_test $? 0 "Flush by destination VNI - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # When not specifying a destination VNI for an entry, traffic is
- # encapsulated with the source VNI. Check that when flushing by a
- # destination VNI that is equal to the source VNI only such entries are
- # flushed and the rest are not.
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent vni 20010 dst 198.51.100.2 src_vni 10010"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 vni 10010"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.1"
- log_test $? 1 "Flush by destination VNI equal to source VNI - matching"
- run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.2"
- log_test $? 0 "Flush by destination VNI equal to source VNI - non-matching"
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0"
- # Test that an error is returned when trying to flush using VLAN ID.
- run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 vid 10"
- log_test $? 255 "Flush by VLAN ID"
- }
- ################################################################################
- # Tests - Data path
- encap_params_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local plen=$1; shift
- local enc_ethtype=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local src=$1; shift
- local mz=$1; shift
- # Test that packets forwarded by the VXLAN MDB are encapsulated with
- # the correct parameters. Transmit packets from the first namespace and
- # check that they hit the corresponding filters on the ingress of the
- # second namespace.
- run_cmd "tc -n $ns2 qdisc replace dev veth0 clsact"
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo"
- # Check destination IP.
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep2_ip src_vni 10020"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Destination IP - match"
- run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Destination IP - no match"
- run_cmd "tc -n $ns2 filter del dev vx0 ingress pref 1 handle 101 flower"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep2_ip src_vni 10020"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010"
- # Check destination port.
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip dst_port 1111 src_vni 10020"
- run_cmd "tc -n $ns2 filter replace dev veth0 ingress pref 1 handle 101 proto $enc_ethtype flower ip_proto udp dst_port 4789 action pass"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev veth0 ingress" 101 1
- log_test $? 0 "Default destination port - match"
- run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev veth0 ingress" 101 1
- log_test $? 0 "Default destination port - no match"
- run_cmd "tc -n $ns2 filter replace dev veth0 ingress pref 1 handle 101 proto $enc_ethtype flower ip_proto udp dst_port 1111 action pass"
- run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev veth0 ingress" 101 1
- log_test $? 0 "Non-default destination port - match"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev veth0 ingress" 101 1
- log_test $? 0 "Non-default destination port - no match"
- run_cmd "tc -n $ns2 filter del dev veth0 ingress pref 1 handle 101 flower"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10020"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010"
- # Check default VNI.
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10020"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_key_id 10010 action pass"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Default destination VNI - match"
- run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Default destination VNI - no match"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip vni 10020 src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip vni 10010 src_vni 10020"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_key_id 10020 action pass"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Non-default destination VNI - match"
- run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Non-default destination VNI - no match"
- run_cmd "tc -n $ns2 filter del dev vx0 ingress pref 1 handle 101 flower"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10020"
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010"
- }
- encap_params_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local enc_ethtype="ip"
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local src=192.0.2.129
- echo
- echo "Data path: Encapsulation parameters - IPv4 overlay / IPv4 underlay"
- echo "------------------------------------------------------------------"
- encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \
- $grp $grp_dmac $src "mausezahn"
- }
- encap_params_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local enc_ethtype="ip"
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local src=2001:db8:100::1
- echo
- echo "Data path: Encapsulation parameters - IPv6 overlay / IPv4 underlay"
- echo "------------------------------------------------------------------"
- encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \
- $grp $grp_dmac $src "mausezahn -6"
- }
- encap_params_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local enc_ethtype="ipv6"
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local src=192.0.2.129
- echo
- echo "Data path: Encapsulation parameters - IPv4 overlay / IPv6 underlay"
- echo "------------------------------------------------------------------"
- encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \
- $grp $grp_dmac $src "mausezahn"
- }
- encap_params_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local enc_ethtype="ipv6"
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local src=2001:db8:100::1
- echo
- echo "Data path: Encapsulation parameters - IPv6 overlay / IPv6 underlay"
- echo "------------------------------------------------------------------"
- encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \
- $grp $grp_dmac $src "mausezahn -6"
- }
- starg_exclude_ir_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local plen=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local valid_src=$1; shift
- local invalid_src=$1; shift
- local mz=$1; shift
- # Install a (*, G) EXCLUDE MDB entry with one source and two remote
- # VTEPs. Make sure that the source in the source list is not forwarded
- # and that a source not in the list is forwarded. Remove one of the
- # VTEPs from the entry and make sure that packets are only forwarded to
- # the remaining VTEP.
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $invalid_src dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $invalid_src dst $vtep2_ip src_vni 10010"
- # Check that invalid source is not forwarded to any VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 0
- log_test $? 0 "Block excluded source - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 0
- log_test $? 0 "Block excluded source - second VTEP"
- # Check that valid source is forwarded to both VTEPs.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Forward valid source - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Forward valid source - second VTEP"
- # Remove second VTEP.
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep2_ip src_vni 10010"
- # Check that invalid source is not forwarded to any VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Block excluded source after removal - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Block excluded source after removal - second VTEP"
- # Check that valid source is forwarded to the remaining VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 2
- log_test $? 0 "Forward valid source after removal - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Forward valid source after removal - second VTEP"
- }
- starg_exclude_ir_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) EXCLUDE - IR - IPv4 overlay / IPv4 underlay"
- echo "-------------------------------------------------------------"
- starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn"
- }
- starg_exclude_ir_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) EXCLUDE - IR - IPv6 overlay / IPv4 underlay"
- echo "-------------------------------------------------------------"
- starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn -6"
- }
- starg_exclude_ir_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) EXCLUDE - IR - IPv4 overlay / IPv6 underlay"
- echo "-------------------------------------------------------------"
- starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn"
- }
- starg_exclude_ir_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) EXCLUDE - IR - IPv6 overlay / IPv6 underlay"
- echo "-------------------------------------------------------------"
- starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn -6"
- }
- starg_include_ir_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local plen=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local valid_src=$1; shift
- local invalid_src=$1; shift
- local mz=$1; shift
- # Install a (*, G) INCLUDE MDB entry with one source and two remote
- # VTEPs. Make sure that the source in the source list is forwarded and
- # that a source not in the list is not forwarded. Remove one of the
- # VTEPs from the entry and make sure that packets are only forwarded to
- # the remaining VTEP.
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $valid_src dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $valid_src dst $vtep2_ip src_vni 10010"
- # Check that invalid source is not forwarded to any VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 0
- log_test $? 0 "Block excluded source - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 0
- log_test $? 0 "Block excluded source - second VTEP"
- # Check that valid source is forwarded to both VTEPs.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Forward valid source - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Forward valid source - second VTEP"
- # Remove second VTEP.
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep2_ip src_vni 10010"
- # Check that invalid source is not forwarded to any VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Block excluded source after removal - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Block excluded source after removal - second VTEP"
- # Check that valid source is forwarded to the remaining VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 2
- log_test $? 0 "Forward valid source after removal - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Forward valid source after removal - second VTEP"
- }
- starg_include_ir_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) INCLUDE - IR - IPv4 overlay / IPv4 underlay"
- echo "-------------------------------------------------------------"
- starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn"
- }
- starg_include_ir_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) INCLUDE - IR - IPv6 overlay / IPv4 underlay"
- echo "-------------------------------------------------------------"
- starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn -6"
- }
- starg_include_ir_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) INCLUDE - IR - IPv4 overlay / IPv6 underlay"
- echo "-------------------------------------------------------------"
- starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn"
- }
- starg_include_ir_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) INCLUDE - IR - IPv6 overlay / IPv6 underlay"
- echo "-------------------------------------------------------------"
- starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \
- $grp_dmac $valid_src $invalid_src "mausezahn -6"
- }
- starg_exclude_p2mp_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local mcast_grp=$1; shift
- local plen=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local valid_src=$1; shift
- local invalid_src=$1; shift
- local mz=$1; shift
- # Install a (*, G) EXCLUDE MDB entry with one source and one multicast
- # group to which packets are sent. Make sure that the source in the
- # source list is not forwarded and that a source not in the list is
- # forwarded.
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "ip -n $ns2 address replace $mcast_grp/$plen dev veth0 autojoin"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $mcast_grp action pass"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $invalid_src dst $mcast_grp src_vni 10010 via veth0"
- # Check that invalid source is not forwarded.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 0
- log_test $? 0 "Block excluded source"
- # Check that valid source is forwarded.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Forward valid source"
- # Remove the VTEP from the multicast group.
- run_cmd "ip -n $ns2 address del $mcast_grp/$plen dev veth0"
- # Check that valid source is not received anymore.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Receive of valid source after removal from group"
- }
- starg_exclude_p2mp_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local mcast_grp=238.1.1.1
- local plen=32
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) EXCLUDE - P2MP - IPv4 overlay / IPv4 underlay"
- echo "---------------------------------------------------------------"
- starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn"
- }
- starg_exclude_p2mp_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local mcast_grp=238.1.1.1
- local plen=32
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) EXCLUDE - P2MP - IPv6 overlay / IPv4 underlay"
- echo "---------------------------------------------------------------"
- starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn -6"
- }
- starg_exclude_p2mp_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local mcast_grp=ff0e::2
- local plen=128
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) EXCLUDE - P2MP - IPv4 overlay / IPv6 underlay"
- echo "---------------------------------------------------------------"
- starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn"
- }
- starg_exclude_p2mp_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local mcast_grp=ff0e::2
- local plen=128
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) EXCLUDE - P2MP - IPv6 overlay / IPv6 underlay"
- echo "---------------------------------------------------------------"
- starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn -6"
- }
- starg_include_p2mp_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local mcast_grp=$1; shift
- local plen=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local valid_src=$1; shift
- local invalid_src=$1; shift
- local mz=$1; shift
- # Install a (*, G) INCLUDE MDB entry with one source and one multicast
- # group to which packets are sent. Make sure that the source in the
- # source list is forwarded and that a source not in the list is not
- # forwarded.
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "ip -n $ns2 address replace $mcast_grp/$plen dev veth0 autojoin"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $mcast_grp action pass"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $valid_src dst $mcast_grp src_vni 10010 via veth0"
- # Check that invalid source is not forwarded.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 0
- log_test $? 0 "Block excluded source"
- # Check that valid source is forwarded.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Forward valid source"
- # Remove the VTEP from the multicast group.
- run_cmd "ip -n $ns2 address del $mcast_grp/$plen dev veth0"
- # Check that valid source is not received anymore.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Receive of valid source after removal from group"
- }
- starg_include_p2mp_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local mcast_grp=238.1.1.1
- local plen=32
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) INCLUDE - P2MP - IPv4 overlay / IPv4 underlay"
- echo "---------------------------------------------------------------"
- starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn"
- }
- starg_include_p2mp_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local mcast_grp=238.1.1.1
- local plen=32
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) INCLUDE - P2MP - IPv6 overlay / IPv4 underlay"
- echo "---------------------------------------------------------------"
- starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn -6"
- }
- starg_include_p2mp_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local mcast_grp=ff0e::2
- local plen=128
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local valid_src=192.0.2.129
- local invalid_src=192.0.2.145
- echo
- echo "Data path: (*, G) INCLUDE - P2MP - IPv4 overlay / IPv6 underlay"
- echo "---------------------------------------------------------------"
- starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn"
- }
- starg_include_p2mp_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local mcast_grp=ff0e::2
- local plen=128
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local valid_src=2001:db8:100::1
- local invalid_src=2001:db8:200::1
- echo
- echo "Data path: (*, G) INCLUDE - P2MP - IPv6 overlay / IPv6 underlay"
- echo "---------------------------------------------------------------"
- starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \
- $valid_src $invalid_src "mausezahn -6"
- }
- egress_vni_translation_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local mcast_grp=$1; shift
- local plen=$1; shift
- local proto=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local src=$1; shift
- local mz=$1; shift
- # When P2MP tunnels are used with optimized inter-subnet multicast
- # (OISM) [1], the ingress VTEP does not perform VNI translation and
- # uses the VNI of the source broadcast domain (BD). If the egress VTEP
- # is a member in the source BD, then no VNI translation is needed.
- # Otherwise, the egress VTEP needs to translate the VNI to the
- # supplementary broadcast domain (SBD) VNI, which is usually the L3VNI.
- #
- # In this test, remove the VTEP in the second namespace from VLAN 10
- # (VNI 10010) and make sure that a packet sent from this VLAN on the
- # first VTEP is received by the SVI corresponding to the L3VNI (14000 /
- # VLAN 4000) on the second VTEP.
- #
- # The second VTEP will be able to decapsulate the packet with VNI 10010
- # because this VNI is configured on its shared VXLAN device. Later,
- # when ingressing the bridge, the VNI to VLAN lookup will fail because
- # the VTEP is not a member in VLAN 10, which will cause the packet to
- # be tagged with VLAN 4000 since it is configured as PVID.
- #
- # [1] https://datatracker.ietf.org/doc/html/draft-ietf-bess-evpn-irb-mcast
- run_cmd "tc -n $ns2 qdisc replace dev br0.4000 clsact"
- run_cmd "ip -n $ns2 address replace $mcast_grp/$plen dev veth0 autojoin"
- run_cmd "tc -n $ns2 filter replace dev br0.4000 ingress pref 1 handle 101 proto $proto flower src_ip $src dst_ip $grp action pass"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp src $src permanent dst $mcast_grp src_vni 10010 via veth0"
- # Remove the second VTEP from VLAN 10.
- run_cmd "bridge -n $ns2 vlan del vid 10 dev vx0"
- # Make sure that packets sent from the first VTEP over VLAN 10 are
- # received by the SVI corresponding to the L3VNI (14000 / VLAN 4000) on
- # the second VTEP, since it is configured as PVID.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev br0.4000 ingress" 101 1
- log_test $? 0 "Egress VNI translation - PVID configured"
- # Remove PVID flag from VLAN 4000 on the second VTEP and make sure
- # packets are no longer received by the SVI interface.
- run_cmd "bridge -n $ns2 vlan add vid 4000 dev vx0"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev br0.4000 ingress" 101 1
- log_test $? 0 "Egress VNI translation - no PVID configured"
- # Reconfigure the PVID and make sure packets are received again.
- run_cmd "bridge -n $ns2 vlan add vid 4000 dev vx0 pvid"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev br0.4000 ingress" 101 2
- log_test $? 0 "Egress VNI translation - PVID reconfigured"
- }
- egress_vni_translation_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local mcast_grp=238.1.1.1
- local plen=32
- local proto="ipv4"
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local src=192.0.2.129
- echo
- echo "Data path: Egress VNI translation - IPv4 overlay / IPv4 underlay"
- echo "----------------------------------------------------------------"
- egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \
- $grp_dmac $src "mausezahn"
- }
- egress_vni_translation_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local mcast_grp=238.1.1.1
- local plen=32
- local proto="ipv6"
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local src=2001:db8:100::1
- echo
- echo "Data path: Egress VNI translation - IPv6 overlay / IPv4 underlay"
- echo "----------------------------------------------------------------"
- egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \
- $grp_dmac $src "mausezahn -6"
- }
- egress_vni_translation_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local mcast_grp=ff0e::2
- local plen=128
- local proto="ipv4"
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local src=192.0.2.129
- echo
- echo "Data path: Egress VNI translation - IPv4 overlay / IPv6 underlay"
- echo "----------------------------------------------------------------"
- egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \
- $grp_dmac $src "mausezahn"
- }
- egress_vni_translation_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local mcast_grp=ff0e::2
- local plen=128
- local proto="ipv6"
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local src=2001:db8:100::1
- echo
- echo "Data path: Egress VNI translation - IPv6 overlay / IPv6 underlay"
- echo "----------------------------------------------------------------"
- egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \
- $grp_dmac $src "mausezahn -6"
- }
- all_zeros_mdb_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local vtep3_ip=$1; shift
- local vtep4_ip=$1; shift
- local plen=$1; shift
- local ipv4_grp=239.1.1.1
- local ipv4_grp_dmac=01:00:5e:01:01:01
- local ipv4_unreg_grp=239.2.2.2
- local ipv4_unreg_grp_dmac=01:00:5e:02:02:02
- local ipv4_ll_grp=224.0.0.100
- local ipv4_ll_grp_dmac=01:00:5e:00:00:64
- local ipv4_src=192.0.2.129
- local ipv6_grp=ff0e::1
- local ipv6_grp_dmac=33:33:00:00:00:01
- local ipv6_unreg_grp=ff0e::2
- local ipv6_unreg_grp_dmac=33:33:00:00:00:02
- local ipv6_ll_grp=ff02::1
- local ipv6_ll_grp_dmac=33:33:00:00:00:01
- local ipv6_src=2001:db8:100::1
- # Install all-zeros (catchall) MDB entries for IPv4 and IPv6 traffic
- # and make sure they only forward unregistered IP multicast traffic
- # which is not link-local. Also make sure that each entry only forwards
- # traffic from the matching address family.
- # Associate two different VTEPs with one all-zeros MDB entry: Two with
- # the IPv4 entry (0.0.0.0) and another two with the IPv6 one (::).
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp 0.0.0.0 permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp 0.0.0.0 permanent dst $vtep2_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp :: permanent dst $vtep3_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp :: permanent dst $vtep4_ip src_vni 10010"
- # Associate one VTEP from each set with a regular MDB entry: One with
- # an IPv4 entry and another with an IPv6 one.
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $ipv4_grp permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $ipv6_grp permanent dst $vtep3_ip src_vni 10010"
- # Add filters to match on decapsulated traffic in the second namespace.
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 103 proto all flower enc_dst_ip $vtep3_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 104 proto all flower enc_dst_ip $vtep4_ip action pass"
- # Configure the VTEP addresses in the second namespace to enable
- # decapsulation.
- run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep3_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep4_ip/$plen dev lo"
- # Send registered IPv4 multicast and make sure it only arrives to the
- # first VTEP.
- run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b $ipv4_grp_dmac -A $ipv4_src -B $ipv4_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Registered IPv4 multicast - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 0
- log_test $? 0 "Registered IPv4 multicast - second VTEP"
- # Send unregistered IPv4 multicast that is not link-local and make sure
- # it arrives to the first and second VTEPs.
- run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b $ipv4_unreg_grp_dmac -A $ipv4_src -B $ipv4_unreg_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 2
- log_test $? 0 "Unregistered IPv4 multicast - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Unregistered IPv4 multicast - second VTEP"
- # Send IPv4 link-local multicast traffic and make sure it does not
- # arrive to any VTEP.
- run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b $ipv4_ll_grp_dmac -A $ipv4_src -B $ipv4_ll_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 2
- log_test $? 0 "Link-local IPv4 multicast - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Link-local IPv4 multicast - second VTEP"
- # Send registered IPv4 multicast using a unicast MAC address and make
- # sure it does not arrive to any VTEP.
- run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b 00:11:22:33:44:55 -A $ipv4_src -B $ipv4_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 2
- log_test $? 0 "Registered IPv4 multicast with a unicast MAC - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Registered IPv4 multicast with a unicast MAC - second VTEP"
- # Send registered IPv4 multicast using a broadcast MAC address and make
- # sure it does not arrive to any VTEP.
- run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b bcast -A $ipv4_src -B $ipv4_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 2
- log_test $? 0 "Registered IPv4 multicast with a broadcast MAC - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Registered IPv4 multicast with a broadcast MAC - second VTEP"
- # Make sure IPv4 traffic did not reach the VTEPs associated with
- # IPv6 entries.
- tc_check_packets "$ns2" "dev vx0 ingress" 103 0
- log_test $? 0 "IPv4 traffic - third VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 104 0
- log_test $? 0 "IPv4 traffic - fourth VTEP"
- # Reset IPv4 filters before testing IPv6 traffic.
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass"
- # Send registered IPv6 multicast and make sure it only arrives to the
- # third VTEP.
- run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b $ipv6_grp_dmac -A $ipv6_src -B $ipv6_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 103 1
- log_test $? 0 "Registered IPv6 multicast - third VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 104 0
- log_test $? 0 "Registered IPv6 multicast - fourth VTEP"
- # Send unregistered IPv6 multicast that is not link-local and make sure
- # it arrives to the third and fourth VTEPs.
- run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b $ipv6_unreg_grp_dmac -A $ipv6_src -B $ipv6_unreg_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 103 2
- log_test $? 0 "Unregistered IPv6 multicast - third VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 104 1
- log_test $? 0 "Unregistered IPv6 multicast - fourth VTEP"
- # Send IPv6 link-local multicast traffic and make sure it does not
- # arrive to any VTEP.
- run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b $ipv6_ll_grp_dmac -A $ipv6_src -B $ipv6_ll_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 103 2
- log_test $? 0 "Link-local IPv6 multicast - third VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 104 1
- log_test $? 0 "Link-local IPv6 multicast - fourth VTEP"
- # Send registered IPv6 multicast using a unicast MAC address and make
- # sure it does not arrive to any VTEP.
- run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b 00:11:22:33:44:55 -A $ipv6_src -B $ipv6_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 103 2
- log_test $? 0 "Registered IPv6 multicast with a unicast MAC - third VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 104 1
- log_test $? 0 "Registered IPv6 multicast with a unicast MAC - fourth VTEP"
- # Send registered IPv6 multicast using a broadcast MAC address and make
- # sure it does not arrive to any VTEP.
- run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b bcast -A $ipv6_src -B $ipv6_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 103 2
- log_test $? 0 "Registered IPv6 multicast with a broadcast MAC - third VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 104 1
- log_test $? 0 "Registered IPv6 multicast with a broadcast MAC - fourth VTEP"
- # Make sure IPv6 traffic did not reach the VTEPs associated with
- # IPv4 entries.
- tc_check_packets "$ns2" "dev vx0 ingress" 101 0
- log_test $? 0 "IPv6 traffic - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 0
- log_test $? 0 "IPv6 traffic - second VTEP"
- }
- all_zeros_mdb_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.101
- local vtep2_ip=198.51.100.102
- local vtep3_ip=198.51.100.103
- local vtep4_ip=198.51.100.104
- local plen=32
- echo
- echo "Data path: All-zeros MDB entry - IPv4 underlay"
- echo "----------------------------------------------"
- all_zeros_mdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $vtep3_ip \
- $vtep4_ip $plen
- }
- all_zeros_mdb_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local vtep3_ip=2001:db8:3000::1
- local vtep4_ip=2001:db8:4000::1
- local plen=128
- echo
- echo "Data path: All-zeros MDB entry - IPv6 underlay"
- echo "----------------------------------------------"
- all_zeros_mdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $vtep3_ip \
- $vtep4_ip $plen
- }
- mdb_fdb_common()
- {
- local ns1=$1; shift
- local ns2=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local plen=$1; shift
- local proto=$1; shift
- local grp=$1; shift
- local grp_dmac=$1; shift
- local src=$1; shift
- local mz=$1; shift
- # Install an MDB entry and an FDB entry and make sure that the FDB
- # entry only forwards traffic that was not forwarded by the MDB.
- # Associate the MDB entry with one VTEP and the FDB entry with another
- # VTEP.
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 fdb add 00:00:00:00:00:00 dev vx0 self static dst $vtep2_ip src_vni 10010"
- # Add filters to match on decapsulated traffic in the second namespace.
- run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto $proto flower ip_proto udp dst_port 54321 enc_dst_ip $vtep1_ip action pass"
- run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto $proto flower ip_proto udp dst_port 54321 enc_dst_ip $vtep2_ip action pass"
- # Configure the VTEP addresses in the second namespace to enable
- # decapsulation.
- run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo"
- run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo"
- # Send IP multicast traffic and make sure it is forwarded by the MDB
- # and only arrives to the first VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "IP multicast - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 0
- log_test $? 0 "IP multicast - second VTEP"
- # Send broadcast traffic and make sure it is forwarded by the FDB and
- # only arrives to the second VTEP.
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b bcast -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "Broadcast - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 1
- log_test $? 0 "Broadcast - second VTEP"
- # Remove the MDB entry and make sure that IP multicast is now forwarded
- # by the FDB to the second VTEP.
- run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010"
- run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q"
- tc_check_packets "$ns2" "dev vx0 ingress" 101 1
- log_test $? 0 "IP multicast after removal - first VTEP"
- tc_check_packets "$ns2" "dev vx0 ingress" 102 2
- log_test $? 0 "IP multicast after removal - second VTEP"
- }
- mdb_fdb_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local proto="ipv4"
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local src=192.0.2.129
- echo
- echo "Data path: MDB with FDB - IPv4 overlay / IPv4 underlay"
- echo "------------------------------------------------------"
- mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \
- $grp_dmac $src "mausezahn"
- }
- mdb_fdb_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local ns2=$ns2_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local plen=32
- local proto="ipv6"
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local src=2001:db8:100::1
- echo
- echo "Data path: MDB with FDB - IPv6 overlay / IPv4 underlay"
- echo "------------------------------------------------------"
- mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \
- $grp_dmac $src "mausezahn -6"
- }
- mdb_fdb_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local proto="ipv4"
- local grp=239.1.1.1
- local grp_dmac=01:00:5e:01:01:01
- local src=192.0.2.129
- echo
- echo "Data path: MDB with FDB - IPv4 overlay / IPv6 underlay"
- echo "------------------------------------------------------"
- mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \
- $grp_dmac $src "mausezahn"
- }
- mdb_fdb_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local ns2=$ns2_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local plen=128
- local proto="ipv6"
- local grp=ff0e::1
- local grp_dmac=33:33:00:00:00:01
- local src=2001:db8:100::1
- echo
- echo "Data path: MDB with FDB - IPv6 overlay / IPv6 underlay"
- echo "------------------------------------------------------"
- mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \
- $grp_dmac $src "mausezahn -6"
- }
- mdb_grp1_loop()
- {
- local ns1=$1; shift
- local vtep1_ip=$1; shift
- local grp1=$1; shift
- while true; do
- bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp1 dst $vtep1_ip src_vni 10010
- bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp1 permanent dst $vtep1_ip src_vni 10010
- done >/dev/null 2>&1
- }
- mdb_grp2_loop()
- {
- local ns1=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local grp2=$1; shift
- while true; do
- bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp2 dst $vtep1_ip src_vni 10010
- bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp2 permanent dst $vtep1_ip src_vni 10010
- bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp2 permanent dst $vtep2_ip src_vni 10010
- done >/dev/null 2>&1
- }
- mdb_torture_common()
- {
- local ns1=$1; shift
- local vtep1_ip=$1; shift
- local vtep2_ip=$1; shift
- local grp1=$1; shift
- local grp1_dmac=$1; shift
- local grp2=$1; shift
- local grp2_dmac=$1; shift
- local src=$1; shift
- local mz=$1; shift
- local pid1
- local pid2
- local pid3
- local pid4
- # Continuously send two streams that are forwarded by two different MDB
- # entries. The first entry will be added and deleted in a loop. This
- # allows us to test that the data path does not use freed MDB entry
- # memory. The second entry will have two remotes, one that is added and
- # deleted in a loop and another that is replaced in a loop. This allows
- # us to test that the data path does not use freed remote entry memory.
- # The test is considered successful if nothing crashed.
- # Create the MDB entries that will be continuously deleted / replaced.
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp1 permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp2 permanent dst $vtep1_ip src_vni 10010"
- run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp2 permanent dst $vtep2_ip src_vni 10010"
- mdb_grp1_loop $ns1 $vtep1_ip $grp1 &
- pid1=$!
- mdb_grp2_loop $ns1 $vtep1_ip $vtep2_ip $grp2 &
- pid2=$!
- ip netns exec $ns1 $mz br0.10 -a own -b $grp1_dmac -A $src -B $grp1 -t udp sp=12345,dp=54321 -p 100 -c 0 -q &
- pid3=$!
- ip netns exec $ns1 $mz br0.10 -a own -b $grp2_dmac -A $src -B $grp2 -t udp sp=12345,dp=54321 -p 100 -c 0 -q &
- pid4=$!
- sleep 30
- kill -9 $pid1 $pid2 $pid3 $pid4
- wait $pid1 $pid2 $pid3 $pid4 2>/dev/null
- log_test 0 0 "Torture test"
- }
- mdb_torture_ipv4_ipv4()
- {
- local ns1=$ns1_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local grp1=239.1.1.1
- local grp1_dmac=01:00:5e:01:01:01
- local grp2=239.2.2.2
- local grp2_dmac=01:00:5e:02:02:02
- local src=192.0.2.129
- echo
- echo "Data path: MDB torture test - IPv4 overlay / IPv4 underlay"
- echo "----------------------------------------------------------"
- mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \
- $grp2_dmac $src "mausezahn"
- }
- mdb_torture_ipv6_ipv4()
- {
- local ns1=$ns1_v4
- local vtep1_ip=198.51.100.100
- local vtep2_ip=198.51.100.200
- local grp1=ff0e::1
- local grp1_dmac=33:33:00:00:00:01
- local grp2=ff0e::2
- local grp2_dmac=33:33:00:00:00:02
- local src=2001:db8:100::1
- echo
- echo "Data path: MDB torture test - IPv6 overlay / IPv4 underlay"
- echo "----------------------------------------------------------"
- mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \
- $grp2_dmac $src "mausezahn -6"
- }
- mdb_torture_ipv4_ipv6()
- {
- local ns1=$ns1_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local grp1=239.1.1.1
- local grp1_dmac=01:00:5e:01:01:01
- local grp2=239.2.2.2
- local grp2_dmac=01:00:5e:02:02:02
- local src=192.0.2.129
- echo
- echo "Data path: MDB torture test - IPv4 overlay / IPv6 underlay"
- echo "----------------------------------------------------------"
- mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \
- $grp2_dmac $src "mausezahn"
- }
- mdb_torture_ipv6_ipv6()
- {
- local ns1=$ns1_v6
- local vtep1_ip=2001:db8:1000::1
- local vtep2_ip=2001:db8:2000::1
- local grp1=ff0e::1
- local grp1_dmac=33:33:00:00:00:01
- local grp2=ff0e::2
- local grp2_dmac=33:33:00:00:00:02
- local src=2001:db8:100::1
- echo
- echo "Data path: MDB torture test - IPv6 overlay / IPv6 underlay"
- echo "----------------------------------------------------------"
- mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \
- $grp2_dmac $src "mausezahn -6"
- }
- ################################################################################
- # Usage
- usage()
- {
- cat <<EOF
- usage: ${0##*/} OPTS
- -t <test> Test(s) to run (default: all)
- (options: $TESTS)
- -c Control path tests only
- -d Data path tests only
- -p Pause on fail
- -P Pause after each test before cleanup
- -v Verbose mode (show commands and output)
- EOF
- }
- ################################################################################
- # Main
- trap cleanup EXIT
- while getopts ":t:cdpPvh" opt; do
- case $opt in
- t) TESTS=$OPTARG;;
- c) TESTS=${CONTROL_PATH_TESTS};;
- d) TESTS=${DATA_PATH_TESTS};;
- p) PAUSE_ON_FAIL=yes;;
- P) PAUSE=yes;;
- v) VERBOSE=$(($VERBOSE + 1));;
- h) usage; exit 0;;
- *) usage; exit 1;;
- esac
- done
- # Make sure we don't pause twice.
- [ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
- if [ "$(id -u)" -ne 0 ];then
- echo "SKIP: Need root privileges"
- exit $ksft_skip;
- fi
- if [ ! -x "$(command -v ip)" ]; then
- echo "SKIP: Could not run test without ip tool"
- exit $ksft_skip
- fi
- if [ ! -x "$(command -v bridge)" ]; then
- echo "SKIP: Could not run test without bridge tool"
- exit $ksft_skip
- fi
- if [ ! -x "$(command -v mausezahn)" ]; then
- echo "SKIP: Could not run test without mausezahn tool"
- exit $ksft_skip
- fi
- if [ ! -x "$(command -v jq)" ]; then
- echo "SKIP: Could not run test without jq tool"
- exit $ksft_skip
- fi
- bridge mdb help 2>&1 | grep -q "flush"
- if [ $? -ne 0 ]; then
- echo "SKIP: iproute2 bridge too old, missing VXLAN MDB flush support"
- exit $ksft_skip
- fi
- # Start clean.
- cleanup
- for t in $TESTS
- do
- setup; $t; cleanup;
- done
- if [ "$TESTS" != "none" ]; then
- printf "\nTests passed: %3d\n" ${nsuccess}
- printf "Tests failed: %3d\n" ${nfail}
- fi
- exit $ret
|