Merge pull request #16719 from FRRouting/mergify/bp/stable/10.0/pr-16699

nhrpd, test: fix nhrp_redundancy topotest (backport #16698) (backport #16699)
This commit is contained in:
Donatas Abraitis 2024-10-03 09:33:41 +03:00 committed by GitHub
commit 65854714d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
43 changed files with 864 additions and 289 deletions

View File

@ -826,7 +826,7 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN]; char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN];
struct json_object *json = NULL; struct json_object *json = NULL;
if (!ctx->count) { if (!ctx->count && !ctx->json) {
vty_out(vty, "%-8s %-24s %-24s %s\n", "Type", "Prefix", "Via", vty_out(vty, "%-8s %-24s %-24s %s\n", "Type", "Prefix", "Via",
"Identity"); "Identity");
} }

View File

@ -0,0 +1,4 @@
interface host-eth0
ip address 10.4.4.7/24
!
ip route 0.0.0.0/0 10.4.4.4

View File

@ -4,9 +4,9 @@
}, },
"table": [ "table": [
{ {
"interface": "r4-gre0", "interface": "nhc1-gre0",
"type": "nhs", "type": "nhs",
"protocol": "176.16.1.2", "protocol": "172.16.1.2",
"nbma": "192.168.1.2", "nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2", "claimed_nbma": "192.168.1.2",
"used": false, "used": false,
@ -15,9 +15,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r4-gre0", "interface": "nhc1-gre0",
"type": "local", "type": "local",
"protocol": "176.16.1.4", "protocol": "172.16.1.4",
"nbma": "192.168.2.4", "nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4", "claimed_nbma": "192.168.2.4",
"used": false, "used": false,
@ -26,9 +26,9 @@
"identity": "-" "identity": "-"
}, },
{ {
"interface": "r4-gre0", "interface": "nhc1-gre0",
"type": "nhs", "type": "nhs",
"protocol": "176.16.1.3", "protocol": "172.16.1.3",
"nbma": "192.168.1.3", "nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3", "claimed_nbma": "192.168.1.3",
"used": false, "used": false,
@ -37,9 +37,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r4-gre0", "interface": "nhc1-gre0",
"type": "nhs", "type": "nhs",
"protocol": "176.16.1.1", "protocol": "172.16.1.1",
"nbma": "192.168.1.1", "nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1", "claimed_nbma": "192.168.1.1",
"used": false, "used": false,

View File

@ -0,0 +1,40 @@
{
"attr": {
"entriesCount": 3
},
"table": [
{
"interface": "nhc1-gre0",
"type": "nhs",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
},
{
"interface": "nhc1-gre0",
"type": "local",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"timeout": false,
"auth": false,
"identity": "-"
},
{
"interface": "nhc1-gre0",
"type": "nhs",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
}
]
}

View File

@ -1,7 +1,7 @@
{ {
"176.16.1.1\/32": [ "172.16.1.1\/32": [
{ {
"prefix": "176.16.1.1\/32", "prefix": "172.16.1.1\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -16,15 +16,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r5-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.2\/32": [ "172.16.1.2\/32": [
{ {
"prefix": "176.16.1.2\/32", "prefix": "172.16.1.2\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -39,15 +39,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r5-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.3\/32": [ "172.16.1.3\/32": [
{ {
"prefix": "176.16.1.3\/32", "prefix": "172.16.1.3\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -62,7 +62,7 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r5-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]

View File

@ -0,0 +1,49 @@
{
"172.16.1.1\/32": null,
"172.16.1.2\/32": [
{
"prefix": "172.16.1.2\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
"172.16.1.3\/32": [
{
"prefix": "172.16.1.3\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc1-gre0",
"active": true
}
]
}
]
}

View File

@ -1,7 +1,7 @@
{ {
"5.5.5.5\/32": [ "10.5.5.0\/24": [
{ {
"prefix": "5.5.5.5\/32", "prefix": "10.5.5.0\/24",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -15,17 +15,17 @@
"nexthops": [ "nexthops": [
{ {
"fib": true, "fib": true,
"ip": "176.16.1.5", "ip": "172.16.1.5",
"afi": "ipv4", "afi": "ipv4",
"interfaceName": "r4-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.1\/32": [ "172.16.1.1\/32": [
{ {
"prefix": "176.16.1.1\/32", "prefix": "172.16.1.1\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -40,15 +40,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.2\/32": [ "172.16.1.2\/32": [
{ {
"prefix": "176.16.1.2\/32", "prefix": "172.16.1.2\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -63,15 +63,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.3\/32": [ "172.16.1.3\/32": [
{ {
"prefix": "176.16.1.3\/32", "prefix": "172.16.1.3\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -86,15 +86,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.5\/32": [ "172.16.1.5\/32": [
{ {
"prefix": "176.16.1.5\/32", "prefix": "172.16.1.5\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -109,7 +109,7 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc1-gre0",
"active": true "active": true
} }
] ]

View File

@ -0,0 +1,96 @@
{
"10.5.5.0\/24": [
{
"prefix": "10.5.5.0\/24",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"ip": "172.16.1.5",
"afi": "ipv4",
"interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
"172.16.1.1\/32": null,
"172.16.1.2\/32": [
{
"prefix": "172.16.1.2\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
"172.16.1.3\/32": [
{
"prefix": "172.16.1.3\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc1-gre0",
"active": true
}
]
}
],
"172.16.1.5\/32": [
{
"prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc1-gre0",
"active": true
}
]
}
]
}

View File

@ -0,0 +1,5 @@
{
"attr":{
"entriesCount":0
}
}

View File

@ -0,0 +1,9 @@
{
"table":[
{
"type":"dynamic",
"prefix":"10.5.5.0/24",
"via":"172.16.1.5"
}
]
}

View File

@ -1,5 +1,5 @@
!debug nhrp all !debug nhrp all
interface r4-gre0 interface nhc1-gre0
ip nhrp holdtime 10 ip nhrp holdtime 10
ip nhrp network-id 42 ip nhrp network-id 42
ip nhrp registration no-unique ip nhrp registration no-unique
@ -7,5 +7,5 @@ interface r4-gre0
ip nhrp nhs dynamic nbma 192.168.1.2 ip nhrp nhs dynamic nbma 192.168.1.2
ip nhrp nhs dynamic nbma 192.168.1.3 ip nhrp nhs dynamic nbma 192.168.1.3
ip nhrp shortcut ip nhrp shortcut
tunnel source r4-eth0 tunnel source nhc1-eth0
exit exit

View File

@ -0,0 +1,16 @@
ip forwarding
interface nhc1-eth0
ip address 192.168.2.4/24
!
ip route 192.168.1.0/24 192.168.2.6
interface nhc1-gre0
ip address 172.16.1.4/32
no link-detect
ipv6 nd suppress-ra
!
interface nhc1-eth1
ip address 10.4.4.4/24
!
ip route 0.0.0.0/0 172.16.1.1 50
ip route 0.0.0.0/0 172.16.1.2 60
ip route 0.0.0.0/0 172.16.1.3 70

View File

@ -4,9 +4,9 @@
}, },
"table": [ "table": [
{ {
"interface": "r5-gre0", "interface": "nhc2-gre0",
"type": "nhs", "type": "nhs",
"protocol": "176.16.1.2", "protocol": "172.16.1.2",
"nbma": "192.168.1.2", "nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2", "claimed_nbma": "192.168.1.2",
"used": false, "used": false,
@ -15,9 +15,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r5-gre0", "interface": "nhc2-gre0",
"type": "nhs", "type": "nhs",
"protocol": "176.16.1.3", "protocol": "172.16.1.3",
"nbma": "192.168.1.3", "nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3", "claimed_nbma": "192.168.1.3",
"used": false, "used": false,
@ -26,9 +26,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r5-gre0", "interface": "nhc2-gre0",
"type": "nhs", "type": "nhs",
"protocol": "176.16.1.1", "protocol": "172.16.1.1",
"nbma": "192.168.1.1", "nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1", "claimed_nbma": "192.168.1.1",
"used": false, "used": false,
@ -37,9 +37,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r5-gre0", "interface": "nhc2-gre0",
"type": "local", "type": "local",
"protocol": "176.16.1.5", "protocol": "172.16.1.5",
"nbma": "192.168.2.5", "nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5", "claimed_nbma": "192.168.2.5",
"used": false, "used": false,

View File

@ -0,0 +1,40 @@
{
"attr": {
"entriesCount": 3
},
"table": [
{
"interface": "nhc2-gre0",
"type": "nhs",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
},
{
"interface": "nhc2-gre0",
"type": "nhs",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
},
{
"interface": "nhc2-gre0",
"type": "local",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"timeout": false,
"auth": false,
"identity": "-"
}
]
}

View File

@ -1,7 +1,7 @@
{ {
"176.16.1.1\/32": [ "172.16.1.1\/32": [
{ {
"prefix": "176.16.1.1\/32", "prefix": "172.16.1.1\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -16,15 +16,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc2-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.2\/32": [ "172.16.1.2\/32": [
{ {
"prefix": "176.16.1.2\/32", "prefix": "172.16.1.2\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -39,15 +39,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc2-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.3\/32": [ "172.16.1.3\/32": [
{ {
"prefix": "176.16.1.3\/32", "prefix": "172.16.1.3\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -62,7 +62,7 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r4-gre0", "interfaceName": "nhc2-gre0",
"active": true "active": true
} }
] ]

View File

@ -0,0 +1,49 @@
{
"172.16.1.1\/32": null,
"172.16.1.2\/32": [
{
"prefix": "172.16.1.2\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc2-gre0",
"active": true
}
]
}
],
"172.16.1.3\/32": [
{
"prefix": "172.16.1.3\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhc2-gre0",
"active": true
}
]
}
]
}

View File

@ -1,5 +1,5 @@
!debug nhrp all !debug nhrp all
interface r5-gre0 interface nhc2-gre0
ip nhrp holdtime 10 ip nhrp holdtime 10
ip nhrp network-id 42 ip nhrp network-id 42
ip nhrp nhs dynamic nbma 192.168.1.1 ip nhrp nhs dynamic nbma 192.168.1.1
@ -7,5 +7,5 @@ interface r5-gre0
ip nhrp nhs dynamic nbma 192.168.1.3 ip nhrp nhs dynamic nbma 192.168.1.3
ip nhrp registration no-unique ip nhrp registration no-unique
ip nhrp shortcut ip nhrp shortcut
tunnel source r5-eth0 tunnel source nhc2-eth0
exit exit

View File

@ -0,0 +1,16 @@
ip forwarding
interface nhc2-eth0
ip address 192.168.2.5/24
!
ip route 192.168.1.0/24 192.168.2.6
interface nhc2-gre0
ip address 172.16.1.5/32
no link-detect
ipv6 nd suppress-ra
!
interface nhc2-eth1
ip address 10.5.5.5/24
!
ip route 0.0.0.0/0 172.16.1.1 50
ip route 0.0.0.0/0 172.16.1.2 60
ip route 0.0.0.0/0 172.16.1.3 70

View File

@ -4,9 +4,9 @@
}, },
"table": [ "table": [
{ {
"interface": "r1-gre0", "interface": "nhs1-gre0",
"type": "dynamic", "type": "dynamic",
"protocol": "176.16.1.4", "protocol": "172.16.1.4",
"nbma": "192.168.2.4", "nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4", "claimed_nbma": "192.168.2.4",
"used": false, "used": false,
@ -15,9 +15,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r1-gre0", "interface": "nhs1-gre0",
"type": "local", "type": "local",
"protocol": "176.16.1.1", "protocol": "172.16.1.1",
"nbma": "192.168.1.1", "nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1", "claimed_nbma": "192.168.1.1",
"used": false, "used": false,
@ -26,9 +26,9 @@
"identity": "-" "identity": "-"
}, },
{ {
"interface": "r1-gre0", "interface": "nhs1-gre0",
"type": "dynamic", "type": "dynamic",
"protocol": "176.16.1.5", "protocol": "172.16.1.5",
"nbma": "192.168.2.5", "nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5", "claimed_nbma": "192.168.2.5",
"used": false, "used": false,

View File

@ -1,7 +1,7 @@
{ {
"176.16.1.4\/32": [ "172.16.1.4\/32": [
{ {
"prefix": "176.16.1.4\/32", "prefix": "172.16.1.4\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -16,15 +16,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r3-gre0", "interfaceName": "nhs1-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.5\/32": [ "172.16.1.5\/32": [
{ {
"prefix": "176.16.1.5\/32", "prefix": "172.16.1.5\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -39,7 +39,7 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r3-gre0", "interfaceName": "nhs1-gre0",
"active": true "active": true
} }
] ]

View File

@ -1,9 +1,9 @@
!debug nhrp all !debug nhrp all
nhrp nflog-group 1 nhrp nflog-group 1
interface r2-gre0 interface nhs1-gre0
ip nhrp holdtime 10 ip nhrp holdtime 10
ip nhrp network-id 42 ip nhrp network-id 42
ip nhrp registration no-unique ip nhrp registration no-unique
ip nhrp redirect ip nhrp redirect
tunnel source r2-eth0 tunnel source nhs1-eth0
exit exit

View File

@ -0,0 +1,12 @@
ip forwarding
interface nhs1-eth0
ip address 192.168.1.1/24
!
ip route 192.168.2.0/24 192.168.1.6
interface nhs1-gre0
ip address 172.16.1.1/32
no link-detect
ipv6 nd suppress-ra
!
ip route 10.4.4.0/24 172.16.1.4
ip route 10.5.5.0/24 172.16.1.5

View File

@ -4,9 +4,9 @@
}, },
"table": [ "table": [
{ {
"interface": "r2-gre0", "interface": "nhs2-gre0",
"type": "local", "type": "local",
"protocol": "176.16.1.2", "protocol": "172.16.1.2",
"nbma": "192.168.1.2", "nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2", "claimed_nbma": "192.168.1.2",
"used": false, "used": false,
@ -15,9 +15,9 @@
"identity": "-" "identity": "-"
}, },
{ {
"interface": "r2-gre0", "interface": "nhs2-gre0",
"type": "dynamic", "type": "dynamic",
"protocol": "176.16.1.4", "protocol": "172.16.1.4",
"nbma": "192.168.2.4", "nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4", "claimed_nbma": "192.168.2.4",
"used": false, "used": false,
@ -26,9 +26,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r2-gre0", "interface": "nhs2-gre0",
"type": "dynamic", "type": "dynamic",
"protocol": "176.16.1.5", "protocol": "172.16.1.5",
"nbma": "192.168.2.5", "nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5", "claimed_nbma": "192.168.2.5",
"used": false, "used": false,

View File

@ -0,0 +1,40 @@
{
"attr": {
"entriesCount": 3
},
"table": [
{
"interface": "nhs2-gre0",
"type": "local",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"timeout": false,
"auth": false,
"identity": "-"
},
{
"interface": "nhs2-gre0",
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
},
{
"interface": "nhs2-gre0",
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
}
]
}

View File

@ -1,7 +1,7 @@
{ {
"176.16.1.4\/32": [ "172.16.1.4\/32": [
{ {
"prefix": "176.16.1.4\/32", "prefix": "172.16.1.4\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -16,15 +16,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r1-gre0", "interfaceName": "nhs2-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.5\/32": [ "172.16.1.5\/32": [
{ {
"prefix": "176.16.1.5\/32", "prefix": "172.16.1.5\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -39,7 +39,7 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r1-gre0", "interfaceName": "nhs2-gre0",
"active": true "active": true
} }
] ]

View File

@ -0,0 +1,48 @@
{
"172.16.1.4\/32": [
{
"prefix": "172.16.1.4\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhs2-gre0",
"active": true
}
]
}
],
"172.16.1.5\/32": [
{
"prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhs2-gre0",
"active": true
}
]
}
]
}

View File

@ -1,9 +1,9 @@
!debug nhrp all !debug nhrp all
nhrp nflog-group 1 nhrp nflog-group 1
interface r3-gre0 interface nhs2-gre0
ip nhrp holdtime 10 ip nhrp holdtime 10
ip nhrp network-id 42 ip nhrp network-id 42
ip nhrp registration no-unique ip nhrp registration no-unique
ip nhrp redirect ip nhrp redirect
tunnel source r3-eth0 tunnel source nhs2-eth0
exit exit

View File

@ -0,0 +1,12 @@
ip forwarding
interface nhs2-eth0
ip address 192.168.1.2/24
!
ip route 192.168.2.0/24 192.168.1.6
interface nhs2-gre0
ip address 172.16.1.2/32
no link-detect
ipv6 nd suppress-ra
!
ip route 10.4.4.0/24 172.16.1.4
ip route 10.5.5.0/24 172.16.1.5

View File

@ -4,9 +4,9 @@
}, },
"table": [ "table": [
{ {
"interface": "r3-gre0", "interface": "nhs3-gre0",
"type": "dynamic", "type": "dynamic",
"protocol": "176.16.1.4", "protocol": "172.16.1.4",
"nbma": "192.168.2.4", "nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4", "claimed_nbma": "192.168.2.4",
"used": false, "used": false,
@ -15,9 +15,9 @@
"identity": "" "identity": ""
}, },
{ {
"interface": "r3-gre0", "interface": "nhs3-gre0",
"type": "local", "type": "local",
"protocol": "176.16.1.3", "protocol": "172.16.1.3",
"nbma": "192.168.1.3", "nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3", "claimed_nbma": "192.168.1.3",
"used": false, "used": false,
@ -26,9 +26,9 @@
"identity": "-" "identity": "-"
}, },
{ {
"interface": "r3-gre0", "interface": "nhs3-gre0",
"type": "dynamic", "type": "dynamic",
"protocol": "176.16.1.5", "protocol": "172.16.1.5",
"nbma": "192.168.2.5", "nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5", "claimed_nbma": "192.168.2.5",
"used": false, "used": false,

View File

@ -0,0 +1,40 @@
{
"attr": {
"entriesCount": 3
},
"table": [
{
"interface": "nhs3-gre0",
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
},
{
"interface": "nhs3-gre0",
"type": "local",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"timeout": false,
"auth": false,
"identity": "-"
},
{
"interface": "nhs3-gre0",
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"timeout": true,
"auth": false,
"identity": ""
}
]
}

View File

@ -1,7 +1,7 @@
{ {
"176.16.1.4\/32": [ "172.16.1.4\/32": [
{ {
"prefix": "176.16.1.4\/32", "prefix": "172.16.1.4\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -16,15 +16,15 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r2-gre0", "interfaceName": "nhs3-gre0",
"active": true "active": true
} }
] ]
} }
], ],
"176.16.1.5\/32": [ "172.16.1.5\/32": [
{ {
"prefix": "176.16.1.5\/32", "prefix": "172.16.1.5\/32",
"protocol": "nhrp", "protocol": "nhrp",
"vrfId": 0, "vrfId": 0,
"vrfName": "default", "vrfName": "default",
@ -39,7 +39,7 @@
{ {
"fib": true, "fib": true,
"directlyConnected": true, "directlyConnected": true,
"interfaceName": "r2-gre0", "interfaceName": "nhs3-gre0",
"active": true "active": true
} }
] ]

View File

@ -0,0 +1,48 @@
{
"172.16.1.4\/32": [
{
"prefix": "172.16.1.4\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhs3-gre0",
"active": true
}
]
}
],
"172.16.1.5\/32": [
{
"prefix": "172.16.1.5\/32",
"protocol": "nhrp",
"vrfId": 0,
"vrfName": "default",
"selected": true,
"destSelected": true,
"distance": 10,
"metric": 0,
"installed": true,
"internalNextHopNum": 1,
"internalNextHopActiveNum": 1,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "nhs3-gre0",
"active": true
}
]
}
]
}

View File

@ -1,9 +1,9 @@
!debug nhrp all !debug nhrp all
nhrp nflog-group 1 nhrp nflog-group 1
interface r1-gre0 interface nhs3-gre0
ip nhrp holdtime 10 ip nhrp holdtime 10
ip nhrp network-id 42 ip nhrp network-id 42
ip nhrp registration no-unique ip nhrp registration no-unique
ip nhrp redirect ip nhrp redirect
tunnel source r1-eth0 tunnel source nhs3-eth0
exit exit

View File

@ -0,0 +1,12 @@
ip forwarding
interface nhs3-eth0
ip address 192.168.1.3/24
!
ip route 192.168.2.0/24 192.168.1.6
interface nhs3-gre0
ip address 172.16.1.3/32
no link-detect
ipv6 nd suppress-ra
!
ip route 10.4.4.0/24 172.16.1.4
ip route 10.5.5.0/24 172.16.1.5

View File

@ -1,12 +0,0 @@
ip forwarding
interface r1-eth0
ip address 192.168.1.1/24
!
ip route 192.168.2.0/24 192.168.1.6
interface r1-gre0
ip address 176.16.1.1/32
no link-detect
ipv6 nd suppress-ra
!
ip route 4.4.4.0/24 176.16.1.4
ip route 5.5.5.0/24 176.16.1.5

View File

@ -1,12 +0,0 @@
ip forwarding
interface r2-eth0
ip address 192.168.1.2/24
!
ip route 192.168.2.0/24 192.168.1.6
interface r2-gre0
ip address 176.16.1.2/32
no link-detect
ipv6 nd suppress-ra
!
ip route 4.4.4.0/24 176.16.1.4
ip route 5.5.5.0/24 176.16.1.5

View File

@ -1,12 +0,0 @@
ip forwarding
interface r3-eth0
ip address 192.168.1.3/24
!
ip route 192.168.2.0/24 192.168.1.6
interface r3-gre0
ip address 176.16.1.3/32
no link-detect
ipv6 nd suppress-ra
!
ip route 4.4.4.0/24 176.16.1.4
ip route 5.5.5.0/24 176.16.1.5

View File

@ -1,16 +0,0 @@
ip forwarding
interface r4-eth0
ip address 192.168.2.4/24
!
ip route 192.168.1.0/24 192.168.2.6
interface r4-gre0
ip address 176.16.1.4/32
no link-detect
ipv6 nd suppress-ra
!
interface r4-eth1
ip address 4.4.4.4/24
!
ip route 0.0.0.0/0 176.16.1.1 50
ip route 0.0.0.0/0 176.16.1.2 60
ip route 0.0.0.0/0 176.16.1.3 70

View File

@ -1,16 +0,0 @@
ip forwarding
interface r5-eth0
ip address 192.168.2.5/24
!
ip route 192.168.1.0/24 192.168.2.6
interface r5-gre0
ip address 176.16.1.5/32
no link-detect
ipv6 nd suppress-ra
!
interface r5-eth1
ip address 5.5.5.5/24
!
ip route 0.0.0.0/0 176.16.1.1 50
ip route 0.0.0.0/0 176.16.1.2 60
ip route 0.0.0.0/0 176.16.1.3 70

View File

@ -1,4 +0,0 @@
interface r7-eth0
ip address 4.4.4.7/24
!
ip route 0.0.0.0/0 4.4.4.4

View File

@ -1,7 +1,7 @@
ip forwarding ip forwarding
interface r6-eth0 interface router-eth0
ip address 192.168.1.6/24 ip address 192.168.1.6/24
! !
interface r6-eth1 interface router-eth1
ip address 192.168.2.6/24 ip address 192.168.2.6/24
exit exit

View File

@ -16,43 +16,43 @@ graph template {
label="nhrp-topo-redundant-nhs"; label="nhrp-topo-redundant-nhs";
# Routers # Routers
r1 [ nhs1 [
shape=doubleoctagon, shape=doubleoctagon,
label="NHS 1", label="NHS 1",
fillcolor="#f08080", fillcolor="#f08080",
style=filled, style=filled,
]; ];
r2 [ nhs2 [
shape=doubleoctagon shape=doubleoctagon
label="NHS 2", label="NHS 2",
fillcolor="#f08080", fillcolor="#f08080",
style=filled, style=filled,
]; ];
r3 [ nhs3 [
shape=doubleoctagon shape=doubleoctagon
label="NHS 3", label="NHS 3",
fillcolor="#f08080", fillcolor="#f08080",
style=filled, style=filled,
]; ];
r4 [ nhc1 [
shape=doubleoctagon shape=doubleoctagon
label="NHC 1", label="NHC 1",
fillcolor="#f08080", fillcolor="#f08080",
style=filled, style=filled,
]; ];
r5 [ nhc2 [
shape=doubleoctagon shape=doubleoctagon
label="NHC 2", label="NHC 2",
fillcolor="#f08080", fillcolor="#f08080",
style=filled, style=filled,
]; ];
r6 [ router [
shape=doubleoctagon shape=doubleoctagon
label="router", label="router",
fillcolor="#f08080", fillcolor="#f08080",
style=filled, style=filled,
]; ];
r7 [ host [
shape=doubleoctagon shape=doubleoctagon
label="host", label="host",
fillcolor="#f08080", fillcolor="#f08080",
@ -74,30 +74,30 @@ graph template {
]; ];
sw3 [ sw3 [
shape=oval, shape=oval,
label="sw3\n4.4.4.0/24", label="sw3\n10.4.4.0/24",
fillcolor="#d0e0d0", fillcolor="#d0e0d0",
style=filled, style=filled,
]; ];
sw4 [ sw4 [
shape=oval, shape=oval,
label="sw4\n5.5.5.0/24", label="sw4\n10.5.5.0/24",
fillcolor="#d0e0d0", fillcolor="#d0e0d0",
style=filled, style=filled,
]; ];
# Connections # Connections
r1 -- sw1 [label="eth0"]; nhs1 -- sw1 [label="eth0"];
r2 -- sw1 [label="eth0"]; nhs2 -- sw1 [label="eth0"];
r3 -- sw1 [label="eth0"]; nhs3 -- sw1 [label="eth0"];
r6 -- sw1 [label="eth0"]; router -- sw1 [label="eth0"];
r4 -- sw2 [label="eth0"]; nhc1 -- sw2 [label="eth0"];
r5 -- sw2 [label="eth0"]; nhc2 -- sw2 [label="eth0"];
r6 -- sw2 [label="eth1"]; router -- sw2 [label="eth1"];
r4 -- sw3 [label="eth1"]; nhc1 -- sw3 [label="eth1"];
r7 -- sw3 [label="eth0"]; host -- sw3 [label="eth0"];
r5 -- sw4 [label="eth1"]; nhc2 -- sw4 [label="eth1"];
} }

View File

@ -10,7 +10,6 @@
import os import os
import sys import sys
import json import json
from time import sleep
from functools import partial from functools import partial
import pytest import pytest
@ -57,11 +56,11 @@ TOPOLOGY = """
+------------+ | +-------+----+ +------+-----+ | +------------+ | +-------+----+ +------+-----+ |
| | | | | | | | | | | | | | | |
| | +--------+ | | | | | | +--------+ | | | |
| Host |.7 | | NHC 1 | | NHC 2 +-----+5.5.5.0/24 | Host |.7 | | NHC 1 | | NHC 2 +-----+10.5.5.0/24
| +---------+ | | | | | | +---------+ | | | | |
+------------+ | +------------+ +------------+ | +------------+ | +------------+ +------------+ |
| | | |
4.4.4.0/24 10.4.4.0/24
""" """
# Save the Current Working Directory to find configuration files. # Save the Current Working Directory to find configuration files.
@ -77,30 +76,26 @@ def build_topo(tgen):
"Build function" "Build function"
# Create 7 routers # Create 7 routers
for routern in range(1, 8): for rname in ["nhs1", "nhs2", "nhs3", "nhc1", "nhc2", "router", "host"]:
tgen.add_router("r{}".format(routern)) tgen.add_router(rname)
# Interconnect routers 1, 2, 3, 6
switch = tgen.add_switch("s1") switch = tgen.add_switch("s1")
switch.add_link(tgen.gears["r1"]) switch.add_link(tgen.gears["nhs1"])
switch.add_link(tgen.gears["r2"]) switch.add_link(tgen.gears["nhs2"])
switch.add_link(tgen.gears["r3"]) switch.add_link(tgen.gears["nhs3"])
switch.add_link(tgen.gears["r6"]) switch.add_link(tgen.gears["router"])
# Interconnect routers 4, 5, 6
switch = tgen.add_switch("s2") switch = tgen.add_switch("s2")
switch.add_link(tgen.gears["r4"]) switch.add_link(tgen.gears["nhc1"])
switch.add_link(tgen.gears["r5"]) switch.add_link(tgen.gears["nhc2"])
switch.add_link(tgen.gears["r6"]) switch.add_link(tgen.gears["router"])
# Connect router 4, 7
switch = tgen.add_switch("s3") switch = tgen.add_switch("s3")
switch.add_link(tgen.gears["r4"]) switch.add_link(tgen.gears["nhc1"])
switch.add_link(tgen.gears["r7"]) switch.add_link(tgen.gears["host"])
# Connect router 5
switch = tgen.add_switch("s4") switch = tgen.add_switch("s4")
switch.add_link(tgen.gears["r5"]) switch.add_link(tgen.gears["nhc2"])
def _populate_iface(): def _populate_iface():
@ -111,7 +106,7 @@ def _populate_iface():
"echo 0 > /proc/sys/net/ipv4/ip_forward_use_pmtu", "echo 0 > /proc/sys/net/ipv4/ip_forward_use_pmtu",
"echo 1 > /proc/sys/net/ipv6/conf/{0}-eth0/disable_ipv6", "echo 1 > /proc/sys/net/ipv6/conf/{0}-eth0/disable_ipv6",
"echo 1 > /proc/sys/net/ipv6/conf/{0}-gre0/disable_ipv6", "echo 1 > /proc/sys/net/ipv6/conf/{0}-gre0/disable_ipv6",
"iptables -A FORWARD -i {0}-gre0 -o {0}-gre0 -m hashlimit --hashlimit-upto 4/minute --hashlimit-burst 1 --hashlimit-mode srcip,dstip --hashlimit-srcmask 24 --hashlimit-dstmask 24 --hashlimit-name loglimit-0 -j NFLOG --nflog-group 1 --nflog-range 128", "iptables -A FORWARD -i {0}-gre0 -o {0}-gre0 -m hashlimit --hashlimit-upto 4/minute --hashlimit-burst 1 --hashlimit-mode srcip,dstip --hashlimit-srcmask 24 --hashlimit-dstmask 24 --hashlimit-name loglimit-0 -j NFLOG --nflog-group 1 --nflog-size 128",
] ]
cmds_tot = [ cmds_tot = [
@ -123,40 +118,37 @@ def _populate_iface():
] ]
for cmd in cmds_tot_hub: for cmd in cmds_tot_hub:
# Router 1 input = cmd.format("nhs1", "1")
input = cmd.format("r1", "1")
logger.info("input: " + input) logger.info("input: " + input)
output = tgen.net["r1"].cmd(input) output = tgen.net["nhs1"].cmd(input)
logger.info("output: " + output) logger.info("output: " + output)
# Router 2 input = cmd.format("nhs2", "2")
input = cmd.format("r2", "2")
logger.info("input: " + input) logger.info("input: " + input)
output = tgen.net["r2"].cmd(input) output = tgen.net["nhs2"].cmd(input)
logger.info("output: " + output) logger.info("output: " + output)
# Router 3 input = cmd.format("nhs3", "3")
input = cmd.format("r3", "3")
logger.info("input: " + input) logger.info("input: " + input)
output = tgen.net["r3"].cmd(input) output = tgen.net["nhs3"].cmd(input)
logger.info("output: " + output) logger.info("output: " + output)
for cmd in cmds_tot: for cmd in cmds_tot:
input = cmd.format("r4", "4") input = cmd.format("nhc1", "4")
logger.info("input: " + input) logger.info("input: " + input)
output = tgen.net["r4"].cmd(input) output = tgen.net["nhc1"].cmd(input)
logger.info("output: " + output) logger.info("output: " + output)
input = cmd.format("r5", "5") input = cmd.format("nhc2", "5")
logger.info("input: " + input) logger.info("input: " + input)
output = tgen.net["r5"].cmd(input) output = tgen.net["nhc2"].cmd(input)
logger.info("output: " + output) logger.info("output: " + output)
def _verify_iptables(): def _verify_iptables():
tgen = get_topogen() tgen = get_topogen()
# Verify iptables is installed. Required for shortcuts # Verify iptables is installed. Required for shortcuts
rc, _, _ = tgen.net["r1"].cmd_status("iptables") rc, _, _ = tgen.net["nhs1"].cmd_status("iptables")
return False if rc == 127 else True return False if rc == 127 else True
@ -179,7 +171,7 @@ def setup_module(mod):
TopoRouter.RD_ZEBRA, TopoRouter.RD_ZEBRA,
os.path.join(CWD, "{}/zebra.conf".format(rname)), os.path.join(CWD, "{}/zebra.conf".format(rname)),
) )
if rname in ("r1", "r2", "r3", "r4", "r5"): if rname in ("nhs1", "nhs2", "nhs3", "nhc1", "nhc2"):
router.load_config( router.load_config(
TopoRouter.RD_NHRP, os.path.join(CWD, "{}/nhrpd.conf".format(rname)) TopoRouter.RD_NHRP, os.path.join(CWD, "{}/nhrpd.conf".format(rname))
) )
@ -203,17 +195,15 @@ def test_protocols_convergence():
if tgen.routers_have_failure(): if tgen.routers_have_failure():
pytest.skip(tgen.errors) pytest.skip(tgen.errors)
logger.info("Checking NHRP cache and IPv4 routes for convergence") logger.info("Checking NHRP cache for convergence")
router_list = tgen.routers() router_list = tgen.routers()
# Check NHRP cache on servers and clients # Check NHRP cache on servers and clients
for rname, router in router_list.items(): for rname, router in router_list.items():
if "nh" not in rname:
json_file = "{}/{}/nhrp_cache.json".format(CWD, router.name)
if not os.path.isfile(json_file):
logger.info("skipping file {}".format(json_file))
continue continue
json_file = "{}/{}/nhrp_cache.json".format(CWD, router.name)
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial( test_func = partial(
topotest.router_json_cmp, router, "show ip nhrp cache json", expected topotest.router_json_cmp, router, "show ip nhrp cache json", expected
@ -227,13 +217,12 @@ def test_protocols_convergence():
assert result is None, assertmsg assert result is None, assertmsg
# Check NHRP IPV4 routes on servers and clients # Check NHRP IPV4 routes on servers and clients
logger.info("Checking IPv4 routes for convergence")
for rname, router in router_list.items(): for rname, router in router_list.items():
if "nh" not in rname:
json_file = "{}/{}/nhrp_route.json".format(CWD, router.name)
if not os.path.isfile(json_file):
logger.info("skipping file {}".format(json_file))
continue continue
json_file = "{}/{}/nhrp_route.json".format(CWD, router.name)
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial( test_func = partial(
topotest.router_json_cmp, router, "show ip route nhrp json", expected topotest.router_json_cmp, router, "show ip route nhrp json", expected
@ -247,53 +236,53 @@ def test_protocols_convergence():
assert result is None, assertmsg assert result is None, assertmsg
# Test connectivity from 1 NHRP server to all clients # Test connectivity from 1 NHRP server to all clients
pingrouter = tgen.gears["r1"] nhs1 = tgen.gears["nhs1"]
logger.info("Check Ping IPv4 from R1 to R4 = 176.16.1.4)") logger.info("Check Ping IPv4 from nhs1 to nhc1 = 172.16.1.4)")
output = pingrouter.run("ping 176.16.1.4 -f -c 1000") output = nhs1.run("ping 172.16.1.4 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R1 to R4 should be ok" assertmsg = "expected ping IPv4 from nhs1 to nhc1 should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R1 to R4 OK") logger.info("Check Ping IPv4 from nhs1 to nhc1 OK")
logger.info("Check Ping IPv4 from R1 to R5 = 176.16.1.5)") logger.info("Check Ping IPv4 from nhs1 to nhc2 = 172.16.1.5)")
output = pingrouter.run("ping 176.16.1.5 -f -c 1000") output = nhs1.run("ping 172.16.1.5 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R1 to R5 should be ok" assertmsg = "expected ping IPv4 from nhs1 to nhc2 should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R1 to R5 OK") logger.info("Check Ping IPv4 from nhs1 to nhc2 OK")
# Test connectivity from 1 NHRP client to all servers # Test connectivity from 1 NHRP client to all servers
pingrouter = tgen.gears["r4"] nhc1 = tgen.gears["nhc1"]
logger.info("Check Ping IPv4 from R4 to R1 = 176.16.1.1)") logger.info("Check Ping IPv4 from nhc1 to nhs1 = 172.16.1.1)")
output = pingrouter.run("ping 176.16.1.1 -f -c 1000") output = nhc1.run("ping 172.16.1.1 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R4 to R1 should be ok" assertmsg = "expected ping IPv4 from nhc1 to nhs1 should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R4 to R1 OK") logger.info("Check Ping IPv4 from nhc1 to nhs1 OK")
logger.info("Check Ping IPv4 from R4 to R2 = 176.16.1.2)") logger.info("Check Ping IPv4 from nhc1 to nhs2 = 172.16.1.2)")
output = pingrouter.run("ping 176.16.1.2 -f -c 1000") output = nhc1.run("ping 172.16.1.2 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R4 to R2 should be ok" assertmsg = "expected ping IPv4 from nhc1 to nhs2 should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R4 to R2 OK") logger.info("Check Ping IPv4 from nhc1 to nhs2 OK")
logger.info("Check Ping IPv4 from R4 to R3 = 176.16.1.3)") logger.info("Check Ping IPv4 from nhc1 to nhs3 = 172.16.1.3)")
output = pingrouter.run("ping 176.16.1.3 -f -c 1000") output = nhc1.run("ping 172.16.1.3 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R4 to R3 should be ok" assertmsg = "expected ping IPv4 from nhc1 to nhs3 should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R4 to R3 OK") logger.info("Check Ping IPv4 from nhc1 to nhs3 OK")
@retry(retry_timeout=30, initial_wait=5) @retry(retry_timeout=30, initial_wait=5)
@ -302,22 +291,21 @@ def verify_shortcut_path():
Verifying that traffic flows through shortcut path Verifying that traffic flows through shortcut path
""" """
tgen = get_topogen() tgen = get_topogen()
pingrouter = tgen.gears["r7"] host = tgen.gears["host"]
logger.info("Check Ping IPv4 from R7 to R5 = 5.5.5.5") logger.info("Check Ping IPv4 from host to nhc2 = 10.5.5.5")
output = pingrouter.run("ping 5.5.5.5 -f -c 1000") output = host.run("ping 10.5.5.5 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R7 to R5 should be ok" assertmsg = "expected ping IPv4 from host to nhc2 should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R7 to R5 OK") logger.info("Check Ping IPv4 from host to nhc2 OK")
def test_redundancy_shortcut(): def test_redundancy_shortcut():
""" """
Assert that if shortcut created and then NHS goes down, there is no traffic disruption Assert that if shortcut created and then NHS goes down, there is no traffic disruption
Stop traffic and verify next time traffic started, shortcut is initiated by backup NHS
""" """
tgen = get_topogen() tgen = get_topogen()
if tgen.routers_have_failure(): if tgen.routers_have_failure():
@ -328,84 +316,207 @@ def test_redundancy_shortcut():
logger.info("Testing NHRP shortcuts with redundant servers") logger.info("Testing NHRP shortcuts with redundant servers")
# Verify R4 nhrp routes before shortcut creation # Verify nhc1 nhrp routes before shortcut creation
router = tgen.gears["r4"] nhc1 = tgen.gears["nhc1"]
json_file = "{}/{}/nhrp_route.json".format(CWD, router.name) json_file = "{}/{}/nhrp_route.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found" assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial( test_func = partial(
topotest.router_json_cmp, router, "show ip route nhrp json", expected topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
) )
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5) _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = router.vtysh_cmd("show ip route nhrp") output = nhc1.vtysh_cmd("show ip route nhrp")
logger.info(output) logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(router.name) assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg assert result is None, assertmsg
# Initiate shortcut by pinging between clients # Initiate shortcut by pinging between clients
pingrouter = tgen.gears["r7"] host = tgen.gears["host"]
logger.info("Check Ping IPv4 from R7 to R5 via shortcut = 5.5.5.5") logger.info("Check Ping IPv4 from host to nhc2 via shortcut = 10.5.5.5")
output = pingrouter.run("ping 5.5.5.5 -f -c 1000") output = host.run("ping 10.5.5.5 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R7 to R5 via shortcut should be ok" assertmsg = "expected ping IPv4 from host to nhc2 via shortcut should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R7 to R5 via shortcut OK") logger.info("Check Ping IPv4 from host to nhc2 via shortcut OK")
# Now check that NHRP shortcut route installed # Now check that NHRP shortcut route installed
json_file = "{}/{}/nhrp_route_shortcut.json".format(CWD, router.name) json_file = "{}/{}/nhrp_route_shortcut.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found" assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial( test_func = partial(
topotest.router_json_cmp, router, "show ip route nhrp json", expected topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
) )
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5) _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = router.vtysh_cmd("show ip route nhrp") output = nhc1.vtysh_cmd("show ip route nhrp")
logger.info(output) logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(router.name) assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg assert result is None, assertmsg
json_file = "{}/{}/nhrp_shortcut_present.json".format(CWD, nhc1.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = nhc1.vtysh_cmd("show ip nhrp shortcut")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
# check the shortcut disappears because of no traffic
json_file = "{}/{}/nhrp_shortcut_absent.json".format(CWD, nhc1.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = nhc1.vtysh_cmd("show ip nhrp shortcut")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
def test_redundancy_shortcut_backup():
"""
Stop traffic and verify next time traffic started, shortcut is initiated by backup NHS
"""
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
if not _verify_iptables():
pytest.skip("iptables not installed")
nhc1 = tgen.gears["nhc1"]
router_list = tgen.routers()
# Bring down primary GRE interface and verify shortcut is not disturbed # Bring down primary GRE interface and verify shortcut is not disturbed
logger.info("Bringing down R1, primary NHRP server.") logger.info("Bringing down nhs1, primary NHRP server.")
shutdown_bringup_interface(tgen, "r1", "r1-gre0", False) shutdown_bringup_interface(tgen, "nhs1", "nhs1-gre0", False)
# Check NHRP cache on servers and clients
for rname, router in router_list.items():
if "nh" not in rname:
continue
if "nhs1" in rname:
continue
json_file = "{}/{}/nhrp_cache_nhs1_down.json".format(CWD, router.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, router, "show ip nhrp cache json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = router.vtysh_cmd("show ip nhrp cache")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
# Check NHRP IPV4 routes on servers and clients
logger.info("Checking IPv4 routes for convergence")
for rname, router in router_list.items():
if "nh" not in rname:
continue
if "nhs1" in rname:
continue
json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, router.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, router, "show ip route nhrp json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = router.vtysh_cmd("show ip route nhrp")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(router.name)
assert result is None, assertmsg
# Verify shortcut is still active # Verify shortcut is still active
pingrouter = tgen.gears["r7"] host = tgen.gears["host"]
logger.info("Check Ping IPv4 from R7 to R5 via shortcut = 5.5.5.5") logger.info("Check Ping IPv4 from host to nhc2 via shortcut = 10.5.5.5")
output = pingrouter.run("ping 5.5.5.5 -f -c 1000") output = host.run("ping 10.5.5.5 -f -c 1000")
logger.info(output) logger.info(output)
if "1000 packets transmitted, 1000 received" not in output: if "1000 packets transmitted, 1000 received" not in output:
assertmsg = "expected ping IPv4 from R7 to R5 via shortcut should be ok" assertmsg = "expected ping IPv4 from host to nhc2 via shortcut should be ok"
assert 0, assertmsg assert 0, assertmsg
else: else:
logger.info("Check Ping IPv4 from R7 to R5 via shortcut OK") logger.info("Check Ping IPv4 from host to nhc2 via shortcut OK")
# Now verify shortcut is purged with lack of traffic # Verify shortcut is present in routing table
json_file = "{}/{}/nhrp_route.json".format(CWD, router.name) json_file = "{}/{}/nhrp_route_shortcut_nhs1_down.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found" assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read()) expected = json.loads(open(json_file).read())
test_func = partial( test_func = partial(
topotest.router_json_cmp, router, "show ip route nhrp json", expected topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
) )
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5) _, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = router.vtysh_cmd("show ip route nhrp") output = nhc1.vtysh_cmd("show ip route nhrp")
logger.info(output) logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(router.name) json_file = "{}/{}/nhrp_shortcut_present.json".format(CWD, nhc1.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = nhc1.vtysh_cmd("show ip nhrp shortcut")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
# Now verify shortcut is purged with lack of traffic
json_file = "{}/{}/nhrp_route_nhs1_down.json".format(CWD, nhc1.name)
assertmsg = "No nhrp_route file found"
assert os.path.isfile(json_file), assertmsg
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, nhc1, "show ip route nhrp json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = nhc1.vtysh_cmd("show ip route nhrp")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg
json_file = "{}/{}/nhrp_shortcut_absent.json".format(CWD, nhc1.name)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, nhc1, "show ip nhrp shortcut json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=40, wait=0.5)
output = nhc1.vtysh_cmd("show ip nhrp shortcut")
logger.info(output)
assertmsg = '"{}" JSON output mismatches'.format(nhc1.name)
assert result is None, assertmsg assert result is None, assertmsg