2022-11-28 10:34:10 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
/*
|
|
|
|
* This is an implementation of Segment Routing over IPv6 (SRv6) for IS-IS
|
|
|
|
* as per RFC 9352
|
|
|
|
* https://datatracker.ietf.org/doc/html/rfc9352
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Carmine Scarpitta - University of Rome Tor Vergata
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _FRR_ISIS_SRV6_H
|
|
|
|
#define _FRR_ISIS_SRV6_H
|
|
|
|
|
2023-03-14 02:40:34 +01:00
|
|
|
#include "lib/srv6.h"
|
2023-02-15 11:35:46 +01:00
|
|
|
#include "isisd/isis_tlvs.h"
|
|
|
|
|
2023-11-03 10:03:46 +01:00
|
|
|
#define ISIS_DEFAULT_SRV6_MAX_SEG_LEFT_MSD 3
|
|
|
|
#define ISIS_DEFAULT_SRV6_MAX_END_POP_MSD 3
|
|
|
|
#define ISIS_DEFAULT_SRV6_MAX_H_ENCAPS_MSD 2
|
2025-01-15 13:16:21 +01:00
|
|
|
#define ISIS_DEFAULT_SRV6_MAX_END_D_MSD 5
|
2023-11-03 10:03:46 +01:00
|
|
|
|
2023-02-15 11:28:01 +01:00
|
|
|
/* SRv6 SID structure */
|
|
|
|
struct isis_srv6_sid_structure {
|
|
|
|
uint8_t loc_block_len;
|
|
|
|
uint8_t loc_node_len;
|
|
|
|
uint8_t func_len;
|
|
|
|
uint8_t arg_len;
|
|
|
|
};
|
|
|
|
|
2023-03-14 02:40:34 +01:00
|
|
|
/* SRv6 SID not bound to any adjacency */
|
|
|
|
struct isis_srv6_sid {
|
|
|
|
struct isis_srv6_sid *next;
|
|
|
|
|
|
|
|
/* SID flags */
|
|
|
|
uint8_t flags;
|
|
|
|
|
|
|
|
/* SID value */
|
|
|
|
struct in6_addr sid;
|
|
|
|
|
|
|
|
/* Endpoint behavior bound to the SID */
|
|
|
|
enum srv6_endpoint_behavior_codepoint behavior;
|
|
|
|
|
2023-03-14 02:47:40 +01:00
|
|
|
/* SRv6 SID structure */
|
|
|
|
struct isis_srv6_sid_structure structure;
|
|
|
|
|
2023-03-14 02:40:34 +01:00
|
|
|
/* Parent SRv6 locator */
|
2024-05-09 09:17:49 +02:00
|
|
|
struct srv6_locator *locator;
|
2023-03-14 02:40:34 +01:00
|
|
|
|
|
|
|
/* Backpointer to IS-IS area */
|
|
|
|
struct isis_area *area;
|
|
|
|
};
|
|
|
|
|
2023-02-15 11:23:34 +01:00
|
|
|
/* SRv6 Locator */
|
|
|
|
struct isis_srv6_locator {
|
|
|
|
struct isis_srv6_locator *next;
|
|
|
|
|
|
|
|
uint32_t metric;
|
|
|
|
|
|
|
|
uint8_t flags;
|
|
|
|
#define ISIS_SRV6_LOCATOR_FLAG_D 1 << 7
|
|
|
|
|
|
|
|
uint8_t algorithm;
|
|
|
|
struct prefix_ipv6 prefix;
|
|
|
|
|
|
|
|
struct list *srv6_sid;
|
|
|
|
};
|
|
|
|
|
2023-06-03 22:06:04 +02:00
|
|
|
/* SRv6 Adjacency-SID type */
|
|
|
|
enum srv6_adj_type {
|
|
|
|
ISIS_SRV6_ADJ_NORMAL = 0,
|
2024-04-19 15:46:20 +02:00
|
|
|
ISIS_SRV6_ADJ_BACKUP,
|
2023-06-03 22:06:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* SRv6 Adjacency. */
|
|
|
|
struct srv6_adjacency {
|
|
|
|
/* Adjacency type */
|
|
|
|
enum srv6_adj_type type;
|
|
|
|
|
|
|
|
/* SID flags */
|
|
|
|
uint8_t flags;
|
|
|
|
|
|
|
|
/* SID value */
|
|
|
|
struct in6_addr sid;
|
|
|
|
|
|
|
|
/* Endpoint behavior bound to the SID */
|
|
|
|
enum srv6_endpoint_behavior_codepoint behavior;
|
|
|
|
|
|
|
|
/* SRv6 SID structure */
|
|
|
|
struct isis_srv6_sid_structure structure;
|
|
|
|
|
|
|
|
/* Parent SRv6 locator */
|
2024-05-09 09:17:49 +02:00
|
|
|
struct srv6_locator *locator;
|
2023-06-03 22:06:04 +02:00
|
|
|
|
|
|
|
/* Adjacency-SID nexthop information */
|
|
|
|
struct in6_addr nexthop;
|
|
|
|
|
|
|
|
/* End.X SID TI-LFA backup nexthops */
|
|
|
|
struct list *backup_nexthops;
|
|
|
|
|
|
|
|
/* SRv6 (LAN) End.X SID Sub-TLV */
|
|
|
|
union {
|
|
|
|
struct isis_srv6_endx_sid_subtlv *endx_sid;
|
|
|
|
struct isis_srv6_lan_endx_sid_subtlv *lendx_sid;
|
|
|
|
} u;
|
|
|
|
|
|
|
|
/* Back pointer to IS-IS adjacency. */
|
|
|
|
struct isis_adjacency *adj;
|
|
|
|
};
|
|
|
|
|
2023-01-16 11:14:52 +01:00
|
|
|
/* Per-area IS-IS SRv6 Data Base (SRv6 DB) */
|
|
|
|
struct isis_srv6_db {
|
2024-05-09 09:17:49 +02:00
|
|
|
/* List of SRv6 Locator */
|
|
|
|
struct srv6_locator *srv6_locator;
|
2022-11-28 11:11:22 +01:00
|
|
|
|
2023-02-02 12:30:35 +01:00
|
|
|
/* List of SRv6 Locator chunks */
|
|
|
|
struct list *srv6_locator_chunks;
|
|
|
|
|
2023-02-02 12:32:10 +01:00
|
|
|
/* List of SRv6 SIDs allocated by the IS-IS instance */
|
|
|
|
struct list *srv6_sids;
|
|
|
|
|
2023-06-03 02:08:08 +02:00
|
|
|
/* List of SRv6 End.X SIDs allocated by the IS-IS instance */
|
|
|
|
struct list *srv6_endx_sids;
|
|
|
|
|
2022-11-28 11:11:22 +01:00
|
|
|
/* Area SRv6 configuration. */
|
|
|
|
struct {
|
|
|
|
/* Administrative status of SRv6 */
|
|
|
|
bool enabled;
|
2023-01-18 12:21:16 +01:00
|
|
|
|
2023-03-14 08:39:59 +01:00
|
|
|
/* Name of the SRv6 Locator */
|
|
|
|
char srv6_locator_name[SRV6_LOCNAME_SIZE];
|
|
|
|
|
2023-01-18 12:21:16 +01:00
|
|
|
/* Maximum Segments Left Depth supported by the router */
|
|
|
|
uint8_t max_seg_left_msd;
|
|
|
|
|
|
|
|
/* Maximum Maximum End Pop Depth supported by the router */
|
|
|
|
uint8_t max_end_pop_msd;
|
|
|
|
|
|
|
|
/* Maximum H.Encaps supported by the router */
|
|
|
|
uint8_t max_h_encaps_msd;
|
|
|
|
|
|
|
|
/* Maximum End D MSD supported by the router */
|
|
|
|
uint8_t max_end_d_msd;
|
2023-09-03 08:54:57 +02:00
|
|
|
|
|
|
|
/* Interface used for installing SRv6 SIDs into the data plane */
|
|
|
|
char srv6_ifname[IF_NAMESIZE];
|
2022-11-28 11:11:22 +01:00
|
|
|
} config;
|
2023-01-16 11:14:52 +01:00
|
|
|
};
|
|
|
|
|
2023-03-10 23:50:46 +01:00
|
|
|
bool isis_srv6_locator_unset(struct isis_area *area);
|
|
|
|
|
2023-09-03 08:54:57 +02:00
|
|
|
void isis_srv6_interface_set(struct isis_area *area, const char *ifname);
|
|
|
|
|
2023-02-22 10:51:33 +01:00
|
|
|
struct isis_srv6_sid *
|
2024-05-09 09:17:49 +02:00
|
|
|
isis_srv6_sid_alloc(struct isis_area *area, struct srv6_locator *locator,
|
2023-02-22 10:51:33 +01:00
|
|
|
enum srv6_endpoint_behavior_codepoint behavior,
|
2024-05-09 13:00:30 +02:00
|
|
|
struct in6_addr *sid_value);
|
2023-03-15 08:49:39 +01:00
|
|
|
extern void isis_srv6_sid_free(struct isis_srv6_sid *sid);
|
|
|
|
|
2025-02-15 10:39:30 +01:00
|
|
|
void isis_srv6_locators_request(void);
|
|
|
|
|
2023-01-16 11:24:29 +01:00
|
|
|
extern void isis_srv6_area_init(struct isis_area *area);
|
2022-11-28 10:59:35 +01:00
|
|
|
extern void isis_srv6_area_term(struct isis_area *area);
|
2023-01-16 11:24:29 +01:00
|
|
|
|
2022-11-30 15:06:42 +01:00
|
|
|
void isis_srv6_init(void);
|
2022-11-30 15:09:00 +01:00
|
|
|
void isis_srv6_term(void);
|
2022-11-30 15:06:42 +01:00
|
|
|
|
2023-02-15 11:49:11 +01:00
|
|
|
void isis_srv6_sid_structure2subsubtlv(
|
|
|
|
const struct isis_srv6_sid *sid,
|
|
|
|
struct isis_srv6_sid_structure_subsubtlv *structure_subsubtlv);
|
2023-02-15 11:43:03 +01:00
|
|
|
void isis_srv6_end_sid2subtlv(const struct isis_srv6_sid *sid,
|
|
|
|
struct isis_srv6_end_sid_subtlv *sid_subtlv);
|
2023-02-15 11:35:46 +01:00
|
|
|
void isis_srv6_locator2tlv(const struct isis_srv6_locator *loc,
|
|
|
|
struct isis_srv6_locator_tlv *loc_tlv);
|
|
|
|
|
2023-06-03 02:08:08 +02:00
|
|
|
void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup,
|
2024-05-09 13:00:30 +02:00
|
|
|
struct list *nexthops, struct in6_addr *sid_value);
|
|
|
|
void srv6_endx_sid_add(struct isis_adjacency *adj, struct in6_addr *sid_value);
|
2023-06-03 02:08:08 +02:00
|
|
|
void srv6_endx_sid_del(struct srv6_adjacency *sra);
|
|
|
|
struct srv6_adjacency *isis_srv6_endx_sid_find(struct isis_adjacency *adj,
|
|
|
|
enum srv6_adj_type type);
|
|
|
|
void isis_area_delete_backup_srv6_endx_sids(struct isis_area *area, int level);
|
|
|
|
|
2023-09-03 08:54:57 +02:00
|
|
|
int isis_srv6_ifp_up_notify(struct interface *ifp);
|
|
|
|
|
2022-11-28 10:34:10 +01:00
|
|
|
#endif /* _FRR_ISIS_SRV6_H */
|