]> git.proxmox.com Git - mirror_frr.git/blame - tests/topotests/bgp_tcp_mss/test_bgp_vrf_tcp_mss.py
*: auto-convert to SPDX License IDs
[mirror_frr.git] / tests / topotests / bgp_tcp_mss / test_bgp_vrf_tcp_mss.py
CommitLineData
6a28d135 1#!/usr/bin/env python
acddc0ed 2# SPDX-License-Identifier: ISC
6a28d135
A
3
4#
5# bgp_tcp_mss.py
6# Part of NetDEF Topology Tests
7#
8# Copyright (c) 2021 by
9# Shreenidhi A R <rshreenidhi@vmware.com>
10#
6a28d135
A
11
12"""
13bgp_tcp_mss_vrf.py:
14
15Need to verify if the tcp-mss value is reflected in the TCP session and in VRF.
16"""
17
18import os
19import sys
20import json
21import pytest
22import functools
23import platform
24import socket
25import subprocess
26
27# add after imports, before defining classes or functions:
28pytestmark = [pytest.mark.bgpd]
29
30CWD = os.path.dirname(os.path.realpath(__file__))
31sys.path.append(os.path.join(CWD, "../"))
32
33# pylint: disable=C0413
34from lib import topotest
35from lib.topogen import Topogen, TopoRouter, get_topogen
36from lib.topojson import build_config_from_json
37from lib.topolog import logger
38import time
39from lib.bgp import (
40 clear_bgp,
41 clear_bgp_and_verify,
42 create_router_bgp,
43 modify_as_number,
44 verify_as_numbers,
45 verify_bgp_convergence,
46 verify_bgp_rib,
47 verify_bgp_timers_and_functionality,
48 verify_router_id,
49 verify_tcp_mss
50)
51from lib.common_config import (
52 kill_router_daemons,
53 start_router_daemons,
54 addKernelRoute,
55 apply_raw_config,
56 check_address_types,
57 create_prefix_lists,
58 create_route_maps,
59 create_static_routes,
60 required_linux_kernel_version,
61 reset_config_on_routers,
62 start_topology,
63 step,
64 verify_admin_distance_for_static_routes,
65 verify_bgp_community,
66 verify_fib_routes,
67 verify_rib,
68 write_test_footer,
69 write_test_header
70)
71
72pytestmark = [pytest.mark.bgpd]
73# Global variables
74NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
75NETWORK1_2 = {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
76NETWORK2_1 = {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
77NETWORK2_2 = {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
78NETWORK3_1 = {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
79NETWORK3_2 = {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
80NETWORK4_1 = {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
81NETWORK4_2 = {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
82NETWORK5_1 = {"ipv4": "5.1.1.1/32", "ipv6": "5::1/128"}
83NETWORK5_2 = {"ipv4": "5.1.1.2/32", "ipv6": "5::2/128"}
84
85NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
86
87## File name
88TCPDUMP_FILE="test_tcp_packet_test.txt"
89
90def setup_module(mod):
91 """
92 Sets up the pytest environment
93
94 * `mod`: module name
95 """
96 global topo,TCPDUMP_FILE
97
98 # Required linux kernel version for this suite to run.
99 result = required_linux_kernel_version("4.15")
100 if result is not True:
101 pytest.skip("Kernel requirements are not met")
102
103 testsuite_run_time = time.asctime(time.localtime(time.time()))
104 step("Testsuite start time: {}".format(testsuite_run_time))
105 step("=" * 40)
106
107 step("Running setup_module to create topology")
108
109 # This function initiates the topology build with Topogen...
110 json_file = "{}/bgp_vrf_tcp_mss.json".format(CWD)
111 tgen = Topogen(json_file, mod.__name__)
112 global topo
113 topo = tgen.json_topo
114 # ... and here it calls Mininet initialization functions.
115 # Starting topology, create tmp files which are loaded to routers
d60a3f0e 116 # to start daemons and then start routers
6a28d135
A
117 start_topology(tgen)
118 # Creating configuration from JSON
119 build_config_from_json(tgen, topo)
120
121 global ADDR_TYPES
122 global BGP_CONVERGENCE
123 ADDR_TYPES = check_address_types()
124 BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
125 assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
126 BGP_CONVERGENCE
127 )
128
129 step("Running setup_module() done")
130
131def teardown_module():
132 """Teardown the pytest environment"""
133
134 step("Running teardown_module to delete topology")
135
136 tgen = get_topogen()
137
138 # Stop toplogy and Remove tmp files
139 tgen.stop_topology()
140
141 step(
142 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
143 )
144 step("=" * 40)
145
146
147#####################################################
148#
149# Testcases
150#
151#####################################################
152
153def test_bgp_vrf_tcp_mss(request):
154 tgen = get_topogen()
155 tc_name = request.node.name
156 if tgen.routers_have_failure():
157 pytest.skip(tgen.errors)
158
159 step("Verify the router failures")
160 if tgen.routers_have_failure():
161 check_router_status(tgen)
162
163 step("Configuring 5 static Routes in Router R3 with NULL0 as Next hop")
164 for addr_type in ADDR_TYPES:
165 static_routes_input = {
166 "r3": {
167 "static_routes": [
168 {
169 "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
170 "next_hop": NEXT_HOP_IP[addr_type],
171 },
172 {
173 "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
174 "next_hop": NEXT_HOP_IP[addr_type],
175 },
176 {
177 "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
178 "next_hop": NEXT_HOP_IP[addr_type],
179 },
180 {
181 "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
182 "next_hop": NEXT_HOP_IP[addr_type],
183 },
184 {
185 "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
186 "next_hop": NEXT_HOP_IP[addr_type],
187 },
188 ]
189 }
190 }
191 result = create_static_routes(tgen, static_routes_input)
192 assert result is True, "Testcase {} : Failed \n Error: {}".format(
193 tc_name, result
194 )
195
196 step("Verify the static Routes in R3 on default VRF")
197 for addr_type in ADDR_TYPES:
198 static_routes_input = {
199 "r3": {
200 "static_routes": [
201 {
202 "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
203 "next_hop": NEXT_HOP_IP[addr_type],
204 },
205 {
206 "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
207 "next_hop": NEXT_HOP_IP[addr_type],
208 },
209 {
210 "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
211 "next_hop": NEXT_HOP_IP[addr_type],
212 },
213 {
214 "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
215 "next_hop": NEXT_HOP_IP[addr_type],
216 },
217 {
218 "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
219 "next_hop": NEXT_HOP_IP[addr_type],
220 },
221 ]
222 }
223 }
224 dut = "r3"
225 result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
226 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
227
228 step("Verify the static Routes in R2 on default VRF")
229 for addr_type in ADDR_TYPES:
230 static_routes_input = {
231 "r3": {
232 "static_routes": [
233 {
234 "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
235 "next_hop": NEXT_HOP_IP[addr_type],
236 },
237 {
238 "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
239 "next_hop": NEXT_HOP_IP[addr_type],
240 },
241 {
242 "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
243 "next_hop": NEXT_HOP_IP[addr_type],
244 },
245 {
246 "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
247 "next_hop": NEXT_HOP_IP[addr_type],
248 },
249 {
250 "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
251 "next_hop": NEXT_HOP_IP[addr_type],
252 },
253 ]
254 }
255 }
256 dut = "r2"
257 result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
258 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
259
260 step("importing default vrf on R2 under VRF RED Address Family")
261 for addr_type in ADDR_TYPES:
262 input_import_vrf = {
263 "r2": {
264 "bgp": [
265 {
266 "local_as": 200,
267 "vrf": "RED",
268 "address_family": {
269 addr_type: {"unicast": {"import": {"vrf": "default"}}}
270 },
271 }
272 ]
273 }
274 }
275 result = create_router_bgp(tgen, topo, input_import_vrf)
276 assert result is True, "Testcase {} : Failed \n Error: {}".format(
277 tc_name, result
278 )
279
280 step("Verify the static Routes in R2 on RED VRF")
281 for addr_type in ADDR_TYPES:
282 static_routes_input = {
283 "r3": {
284 "static_routes": [
285 {
286 "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
287 "next_hop": NEXT_HOP_IP[addr_type],
288 "vrf": "RED",
289 },
290 {
291 "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
292 "next_hop": NEXT_HOP_IP[addr_type],
293 "vrf": "RED",
294 },
295 {
296 "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
297 "next_hop": NEXT_HOP_IP[addr_type],
298 "vrf": "RED",
299 },
300 {
301 "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
302 "next_hop": NEXT_HOP_IP[addr_type],
303 "vrf": "RED",
304 },
305 {
306 "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
307 "next_hop": NEXT_HOP_IP[addr_type],
308 "vrf": "RED",
309 },
310 ]
311 }
312 }
313 dut = "r2"
314 result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
315 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
316
317 step("Verify the static Routes in R1 on RED VRF")
318 for addr_type in ADDR_TYPES:
319 static_routes_input = {
320 "r3": {
321 "static_routes": [
322 {
323 "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
324 "next_hop": NEXT_HOP_IP[addr_type],
325 "vrf": "RED",
326 },
327 {
328 "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
329 "next_hop": NEXT_HOP_IP[addr_type],
330 "vrf": "RED",
331 },
332 {
333 "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
334 "next_hop": NEXT_HOP_IP[addr_type],
335 "vrf": "RED",
336 },
337 {
338 "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
339 "next_hop": NEXT_HOP_IP[addr_type],
340 "vrf": "RED",
341 },
342 {
343 "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
344 "next_hop": NEXT_HOP_IP[addr_type],
345 "vrf": "RED",
346 },
347 ]
348 }
349 }
350 dut = "r1"
351 result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
352 assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
353
354 step("Enabling tcp-mss 150 on Router R1 in VRF RED")
355 TCP_MSS = 150
356 raw_config = {
357 "r1": {
358 "raw_config": [
359 "router bgp {} vrf {}".format(
360 topo["routers"]["r1"]["bgp"][0]["local_as"],
361 topo["routers"]["r1"]["bgp"][0]["vrf"],
362 ),
363 "neighbor {} tcp-mss {}".format(
364 topo["routers"]["r2"]["links"]["r1-link1"]["ipv4"].split("/")[0],
365 TCP_MSS,
366 ),
367 "neighbor {} tcp-mss {}".format(
368 topo["routers"]["r2"]["links"]["r1-link1"]["ipv6"].split("/")[0],
369 TCP_MSS,
370 ),
371 ]
372 },
373 }
374
375 result = apply_raw_config(tgen, raw_config)
376 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
377
378 step("Clearing BGP on R1 and R2 ")
379 for addr_type in ADDR_TYPES:
380 clear_bgp(tgen, addr_type, "r1", vrf=topo["routers"]["r1"]["bgp"][0]["vrf"])
381 clear_bgp(tgen, addr_type, "r2", vrf=topo["routers"]["r2"]["bgp"][1]["vrf"])
382
383 step("Verify the BGP Convergence at R1 & R2 after Clear BGP")
384 r1_convergence = verify_bgp_convergence(tgen, topo, dut="r1")
385 assert (
386 r1_convergence is True
387 ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r1_convergence)
388 r2_convergence = verify_bgp_convergence(tgen, topo, dut="r2")
389 assert (
390 r2_convergence is True
391 ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r2_convergence)
392
393 step("Verify the TCP-MSS value on both Router R1 and R2")
394 for addr_type in ADDR_TYPES:
395 dut = "r1"
396 tcp_mss_result = verify_tcp_mss(
397 tgen,
398 dut,
399 topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0],
400 TCP_MSS,
401 "RED",
402 )
403 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
404 tcp_mss_result
405 )
406
407
408
409
410 step("Enabling tcp-mss 500 between R2 and R3 of VRF Default")
411 TCP_MSS = 500
412 raw_config = {
413 "r2": {
414 "raw_config": [
415 "router bgp {} ".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
416 "neighbor {} tcp-mss {}".format(
417 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
418 TCP_MSS,
419 ),
420 "neighbor {} tcp-mss {}".format(
421 topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
422 TCP_MSS,
423 ),
424 ]
425 },
426 "r3": {
427 "raw_config": [
428 "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
429 "neighbor {} tcp-mss {}".format(
430 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
431 TCP_MSS,
432 ),
433 "neighbor {} tcp-mss {}".format(
434 topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
435 TCP_MSS,
436 ),
437 ]
438 },
439 }
440 result = apply_raw_config(tgen, raw_config)
441 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
442
443
444
445 step("Clear BGP at router R2 and R3")
446 for addr_type in ADDR_TYPES:
447 clear_bgp(tgen, topo, "r2", addr_type)
448 clear_bgp(tgen, topo, "r3", addr_type)
449
450 step("Verify the BGP Convergence at R2 & R3 after Clear BGP")
451 r1_convergence = verify_bgp_convergence(tgen, topo, dut="r2")
452 assert (
453 r1_convergence is True
454 ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r2_convergence)
455 r2_convergence = verify_bgp_convergence(tgen, topo, dut="r3")
456 assert (
457 r2_convergence is True
458 ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r2_convergence)
459
460 step("Verify the TCP-MSS value on both Router R2 and R3")
461 for addr_type in ADDR_TYPES:
462 dut = "r2"
463 tcp_mss_result = verify_tcp_mss(
464 tgen,
465 dut,
466 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
467 TCP_MSS,
468 )
469 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
470 tcp_mss_result
471 )
472
473 dut = "r3"
474 tcp_mss_result = verify_tcp_mss(
475 tgen,
476 dut,
477 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
478 TCP_MSS,
479 )
480 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
481 tcp_mss_result
482 )
483
484 step("Removing tcp-mss 150 between R1 and R2 of VRF RED ")
485 TCP_MSS = 150
486 raw_config = {
487 "r1": {
488 "raw_config": [
489 "router bgp {} vrf {}".format(
490 topo["routers"]["r1"]["bgp"][0]["local_as"],
491 topo["routers"]["r1"]["bgp"][0]["vrf"],
492 ),
493 "no neighbor {} tcp-mss {}".format(
494 topo["routers"]["r2"]["links"]["r1-link1"]["ipv4"].split("/")[0],
495 TCP_MSS,
496 ),
497 "no neighbor {} tcp-mss {}".format(
498 topo["routers"]["r2"]["links"]["r1-link1"]["ipv6"].split("/")[0],
499 TCP_MSS,
500 ),
501 ]
502 }
503 }
504 result = apply_raw_config(tgen, raw_config)
505 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
506 raw_config = {
507 "r2": {
508 "raw_config": [
509 "router bgp {} vrf {}".format(
510 topo["routers"]["r2"]["bgp"][0]["local_as"],
511 topo["routers"]["r2"]["bgp"][1]["vrf"],
512 ),
513 "no neighbor {} tcp-mss {}".format(
514 topo["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0],
515 TCP_MSS,
516 ),
517 "no neighbor {} tcp-mss {}".format(
518 topo["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split("/")[0],
519 TCP_MSS,
520 ),
521 ]
522 }
523 }
524 result = apply_raw_config(tgen, raw_config)
525 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
526
527 step("Verify the TCP-MSS value cleared on both Router R1 and R2")
528 for addr_type in ADDR_TYPES:
529 dut = "r1"
530 tcp_mss_result = verify_tcp_mss(
531 tgen,
532 dut,
533 topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0],
534 TCP_MSS,
535 "RED",
536 )
537 assert (
538 tcp_mss_result is not True
539 ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
540
541 dut = "r2"
542 tcp_mss_result = verify_tcp_mss(
543 tgen,
544 dut,
545 topo["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0],
546 TCP_MSS,
547 "RED",
548 )
549 assert (
550 tcp_mss_result is not True
551 ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
552
553
554 step("Removing tcp-mss 500 between R2 and R3 of VRF Default ")
555 TCP_MSS = 500
556 raw_config = {
557 "r2": {
558 "raw_config": [
559 "router bgp {} ".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
560 "no neighbor {} tcp-mss {}".format(
561 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
562 TCP_MSS,
563 ),
564 "no neighbor {} tcp-mss {}".format(
565 topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
566 TCP_MSS,
567 ),
568 ]
569 }
570 }
571 result = apply_raw_config(tgen, raw_config)
572 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
573
574 raw_config = {
575 "r3": {
576 "raw_config": [
577 "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
578 "no neighbor {} tcp-mss {}".format(
579 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
580 TCP_MSS,
581 ),
582 "no neighbor {} tcp-mss {}".format(
583 topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
584 TCP_MSS,
585 ),
586 ]
587 }
588 }
589 result = apply_raw_config(tgen, raw_config)
590 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
591
592 step("Verify the TCP-MSS value got cleared on both Router R2 and R3")
593 for addr_type in ADDR_TYPES:
594 dut = "r2"
595 tcp_mss_result = verify_tcp_mss(
596 tgen,
597 dut,
598 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
599 TCP_MSS,
600 )
601 assert (
602 tcp_mss_result is not True
603 ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
604
605 dut = "r3"
606 tcp_mss_result = verify_tcp_mss(
607 tgen,
608 dut,
609 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
610 TCP_MSS,
611 )
612 assert (
613 tcp_mss_result is not True
614 ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
615
616 step("Configuring different TCP-MSS R2 and R3 ")
617 TCP_MSS = 500
618 raw_config = {
619 "r2": {
620 "raw_config": [
621 "router bgp {}".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
622 "neighbor {} tcp-mss {}".format(
623 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
624 TCP_MSS,
625 ),
626 "neighbor {} tcp-mss {}".format(
627 topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
628 TCP_MSS,
629 ),
630 ]
631 }
632 }
633 result = apply_raw_config(tgen, raw_config)
634 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
635 TCP_MSS = 300
636 raw_config = {
637 "r3": {
638 "raw_config": [
639 "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
640 "neighbor {} tcp-mss {}".format(
641 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
642 TCP_MSS,
643 ),
644 "neighbor {} tcp-mss {}".format(
645 topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
646 TCP_MSS,
647 ),
648 ]
649 }
650 }
651 result = apply_raw_config(tgen, raw_config)
652 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
653
654 step("Verify the TCP-MSS value on both Router R2 and R3")
655 for addr_type in ADDR_TYPES:
656 TCP_MSS = 500
657 dut = "r2"
658 tcp_mss_result = verify_tcp_mss(
659 tgen,
660 dut,
661 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
662 TCP_MSS,
663 )
664 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
665 tcp_mss_result
666 )
667
668 TCP_MSS = 300
669 dut = "r3"
670 tcp_mss_result = verify_tcp_mss(
671 tgen,
672 dut,
673 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
674 TCP_MSS,
675 )
676 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
677 tcp_mss_result
678 )
679
680 step("Configure TCP_MSS > MTU on R2 and R3 and it should be 1460 ")
681 TCP_MSS = 4096
682 REF_TCP_MSS = 1460
683 raw_config = {
684 "r2": {
685 "raw_config": [
686 "router bgp {} ".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
687 "neighbor {} tcp-mss {}".format(
688 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
689 TCP_MSS,
690 ),
691 "neighbor {} tcp-mss {}".format(
692 topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
693 TCP_MSS,
694 ),
695 ]
696 }
697 }
698 result = apply_raw_config(tgen, raw_config)
699 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
700 raw_config = {
701 "r3": {
702 "raw_config": [
703 "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
704 "neighbor {} tcp-mss {}".format(
705 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
706 TCP_MSS,
707 ),
708 "neighbor {} tcp-mss {}".format(
709 topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
710 TCP_MSS,
711 ),
712 ]
713 }
714 }
715 result = apply_raw_config(tgen, raw_config)
716 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
717
718 step("Restarting BGP Daemon on R3")
719
720 kill_router_daemons(tgen, "r3", ["bgpd"])
721 start_router_daemons(tgen, "r3", ["bgpd"])
722
723 step(
724 "Verify the configured TCP-MSS 4096 value on restarting both Daemon both Router R2 and R3 "
725 )
726 for addr_type in ADDR_TYPES:
727 TCP_MSS = 4096
728 dut = "r2"
729 tcp_mss_result = verify_tcp_mss(
730 tgen,
731 dut,
732 topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
733 TCP_MSS,
734 )
735 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
736 tcp_mss_result
737 )
738 dut = "r3"
739 tcp_mss_result = verify_tcp_mss(
740 tgen,
741 dut,
742 topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
743 TCP_MSS,
744 )
745 assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
746 tcp_mss_result
747 )
748 write_test_footer(tc_name)
749
750
751if __name__ == "__main__":
752 args = ["-s"] + sys.argv[1:]
753 sys.exit(pytest.main(args))