diff options
author | David Schweizer <dschweizer@opensourcerouting.org> | 2021-04-05 09:25:50 +0200 |
---|---|---|
committer | David Schweizer <dschweizer@opensourcerouting.org> | 2021-04-05 09:25:50 +0200 |
commit | 3d762f26a6b929bc0a09a3689feb1ad52263c3f2 (patch) | |
tree | 435b27674b3fee5a7b83fc331c33563aab160f8d /tests/topotests/lib/common_config.py | |
parent | Merge pull request #8391 from idryzhov/fix-bgp-nb-prefix-list (diff) | |
download | frr-3d762f26a6b929bc0a09a3689feb1ad52263c3f2.tar.xz frr-3d762f26a6b929bc0a09a3689feb1ad52263c3f2.zip |
tests: add l3mdev config helpers for VRF topotests
Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
Diffstat (limited to '')
-rw-r--r-- | tests/topotests/lib/common_config.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index a4c98924b..9c63ba5dc 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -4372,3 +4372,53 @@ def verify_ip_nht(tgen, input_dict): logger.debug("Exiting lib API: verify_ip_nht()") return False + + +def kernel_requires_l3mdev_adjustment(): + """ + Checks if the L3 master device needs to be adjusted to handle VRF traffic + based on kernel version. + + Returns + ------- + 1 or 0 + """ + + if version_cmp(platform.release(), "4.15") >= 0: + return 1 + return 0 + + +def adjust_router_l3mdev(tgen, router): + """ + Adjusts a routers L3 master device to handle VRF traffic depending on kernel + version. + + Parameters + ---------- + * `tgen` : tgen object + * `router` : router id to be configured. + + Returns + ------- + True + """ + + l3mdev_accept = kernel_requires_l3mdev_adjustment() + + logger.info( + "router {0}: setting net.ipv4.tcp_l3mdev_accept={1}".format( + router, l3mdev_accept + ) + ) + + output = tgen.net[router].cmd("sysctl -n net.ipv4.tcp_l3mdev_accept") + logger.info( + "router {0}: existing tcp_l3mdev_accept was {1}".format(router, output) + ) + + tgen.net[router].cmd( + "sysctl -w net.ipv4.tcp_l3mdev_accept={}".format(l3mdev_accept) + ) + + return True |