mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 08:57:29 +00:00
bgpd: display more than one FS entre per IP
because the IP destination criterium may match several entries, the show command may return more than one entry. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
8805512419
commit
63a0b7a9f1
@ -50,4 +50,12 @@ extern void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
|
|||||||
extern int bgp_fs_config_write_pbr(struct vty *vty, struct bgp *bgp,
|
extern int bgp_fs_config_write_pbr(struct vty *vty, struct bgp *bgp,
|
||||||
afi_t afi, safi_t safi);
|
afi_t afi, safi_t safi);
|
||||||
|
|
||||||
|
extern int bgp_flowspec_display_match_per_ip(afi_t afi,
|
||||||
|
struct bgp_table *rib,
|
||||||
|
struct prefix *match,
|
||||||
|
int prefix_check,
|
||||||
|
struct vty *vty,
|
||||||
|
uint8_t use_json,
|
||||||
|
json_object *json_paths);
|
||||||
|
|
||||||
#endif /* _FRR_BGP_FLOWSPEC_H */
|
#endif /* _FRR_BGP_FLOWSPEC_H */
|
||||||
|
@ -73,9 +73,9 @@ static int bgp_flowspec_call_non_opaque_decode(uint8_t *nlri_content, int len,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool bgp_flowspec_contains_prefix(struct prefix *pfs,
|
bool bgp_flowspec_contains_prefix(struct prefix *pfs,
|
||||||
struct prefix *input,
|
struct prefix *input,
|
||||||
int prefix_check)
|
int prefix_check)
|
||||||
{
|
{
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
int type;
|
int type;
|
||||||
@ -564,24 +564,3 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
|
|||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct bgp_node *bgp_flowspec_get_match_per_ip(afi_t afi,
|
|
||||||
struct bgp_table *rib,
|
|
||||||
struct prefix *match,
|
|
||||||
int prefix_check)
|
|
||||||
{
|
|
||||||
struct bgp_node *rn;
|
|
||||||
struct prefix *prefix;
|
|
||||||
|
|
||||||
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
|
|
||||||
prefix = &rn->p;
|
|
||||||
|
|
||||||
if (prefix->family != AF_FLOWSPEC)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check))
|
|
||||||
return rn;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
@ -50,8 +50,8 @@ struct bgp_pbr_entry_main;
|
|||||||
extern int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
|
extern int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,
|
||||||
struct bgp_pbr_entry_main *bpem);
|
struct bgp_pbr_entry_main *bpem);
|
||||||
|
|
||||||
extern struct bgp_node *bgp_flowspec_get_match_per_ip(afi_t afi,
|
extern bool bgp_flowspec_contains_prefix(struct prefix *pfs,
|
||||||
struct bgp_table *rib,
|
struct prefix *input,
|
||||||
struct prefix *match,
|
int prefix_check);
|
||||||
int prefix_check);
|
|
||||||
#endif /* _FRR_BGP_FLOWSPEC_UTIL_H */
|
#endif /* _FRR_BGP_FLOWSPEC_UTIL_H */
|
||||||
|
@ -542,6 +542,36 @@ DEFUN (bgp_fs_local_install_any,
|
|||||||
return bgp_fs_local_install_interface(bgp, no, NULL);
|
return bgp_fs_local_install_interface(bgp, no, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int bgp_flowspec_display_match_per_ip(afi_t afi,
|
||||||
|
struct bgp_table *rib,
|
||||||
|
struct prefix *match,
|
||||||
|
int prefix_check,
|
||||||
|
struct vty *vty,
|
||||||
|
uint8_t use_json,
|
||||||
|
json_object *json_paths)
|
||||||
|
{
|
||||||
|
struct bgp_node *rn;
|
||||||
|
struct prefix *prefix;
|
||||||
|
int display = 0;
|
||||||
|
|
||||||
|
for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) {
|
||||||
|
prefix = &rn->p;
|
||||||
|
|
||||||
|
if (prefix->family != AF_FLOWSPEC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
|
||||||
|
route_vty_out_flowspec(vty, &rn->p,
|
||||||
|
rn->info, use_json ?
|
||||||
|
NLRI_STRING_FORMAT_JSON :
|
||||||
|
NLRI_STRING_FORMAT_LARGE,
|
||||||
|
json_paths);
|
||||||
|
display++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
void bgp_flowspec_vty_init(void)
|
void bgp_flowspec_vty_init(void)
|
||||||
{
|
{
|
||||||
install_element(ENABLE_NODE, &debug_bgp_flowspec_cmd);
|
install_element(ENABLE_NODE, &debug_bgp_flowspec_cmd);
|
||||||
|
@ -8793,17 +8793,11 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
|
|||||||
bgp_unlock_node(rm);
|
bgp_unlock_node(rm);
|
||||||
}
|
}
|
||||||
} else if (safi == SAFI_FLOWSPEC) {
|
} else if (safi == SAFI_FLOWSPEC) {
|
||||||
rn = bgp_flowspec_get_match_per_ip(afi, rib,
|
display = bgp_flowspec_display_match_per_ip(afi, rib,
|
||||||
&match, prefix_check);
|
&match, prefix_check,
|
||||||
if (rn != NULL) {
|
vty,
|
||||||
route_vty_out_flowspec(vty, &rn->p,
|
use_json,
|
||||||
rn->info, use_json ?
|
json_paths);
|
||||||
NLRI_STRING_FORMAT_JSON :
|
|
||||||
NLRI_STRING_FORMAT_LARGE,
|
|
||||||
json_paths);
|
|
||||||
display++;
|
|
||||||
bgp_unlock_node(rn);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
header = 1;
|
header = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user