-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zebra,bgpd: add match tracker option to bgp route-map #12372
Conversation
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 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is missing as well.
|
||
DEFUNSH(VTYSH_ZEBRA, no_tracker_file, vtysh_no_trackerfile_cmd, | ||
"no tracker NAME [file]", | ||
"Tracker configuration\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO_STR is missing,
"Event trackers"; | ||
key name; | ||
leaf name { | ||
type string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string?
|
||
for (ALL_LIST_ELEMENTS_RO(zebra_tracker_file_master, node, | ||
tracker_file)) { | ||
if (strncmp(name, tracker_file->name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: strmatch()
.
tracker_file = | ||
XCALLOC(MTYPE_TRACKER_FILE, sizeof(struct zebra_tracker_file)); | ||
|
||
snprintf(tracker_file->name, sizeof(tracker_file->name), "%s", name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
is already char, can't we use strlcpy()
, here?
} | ||
|
||
DEFPY_YANG_NOSH(no_tracker_file, no_trackerfile_cmd, | ||
"no tracker NAME$name [file]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO_STR is missing.
} | ||
|
||
DEFPY_YANG(tracker_file_path, tracker_file_path_cmd, "path PATH", | ||
"Absolute file path\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be more descriptive in this place?
zebra/zebra_tracker.c
Outdated
} | ||
|
||
|
||
DEFUN(tracker_file_show, tracker_file_show_cmd, "show tracker file", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFPY
} else if (line > 1) { | ||
if (IS_ZEBRA_DEBUG_TRACKER) | ||
zlog_debug("%s: %s file has more than one line", | ||
__func__, tracker_file->path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No __func__
everywhere, please.
zebra/zebra_tracker_notify.c
Outdated
break; | ||
} | ||
|
||
if (event->mask & IN_CLOSE_WRITE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: CHECK_FLAG()
zebra/zebra_tracker_notify.c
Outdated
event = (struct inotify_event *)((char *)event + sizeof(*event) + | ||
event->len)) { | ||
|
||
if (!(event->mask & (IN_DELETE_SELF | IN_CLOSE_WRITE))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: CHECK_FLAG()
The advantage of this framework is that a change in a file is immediately notified to the route-map.
|
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 |
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. I talk about a kind of trigger. |
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. |
The thread_event system operates on a loop so you could make it poll pretty fast I am sure. |
we can always ship a short lua script along with FRR that already does it so the user doesn't have to write anything |
This PR is stale because it has been open 180 days with no activity. Comment or remove the |
Add yang schema to support zebra file trackers. The schema is ready for future types of tracker. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the file tracker CLI. The commands does nothing more than displaying the configuration in show run and allowing the configuration to be loaded from a file at startup. > conf > tracker TRACKER-KEEPALIVED file > path /var/run/keepalived > condition pattern MASTER > exit > no tracker TRACKER-KEEPALIVED Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the file tracker backend, a struct zebra_tracker_file and make zebra manages the list of file tracker in memory. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the show tracker file command to display running tracker files. > r1# show tracker file > List of file trackers > > Name Status Path Condition > ------------------------------------------------------------------------ > TRACKER-KEEPALIVED down /var/keepalived/notify pattern MASTER exact > TEST down /tmp/test exist Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the "debug zebra tracker" command to display debug info about trackers. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the mechanism to fetch a tracker status and to update it as soon as the file is updated. If the file is not yet created, a check happens every seconds to check that the file has not been created and when it is created, its updates are triggered by inotify (deletion and content update events are watched). Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add some ZAPI messages to send tracker notifications from zebra to daemons. ZEBRA_TRACKER_NOTIFY notifies about new trackers and their status change. ZEBRA_TRACKER_DEL notifies about tracker deletions. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This set of commits is about adding a conditional advertising of prefix from BGP feature by the means of trackers and a route-map "match tracker" option. The tracker ZAPI messages are flooded to all daemons. Only send tracker ZAPI messages to bgpd. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Send tracker ZAPI notifications to daemons when a new tracker is added, its status is changed and it is deleted. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add a library to decode tracker ZAPI messages in daemons. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Make bgpd manage a list of trackers from the tracker ZAPI messages information. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
If a routing daemon starts after zebra and zebra has finished to update the tracker status, the routing daemon will not be informed of the tracker status. It will consider that no tracker exists. Send notify ZAPI messages about all trackers when a new daemon registers to zebra. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the following "match tracker" command: > r1(config)# route-map RMAP-OUT permit 1 > r1(config-route-map)# match tracker TRACKER-VRRP up The CLI does not check that TRACKER-VRRP exists in zebra configuration. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add the backend logic to deal with the route-map match tracker option. The match tracker takes into account the status of the tracker at the route-map creation. Next commits are going to deal with the update of the tracker status. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Reapply the route-maps that use the tracker that is updated. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
A route-map is re-applied after its configuration changes with a delay. "bgp route-map delay-timer" allows configuring this timer. Re-apply the route-map immediately without waiting for the delay timer to expire when a tracker status changes. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Add a bgp_route_map_tracker topotest to test the zebra tracker file and the BGP route-map match tracker feature. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
a1d1af6
to
433cae6
Compare
Continuous Integration Result: FAILEDSee below for issues. This is a comment from an automated CI system. Get source / Pull Request: SuccessfulBuilding Stage: FailedOpenBSD 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.statusMake failed for OpenBSD 7 amd64 build:
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.statusMake failed for FreeBSD 11 amd64 build:
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.statusMake failed for FreeBSD 12 amd64 build:
Successful on other platforms/tests
Warnings Generated during build:Checkout code: Successful with additional warningsOpenBSD 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.statusMake failed for OpenBSD 7 amd64 build:
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.statusMake failed for FreeBSD 11 amd64 build:
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.statusMake failed for FreeBSD 12 amd64 build:
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
not accepted by the community |
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:
An event driven "match" option is present in Cisco IOS-XR route-policy.
Other community suggestions:
The current pull request is a draft. We need to agree on the design before continuing