diff options
author | Hiroki Shirokura <slank.dev@gmail.com> | 2021-02-24 11:10:06 +0100 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2021-06-02 16:24:48 +0200 |
commit | 7de4c88525f9f234fbf68f7fdbd7fcdf4fc2aacd (patch) | |
tree | 467ecd8e0f09cc6f6c8091aec059a0c77f1be56a /bgpd | |
parent | topotests: bgp_srv6l3vpn_to_bgp_vrf (step4) (diff) | |
download | frr-7de4c88525f9f234fbf68f7fdbd7fcdf4fc2aacd.tar.xz frr-7de4c88525f9f234fbf68f7fdbd7fcdf4fc2aacd.zip |
*: fix code format accourding to checkpatch
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_mplsvpn.c | 51 | ||||
-rw-r--r-- | bgpd/bgp_mplsvpn.h | 4 | ||||
-rw-r--r-- | bgpd/bgp_nb_config.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 17 | ||||
-rw-r--r-- | bgpd/bgp_zebra.c | 13 |
5 files changed, 49 insertions, 44 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 2d0c9ec01..33266ef51 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -366,7 +366,7 @@ void vpn_leak_zebra_vrf_sid_update(struct bgp *bgp, afi_t afi) { 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; @@ -374,8 +374,7 @@ void vpn_leak_zebra_vrf_sid_update(struct bgp *bgp, afi_t afi) 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; } @@ -419,8 +418,7 @@ void vpn_leak_zebra_vrf_sid_withdraw(struct bgp *bgp, afi_t afi) 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; } @@ -513,14 +511,17 @@ static bool sid_exist(struct bgp *bgp, const struct in6_addr *sid) { 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) { @@ -540,14 +541,14 @@ static bool alloc_new_sid(struct bgp *bgp, uint32_t index, 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; } } @@ -576,8 +577,10 @@ void ensure_vrf_tovpn_sid(struct bgp *bgp_vpn, struct bgp *bgp_vrf, afi_t afi) 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; @@ -611,7 +614,6 @@ void ensure_vrf_tovpn_sid(struct bgp *bgp_vpn, struct bgp *bgp_vrf, afi_t afi) afi2str(afi)); } bgp_vrf->vpn_policy[afi].tovpn_sid = sid; - return; } static bool ecom_intersect(struct ecommunity *e1, struct ecommunity *e2) @@ -705,9 +707,8 @@ static void setsids(struct bgp_path_info *bpi, } 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; } @@ -726,8 +727,8 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ 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; @@ -813,9 +814,11 @@ leak_update(struct bgp *bgp, /* destination bgp instance */ */ 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) @@ -1149,7 +1152,7 @@ void vpn_leak_from_vrf_update(struct bgp *bgp_vpn, /* to */ /* 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, diff --git a/bgpd/bgp_mplsvpn.h b/bgpd/bgp_mplsvpn.h index 172372bdf..38193721b 100644 --- a/bgpd/bgp_mplsvpn.h +++ b/bgpd/bgp_mplsvpn.h @@ -244,8 +244,8 @@ static inline void vpn_leak_postchange(vpn_policy_direction_t direction, ensure_vrf_tovpn_sid(bgp_vpn, bgp_vrf, afi); if (sid_diff(bgp_vrf->vpn_policy[afi].tovpn_sid, - bgp_vrf->vpn_policy[afi]. - tovpn_zebra_vrf_sid_last_sent)) { + bgp_vrf->vpn_policy[afi] + .tovpn_zebra_vrf_sid_last_sent)) { vpn_leak_zebra_vrf_sid_update(bgp_vrf, afi); } diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index e83b9e20a..5189d7ba8 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -11451,8 +11451,8 @@ int bgp_global_afi_safis_afi_safi_ipv6_unicast_vpn_config_import_vpn_modify( if (!bgp) return NB_OK; - if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type - && BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { + if (bgp->inst_type != BGP_INSTANCE_TYPE_VRF + && bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) { snprintf( args->errmsg, args->errmsg_len, "import|export vpn valid only for bgp vrf or default instance"); @@ -11491,8 +11491,8 @@ int bgp_global_afi_safis_afi_safi_ipv6_unicast_vpn_config_export_vpn_modify( if (!bgp) return NB_OK; - if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type - && BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { + if (bgp->inst_type != BGP_INSTANCE_TYPE_VRF + && bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) { snprintf( args->errmsg, args->errmsg_len, "import|export vpn valid only for bgp vrf or default instance"); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 03c4e6959..db3a15d48 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9269,9 +9269,10 @@ DEFPY (af_sid_vpn_export, 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))) { @@ -9948,16 +9949,18 @@ DEFPY (bgp_srv6_locator, "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; diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 8349358da..7e2dfed64 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -3004,8 +3004,10 @@ static void bgp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS) 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); @@ -3026,15 +3028,12 @@ static void bgp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS) 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; @@ -3048,7 +3047,6 @@ stream_failure: free(chunk); zlog_err("%s: can't get locator_chunk!!", __func__); - return; } void bgp_zebra_init(struct thread_master *master, unsigned short instance) @@ -3093,7 +3091,8 @@ 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) |