mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-04 14:11:48 +00:00
bgpd: update logic to allocate SRv6 locator
For the later patches, this patch changes the behavior of alloc_new sid so that bgpd record not only SID for VRF, but also Locator of SID. Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
This commit is contained in:
parent
41ff140670
commit
921c7e77b0
@ -520,7 +520,7 @@ static bool sid_exist(struct bgp *bgp, const struct in6_addr *sid)
|
|||||||
* else: try to allocate as auto-mode
|
* else: try to allocate as auto-mode
|
||||||
*/
|
*/
|
||||||
static uint32_t alloc_new_sid(struct bgp *bgp, uint32_t index,
|
static uint32_t alloc_new_sid(struct bgp *bgp, uint32_t index,
|
||||||
struct in6_addr *sid)
|
struct in6_addr *sid_locator)
|
||||||
{
|
{
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct prefix_ipv6 *chunk;
|
struct prefix_ipv6 *chunk;
|
||||||
@ -528,10 +528,11 @@ static uint32_t alloc_new_sid(struct bgp *bgp, uint32_t index,
|
|||||||
bool alloced = false;
|
bool alloced = false;
|
||||||
int label = 0;
|
int label = 0;
|
||||||
|
|
||||||
if (!bgp || !sid)
|
if (!bgp || !sid_locator)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) {
|
for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) {
|
||||||
|
*sid_locator = chunk->prefix;
|
||||||
sid_buf = chunk->prefix;
|
sid_buf = chunk->prefix;
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
label = index << 12;
|
label = index << 12;
|
||||||
@ -556,7 +557,6 @@ static uint32_t alloc_new_sid(struct bgp *bgp, uint32_t index,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sid_register(bgp, &sid_buf, bgp->srv6_locator_name);
|
sid_register(bgp, &sid_buf, bgp->srv6_locator_name);
|
||||||
*sid = sid_buf;
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ void ensure_vrf_tovpn_sid(struct bgp *bgp_vpn, struct bgp *bgp_vrf, afi_t afi)
|
|||||||
{
|
{
|
||||||
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
|
int debug = BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF);
|
||||||
char buf[256];
|
char buf[256];
|
||||||
struct in6_addr *sid;
|
struct in6_addr *tovpn_sid, *tovpn_sid_locator;
|
||||||
uint32_t tovpn_sid_index = 0, tovpn_sid_transpose_label;
|
uint32_t tovpn_sid_index = 0, tovpn_sid_transpose_label;
|
||||||
bool tovpn_sid_auto = false;
|
bool tovpn_sid_auto = false;
|
||||||
|
|
||||||
@ -598,24 +598,33 @@ void ensure_vrf_tovpn_sid(struct bgp *bgp_vpn, struct bgp *bgp_vrf, afi_t afi)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sid = XCALLOC(MTYPE_BGP_SRV6_SID, sizeof(struct in6_addr));
|
tovpn_sid_locator =
|
||||||
|
XCALLOC(MTYPE_BGP_SRV6_SID, sizeof(struct in6_addr));
|
||||||
tovpn_sid_transpose_label =
|
tovpn_sid_transpose_label =
|
||||||
alloc_new_sid(bgp_vpn, tovpn_sid_index, sid);
|
alloc_new_sid(bgp_vpn, tovpn_sid_index, tovpn_sid_locator);
|
||||||
if (tovpn_sid_transpose_label == 0) {
|
if (tovpn_sid_transpose_label == 0) {
|
||||||
zlog_debug("%s: not allocated new sid for vrf %s: afi %s",
|
zlog_debug("%s: not allocated new sid for vrf %s: afi %s",
|
||||||
__func__, bgp_vrf->name_pretty, afi2str(afi));
|
__func__, bgp_vrf->name_pretty, afi2str(afi));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tovpn_sid = XCALLOC(MTYPE_BGP_SRV6_SID, sizeof(struct in6_addr));
|
||||||
|
*tovpn_sid = *tovpn_sid_locator;
|
||||||
|
transpose_sid(tovpn_sid, tovpn_sid_transpose_label,
|
||||||
|
BGP_PREFIX_SID_SRV6_TRANSPOSITION_OFFSET,
|
||||||
|
BGP_PREFIX_SID_SRV6_TRANSPOSITION_LENGTH);
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
inet_ntop(AF_INET6, sid, buf, sizeof(buf));
|
inet_ntop(AF_INET6, tovpn_sid, buf, sizeof(buf));
|
||||||
zlog_debug("%s: new sid %s allocated for vrf %s: afi %s",
|
zlog_debug("%s: new sid %s allocated for vrf %s: afi %s",
|
||||||
__func__, buf, bgp_vrf->name_pretty,
|
__func__, buf, bgp_vrf->name_pretty,
|
||||||
afi2str(afi));
|
afi2str(afi));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bgp_vrf->vpn_policy[afi].tovpn_sid = tovpn_sid;
|
||||||
|
bgp_vrf->vpn_policy[afi].tovpn_sid_locator = tovpn_sid_locator;
|
||||||
bgp_vrf->vpn_policy[afi].tovpn_sid_transpose_label =
|
bgp_vrf->vpn_policy[afi].tovpn_sid_transpose_label =
|
||||||
tovpn_sid_transpose_label;
|
tovpn_sid_transpose_label;
|
||||||
bgp_vrf->vpn_policy[afi].tovpn_sid = sid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void transpose_sid(struct in6_addr *sid, uint32_t label, uint8_t offset,
|
void transpose_sid(struct in6_addr *sid, uint32_t label, uint8_t offset,
|
||||||
|
@ -234,6 +234,7 @@ struct vpn_policy {
|
|||||||
*/
|
*/
|
||||||
uint32_t tovpn_sid_index; /* unset => set to 0 */
|
uint32_t tovpn_sid_index; /* unset => set to 0 */
|
||||||
struct in6_addr *tovpn_sid;
|
struct in6_addr *tovpn_sid;
|
||||||
|
struct in6_addr *tovpn_sid_locator;
|
||||||
uint32_t tovpn_sid_transpose_label;
|
uint32_t tovpn_sid_transpose_label;
|
||||||
struct in6_addr *tovpn_zebra_vrf_sid_last_sent;
|
struct in6_addr *tovpn_zebra_vrf_sid_last_sent;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user