Skip to content

Commit

Permalink
Merge pull request FRRouting#14373 from donaldsharp/evpn_bgp_bestpath…
Browse files Browse the repository at this point in the history
…_debug_issues

Evpn bgp bestpath debug issues
  • Loading branch information
ton31337 authored Sep 10, 2023
2 parents bee4e27 + 36f7852 commit 92a71ea
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
30 changes: 14 additions & 16 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ struct bgp_path_info *bgp_get_imported_bpi_ultimate(struct bgp_path_info *info)
*/
int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
struct bgp_path_info *exist, int *paths_eq,
struct bgp_maxpaths_cfg *mpath_cfg, int debug,
struct bgp_maxpaths_cfg *mpath_cfg, bool debug,
char *pfx_buf, afi_t afi, safi_t safi,
enum bgp_path_selection_reason *reason)
{
Expand Down Expand Up @@ -715,16 +715,6 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
* sticky flag.
*/
if (newattr->sticky != existattr->sticky) {
if (!debug) {
prefix2str(new_p, pfx_buf,
sizeof(*pfx_buf)
* PREFIX2STR_BUFFER);
bgp_path_info_path_with_addpath_rx_str(
new, new_buf, sizeof(new_buf));
bgp_path_info_path_with_addpath_rx_str(
exist, exist_buf, sizeof(exist_buf));
}

if (newattr->sticky && !existattr->sticky) {
*reason = bgp_path_selection_evpn_sticky_mac;
if (debug)
Expand Down Expand Up @@ -1503,9 +1493,14 @@ int bgp_evpn_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
{
enum bgp_path_selection_reason reason;
char pfx_buf[PREFIX2STR_BUFFER] = {};
bool debug = false;

return bgp_path_info_cmp(bgp, new, exist, paths_eq, NULL, 0, pfx_buf,
AFI_L2VPN, SAFI_EVPN, &reason);
if (debug)
prefix2str(bgp_dest_get_prefix(new->net), pfx_buf,
sizeof(pfx_buf));

return bgp_path_info_cmp(bgp, new, exist, paths_eq, NULL, debug,
pfx_buf, AFI_L2VPN, SAFI_EVPN, &reason);
}

/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
Expand All @@ -1519,8 +1514,10 @@ int bgp_path_info_cmp_compatible(struct bgp *bgp, struct bgp_path_info *new,
{
int paths_eq;
int ret;
ret = bgp_path_info_cmp(bgp, new, exist, &paths_eq, NULL, 0, pfx_buf,
afi, safi, reason);
bool debug = false;

ret = bgp_path_info_cmp(bgp, new, exist, &paths_eq, NULL, debug,
pfx_buf, afi, safi, reason);

if (paths_eq)
ret = 0;
Expand Down Expand Up @@ -2708,7 +2705,8 @@ void bgp_best_selection(struct bgp *bgp, struct bgp_dest *dest,
struct bgp_path_info *pi1;
struct bgp_path_info *pi2;
struct bgp_path_info *nextpi = NULL;
int paths_eq, do_mpath, debug;
int paths_eq, do_mpath;
bool debug;
struct list mp_list;
char pfx_buf[PREFIX2STR_BUFFER] = {};
char path_buf[PATH_ADDPATH_STR_BUFFER];
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ extern void bgp_path_info_add_with_caller(const char *caller,
extern void bgp_aggregate_free(struct bgp_aggregate *aggregate);
extern int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
struct bgp_path_info *exist, int *paths_eq,
struct bgp_maxpaths_cfg *mpath_cfg, int debug,
struct bgp_maxpaths_cfg *mpath_cfg, bool debug,
char *pfx_buf, afi_t afi, safi_t safi,
enum bgp_path_selection_reason *reason);
#define bgp_path_info_add(A, B) \
Expand Down
40 changes: 21 additions & 19 deletions lib/prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ static inline void ipv4_addr_copy(struct in_addr *dst,
#endif /*s6_addr32*/

/* Prototypes. */
extern int str2family(const char *);
extern int afi2family(afi_t);
extern afi_t family2afi(int);
extern int str2family(const char *string);
extern int afi2family(afi_t afi);
extern afi_t family2afi(int family);
extern const char *family2str(int family);
extern const char *safi2str(safi_t safi);
extern const char *afi2str(afi_t afi);
Expand Down Expand Up @@ -409,14 +409,15 @@ extern void prefix_free(struct prefix **p);
extern void prefix_free_lists(void *arg);
extern const char *prefix_family_str(union prefixconstptr pu);
extern int prefix_blen(union prefixconstptr pu);
extern int str2prefix(const char *, struct prefix *);
extern int str2prefix(const char *string, struct prefix *prefix);

#define PREFIX2STR_BUFFER PREFIX_STRLEN

extern void prefix_mcast_inet4_dump(const char *onfail, struct in_addr addr,
char *buf, int buf_size);
extern const char *prefix_sg2str(const struct prefix_sg *sg, char *str);
extern const char *prefix2str(union prefixconstptr, char *, int);
extern const char *prefix2str(union prefixconstptr upfx, char *buffer,
int size);
extern int evpn_type5_prefix_match(const struct prefix *evpn_pfx,
const struct prefix *match_pfx);
extern int prefix_match(union prefixconstptr unet, union prefixconstptr upfx);
Expand All @@ -437,36 +438,37 @@ extern bool evpn_addr_same(const struct evpn_addr *e1, const struct evpn_addr *e
#define prefix_copy(a, b) ({ memset(a, 0, sizeof(*a)); prefix_copy(a, b); })
#endif

extern struct prefix *sockunion2hostprefix(const union sockunion *,
extern struct prefix *sockunion2hostprefix(const union sockunion *su,
struct prefix *p);
extern void prefix2sockunion(const struct prefix *, union sockunion *);
extern void prefix2sockunion(const struct prefix *p, union sockunion *su);

extern int str2prefix_eth(const char *, struct prefix_eth *);
extern int str2prefix_eth(const char *string, struct prefix_eth *p);

extern struct prefix_ipv4 *prefix_ipv4_new(void);
extern void prefix_ipv4_free(struct prefix_ipv4 **p);
extern int str2prefix_ipv4(const char *, struct prefix_ipv4 *);
extern void apply_mask_ipv4(struct prefix_ipv4 *);
extern int str2prefix_ipv4(const char *string, struct prefix_ipv4 *p);
extern void apply_mask_ipv4(struct prefix_ipv4 *p);

extern int prefix_ipv4_any(const struct prefix_ipv4 *);
extern void apply_classful_mask_ipv4(struct prefix_ipv4 *);
extern int prefix_ipv4_any(const struct prefix_ipv4 *p);
extern void apply_classful_mask_ipv4(struct prefix_ipv4 *p);

extern uint8_t ip_masklen(struct in_addr);
extern void masklen2ip(const int, struct in_addr *);
extern uint8_t ip_masklen(struct in_addr addr);
extern void masklen2ip(const int length, struct in_addr *addr);
/* given the address of a host on a network and the network mask length,
* calculate the broadcast address for that network;
* special treatment for /31 according to RFC3021 section 3.3 */
extern in_addr_t ipv4_broadcast_addr(in_addr_t hostaddr, int masklen);

extern int netmask_str2prefix_str(const char *, const char *, char *, size_t);
extern int netmask_str2prefix_str(const char *net_str, const char *mask_str,
char *prefix_str, size_t prefix_str_len);

extern struct prefix_ipv6 *prefix_ipv6_new(void);
extern void prefix_ipv6_free(struct prefix_ipv6 **p);
extern int str2prefix_ipv6(const char *, struct prefix_ipv6 *);
extern void apply_mask_ipv6(struct prefix_ipv6 *);
extern int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p);
extern void apply_mask_ipv6(struct prefix_ipv6 *p);

extern int ip6_masklen(struct in6_addr);
extern void masklen2ip6(const int, struct in6_addr *);
extern int ip6_masklen(struct in6_addr netmask);
extern void masklen2ip6(const int masklen, struct in6_addr *netmask);

extern int is_zero_mac(const struct ethaddr *mac);
extern bool is_mcast_mac(const struct ethaddr *mac);
Expand Down

0 comments on commit 92a71ea

Please sign in to comment.