-
Notifications
You must be signed in to change notification settings - Fork 38
ospf: Add RFC 9339 support #78
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?
Conversation
Indeed. I see there's [email protected] but no equivalent module for OSPF. There's draft-ietf-lsr-ospf-yang-augmentation-v1, which adds several augmenting modules to ietf-ospf. We can add our own holo-ospf-reverse-metric and potentially ask the IETF folks to integrate it into that draft. That would probably be welcome on their part, especially since it would come with a working implementation. |
rwestphal
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.
Awesome work. I really like how this is shaping up!
As a preliminary review comment, I think the YANG module could be simplified.
Currently, the interface augmentation looks like this:
+--rw holo-ospf-reverse-metric:reverse-metric
+--rw holo-ospf-reverse-metric:enable-receive? boolean
+--rw holo-ospf-reverse-metric:enable-advertise? boolean
+--rw holo-ospf-reverse-metric:config* [mtid]
+--rw holo-ospf-reverse-metric:mtid uint8
+--rw holo-ospf-reverse-metric:metric? ospf:ospf-link-metric
+--rw holo-ospf-reverse-metric:flags
+--rw holo-ospf-reverse-metric:higher? boolean
+--rw holo-ospf-reverse-metric:offset? boolean
It could be simplified to something like this, more in line with the IS-IS RM module:
+--rw holo-ospf-reverse-metric:reverse-metric
+--rw holo-ospf-reverse-metric:enable-receive? boolean
+--rw holo-ospf-reverse-metric:metric? ospf:ospf-link-metric
+--rw holo-ospf-reverse-metric:flags
+--rw holo-ospf-reverse-metric:higher? boolean
+--rw holo-ospf-reverse-metric:offset? boolean
Later, once support for RFC 4915 is implemented, a separate augmentation could be added for "interface/topologies/topology". I think that would be cleaner, especially since "mtid" only makes sense for OSPFv2.
Also, the "enable-advertise" leaf can be removed, as the presence of "metric" already implies we want to advertise the reverse metric.
What do you think?
|
Thanks for this first review!
This was also my initial though but when I implemented the
I prefer defining a module that completely specifies RFC 9339 and then add a deviation that indicates unsupported augmentations.
That's a good point that I completely overlooked. I will add two augmentations then, one that accepts a single RM on the interface and enforce that We will then add an 'unsupported' deviation for the last one in Does that sounds reasonable to you? |
This commit addresses the comment from holo-routing#78 (review) with the suggestion proposed in holo-routing#78 (comment). Signed-off-by: Nicolas Rybowski <[email protected]>
This patch adds Reverse Metric and Reverse TE Metric TLVs to LLS data blocks. This patch hence depends on RFC 5613, added with holo-routing#77. Signed-off-by: Nicolas Rybowski <[email protected]>
Signed-off-by: Nicolas Rybowski <[email protected]>
Signed-off-by: Nicolas Rybowski <[email protected]>
This commit adds a custom YANG module to configure Reverse Metrics per interface and the related callbacks. It also implements the handling of such Reverse Metric both at the sender and receiver sides. Signed-off-by: Nicolas Rybowski <[email protected]>
Awesome.
That's indeed better!
Sounds good to me. Just keep in mind that in "interface/topologies/topology" you can configure a topology name, but not an "mtid", which can be a bit confusing. This is probably because the IETF folks couldn't agree on whether the MT-ID should be explicitly configured or inferred from the selected RIB. In any case, this shouldn't affect your augmentation. I just wanted to point it out in case it causes any confusion :) |
This commit addresses the comment from holo-routing#78 (review) with the suggestion proposed in holo-routing#78 (comment). Signed-off-by: Nicolas Rybowski <[email protected]>
|
Just rebased on master to clear the conflicts. 81df85f contains the changes we just discussed.
The good news is that the "mtid" augmentation for OSPFv2 is gated with the feature "multi-topology" so we don't even need a deviation to "unsupport" the augmentation and we can keep the headache of handling that when RFC 4915 is implemented :) |
Yeah that makes things easier for us :) From a quick look, it seems most of the RFC is already implemented. Tomorrow I'll run some tests and do a full review. Looking forward to it :) |
rwestphal
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.
I just ran some tests and it's very interesting to see the reverse metric in action! It's quite a useful feature for operators to have in their toolbox.
Please find my review comments below.
| // Dynamic value of the interface cost. | ||
| pub cost: u16, | ||
| // History of known Reverse Metric received on this interface. | ||
| pub rms: BTreeMap<u8, (ReverseMetricFlags, u16)>, |
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 think s/History of known/Last known/ would be more accurate.
Also, since we don't support RFC 4915 yet, it would be simpler to replace the BTreeMap with an Option. We don't need to keep track of MT-IDs other than zero. If we were to keep the BTreeMap, we would also need to use a BTreeMap for the cost field.
| // If it has not changed, we do not update the metric nor we | ||
| // originate a new Router LSA. | ||
| // If the Reverse Metric from the neighbor has been updated since | ||
| // the last one we received, then we propagate the information. |
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.
In this code, we are handling changes in the reverse metric, but the case where the RM TLV is no longer present is being ignored.
| "RFC 9339: OSPF Reverse Metric, Section 4."; | ||
| } | ||
| } | ||
| leaf mtid { |
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 leaf should be removed. The MT-ID is a property of the topology, not from the reverse metric. (yes, "interface/topologies/topology" is missing an "mtid" leaf, but that's a separate issue)
| @@ -0,0 +1,186 @@ | |||
| module holo-ospf-reverse-metric { | |||
| yang-version 1.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.
nit: both the IETF and Holo YANG modules use two spaces for indentation, not four.
| } | ||
| } | ||
|
|
||
| impl From<&LlsHelloData> for LlsDataBlock { |
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.
Why this instead of implementing From<LlsHelloData> for LlsDataBlock?
| None | ||
| }; | ||
| let advertise_rm = iface.config.reverse_metric.metric.is_some(); | ||
| let lls = (iface.config.lls_enabled & advertise_rm).then(|| { |
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 think you meant && and not & :)
In any case, this code can be a bit simpler if we use a mutable lls variable:
// Handle Reverse Metric (RFC 9339).
let mut lls = None;
let rm_cfg = &iface.config.reverse_metric;
if iface.config.lls_enabled
&& let Some(metric) = rm_cfg.metric
{
let mut lls_data = LlsHelloData::default();
let mut flags = ReverseMetricFlags::empty();
if rm_cfg.higher {
flags |= ReverseMetricFlags::H;
}
if rm_cfg.offset {
flags |= ReverseMetricFlags::O;
}
lls_data.reverse_metric.insert(0, (flags, metric));
lls = Some(lls_data);
}| impl From<&LlsDataBlock> for LlsHelloData { | ||
| fn from(value: &LlsDataBlock) -> Self { | ||
| let mut reverse_metrics = BTreeMap::new(); | ||
| value.reverse_metric.iter().for_each(|tlv| { |
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: this is a matter of style, but I'd prefer sticking to regular for loops instead of using for_each. It would be good to keep the codebase consistent by using a single style.
| 0x04, 0x00, 0x01, 0x12, 0x34, 0x00, 0x13, 0x00, 0x04, 0x01, 0x02, | ||
| 0x43, 0x21, 0x00, 0x14, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, | ||
| 0x00, 0x56, 0x78, | ||
| // 0x00, 0x00, 0x00, 0x03, |
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: unnecessary comments.
This PR adds the support for Reverse Metric and Reverse TE Metric advertisement through the LLS data block of Hello packets, as defined by RFC 9339.
It depends on RFC 5613 whose support has been added with #77.
TODO