ospfd: OSPF Segment Routing topostest update

Update OSPF Segment Routing topotest in conformity to ECMP
 - Add one more interface between r1 and r2 for ECMP
 - Anonymize Adjacency SID
 - Update expected json output

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2020-04-07 20:29:28 +02:00
parent b61264a8a3
commit 008bcff499
14 changed files with 357 additions and 166 deletions

View File

@ -15,9 +15,18 @@
"prefix":"10.0.255.2\/32",
"sid":200,
"inputLabel":20200,
"outputLabel":"pop",
"interface":"r1-eth0",
"nexthop":"10.0.1.2"
"prefixRoute":[
{
"outputLabel":3,
"interface":"r1-eth0",
"nexthop":"10.0.0.2"
},
{
"outputLabel":3,
"interface":"r1-eth1",
"nexthop":"10.0.1.2"
}
]
}
]
},
@ -36,9 +45,18 @@
"prefix":"10.0.255.4\/32",
"sid":400,
"inputLabel":20400,
"outputLabel":"8400",
"interface":"r1-eth0",
"nexthop":"10.0.1.2"
"prefixRoute":[
{
"outputLabel":8400,
"interface":"r1-eth0",
"nexthop":"10.0.0.2"
},
{
"outputLabel":8400,
"interface":"r1-eth1",
"nexthop":"10.0.1.2"
}
]
}
]
},
@ -47,19 +65,24 @@
"srgbSize":10000,
"srgbLabel":10000,
"algorithms":[
{
"0":"SPF"
}
],
"nodeMsd":8,
"extendedPrefix":[
{
"prefix":"10.0.255.3\/32",
"sid":300,
"inputLabel":20300,
"outputLabel":"8300",
"interface":"r1-eth0",
"nexthop":"10.0.1.2"
"prefixRoute":[
{
"outputLabel":8300,
"interface":"r1-eth0",
"nexthop":"10.0.0.2"
},
{
"outputLabel":8300,
"interface":"r1-eth1",
"nexthop":"10.0.1.2"
}
]
}
]
},
@ -78,26 +101,46 @@
"prefix":"10.0.255.1\/32",
"sid":100,
"inputLabel":20100,
"outputLabel":"pop",
"interface":"lo",
"nexthop":"10.0.255.1"
"prefixRoute":[
{
"outputLabel":3,
"interface":"lo",
"nexthop":"10.0.255.1"
}
]
}
],
"extendedLink":[
{
"prefix":"10.0.1.1\/32",
"sid":50001,
"inputLabel":50001,
"outputLabel":"pop",
"prefix":"10.0.0.1\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r1-eth0",
"nexthop":"10.0.0.2"
},
{
"prefix":"10.0.0.1\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r1-eth0",
"nexthop":"10.0.0.2"
},
{
"prefix":"10.0.1.1\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r1-eth1",
"nexthop":"10.0.1.2"
},
{
"prefix":"10.0.1.1\/32",
"sid":50000,
"inputLabel":50000,
"outputLabel":"pop",
"interface":"r1-eth0",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r1-eth1",
"nexthop":"10.0.1.2"
}
]

View File

@ -3,6 +3,11 @@ interface lo
ip ospf area 0.0.0.0
!
interface r1-eth0
ip ospf network point-to-point
ip ospf area 0.0.0.0
!
interface r1-eth1
ip ospf network point-to-point
ip ospf area 0.0.0.0
!
router ospf

View File

@ -3,6 +3,9 @@ interface lo
ip address 10.0.255.1/32
!
interface r1-eth0
ip address 10.0.0.1/24
!
interface r1-eth1
ip address 10.0.1.1/24
!
ip forwarding

View File

