frr icon indicating copy to clipboard operation
frr copied to clipboard

zebra,bgpd: add match tracker option to bgp route-map

Open louis-6wind opened this issue 2 years ago • 13 comments

We have a cluster of two routers running the same daemons to deal with the traffic (IPSec, firewall...). Some daemons must not process traffic simultaneously on both cluster members. We use Keepalived to decide which of them should deal with the traffic. Basically, when Keepalived elects the router as the MASTER, the router must process the traffic, else it must not process the traffic but must router it to the MASTER.

To do this, we would like to advertise some prefixes from BGP only when the router is in MASTER state.

Since Keepalived is able to write its state on a file, I suggest to the community a feature to:

  • track the state of a file
  • add a route-map option "match tracker NAME" to advertise the prefixes when the tracker is up
  • re process the route-map to remove or add prefix advertisement without delay and without changing the user configuration

An event driven "match" option is present in Cisco IOS-XR route-policy.

Other community suggestions:

  • using a custom LUA script. Writing a custom script is more complex for the end user than using a native solution. Not sure we can reprocess the route-map in case an external file changes.
  • use an external script to modify the conf and add an option to process route-map immediately. We do not want the user configuration to change on an event. I prefer a native solution than writting a custom external script.

The current pull request is a draft. We need to agree on the design before continuing

louis-6wind avatar Nov 22 '22 15:11 louis-6wind

This is what I was saying may be of interest to you:

http://docs.frrouting.org/projects/dev-guide/en/latest/scripting.html#examples

Basically you can use lua scripts to track external object state in a route-map

sworleys avatar Nov 22 '22 16:11 sworleys

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Nov 22 '22 17:11 github-actions[bot]

The advantage of this framework is that a change in a file is immediately notified to the route-map. Without this, a change may be propagated in tens of seconds.

This is what I was saying may be of interest to you:

http://docs.frrouting.org/projects/dev-guide/en/latest/scripting.html#examples

Basically you can use lua scripts to track external object state in a route-map

pguibert6WIND avatar Nov 29 '22 14:11 pguibert6WIND

I agree w/ @sworleys -> this is something that should be done with the lua event hooks system already in place. We need agreement in general that this is the approach we want to take or not. I also fail to see how any of this can't be done within the lua framework

donaldsharp avatar Nov 29 '22 14:11 donaldsharp

Extending Lua subsystem would be a better choice. Not only in terms of this case but overall, improving an existing, which is a bit abandoned right now.

ton31337 avatar Nov 29 '22 15:11 ton31337

Extending Lua subsystem would be a better choice. Not only in terms of this case but overall, improving an existing, which is a bit abandoned right now.

There is a brick missing in what is proposed. If I understand right, lua is called periodically (as per the route-map period of 20 seconds if I remember well). you say, lets use lua, but how can we speed up the polling without flooding the bgp CPU ?

I talk about a kind of trigger. For instance, I was thinking of zlog_rotate mechanism. Today it is reopening the file, if a given interrupt is received. what about using that mechanism ?

pguibert6WIND avatar Dec 13 '22 09:12 pguibert6WIND

There is a brick missing in what is proposed. If I understand right, lua is called periodically (as per the route-map period of 20 seconds if I remember well). you say, lets use lua, but how can we speed up the polling without flooding the bgp CPU ?

For what you need, I would first look at adding a hook point to our thread_event system such that at X specified poll intervals when we hit that event we call into a lua script to check whatever object you want to. In this case, a file. And then return from the script and handle any resulting change in C code based on file state.

sworleys avatar Dec 13 '22 15:12 sworleys

The thread_event system operates on a loop so you could make it poll pretty fast I am sure.

sworleys avatar Dec 13 '22 15:12 sworleys

using a custom LUA script. Writing a custom script is more complex for the end user than using a native solution

we can always ship a short lua script along with FRR that already does it so the user doesn't have to write anything

sworleys avatar Dec 13 '22 16:12 sworleys

This PR is stale because it has been open 180 days with no activity. Comment or remove the autoclose label in order to avoid having this PR closed.

github-actions[bot] avatar Jun 12 '23 02:06 github-actions[bot]

Continuous Integration Result: FAILED

See below for issues. CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/

This is a comment from an automated CI system. For questions and feedback in regards to this CI system, please feel free to email Martin Winter - mwinter (at) opensourcerouting.org.

Get source / Pull Request: Successful

Building Stage: Failed

OpenBSD 7 amd64 build: Failed (click for details) OpenBSD 7 amd64 build: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI011BUILD/config.log/config.log.gz OpenBSD 7 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI011BUILD/config.status/config.status

Make failed for OpenBSD 7 amd64 build: (see full Make log at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI011BUILD/ErrorLog/log_make.txt)

