mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-17 14:27:30 +00:00
bgpd: move label allocation code to a specific function
The label allocation mechanism is called implicitly for labeled unicast paths. The check should be explicit, because the current patch set will extend the mechanism for mpls vpn paths, and the code should explicitly tell which safi calls which code. Fix this implicit call by checking the safi value. Move the code to a specific function. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
76c803171b
commit
28d5c6e531
102
bgpd/bgp_route.c
102
bgpd/bgp_route.c
@ -3097,6 +3097,58 @@ need_null_label:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Right now, since we only deal with per-prefix labels, it is not
|
||||||
|
* necessary to do this upon changes to best path. Exceptions:
|
||||||
|
* - label index has changed -> recalculate resulting label
|
||||||
|
* - path_info sub_type changed -> switch to/from null label value
|
||||||
|
* - no valid label (due to removed static label binding) -> get new one
|
||||||
|
*/
|
||||||
|
static void bgp_lu_handle_label_allocation(struct bgp *bgp,
|
||||||
|
struct bgp_dest *dest,
|
||||||
|
struct bgp_path_info *new_select,
|
||||||
|
struct bgp_path_info *old_select,
|
||||||
|
afi_t afi)
|
||||||
|
{
|
||||||
|
mpls_label_t mpls_label_null;
|
||||||
|
|
||||||
|
if (bgp->allocate_mpls_labels[afi][SAFI_UNICAST]) {
|
||||||
|
if (new_select) {
|
||||||
|
if (!old_select ||
|
||||||
|
bgp_label_index_differs(new_select, old_select) ||
|
||||||
|
new_select->sub_type != old_select->sub_type ||
|
||||||
|
!bgp_is_valid_label(&dest->local_label)) {
|
||||||
|
/* control label imposition for local
|
||||||
|
* routes, aggregate and redistributed
|
||||||
|
* routes
|
||||||
|
*/
|
||||||
|
mpls_label_null = MPLS_LABEL_IMPLICIT_NULL;
|
||||||
|
if (bgp_lu_need_null_label(bgp, new_select, afi,
|
||||||
|
&mpls_label_null)) {
|
||||||
|
if (CHECK_FLAG(
|
||||||
|
dest->flags,
|
||||||
|
BGP_NODE_REGISTERED_FOR_LABEL) ||
|
||||||
|
CHECK_FLAG(
|
||||||
|
dest->flags,
|
||||||
|
BGP_NODE_LABEL_REQUESTED))
|
||||||
|
bgp_unregister_for_label(dest);
|
||||||
|
dest->local_label = mpls_lse_encode(
|
||||||
|
mpls_label_null, 0, 0, 1);
|
||||||
|
bgp_set_valid_label(&dest->local_label);
|
||||||
|
} else
|
||||||
|
bgp_register_for_label(dest,
|
||||||
|
new_select);
|
||||||
|
}
|
||||||
|
} else if (CHECK_FLAG(dest->flags,
|
||||||
|
BGP_NODE_REGISTERED_FOR_LABEL) ||
|
||||||
|
CHECK_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED)) {
|
||||||
|
bgp_unregister_for_label(dest);
|
||||||
|
}
|
||||||
|
} else if (CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL) ||
|
||||||
|
CHECK_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED)) {
|
||||||
|
bgp_unregister_for_label(dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* old_select = The old best path
|
* old_select = The old best path
|
||||||
* new_select = the new best path
|
* new_select = the new best path
|
||||||
@ -3123,7 +3175,6 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
|
|||||||
struct bgp_path_info *old_select;
|
struct bgp_path_info *old_select;
|
||||||
struct bgp_path_info_pair old_and_new;
|
struct bgp_path_info_pair old_and_new;
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
mpls_label_t mpls_label_null;
|
|
||||||
|
|
||||||
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
|
if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS)) {
|
||||||
if (dest)
|
if (dest)
|
||||||
@ -3174,49 +3225,12 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
|
|||||||
old_select = old_and_new.old;
|
old_select = old_and_new.old;
|
||||||
new_select = old_and_new.new;
|
new_select = old_and_new.new;
|
||||||
|
|
||||||
/* Do we need to allocate or free labels?
|
if (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST)
|
||||||
* Right now, since we only deal with per-prefix labels, it is not
|
/* label unicast path :
|
||||||
* necessary to do this upon changes to best path. Exceptions:
|
* Do we need to allocate or free labels?
|
||||||
* - label index has changed -> recalculate resulting label
|
*/
|
||||||
* - path_info sub_type changed -> switch to/from null label value
|
bgp_lu_handle_label_allocation(bgp, dest, new_select,
|
||||||
* - no valid label (due to removed static label binding) -> get new one
|
old_select, afi);
|
||||||
*/
|
|
||||||
if (bgp->allocate_mpls_labels[afi][safi]) {
|
|
||||||
if (new_select) {
|
|
||||||
if (!old_select
|
|
||||||
|| bgp_label_index_differs(new_select, old_select)
|
|
||||||
|| new_select->sub_type != old_select->sub_type
|
|
||||||
|| !bgp_is_valid_label(&dest->local_label)) {
|
|
||||||
/* control label imposition for local routes,
|
|
||||||
* aggregate and redistributed routes
|
|
||||||
*/
|
|
||||||
mpls_label_null = MPLS_LABEL_IMPLICIT_NULL;
|
|
||||||
if (bgp_lu_need_null_label(bgp, new_select, afi,
|
|
||||||
&mpls_label_null)) {
|
|
||||||
if (CHECK_FLAG(
|
|
||||||
dest->flags,
|
|
||||||
BGP_NODE_REGISTERED_FOR_LABEL)
|
|
||||||
|| CHECK_FLAG(
|
|
||||||
dest->flags,
|
|
||||||
BGP_NODE_LABEL_REQUESTED))
|
|
||||||
bgp_unregister_for_label(dest);
|
|
||||||
dest->local_label = mpls_lse_encode(
|
|
||||||
mpls_label_null, 0, 0, 1);
|
|
||||||
bgp_set_valid_label(&dest->local_label);
|
|
||||||
} else
|
|
||||||
bgp_register_for_label(dest,
|
|
||||||
new_select);
|
|
||||||
}
|
|
||||||
} else if (CHECK_FLAG(dest->flags,
|
|
||||||
BGP_NODE_REGISTERED_FOR_LABEL)
|
|
||||||
|| CHECK_FLAG(dest->flags,
|
|
||||||
BGP_NODE_LABEL_REQUESTED)) {
|
|
||||||
bgp_unregister_for_label(dest);
|
|
||||||
}
|
|
||||||
} else if (CHECK_FLAG(dest->flags, BGP_NODE_REGISTERED_FOR_LABEL)
|
|
||||||
|| CHECK_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED)) {
|
|
||||||
bgp_unregister_for_label(dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
|
Loading…
Reference in New Issue
Block a user