@ -7,8 +7,7 @@
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.255.1"
"installed":true
}
]
},
@ -22,6 +21,13 @@
"distance":150,
"installed":true,
"nexthop":"10.0.1.2"
},
{
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.0.2"
}
]
},
@ -35,6 +41,13 @@
"distance":150,
"installed":true,
"nexthop":"10.0.1.2"
},
{
"type":"SR (OSPF)",
"outLabel":8300,
"distance":150,
"installed":true,
"nexthop":"10.0.0.2"
}
]
},
@ -48,11 +61,44 @@
"distance":150,
"installed":true,
"nexthop":"10.0.1.2"
},
{
"type":"SR (OSPF)",
"outLabel":8400,
"distance":150,
"installed":true,
"nexthop":"10.0.0.2"
}
]
},
"50000":{
"inLabel":50000,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.0.2"
}
]
},
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.0.2"
}
]
},
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -64,8 +110,8 @@
}
]
},
"50001":{
"inLabel":50001,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{

View File

@ -15,59 +15,79 @@
"prefix":"10.0.255.2\/32",
"sid":200,
"inputLabel":0,
"outputLabel":"0",
"interface":"lo",
"nexthop":"10.0.255.2"
"prefixRoute":[
{
"outputLabel":0,
"interface":"lo",
"nexthop":"10.0.255.2"
}
]
}
],
"extendedLink":[
{
"prefix":"10.0.4.2\/32",
"sid":50001,
"inputLabel":50001,
"outputLabel":"pop",
"interface":"r2-eth2",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth3",
"nexthop":"10.0.4.1"
},
{
"prefix":"10.0.4.2\/32",
"sid":50000,
"inputLabel":50000,
"outputLabel":"pop",
"interface":"r2-eth2",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth3",
"nexthop":"10.0.4.1"
},
{
"prefix":"10.0.3.2\/32",
"sid":50003,
"inputLabel":50003,
"outputLabel":"pop",
"interface":"r2-eth1",
"nexthop":"10.0.3.1"
"prefix":"10.0.0.2\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth0",
"nexthop":"10.0.0.1"
},
{
"prefix":"10.0.3.2\/32",
"sid":50002,
"inputLabel":50002,
"outputLabel":"pop",
"interface":"r2-eth1",
"nexthop":"10.0.3.1"
"prefix":"10.0.0.2\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth0",
"nexthop":"10.0.0.1"
},
{
"prefix":"10.0.1.2\/32",
"sid":50005,
"inputLabel":50005,
"outputLabel":"pop",
"interface":"r2-eth0",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth1",
"nexthop":"10.0.1.1"
},
{
"prefix":"10.0.1.2\/32",
"sid":50004,
"inputLabel":50004,
"outputLabel":"pop",
"interface":"r2-eth0",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth1",
"nexthop":"10.0.1.1"
},
{
"prefix":"10.0.3.2\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth2",
"nexthop":"10.0.3.1"
},
{
"prefix":"10.0.3.2\/32",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r2-eth2",
"nexthop":"10.0.3.1"
}
]
},
@ -76,19 +96,19 @@
"srgbSize":10000,
"srgbLabel":10000,
"algorithms":[
{
"0":"SPF"
}
],
"nodeMsd":12,
"extendedPrefix":[
{
"prefix":"10.0.255.4\/32",
"sid":400,
"inputLabel":8400,
"outputLabel":"10400",
"interface":"r2-eth2",
"nexthop":"10.0.4.1"
"prefixRoute":[
{
"outputLabel":10400,
"interface":"r2-eth3",
"nexthop":"10.0.4.1"
}
]
}
]
},
@ -97,19 +117,19 @@
"srgbSize":10000,
"srgbLabel":10000,
"algorithms":[
{
"0":"SPF"
}
],
"nodeMsd":8,
"extendedPrefix":[
{
"prefix":"10.0.255.3\/32",
"sid":300,
"inputLabel":8300,
"outputLabel":"pop",
"interface":"r2-eth1",
"nexthop":"10.0.3.1"
"prefixRoute":[
{
"outputLabel":3,
"interface":"r2-eth2",
"nexthop":"10.0.3.1"
}
]
}
]
},
@ -118,19 +138,24 @@
"srgbSize":10000,
"srgbLabel":20000,
"algorithms":[
{
"0":"SPF"
}
],
"nodeMsd":16,
"extendedPrefix":[
{
"prefix":"10.0.255.1\/32",
"sid":100,
"inputLabel":8100,
"outputLabel":"20100",
"interface":"r2-eth0",
"nexthop":"10.0.1.1"
"prefixRoute":[
{
"outputLabel":20100,
"interface":"r2-eth0",
"nexthop":"10.0.0.1"
},
{
"outputLabel":20100,
"interface":"r2-eth1",
"nexthop":"10.0.1.1"
}
]
}
]
}

View File

