{
int debug = BGP_DEBUG(vpn, VPN_LEAK_LABEL);
enum seg6local_action_t act;
- struct seg6local_context ctx = {{0}};
+ struct seg6local_context ctx = { {0} };
struct in6_addr *tovpn_sid = NULL;
struct in6_addr *tovpn_sid_ls = NULL;
struct vrf *vrf;
if (bgp->vrf_id == VRF_UNKNOWN) {
if (debug)
- zlog_debug("%s: vrf %s: afi %s: vrf_id not set, "
- "can't set zebra vrf label",
+ zlog_debug("%s: vrf %s: afi %s: vrf_id not set, can't set zebra vrf label",
__func__, bgp->name_pretty, afi2str(afi));
return;
}
if (bgp->vrf_id == VRF_UNKNOWN) {
if (debug)
- zlog_debug("%s: vrf %s: afi %s: vrf_id not set, "
- "can't set zebra vrf label",
+ zlog_debug("%s: vrf %s: afi %s: vrf_id not set, can't set zebra vrf label",
__func__, bgp->name_pretty, afi2str(afi));
return;
}
{
struct listnode *node;
struct bgp_srv6_function *func;
+
for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func))
if (sid_same(&func->sid, sid))
return true;
return false;
}
-/* if index != 0: try to allocate as index-mode
- * else: try to allocate as auto-mode */
+/*
+ * if index != 0: try to allocate as index-mode
+ * else: try to allocate as auto-mode
+ */
static bool alloc_new_sid(struct bgp *bgp, uint32_t index,
struct in6_addr *sid)
{
return false;
alloced = true;
break;
- } else {
- for (size_t i=1; i<255; i++) {
- sid_buf.s6_addr16[7] = i;
- if (sid_exist(bgp, &sid_buf))
- continue;
- alloced = true;
- break;
- }
+ }
+
+ for (size_t i = 1; i < 255; i++) {
+ sid_buf.s6_addr16[7] = i;
+ if (sid_exist(bgp, &sid_buf))
+ continue;
+ alloced = true;
+ break;
}
}
if (bgp_vrf->vpn_policy[afi].tovpn_sid)
return;
- /* skip when bgp vpn instance ins't allocated
- * or srv6 locator chunk isn't allocated */
+ /*
+ * skip when bgp vpn instance ins't allocated
+ * or srv6 locator chunk isn't allocated
+ */
if (!bgp_vpn || !bgp_vpn->srv6_locator_chunks || !bgp_vrf)
return;
afi2str(afi));
}
bgp_vrf->vpn_policy[afi].tovpn_sid = sid;
- return;
}
static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2)
}
extra = bgp_path_info_extra_get(bpi);
- for (i = 0; i < num_sids; i++) {
+ for (i = 0; i < num_sids; i++)
memcpy(&extra->sid[i], &sid[i], sizeof(struct in6_addr));
- }
extra->num_sids = num_sids;
}
struct bgp_path_info *bpi;
struct bgp_path_info *bpi_ultimate;
struct bgp_path_info *new;
-
uint32_t num_sids = 0;
+
if (new_attr->srv6_l3vpn || new_attr->srv6_vpn)
num_sids = 1;
*/
if (num_sids) {
if (new_attr->srv6_l3vpn)
- setsids(bpi, &new_attr->srv6_l3vpn->sid, num_sids);
+ setsids(bpi, &new_attr->srv6_l3vpn->sid,
+ num_sids);
else if (new_attr->srv6_vpn)
- setsids(bpi, &new_attr->srv6_vpn->sid, num_sids);
+ setsids(bpi, &new_attr->srv6_vpn->sid,
+ num_sids);
}
if (nexthop_self_flag)
/* Set SID for SRv6 VPN */
if (!sid_zero(bgp_vrf->vpn_policy[afi].tovpn_sid)) {
static_attr.srv6_l3vpn = XCALLOC(MTYPE_BGP_SRV6_L3VPN,
- sizeof(struct bgp_attr_srv6_l3vpn)* 100);
+ sizeof(struct bgp_attr_srv6_l3vpn) * 100);
static_attr.srv6_l3vpn->sid_flags = 0x00;
static_attr.srv6_l3vpn->endpoint_behavior = 0xffff;
memcpy(&static_attr.srv6_l3vpn->sid,
BGP_VPN_POLICY_TOVPN_SID_AUTO)))
return CMD_SUCCESS;
- /* mode change between sid_idx and sid_auto isn't supported.
- * user must negate sid vpn export when they want to change
- * the mode */
+ /*
+ * mode change between sid_idx and sid_auto isn't supported.
+ * user must negate sid vpn export when they want to change the mode
+ */
if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0)
|| (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags,
BGP_VPN_POLICY_TOVPN_SID_AUTO))) {
"Specify SRv6 locator\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
+ int ret;
if (strlen(bgp->srv6_locator_name) > 0
&& strcmp(name, bgp->srv6_locator_name) != 0) {
vty_out(vty, "srv6 locator is already configured\n");
return CMD_WARNING_CONFIG_FAILED;
- } else
- snprintf(bgp->srv6_locator_name,
- sizeof(bgp->srv6_locator_name), "%s", name);
+ }
+
+ snprintf(bgp->srv6_locator_name,
+ sizeof(bgp->srv6_locator_name), "%s", name);
- int ret = bgp_zebra_srv6_manager_get_locator_chunk(name);
+ ret = bgp_zebra_srv6_manager_get_locator_chunk(name);
if (ret < 0)
return CMD_WARNING_CONFIG_FAILED;
uint16_t instance;
uint16_t len;
char name[256] = {0};
- struct prefix_ipv6 *chunk = NULL;
- chunk = prefix_ipv6_new();
+ struct bgp *bgp = bgp_get_default();
+ struct listnode *node;
+ struct prefix_ipv6 *c;
+ struct prefix_ipv6 *chunk = prefix_ipv6_new();
s = zclient->ibuf;
STREAM_GETC(s, proto);
return;
}
- struct bgp *bgp = bgp_get_default();
if (strcmp(bgp->srv6_locator_name, name) != 0) {
zlog_info("name unmatch %s:%s",
bgp->srv6_locator_name, name);
return;
}
- struct listnode *node;
- struct prefix_ipv6 *c;
for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, c)) {
if (!prefix_cmp(c, chunk))
return;
free(chunk);
zlog_err("%s: can't get locator_chunk!!", __func__);
- return;
}
void bgp_zebra_init(struct thread_master *master, unsigned short instance)
zclient->iptable_notify_owner = iptable_notify_owner;
zclient->route_notify_owner = bgp_zebra_route_notify_owner;
zclient->instance = instance;
- zclient->process_srv6_locator_chunk = bgp_zebra_process_srv6_locator_chunk;
+ zclient->process_srv6_locator_chunk =
+ bgp_zebra_process_srv6_locator_chunk;
}
void bgp_zebra_destroy(void)