mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-29 20:23:01 +02:00
@@ -17,3 +17,5 @@ include::ospf_bfd/Readme.adoc[]
|
||||
include::route_pref_ospf/Readme.adoc[]
|
||||
|
||||
include::route_pref_dhcp/Readme.adoc[]
|
||||
|
||||
include::route_pref_255/Readme.adoc[]
|
||||
|
||||
@@ -19,3 +19,6 @@
|
||||
|
||||
- name: route_pref_dhcp
|
||||
case: route_pref_dhcp/test.py
|
||||
|
||||
- name: route_pref_255
|
||||
case: route_pref_255/test.py
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
<<<
|
||||
|
||||
+118
@@ -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()
|
||||
@@ -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"]
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
|
||||
<!-- Title: route-preference Pages: 1 -->
|
||||
<svg width="500pt" height="198pt"
|
||||
viewBox="0.00 0.00 499.77 198.01" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 194.01)">
|
||||
<title>route-preference</title>
|
||||
<polygon fill="white" stroke="transparent" points="-4,4 -4,-194.01 495.77,-194.01 495.77,4 -4,4"/>
|
||||
<!-- PC -->
|
||||
<g id="node1" class="node">
|
||||
<title>PC</title>
|
||||
<polygon fill="none" stroke="black" points="0,-95.68 0,-187.68 91,-187.68 91,-95.68 0,-95.68"/>
|
||||
<text text-anchor="middle" x="16.5" y="-137.98" font-family="DejaVu Sans Mono, Book" font-size="14.00">PC</text>
|
||||
<polyline fill="none" stroke="black" points="33,-95.68 33,-187.68 "/>
|
||||
<text text-anchor="middle" x="62" y="-172.48" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt1</text>
|
||||
<polyline fill="none" stroke="black" points="33,-164.68 91,-164.68 "/>
|
||||
<text text-anchor="middle" x="62" y="-149.48" font-family="DejaVu Sans Mono, Book" font-size="14.00">data1</text>
|
||||
<polyline fill="none" stroke="black" points="33,-141.68 91,-141.68 "/>
|
||||
<text text-anchor="middle" x="62" y="-126.48" font-family="DejaVu Sans Mono, Book" font-size="14.00">data2</text>
|
||||
<polyline fill="none" stroke="black" points="33,-118.68 91,-118.68 "/>
|
||||
<text text-anchor="middle" x="62" y="-103.48" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt2</text>
|
||||
</g>
|
||||
<!-- R1 -->
|
||||
<g id="node2" class="node">
|
||||
<title>R1</title>
|
||||
<polygon fill="none" stroke="black" points="404.04,-120.51 404.04,-189.51 487.04,-189.51 487.04,-120.51 404.04,-120.51"/>
|
||||
<text text-anchor="middle" x="429.04" y="-174.31" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt</text>
|
||||
<polyline fill="none" stroke="black" points="404.04,-166.51 454.04,-166.51 "/>
|
||||
<text text-anchor="middle" x="429.04" y="-151.31" font-family="DejaVu Sans Mono, Book" font-size="14.00">data</text>
|
||||
<polyline fill="none" stroke="black" points="404.04,-143.51 454.04,-143.51 "/>
|
||||
<text text-anchor="middle" x="429.04" y="-128.31" font-family="DejaVu Sans Mono, Book" font-size="14.00">link</text>
|
||||
<polyline fill="none" stroke="black" points="454.04,-120.51 454.04,-189.51 "/>
|
||||
<text text-anchor="middle" x="470.54" y="-151.31" font-family="DejaVu Sans Mono, Book" font-size="14.00">R1</text>
|
||||
</g>
|
||||
<!-- PC--R1 -->
|
||||
<g id="edge1" class="edge">
|
||||
<title>PC:mgmt1--R1:mgmt</title>
|
||||
<path fill="none" stroke="lightgray" stroke-width="2" d="M91.5,-176.68C91.5,-176.68 403.54,-178.01 403.54,-178.01"/>
|
||||
</g>
|
||||
<!-- PC--R1 -->
|
||||
<g id="edge3" class="edge">
|
||||
<title>PC:data1--R1:data</title>
|
||||
<path fill="none" stroke="black" stroke-width="2" d="M91.5,-153.68C91.5,-153.68 403.54,-155.01 403.54,-155.01"/>
|
||||
<text text-anchor="middle" x="344.54" y="-158.81" font-family="DejaVu Serif, Book" font-size="14.00">192.168.10.1/24</text>
|
||||
<text text-anchor="middle" x="155" y="-157.48" font-family="DejaVu Serif, Book" font-size="14.00">192.168.10.11/24</text>
|
||||
</g>
|
||||
<!-- R2 -->
|
||||
<g id="node3" class="node">
|
||||
<title>R2</title>
|
||||
<polygon fill="none" stroke="black" points="404.04,-0.5 404.04,-69.5 487.04,-69.5 487.04,-0.5 404.04,-0.5"/>
|
||||
<text text-anchor="middle" x="429.04" y="-54.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">link</text>
|
||||
<polyline fill="none" stroke="black" points="404.04,-46.5 454.04,-46.5 "/>
|
||||
<text text-anchor="middle" x="429.04" y="-31.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">data</text>
|
||||
<polyline fill="none" stroke="black" points="404.04,-23.5 454.04,-23.5 "/>
|
||||
<text text-anchor="middle" x="429.04" y="-8.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">mgmt</text>
|
||||
<polyline fill="none" stroke="black" points="454.04,-0.5 454.04,-69.5 "/>
|
||||
<text text-anchor="middle" x="470.54" y="-31.3" font-family="DejaVu Sans Mono, Book" font-size="14.00">R2</text>
|
||||
</g>
|
||||
<!-- PC--R2 -->
|
||||
<g id="edge2" class="edge">
|
||||
<title>PC:mgmt2--R2:mgmt</title>
|
||||
<path fill="none" stroke="lightgray" stroke-width="2" d="M91.5,-106.68C91.5,-106.68 403.54,-12 403.54,-12"/>
|
||||
</g>
|
||||
<!-- PC--R2 -->
|
||||
<g id="edge4" class="edge">
|
||||
<title>PC:data2--R2:data</title>
|
||||
<path fill="none" stroke="black" stroke-width="2" d="M91.5,-129.68C91.5,-129.68 403.54,-35 403.54,-35"/>
|
||||
<text text-anchor="middle" x="344.54" y="-38.8" font-family="DejaVu Serif, Book" font-size="14.00">192.168.20.2/24</text>
|
||||
<text text-anchor="middle" x="155" y="-133.48" font-family="DejaVu Serif, Book" font-size="14.00">192.168.20.22/24</text>
|
||||
</g>
|
||||
<!-- R1--R2 -->
|
||||
<g id="edge5" class="edge">
|
||||
<title>R1:link--R2:link</title>
|
||||
<path fill="none" stroke="black" stroke-width="2" d="M428.54,-120.01C428.54,-120.01 428.54,-70 428.54,-70"/>
|
||||
<text text-anchor="middle" x="432.77" y="-75.36" font-family="DejaVu Serif, Book" font-size="14.00">192.168.50.2/24</text>
|
||||
<text text-anchor="middle" x="424.31" y="-107.25" font-family="DejaVu Serif, Book" font-size="14.00">192.168.50.1/24</text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
Reference in New Issue
Block a user