@ -5,6 +5,7 @@ interface lo
ip ospf area 0.0.0.0
!
interface r2-eth0
ip ospf network point-to-point
ip ospf area 0.0.0.0
!
interface r2-eth1
@ -12,6 +13,9 @@ interface r2-eth1
ip ospf area 0.0.0.0
!
interface r2-eth2
ip ospf area 0.0.0.0
!
interface r2-eth3
ip ospf network point-to-point
ip ospf area 0.0.0.0
!

View File

@ -3,12 +3,15 @@ interface lo
ip address 10.0.255.2/32
!
interface r2-eth0
ip address 10.0.1.2/24
ip address 10.0.0.2/24
!
interface r2-eth1
ip address 10.0.3.2/24
ip address 10.0.1.2/24
!
interface r2-eth2
ip address 10.0.3.2/24
!
interface r2-eth3
ip address 10.0.4.2/24
!
ip forwarding

View File

@ -9,6 +9,13 @@
"distance":150,
"installed":true,
"nexthop":"10.0.1.1"
},
{
"type":"SR (OSPF)",
"outLabel":20100,
"distance":150,
"installed":true,
"nexthop":"10.0.0.1"
}
]
},
@ -38,8 +45,8 @@
}
]
},
"50000":{
"inLabel":50000,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -51,8 +58,8 @@
}
]
},
"50001":{
"inLabel":50001,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -64,8 +71,8 @@
}
]
},
"50002":{
"inLabel":50002,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -73,12 +80,12 @@
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.3.1"
"nexthop":"10.0.0.1"
}
]
},
"50003":{
"inLabel":50003,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -86,12 +93,12 @@
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.3.1"
"nexthop":"10.0.0.1"
}
]
},
"50004":{
"inLabel":50004,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -103,8 +110,8 @@
}
]
},
"50005":{
"inLabel":50005,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -115,5 +122,31 @@
"nexthop":"10.0.1.1"
}
]
},
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.3.1"
}
]
},
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.3.1"
}
]
}
}

View File

@ -15,9 +15,13 @@
"prefix":"10.0.255.2\/32",
"sid":200,
"inputLabel":10200,
"outputLabel":"pop",
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
"prefixRoute":[
{
"outputLabel":3,
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
}
]
}
]
},
@ -36,9 +40,13 @@
"prefix":"10.0.255.4\/32",
"sid":400,
"inputLabel":10400,
"outputLabel":"8400",
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
"prefixRoute":[
{
"outputLabel":8400,
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
}
]
}
]
},
@ -57,25 +65,29 @@
"prefix":"10.0.255.3\/32",
"sid":300,
"inputLabel":0,
"outputLabel":"0",
"interface":"lo",
"nexthop":"10.0.255.3"
"prefixRoute":[
{
"outputLabel":0,
"interface":"lo",
"nexthop":"10.0.255.3"
}
]
}
],
"extendedLink":[
{
"prefix":"10.0.3.1\/32",
"sid":50001,
"inputLabel":50001,
"outputLabel":"pop",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
},
{
"prefix":"10.0.3.1\/32",
"sid":50000,
"inputLabel":50000,
"outputLabel":"pop",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
}
@ -96,9 +108,13 @@
"prefix":"10.0.255.1\/32",
"sid":100,
"inputLabel":10100,
"outputLabel":"8100",
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
"prefixRoute":[
{
"outputLabel":8100,
"interface":"r3-eth0",
"nexthop":"10.0.3.2"
}
]
}
]
}

View File

@ -3,7 +3,6 @@ interface lo
ip ospf area 0.0.0.0
!
interface r3-eth0
ip ospf network point-to-point
ip ospf area 0.0.0.0
!
!

View File

