-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #824 from kernelkit/add-routing-pref-tests
Add Routing Preference Tests
- Loading branch information
Showing
17 changed files
with
1,051 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== Route preference: Static Route Activation and Maximum Distance | ||
==== Description | ||
This test configures a device with a static route to a destination with | ||
a moderate routing preference (254), verifying that it becomes active. | ||
Then, the routing preference is increased to the maximum value (255), | ||
which should prevent the route from becoming active. | ||
|
||
==== Topology | ||
ifdef::topdoc[] | ||
image::../../test/case/ietf_routing/route_pref_255/topology.svg[Route preference: Static Route Activation and Maximum Distance topology] | ||
endif::topdoc[] | ||
ifndef::topdoc[] | ||
ifdef::testgroup[] | ||
image::route_pref_255/topology.svg[Route preference: Static Route Activation and Maximum Distance topology] | ||
endif::testgroup[] | ||
ifndef::testgroup[] | ||
image::topology.svg[Route preference: Static Route Activation and Maximum Distance topology] | ||
endif::testgroup[] | ||
endif::topdoc[] | ||
==== Test sequence | ||
. Set up topology and attach to target DUTs | ||
. Configure targets with active static route | ||
. Verify that static route with preference 254 is active | ||
. Update static route preference to 255 | ||
. Verify that high-preference static route (255) does not become active | ||
|
||
|
||
<<< | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Route preference: Static Route Activation and Maximum Distance | ||
This test configures a device with a static route to a destination with | ||
a moderate routing preference (254), verifying that it becomes active. | ||
Then, the routing preference is increased to the maximum value (255), | ||
which should prevent the route from becoming active. | ||
""" | ||
|
||
import infamy | ||
import infamy.route as route | ||
from infamy.util import until, parallel | ||
|
||
def configure_interface(name, ip, prefix_length, forwarding=True): | ||
return { | ||
"name": name, | ||
"enabled": True, | ||
"ipv4": { | ||
"forwarding": forwarding, | ||
"address": [{"ip": ip, "prefix-length": prefix_length}] | ||
} | ||
} | ||
|
||
def config_target1_initial(target, data, link): | ||
target.put_config_dicts({ | ||
"ietf-interfaces": { | ||
"interfaces": { | ||
"interface": [ | ||
configure_interface(data, "192.168.10.1", 24), | ||
configure_interface(link, "192.168.50.1", 24) | ||
] | ||
} | ||
}, | ||
"ietf-routing": { | ||
"routing": { | ||
"control-plane-protocols": { | ||
"control-plane-protocol": [ | ||
{ | ||
"type": "infix-routing:static", | ||
"name": "default", | ||
"static-routes": { | ||
"ipv4": { | ||
"route": [{ | ||
"destination-prefix": "192.168.20.0/24", | ||
"next-hop": {"next-hop-address": "192.168.50.2"}, | ||
"route-preference": 254 | ||
}] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}) | ||
|
||
def config_target1_update(target): | ||
target.put_config_dicts({ | ||
"ietf-routing": { | ||
"routing": { | ||
"control-plane-protocols": { | ||
"control-plane-protocol": [ | ||
{ | ||
"type": "infix-routing:static", | ||
"name": "default", | ||
"static-routes": { | ||
"ipv4": { | ||
"route": [{ | ||
"destination-prefix": "192.168.20.0/24", | ||
"next-hop": {"next-hop-address": "192.168.50.2"}, | ||
"route-preference": 255 | ||
}] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}) | ||
|
||
def config_target2(target, data, link): | ||
target.put_config_dicts({ | ||
"ietf-interfaces": { | ||
"interfaces": { | ||
"interface": [ | ||
configure_interface(data, "192.168.20.2", 24), | ||
configure_interface(link, "192.168.50.2", 24) | ||
] | ||
} | ||
} | ||
}) | ||
|
||
with infamy.Test() as test: | ||
with test.step("Set up topology and attach to target DUTs"): | ||
env = infamy.Env() | ||
R1 = env.attach("R1", "mgmt") | ||
R2 = env.attach("R2", "mgmt") | ||
|
||
with test.step("Configure targets with active static route"): | ||
_, R1data = env.ltop.xlate("R1", "data") | ||
_, R1link = env.ltop.xlate("R1", "link") | ||
_, R2data = env.ltop.xlate("R2", "data") | ||
_, R2link = env.ltop.xlate("R2", "link") | ||
|
||
parallel(config_target1_initial(R1, R1data, R1link), config_target2(R2, R2data, R2link)) | ||
|
||
with test.step("Verify that static route with preference 254 is active"): | ||
until(lambda: route.ipv4_route_exist(R1, "192.168.20.0/24", proto="ietf-routing:static", active_check=True)) | ||
|
||
with test.step("Update static route preference to 255"): | ||
config_target1_update(R1) | ||
|
||
with test.step("Verify that high-preference static route (255) does not become active"): | ||
until(lambda: not route.ipv4_route_exist(R1, "192.168.20.0/24", proto="ietf-routing:static", active_check=True)) | ||
|
||
test.succeed() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
graph "route-preference" { | ||
layout="neato"; | ||
overlap="false"; | ||
esep="+20"; | ||
size=10 | ||
|
||
node [shape=record, fontname="DejaVu Sans Mono, Book"]; | ||
edge [color="cornflowerblue", penwidth="2", fontname="DejaVu Serif, Book"]; | ||
|
||
PC | ||
[ | ||
label="PC | { <mgmt1> mgmt1 | <data1> data1 | <data2> data2 | <mgmt2> mgmt2 }", | ||
pos="20,58!", | ||
kind="controller", | ||
]; | ||
|
||
R1 | ||
[ | ||
label="{ <mgmt> mgmt | <data> data | <link> link } | R1", | ||
pos="80,60!", | ||
kind="infix", | ||
]; | ||
|
||
R2 | ||
[ | ||
label="{ <link> link | <data> data | <mgmt> mgmt } | R2", | ||
pos="80,42!", | ||
kind="infix", | ||
]; | ||
|
||
PC:mgmt1 -- R1:mgmt [kind=mgmt, color="lightgray"] | ||
PC:mgmt2 -- R2:mgmt [kind=mgmt, color="lightgray"] | ||
|
||
PC:data1 -- R1:data [color="black", headlabel="192.168.10.1/24", taillabel="192.168.10.11/24", fontcolor="black"] | ||
PC:data2 -- R2:data [color="black", headlabel="192.168.20.2/24", taillabel="192.168.20.22/24", fontcolor="black"] | ||
|
||
R1:link -- R2:link [headlabel="192.168.50.2/24", taillabel="192.168.50.1/24", labeldistance=1, fontcolor="black", color="black"] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
=== Route preference: DHCP vs Static | ||
==== Description | ||
This test configures a device with both a DHCP-acquired route on a | ||
dedicated interface and a static route to the same destination on | ||
another interface. | ||
|
||
Initially, DHCP is preferred over Static. Afterwards, the static | ||
route takes precedence by adjusting the routing preference value | ||
to the one lower than DHCP. | ||
|
||
==== Topology | ||
ifdef::topdoc[] | ||
image::../../test/case/ietf_routing/route_pref_dhcp/topology.svg[Route preference: DHCP vs Static topology] | ||
endif::topdoc[] | ||
ifndef::topdoc[] | ||
ifdef::testgroup[] | ||
image::route_pref_dhcp/topology.svg[Route preference: DHCP vs Static topology] | ||
endif::testgroup[] | ||
ifndef::testgroup[] | ||
image::topology.svg[Route preference: DHCP vs Static topology] | ||
endif::testgroup[] | ||
endif::topdoc[] | ||
==== Test sequence | ||
. Set up topology and attach to target DUTs | ||
. Configure targets. Assign higher priority to the dhcp route | ||
. Wait for DHCP and static routes | ||
. Verify connectivity from PC:data12 to R2:lo via DHCP | ||
. Assign higher priority to the static route | ||
. Verify connectivity from PC:data12 to R2:lo via static route | ||
|
||
|
||
<<< | ||
|
Oops, something went wrong.