-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ospf6d: Fix metric when sending AS-external LSAs #15627
ospf6d: Fix metric when sending AS-external LSAs #15627
Conversation
a481212
to
f5a1687
Compare
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.
This is wrong to change the behavior to unconditionally add the existing route metric to the redistributed metric. I'd hope we have a topotest that would catch this. If this behavior is desired is should be conditional (possibly via a route-map) and be available for all redistributions (not just applied to OSPFv3).
I could not find a lot about this in the FRRouting documentation, but after some tests it looks like the following config-option allows using the existing route metric as redistributed metric. At least for IPv4 it does. redistribute kernel route-map ABC route-map ABC permit 10 When using the same config with IPv6 I end up with metric 1 for all redistributed kernel-routes. (without my patch) Is there possibly a bug in ospf6d that prevents this config from actually working or is there an intention behind the different behaviour? |
Ok - I see that the route-map increment and decrement functions are not implemented. However, you have the wrong fix. The right fix is to add this capability to the route-map callback for ospf6d. static enum route_map_cmd_result_t |
Look at ospfd/ospf_routemap.c - route_set_metric(). You need to stash the redistributed metric in the route (but not as the the default metric) and do something like this. |
Thank you, I will look into that. |
f5a1687
to
85e39be
Compare
I added support for metric increment and decrement in ospf6d routemaps. Is this what you had in your mind? |
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.
Looks like it should work but it could read a lot better and the range checking is needed to assure the metric is valid for AS External LSAs.
arg++; | ||
} | ||
|
||
metric->metric = strtoul(arg, NULL, 10); |
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.
Does this work with a metric subtraction since this could be misinterpreted? Shouldn't you skip the +/- so we don't have to wonder about the precise strtoul() behavior where "u" stands for unsigned.
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.
Skipping the +/- is exactly what this code is doing. strtoul() will only see a number with no sign beforehand.
btw this is the same code as ospfd is using.
ospf6d/ospf6_asbr.c
Outdated
route->path.cost += metric->metric; | ||
else if (metric->type == metric_decrement) | ||
route->path.cost -= metric->metric; | ||
else if (metric->type == metric_absolute) |
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.
Don't you need range checking for the increment and decrement cases?
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.
I added range checking in those cases.
As this code is basically copy-paste from ospfd, I think there is also a problem - except if the range checking is done somewhere else.
85e39be
to
a8fc0d3
Compare
a8fc0d3
to
8c83b82
Compare
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.
Looks good to me.
|
||
/* Check overflow */ | ||
if (route->path.cost == 0 || route->path.cost > route->path.redistribute_cost) | ||
route->path.cost = 1; |
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.
Not sure if OSPFv2 default to 1 or 0 in this case but it is a real cornercase anyway.
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.
I was asking myself the same question. After reading the RFC It looks like metric 0 is only for some special cases.
Is there something to do on my side? Like rebasing for example? Or will that be done upon merging? |
Yes - you need to rebase as indicated by the @github-actions github-actions bot added the rebase label last week Note that this could also help with the CI tests as the intermittent BFD failure (not related to your change) has been mitigated. |
8c83b82
to
d0320e8
Compare
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.
looks good
Please fix styling/formatting (frrbot check) before merging. |
When ospf6d originates an AS-external route that has been read from a kernel routing table, then the metric of that route was ignored until now. If a routemap is configured, then this metric will be redistributed from now on. Using metric increment and decrement in routemaps is supported by ospf6d now. Signed-off-by: Alexander Rose <[email protected]>
d0320e8
to
84d1285
Compare
Thanks for the hint. I missed that one. |
When ospf6d originates an AS-external route that has been read from a kernel routing table, then the metric of that route was ignored until now. In my case all of these routes were announced with metric 1 in LS-updates.
Now the metric of the kernel route is added to whatever metric ospf6d already computed originally.