/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:830: WARNING: duplicate clicmd description of segment-routing, other instance in pathd
/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:843: WARNING: duplicate clicmd description of locator NAME, other instance in isisd
zebra/zebra_tracker_notify.c:23:10: fatal error: 'sys/inotify.h' file not found
#include <sys/inotify.h>
1 error generated.
gmake[1]: *** [Makefile:10627: zebra/zebra_tracker_notify.o] Error 1
gmake[1]: Leaving directory '/home/ci/cibuild.14278/frr-source'
gmake[1]: Target 'all-am' not remade because of errors.
gmake: *** [Makefile:6483: all] Error 2
FreeBSD 11 amd64 build: Failed (click for details) FreeBSD 11 amd64 build: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI009BUILD/config.log/config.log.gz FreeBSD 11 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI009BUILD/config.status/config.status

Make failed for FreeBSD 11 amd64 build: (see full Make log at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI009BUILD/ErrorLog/log_make.txt)

/usr/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:830: WARNING: duplicate clicmd description of segment-routing, other instance in pathd
/usr/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:843: WARNING: duplicate clicmd description of locator NAME, other instance in isisd
zebra/zebra_tracker_notify.c:23:10: fatal error: sys/inotify.h: No such file or directory
compilation terminated.
gmake[1]: *** [Makefile:10627: zebra/zebra_tracker_notify.o] Error 1
gmake[1]: Leaving directory '/usr/home/ci/cibuild.14278/frr-source'
gmake[1]: Target 'all-am' not remade because of errors.
gmake: *** [Makefile:6483: all] Error 2
FreeBSD 12 amd64 build: Failed (click for details) FreeBSD 12 amd64 build: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/FBSD12AMD64/config.log/config.log.gz FreeBSD 12 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/FBSD12AMD64/config.status/config.status

Make failed for FreeBSD 12 amd64 build: (see full Make log at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/FBSD12AMD64/ErrorLog/log_make.txt)

/usr/home/ci/cibuild.14278/frr-source/doc/user/ospfd.rst:642: WARNING: Cannot analyze code. No Pygments lexer found for "frr".
/usr/home/ci/cibuild.14278/frr-source/doc/user/pbr.rst:50: WARNING: duplicate label nexthop-groups, other instance in /usr/home/ci/cibuild.14278/frr-source/doc/user/nexthop_groups.rst
zebra/zebra_tracker_notify.c:23:10: fatal error: sys/inotify.h: No such file or directory
 #include <sys/inotify.h>
compilation terminated.
gmake[1]: *** [Makefile:10624: zebra/zebra_tracker_notify.o] Error 1
gmake[1]: Target 'all-am' not remade because of errors.
gmake[1]: Leaving directory '/usr/home/ci/cibuild.14278/frr-source'
gmake: *** [Makefile:6480: all] Error 2
Successful on other platforms/tests
  • Redhat 8 amd64 build
  • Debian 10 amd64 build
  • Ubuntu 20.04 amd64 build
  • Ubuntu 22.04 amd64 build
  • CentOS 7 amd64 build
  • Debian 9 amd64 build
  • Ubuntu 18.04 amd64 build
  • Redhat 9 amd64 build
  • Ubuntu 18.04 ppc64le build
  • Ubuntu 18.04 i386 build
  • Ubuntu 18.04 arm7 build
  • Ubuntu 18.04 arm8 build
  • Debian 11 amd64 build

Warnings Generated during build:

Checkout code: Successful with additional warnings
OpenBSD 7 amd64 build: Failed (click for details) OpenBSD 7 amd64 build: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI011BUILD/config.log/config.log.gz OpenBSD 7 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI011BUILD/config.status/config.status

Make failed for OpenBSD 7 amd64 build: (see full Make log at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI011BUILD/ErrorLog/log_make.txt)

/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:830: WARNING: duplicate clicmd description of segment-routing, other instance in pathd
/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:843: WARNING: duplicate clicmd description of locator NAME, other instance in isisd
zebra/zebra_tracker_notify.c:23:10: fatal error: 'sys/inotify.h' file not found
#include <sys/inotify.h>
1 error generated.
gmake[1]: *** [Makefile:10627: zebra/zebra_tracker_notify.o] Error 1
gmake[1]: Leaving directory '/home/ci/cibuild.14278/frr-source'
gmake[1]: Target 'all-am' not remade because of errors.
gmake: *** [Makefile:6483: all] Error 2
FreeBSD 11 amd64 build: Failed (click for details) FreeBSD 11 amd64 build: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI009BUILD/config.log/config.log.gz FreeBSD 11 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI009BUILD/config.status/config.status

Make failed for FreeBSD 11 amd64 build: (see full Make log at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/CI009BUILD/ErrorLog/log_make.txt)

