|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""RIP Basic |
| 3 | +
|
| 4 | +Verifies basic RIP functionality by configuring two routers (R1 and R2) |
| 5 | +with RIP on their interconnecting link. The test ensures RIP routes are |
| 6 | +exchanged between the routers and end-to-end connectivity is achieved. |
| 7 | +
|
| 8 | +The test PC uses data1 interface to connect to R1's data port, and data2 |
| 9 | +interface to connect to R2's data port (which does not have RIP enabled). |
| 10 | +This verifies that RIP status information remains accessible when a router |
| 11 | +has non-RIP interfaces. |
| 12 | +
|
| 13 | +""" |
| 14 | + |
| 15 | +import infamy |
| 16 | +import infamy.route as route |
| 17 | +from infamy.util import until, parallel |
| 18 | + |
| 19 | + |
| 20 | +def config_target1(target, data, link): |
| 21 | + target.put_config_dicts({ |
| 22 | + "ietf-interfaces": { |
| 23 | + "interfaces": { |
| 24 | + "interface": [{ |
| 25 | + "name": data, |
| 26 | + "enabled": True, |
| 27 | + "ipv4": { |
| 28 | + "forwarding": True, |
| 29 | + "address": [{ |
| 30 | + "ip": "192.168.10.1", |
| 31 | + "prefix-length": 24 |
| 32 | + }]} |
| 33 | + }, { |
| 34 | + "name": link, |
| 35 | + "enabled": True, |
| 36 | + "ipv4": { |
| 37 | + "forwarding": True, |
| 38 | + "address": [{ |
| 39 | + "ip": "192.168.50.1", |
| 40 | + "prefix-length": 24 |
| 41 | + }] |
| 42 | + } |
| 43 | + }, { |
| 44 | + "name": "lo", |
| 45 | + "enabled": True, |
| 46 | + "ipv4": { |
| 47 | + "address": [{ |
| 48 | + "ip": "192.168.100.1", |
| 49 | + "prefix-length": 32 |
| 50 | + }] |
| 51 | + } |
| 52 | + }] |
| 53 | + } |
| 54 | + }, |
| 55 | + "ietf-system": { |
| 56 | + "system": { |
| 57 | + "hostname": "R1" |
| 58 | + } |
| 59 | + }, |
| 60 | + "ietf-routing": { |
| 61 | + "routing": { |
| 62 | + "control-plane-protocols": { |
| 63 | + "control-plane-protocol": [{ |
| 64 | + "type": "infix-routing:static", |
| 65 | + "name": "default", |
| 66 | + "static-routes": { |
| 67 | + "ipv4": { |
| 68 | + "route": [{ |
| 69 | + "destination-prefix": "192.168.33.1/32", |
| 70 | + "next-hop": { |
| 71 | + "special-next-hop": "blackhole" |
| 72 | + } |
| 73 | + }] |
| 74 | + } |
| 75 | + } |
| 76 | + }, { |
| 77 | + "type": "infix-routing:ripv2", |
| 78 | + "name": "default", |
| 79 | + "rip": { |
| 80 | + "timers": { |
| 81 | + "update-interval": 5, |
| 82 | + "invalid-interval": 15, |
| 83 | + "flush-interval": 20 |
| 84 | + }, |
| 85 | + "redistribute": { |
| 86 | + "redistribute": [{ |
| 87 | + "protocol": "static" |
| 88 | + }, { |
| 89 | + "protocol": "connected" |
| 90 | + }] |
| 91 | + }, |
| 92 | + "interfaces": { |
| 93 | + "interface": [{ |
| 94 | + "interface": link |
| 95 | + }] |
| 96 | + } |
| 97 | + } |
| 98 | + }] |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + }) |
| 103 | + |
| 104 | + |
| 105 | +def config_target2(target, link, data): |
| 106 | + target.put_config_dicts({ |
| 107 | + "ietf-interfaces": { |
| 108 | + "interfaces": { |
| 109 | + "interface": [{ |
| 110 | + "name": link, |
| 111 | + "enabled": True, |
| 112 | + "ipv4": { |
| 113 | + "forwarding": True, |
| 114 | + "address": [{ |
| 115 | + "ip": "192.168.50.2", |
| 116 | + "prefix-length": 24 |
| 117 | + }] |
| 118 | + } |
| 119 | + }, { |
| 120 | + "name": data, |
| 121 | + "enabled": True, |
| 122 | + "ipv4": { |
| 123 | + "forwarding": True, |
| 124 | + "address": [{ |
| 125 | + "ip": "192.168.60.1", |
| 126 | + "prefix-length": 24 |
| 127 | + }] |
| 128 | + } |
| 129 | + }, { |
| 130 | + "name": "lo", |
| 131 | + "enabled": True, |
| 132 | + "forwarding": True, |
| 133 | + "ipv4": { |
| 134 | + "address": [{ |
| 135 | + "ip": "192.168.200.1", |
| 136 | + "prefix-length": 32 |
| 137 | + }] |
| 138 | + } |
| 139 | + }] |
| 140 | + } |
| 141 | + }, |
| 142 | + "ietf-system": { |
| 143 | + "system": { |
| 144 | + "hostname": "R2" |
| 145 | + } |
| 146 | + }, |
| 147 | + "ietf-routing": { |
| 148 | + "routing": { |
| 149 | + "control-plane-protocols": { |
| 150 | + "control-plane-protocol": [{ |
| 151 | + "type": "infix-routing:ripv2", |
| 152 | + "name": "default", |
| 153 | + "rip": { |
| 154 | + "timers": { |
| 155 | + "update-interval": 5, |
| 156 | + "invalid-interval": 15, |
| 157 | + "flush-interval": 20 |
| 158 | + }, |
| 159 | + "redistribute": { |
| 160 | + "redistribute": [{ |
| 161 | + "protocol": "connected" |
| 162 | + }] |
| 163 | + }, |
| 164 | + "interfaces": { |
| 165 | + "interface": [{ |
| 166 | + "interface": link |
| 167 | + }] |
| 168 | + } |
| 169 | + } |
| 170 | + }] |
| 171 | + } |
| 172 | + } |
| 173 | + } |
| 174 | + }) |
| 175 | + |
| 176 | + |
| 177 | +with infamy.Test() as test: |
| 178 | + with test.step("Set up topology and attach to target DUTs"): |
| 179 | + env = infamy.Env() |
| 180 | + R1 = env.attach("R1", "mgmt") |
| 181 | + R2 = env.attach("R2", "mgmt") |
| 182 | + |
| 183 | + with test.step("Configure targets"): |
| 184 | + _, R1data = env.ltop.xlate("R1", "data") |
| 185 | + _, R2link = env.ltop.xlate("R2", "link") |
| 186 | + _, R1link = env.ltop.xlate("R1", "link") |
| 187 | + _, R2data = env.ltop.xlate("R2", "data") |
| 188 | + |
| 189 | + parallel(config_target1(R1, R1data, R1link), |
| 190 | + config_target2(R2, R2link, R2data)) |
| 191 | + |
| 192 | + with test.step("Wait for RIP routes to be exchanged"): |
| 193 | + print("Waiting for RIP routes to propagate...") |
| 194 | + # R1 should learn R2's loopback |
| 195 | + until(lambda: route.ipv4_route_exist(R1, "192.168.200.1/32", proto="ietf-rip:rip"), attempts=40) |
| 196 | + # R2 should learn R1's loopback |
| 197 | + until(lambda: route.ipv4_route_exist(R2, "192.168.100.1/32", proto="ietf-rip:rip"), attempts=40) |
| 198 | + # R2 should learn R1's static route (redistributed) |
| 199 | + until(lambda: route.ipv4_route_exist(R2, "192.168.33.1/32", proto="ietf-rip:rip"), attempts=40) |
| 200 | + |
| 201 | + with test.step("Test connectivity from PC:data1 to R2 loopback via RIP"): |
| 202 | + _, hport0 = env.ltop.xlate("PC", "data1") |
| 203 | + with infamy.IsolatedMacVlan(hport0) as ns0: |
| 204 | + ns0.addip("192.168.10.2") |
| 205 | + ns0.addroute("192.168.200.1/32", "192.168.10.1") |
| 206 | + ns0.must_reach("192.168.200.1") |
| 207 | + |
| 208 | + with test.step("Test connectivity from PC:data2 to R1 loopback via RIP"): |
| 209 | + _, hport1 = env.ltop.xlate("PC", "data2") |
| 210 | + with infamy.IsolatedMacVlan(hport1) as ns1: |
| 211 | + ns1.addip("192.168.60.2") |
| 212 | + ns1.addroute("192.168.100.1/32", "192.168.60.1") |
| 213 | + ns1.must_reach("192.168.100.1") |
| 214 | + |
| 215 | + test.succeed() |
0 commit comments