diff options
| author | GalaxyGorilla <sascha@netdef.org> | 2020-08-05 08:44:21 +0000 | 
|---|---|---|
| committer | GalaxyGorilla <sascha@netdef.org> | 2021-01-19 15:32:13 +0000 | 
| commit | 7fd0729f762d96ca78057ed126afdaacc0dd1fd9 (patch) | |
| tree | 0a536202b8ca9e77796d6d1ab661445e970c589d /ospfd/ospf_sr.c | |
| parent | 6351ea6ebf64524583e7a54b4af25e140109d790 (diff) | |
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 e2218957d2..f3bb4cef83 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)  | 
