mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 07:15:33 +00:00
bgpd: add bgp_path_info_has_valid_label()
Add bgp_path_has_valid_label to check that a path_info has a valid label. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
parent
747da057e8
commit
7a513e3361
@ -4130,8 +4130,7 @@ bool bgp_mplsvpn_path_uses_valid_mpls_label(struct bgp_path_info *pi)
|
|||||||
/* prefix_sid attribute */
|
/* prefix_sid attribute */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!pi->extra || !pi->extra->num_labels ||
|
if (!bgp_path_info_has_valid_label(pi))
|
||||||
!bgp_is_valid_label(&pi->extra->label[0]))
|
|
||||||
/* invalid MPLS label */
|
/* invalid MPLS label */
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -324,6 +324,16 @@ struct bgp_path_info_extra *bgp_path_info_extra_get(struct bgp_path_info *pi)
|
|||||||
return pi->extra;
|
return pi->extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bgp_path_info_has_valid_label(const struct bgp_path_info *path)
|
||||||
|
{
|
||||||
|
if (!path->extra)
|
||||||
|
return false;
|
||||||
|
if (!path->extra->num_labels)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return bgp_is_valid_label(&path->extra->label[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Free bgp route information. */
|
/* Free bgp route information. */
|
||||||
void bgp_path_info_free_with_caller(const char *name,
|
void bgp_path_info_free_with_caller(const char *name,
|
||||||
struct bgp_path_info *path)
|
struct bgp_path_info *path)
|
||||||
@ -1361,10 +1371,8 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
|
|||||||
*/
|
*/
|
||||||
bool new_label_valid, exist_label_valid;
|
bool new_label_valid, exist_label_valid;
|
||||||
|
|
||||||
new_label_valid = new->extra && new->extra->num_labels &&
|
new_label_valid = bgp_path_info_has_valid_label(new);
|
||||||
bgp_is_valid_label(&new->extra->label[0]);
|
exist_label_valid = bgp_path_info_has_valid_label(exist);
|
||||||
exist_label_valid = exist->extra && exist->extra->num_labels &&
|
|
||||||
bgp_is_valid_label(&exist->extra->label[0]);
|
|
||||||
|
|
||||||
if (new_label_valid != exist_label_valid) {
|
if (new_label_valid != exist_label_valid) {
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -3450,8 +3458,7 @@ static bool bgp_lu_need_null_label(struct bgp *bgp,
|
|||||||
|| new_select->sub_type == BGP_ROUTE_AGGREGATE
|
|| new_select->sub_type == BGP_ROUTE_AGGREGATE
|
||||||
|| new_select->sub_type == BGP_ROUTE_REDISTRIBUTE)
|
|| new_select->sub_type == BGP_ROUTE_REDISTRIBUTE)
|
||||||
goto need_null_label;
|
goto need_null_label;
|
||||||
else if (new_select->extra && new_select->extra->num_labels &&
|
else if (bgp_path_info_has_valid_label(new_select))
|
||||||
bgp_is_valid_label(&new_select->extra->label[0]))
|
|
||||||
return false;
|
return false;
|
||||||
need_null_label:
|
need_null_label:
|
||||||
if (label == NULL)
|
if (label == NULL)
|
||||||
@ -10064,8 +10071,7 @@ void route_vty_out_tag(struct vty *vty, const struct prefix *p,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path->extra->num_labels &&
|
if (bgp_path_info_has_valid_label(path)) {
|
||||||
bgp_is_valid_label(&path->extra->label[0])) {
|
|
||||||
label = decode_label(&path->extra->label[0]);
|
label = decode_label(&path->extra->label[0]);
|
||||||
if (json) {
|
if (json) {
|
||||||
json_object_int_add(json_out, "notag", label);
|
json_object_int_add(json_out, "notag", label);
|
||||||
@ -11270,8 +11276,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
|
|||||||
bgp_damp_info_vty(vty, bgp, path, afi, safi, json_path);
|
bgp_damp_info_vty(vty, bgp, path, afi, safi, json_path);
|
||||||
|
|
||||||
/* Remote Label */
|
/* Remote Label */
|
||||||
if (path->extra && bgp_is_valid_label(&path->extra->label[0])
|
if (bgp_path_info_has_valid_label(path) &&
|
||||||
&& (safi != SAFI_EVPN && !is_route_parent_evpn(path))) {
|
(safi != SAFI_EVPN && !is_route_parent_evpn(path))) {
|
||||||
mpls_lse_decode(path->extra->label[0], &label, &ttl, &exp,
|
mpls_lse_decode(path->extra->label[0], &label, &ttl, &exp,
|
||||||
&bos);
|
&bos);
|
||||||
|
|
||||||
|
@ -753,6 +753,7 @@ extern void bgp_path_info_delete(struct bgp_dest *dest,
|
|||||||
struct bgp_path_info *pi);
|
struct bgp_path_info *pi);
|
||||||
extern struct bgp_path_info_extra *
|
extern struct bgp_path_info_extra *
|
||||||
bgp_path_info_extra_get(struct bgp_path_info *path);
|
bgp_path_info_extra_get(struct bgp_path_info *path);
|
||||||
|
extern bool bgp_path_info_has_valid_label(const struct bgp_path_info *path);
|
||||||
extern void bgp_path_info_set_flag(struct bgp_dest *dest,
|
extern void bgp_path_info_set_flag(struct bgp_dest *dest,
|
||||||
struct bgp_path_info *path, uint32_t flag);
|
struct bgp_path_info *path, uint32_t flag);
|
||||||
extern void bgp_path_info_unset_flag(struct bgp_dest *dest,
|
extern void bgp_path_info_unset_flag(struct bgp_dest *dest,
|
||||||
|
Loading…
Reference in New Issue
Block a user