-
Notifications
You must be signed in to change notification settings - Fork 320
Allow adding nh_encap to rtnl_nh #443
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
Conversation
06550e7 to
b73f70b
Compare
|
Thanks for the feedback. Will continue going through it in the coming days. |
ff1eac8 to
517050a
Compare
517050a to
6abdf9a
Compare
thom311
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.
getting close. Thank you!
da612f8 to
de3f0fd
Compare
|
@thom311 - as I fix the backwards compatibility for all callers of I'm not sure here to what extend we want to preserve past behavior vs. becoming more backwards compatible. |
OK, there is also if (!lwtunnel_encap_types[e_type].ops->parse_msg)
return -NLE_MSGTYPE_NOSUPPORT;and if (e_type == LWTUNNEL_ENCAP_NONE) {
NL_DBG(2, "RTA_ENCAP_TYPE should not be LWTUNNEL_ENCAP_NONE\n");
return -NLE_INVAL;
}which I think warrant the same handling.
I think in general, unknown (or not implemented) attributes should be ignored. That is the only way to be forward compatible against future attributes. I don't think there is a lot of value in failing to parse unknown attributes (or unknown encap_type, in this case). |
KanjiMonster
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.
As a minor nitpick, I dislike brackets in commit subjects because anything in these get dropped by git-am when applying patches.
But that's just my preference.
| struct rtnl_nexthop *nh; | ||
| _nl_auto_rtnl_nexthop struct rtnl_nexthop *nh = NULL; |
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.
Switching to _nl_auto pointer should be a separate commit IMHO since this is unrelated to the changes according to the commit message, and makes reviewing harder.
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.
Good point - I'm splitting out this commit.
| [LWTUNNEL_ENCAP_IP] = { .name = "ip" }, | ||
| [LWTUNNEL_ENCAP_IP6] = { .name = "ip6" }, | ||
| [LWTUNNEL_ENCAP_ILA] = { .name = "ila" }, | ||
| [LWTUNNEL_ENCAP_BPF] = { .name = "bpf" }, | ||
| [LWTUNNEL_ENCAP_IP] = { .name = "ip" }, | ||
| [LWTUNNEL_ENCAP_IP6] = { .name = "ip6" }, | ||
| [LWTUNNEL_ENCAP_ILA] = { .name = "ila" }, | ||
| [LWTUNNEL_ENCAP_BPF] = { .name = "bpf" }, |
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.
Likewise, being aligned around the equals sign seems to be a deliberate choice.
Unfortunately, the last time I checked there wasn't an option for that in clang-format.
| return NULL; | ||
|
|
||
| return nh->rtnh_encap; | ||
| } |
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.
missing empty line after the function
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.
Fixed!
Fair enough! I will stop doing that. I'm wondering now myself why did I even start doing that 😅 |
Signed-off-by: Christoph Paasch <[email protected]>
Don't do `if (...) expr;`. Always start a new line after the if(). Signed-off-by: Christoph Paasch <[email protected]>
Primarily getter/setter tests as well kernel round-trip. Signed-off-by: Christoph Paasch <[email protected]>
The goal is to have struct rtnl_nh_encap be used for the route's nexthop (In struct rtnl_nexthop) but also directly in an IP nexthop (struct rtnl_nh). So, let's extract some functions to manipulate struct rtnl_nh_encap directly. Ideally, even for the route's nexthop we will use those to manipulate the encap. Ideally we stop using rtnl_route_nh_encap_mpls (and friends) and rather configure an encapsulation on a route's nexthop by using: nh = rtnl_nh_encap_alloc() rtnl_nh_encap_mpls(nh, ...) rtnl_route_nh_set_encap(rtnh, nh) Add tests for these new functions and drop the tests for the deprecated ones. Signed-off-by: Christoph Paasch <[email protected]>
For better and less error-prone failure handling. Signed-off-by: Christoph Paasch <[email protected]>
Signed-off-by: Christoph Paasch <[email protected]>
There is support for parsing and populating rtnl_nexthop's encap. However, not for rtnl_nh's encapsulation. Refactor this and make it such that the parsing code for both is reused. Signed-off-by: Christoph Paasch <[email protected]>
In my opinion, we should never have an encap in
Indeed. I see, iproute2 also handles this case gracefully.
There is also for that one I am adding the graceful handling and just return 0. |
A regular "nexthop object" à la `ip nexthop` can have an associated encapsulation. So, add the code to support that. Signed-off-by: Christoph Paasch <[email protected]>
de3f0fd to
6ec1802
Compare
Makes sense. In that case indeed there is no need for a check. A crash (in case of such a bug) is a perfectly fine (deterministic) behavior. |
|
lgtm. merged. Thanks @cpaasch-oai for your work. |
The goal is to allow setting a nexthop encapsulation on a nexthop object (and passing it down to the kernel). There already is an API to manipulate mpls encap on a route object. However, that API is exclusive to using
rtnl_nexthop, while internally it is actually using anh_encap.Ideally, adding nexthop encaps is done all by using
nh_encapobjects (regardless of whether this is for artnl_nexthopor artnl_nhobject. So, f1263ca is moving towards that direction. It also deprecated the previousrtnl_route_nh_encap_mpls()(and related APIs) as IMO a better way of handling this is by doing:The goal is to add full support for all types of nexthop encapsulations (ipvX tunnels, segment-routing,...). So, directly manipulating the
nh_encapis cleaner.Adding tests along the way, starting with a6a808b and from there on with each commit that is exposing new API.
For the tests to pass PR #442 is needed.