@ -38,8 +38,8 @@
}
]
},
"50000":{
"inLabel":50000,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -51,8 +51,8 @@
}
]
},
"50001":{
"inLabel":50001,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{

View File

@ -6,18 +6,19 @@
"srgbSize":20000,
"srgbLabel":8000,
"algorithms":[
{
"0":"SPF"
}
],
"extendedPrefix":[
{
"prefix":"10.0.255.2\/32",
"sid":200,
"inputLabel":10200,
"outputLabel":"pop",
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
"prefixRoute":[
{
"outputLabel":3,
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
}
]
}
]
},
@ -36,25 +37,29 @@
"prefix":"10.0.255.4\/32",
"sid":400,
"inputLabel":10400,
"outputLabel":"pop",
"interface":"lo",
"nexthop":"10.0.255.4"
"prefixRoute":[
{
"outputLabel":3,
"interface":"lo",
"nexthop":"10.0.255.4"
}
]
}
],
"extendedLink":[
{
"prefix":"10.0.4.1\/32",
"sid":50001,
"inputLabel":50001,
"outputLabel":"pop",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
},
{
"prefix":"10.0.4.1\/32",
"sid":50000,
"inputLabel":50000,
"outputLabel":"pop",
"sid":"XX",
"inputLabel":"XX",
"outputLabel":3,
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
}
@ -65,19 +70,19 @@
"srgbSize":10000,
"srgbLabel":10000,
"algorithms":[
{
"0":"SPF"
}
],
"nodeMsd":8,
"extendedPrefix":[
{
"prefix":"10.0.255.3\/32",
"sid":300,
"inputLabel":10300,
"outputLabel":"8300",
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
"prefixRoute":[
{
"outputLabel":8300,
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
}
]
}
]
},
@ -86,19 +91,19 @@
"srgbSize":10000,
"srgbLabel":20000,
"algorithms":[
{
"0":"SPF"
}
],
"nodeMsd":16,
"extendedPrefix":[
{
"prefix":"10.0.255.1\/32",
"sid":100,
"inputLabel":10100,
"outputLabel":"8100",
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
"prefixRoute":[
{
"outputLabel":8100,
"interface":"r4-eth0",
"nexthop":"10.0.4.2"
}
]
}
]
}

View File

@ -46,13 +46,12 @@
"type":"SR (OSPF)",
"outLabel":3,
"distance":150,
"installed":true,
"nexthop":"10.0.255.4"
"installed":true
}
]
},
"50000":{
"inLabel":50000,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{
@ -64,8 +63,8 @@
}
]
},
"50001":{
"inLabel":50001,
"XX":{
"inLabel":"XX",
"installed":true,
"nexthops":[
{

View File

@ -27,6 +27,7 @@ test_ospf_sr_topo1.py: Test the FRR OSPF routing daemon with Segment Routing.
"""
import os
import re
import sys
from functools import partial
@ -62,20 +63,23 @@ class OspfSrTopo(Topo):
for routern in range(1, 5):
tgen.add_router("r{}".format(routern))
# Interconect router 1 and 2
switch = tgen.add_switch("s1")
switch.add_link(tgen.gears["r1"])
switch.add_link(tgen.gears["r2"])
# Interconect router 1 and 2 with 2 links
switch = tgen.add_switch('s1')
switch.add_link(tgen.gears['r1'])
switch.add_link(tgen.gears['r2'])
switch = tgen.add_switch('s2')
switch.add_link(tgen.gears['r1'])
switch.add_link(tgen.gears['r2'])
# Interconect router 3 and 2
switch = tgen.add_switch("s2")
switch.add_link(tgen.gears["r3"])
switch.add_link(tgen.gears["r2"])
switch = tgen.add_switch('s3')
switch.add_link(tgen.gears['r3'])
switch.add_link(tgen.gears['r2'])
# Interconect router 4 and 2
switch = tgen.add_switch("s3")
switch.add_link(tgen.gears["r4"])
switch.add_link(tgen.gears["r2"])
switch = tgen.add_switch('s4')
switch.add_link(tgen.gears['r4'])
switch.add_link(tgen.gears['r2'])
def setup_module(mod):
@ -130,6 +134,9 @@ def compare_ospf_srdb(rname, expected):
"""
tgen = get_topogen()
current = tgen.gears[rname].vtysh_cmd("show ip ospf database segment-routing json")
# Filter Adjacency SID allocation
current = re.sub(r'"sid":5000[0-9],', '"sid":"XX",', current)
current = re.sub(r'"inputLabel":5000[0-9],', '"inputLabel":"XX",', current)
return topotest.difflines(
current, expected, title1="Current output", title2="Expected output"
)
@ -142,6 +149,9 @@ def compare_mpls_table(rname, expected):
"""
tgen = get_topogen()
current = tgen.gears[rname].vtysh_cmd("show mpls table json")
# Filter Adjacency SID allocation
current = re.sub(r'"5000[0-9]":', '"XX":', current)
current = re.sub(r'"inLabel":5000[0-9],', '"inLabel":"XX",', current)
return topotest.difflines(
current, expected, title1="Current output", title2="Expected output"
)