/usr/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:830: WARNING: duplicate clicmd description of segment-routing, other instance in pathd
/usr/home/ci/cibuild.14278/frr-source/doc/user/zebra.rst:843: WARNING: duplicate clicmd description of locator NAME, other instance in isisd
zebra/zebra_tracker_notify.c:23:10: fatal error: sys/inotify.h: No such file or directory
compilation terminated.
gmake[1]: *** [Makefile:10627: zebra/zebra_tracker_notify.o] Error 1
gmake[1]: Leaving directory '/usr/home/ci/cibuild.14278/frr-source'
gmake[1]: Target 'all-am' not remade because of errors.
gmake: *** [Makefile:6483: all] Error 2
FreeBSD 12 amd64 build: Failed (click for details) FreeBSD 12 amd64 build: Unknown Log URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/FBSD12AMD64/config.log/config.log.gz FreeBSD 12 amd64 build: config.status output from configure script can be found at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/FBSD12AMD64/config.status/config.status

Make failed for FreeBSD 12 amd64 build: (see full Make log at https://ci1.netdef.org/browse/FRR-PULLREQ2-14278/artifact/FBSD12AMD64/ErrorLog/log_make.txt)

/usr/home/ci/cibuild.14278/frr-source/doc/user/ospfd.rst:642: WARNING: Cannot analyze code. No Pygments lexer found for "frr".
/usr/home/ci/cibuild.14278/frr-source/doc/user/pbr.rst:50: WARNING: duplicate label nexthop-groups, other instance in /usr/home/ci/cibuild.14278/frr-source/doc/user/nexthop_groups.rst
zebra/zebra_tracker_notify.c:23:10: fatal error: sys/inotify.h: No such file or directory
 #include <sys/inotify.h>
compilation terminated.
gmake[1]: *** [Makefile:10624: zebra/zebra_tracker_notify.o] Error 1
gmake[1]: Target 'all-am' not remade because of errors.
gmake[1]: Leaving directory '/usr/home/ci/cibuild.14278/frr-source'
gmake: *** [Makefile:6480: all] Error 2
Report for bgp_tracker.c | 12 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/bgp_tracker.c:1:
+/* BGP Tracker

ERROR: Bad function definition - void bgp_tracker_terminate() should probably be void bgp_tracker_terminate(void)
#103: FILE: /tmp/f1-1223375/bgp_tracker.c:103:
+void bgp_tracker_terminate()

ERROR: Bad function definition - void bgp_tracker_init() should probably be void bgp_tracker_init(void)
#119: FILE: /tmp/f1-1223375/bgp_tracker.c:119:
+void bgp_tracker_init()
Report for bgp_tracker.h | 4 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/bgp_tracker.h:1:
+/* BGP Tracker
Report for tracker.h | 4 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/tracker.h:1:
+/*
Report for zclient.c | 2 issues
===============================================
< WARNING: externs should be avoided in .c files
< #1479: FILE: /tmp/f1-1223375/zclient.c:1479:
Report for zebra_tracker.c | 13 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/zebra_tracker.c:1:
+/*

ERROR: do not initialise statics to NULL
#35: FILE: /tmp/f1-1223375/zebra_tracker.c:35:
+static struct list *zebra_tracker_file_master = NULL;

WARNING: break is not useful after a return
#199: FILE: /tmp/f1-1223375/zebra_tracker.c:199:
+		return "init";
+		break;
Report for zebra_tracker.h | 4 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/zebra_tracker.h:1:
+/*
Report for zebra_tracker_nb.c | 4 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/zebra_tracker_nb.c:1:
+/*
Report for zebra_tracker_nb_config.c | 4 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/zebra_tracker_nb_config.c:1:
+/*
Report for zebra_tracker_nb.h | 4 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/zebra_tracker_nb.h:1:
+/*
Report for zebra_tracker_notify.c | 18 issues
===============================================
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#1: FILE: /tmp/f1-1223375/zebra_tracker_notify.c:1:
+/*

ERROR: do not use assignment in if condition
#113: FILE: /tmp/f1-1223375/zebra_tracker_notify.c:113:
+	if ((file = fopen(tracker_file->path, "r"))) {

WARNING: void function return statements are not generally useful
#127: FILE: /tmp/f1-1223375/zebra_tracker_notify.c:127:
+	return;
+}

WARNING: void function return statements are not generally useful
#185: FILE: /tmp/f1-1223375/zebra_tracker_notify.c:185:
+	return;
+}

NetDEF-CI avatar Sep 21 '23 09:09 NetDEF-CI

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Sep 26 '23 14:09 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Jan 23 '24 06:01 github-actions[bot]

not accepted by the community

louis-6wind avatar Jun 10 '24 09:06 louis-6wind