diff options
author | GalaxyGorilla <sascha@netdef.org> | 2020-08-05 10:44:21 +0200 |
---|---|---|
committer | GalaxyGorilla <sascha@netdef.org> | 2021-01-19 16:32:13 +0100 |
commit | 7fd0729f762d96ca78057ed126afdaacc0dd1fd9 (patch) | |
tree | 0a536202b8ca9e77796d6d1ab661445e970c589d /ospfd/ospf_sr.c | |
parent | Merge pull request #7886 from volta-networks/master (diff) | |
download | frr-7fd0729f762d96ca78057ed126afdaacc0dd1fd9.tar.xz frr-7fd0729f762d96ca78057ed126afdaacc0dd1fd9.zip |
ospfd: TI-LFA basic infrastructure and algorithms
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
Diffstat (limited to 'ospfd/ospf_sr.c')
-rw-r--r-- | ospfd/ospf_sr.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ospfd/ospf_sr.c b/ospfd/ospf_sr.c index e2218957d..f3bb4cef8 100644 --- a/ospfd/ospf_sr.c +++ b/ospfd/ospf_sr.c @@ -159,6 +159,16 @@ static struct sr_node *sr_node_new(struct in_addr *rid) return new; } +/* Supposed to be used for testing */ +struct sr_node *ospf_sr_node_create(struct in_addr *rid) +{ + struct sr_node *srn; + + srn = hash_get(OspfSR.neighbors, (void *)rid, (void *)sr_node_new); + + return srn; +} + /* Delete Segment Routing node */ static void sr_node_del(struct sr_node *srn) { @@ -653,6 +663,30 @@ static mpls_label_t index2label(uint32_t index, struct sr_block srgb) return label; } +/* Get the prefix sid for a specific router id */ +mpls_label_t ospf_sr_get_prefix_sid_by_id(struct in_addr *id) +{ + struct sr_node *srn; + struct sr_prefix *srp; + mpls_label_t label; + + srn = (struct sr_node *)hash_lookup(OspfSR.neighbors, id); + + if (srn) { + /* + * TODO: Here we assume that the SRGBs are the same, + * and that the node's prefix SID is at the head of + * the list, probably needs tweaking. + */ + srp = listnode_head(srn->ext_prefix); + label = index2label(srp->sid, srn->srgb); + } else { + label = MPLS_INVALID_LABEL; + } + + return label; +} + /* Get neighbor full structure from address */ static struct ospf_neighbor *get_neighbor_by_addr(struct ospf *top, struct in_addr addr) |