-
Notifications
You must be signed in to change notification settings - Fork 1.4k
lib, bgpd: Move BGP-specific funcs out of lib and refactor #20139
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
base: master
Are you sure you want to change the base?
lib, bgpd: Move BGP-specific funcs out of lib and refactor #20139
Conversation
bgpd/bgp_attr.c
Outdated
| /* Encode labels to buffer and pass to stream_put_labeled_prefix, truncate | ||
| * labels if needed, set/restore BOS of label in this case | ||
| */ | ||
| static void stream_bgp_put_labeled_prefix(struct stream *s, const struct prefix *p, |
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.
let's call this function bgp_attr_stream_put_labeled_prefix.
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.
🫡
|
one minor nit and then we can get this in. |
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.
the PR title - looks unrelated, or vaguely related? Please, say in the title what's being changed (lib, bgpd) and what the change is (moving some bgp-only label-encoding code into bgp)
same with the commit title: the commits and the PR are used to produce release notes, so they need to be meaningful and accurate
mjstapp
left a comment
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 we just do the whole thing here? just remove the bgp api from the stream module; it's only used in bgpd (right?)
|
I can't quickly say whether all those instances can or should be moved to bgp. Moving even just The I think this PR is at least a step forward - merging diverged Regarding commit message I tried my best and it is now: "lib, bgpd: Move label manipulation out of lib + support sending multiple labels", which is long, but not longest in FRR history ) Also I would like to make it clear: the title is very related, it is not only refactoring here, it is also "Support sending multiple labels in BGP-LU" - I've removed possibility to SEND multiple labels from previous PR so that there were no changes in lib/stream, it is added here, and currently in If needed, I can split these changes further to separate commits/PRs with only refactoring as first commit/PR and support of sending multiple labels as second one. |
17b0213 to
82938ee
Compare
|
so here's my suggestion: this problem arose because some folks decided to put this code directly into lib/stream. what they should have done, imo, was to create the bgp-specific blob, and then use the generic stream apis to put that blob into a struct stream. you don't need a big buffer to encode the blob - right? it's only a couple of hundred bytes at most. the bgp code could encode the addpath, if present, then encode the prefix length, then encode the labels and prefix. it's not necessary to do that in the lib/stream code directly, at least I don't think it is. and if we're really missing some api that we need in the lib to support bgpd, then that's a good thing to learn; I'd rather enhance the library to help daemons who want to encode their protocol messages rather than embed protocol code in the lib because that's the only way the daemons can use a stream?
|
* Move stream_put_labeled_prefix and stream_put_prefix_addpath (lib/stream.c) to bgp_attr_stream_put_labeled_prefix and bgp_attr_stream_put_prefix_addpath in bgpd/bgp_attr.c * Merge these two function implementations as stream_put_labeled_prefix is more general Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
82938ee to
199c6bf
Compare
|
Ok, But it is the simplest of the three - just writes prefix length in bits and the prefix itself (currently it uses more general but BGP-specific lib/stream has size_t stream_write(struct stream *s, const void *ptr, size_t size)which is absolutely enough for So I have updated PR and now:
I've removed changes that add ability to send multiple labels in BGP-LU - I'll create yet another PR when this is merged so that this PR has only refactoring changes. |
This is continuation of #19961, where @mjstapp suggested to make changes to lib/stream* a separate PR.
In next PR I'll add sending of multiple labels in BGP-LU at last :)