mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 12:41:21 +00:00
Merge pull request #9265 from ton31337/fix/extcommunity_lb_route-map_persistent
bgpd: Extended community bandwidth fixes
This commit is contained in:
commit
5838d3b452
@ -151,6 +151,12 @@ struct ecommunity_val_ipv6 {
|
|||||||
char val[IPV6_ECOMMUNITY_SIZE];
|
char val[IPV6_ECOMMUNITY_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ecommunity_lb_type {
|
||||||
|
EXPLICIT_BANDWIDTH,
|
||||||
|
CUMULATIVE_BANDWIDTH,
|
||||||
|
COMPUTED_BANDWIDTH
|
||||||
|
};
|
||||||
|
|
||||||
#define ecom_length_size(X, Y) ((X)->size * (Y))
|
#define ecom_length_size(X, Y) ((X)->size * (Y))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5750,7 +5750,7 @@ DEFUN_YANG (set_ecommunity_lb,
|
|||||||
"Attribute is set as non-transitive\n")
|
"Attribute is set as non-transitive\n")
|
||||||
{
|
{
|
||||||
int idx_lb = 3;
|
int idx_lb = 3;
|
||||||
int idx_non_transitive = 4;
|
int idx_non_transitive = 0;
|
||||||
const char *xpath =
|
const char *xpath =
|
||||||
"./set-action[action='frr-bgp-route-map:set-extcommunity-lb']";
|
"./set-action[action='frr-bgp-route-map:set-extcommunity-lb']";
|
||||||
char xpath_lb_type[XPATH_MAXLEN];
|
char xpath_lb_type[XPATH_MAXLEN];
|
||||||
@ -5782,7 +5782,7 @@ DEFUN_YANG (set_ecommunity_lb,
|
|||||||
argv[idx_lb]->arg);
|
argv[idx_lb]->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[idx_non_transitive])
|
if (argv_find(argv, argc, "non-transitive", &idx_non_transitive))
|
||||||
nb_cli_enqueue_change(vty, xpath_non_transitive, NB_OP_MODIFY,
|
nb_cli_enqueue_change(vty, xpath_non_transitive, NB_OP_MODIFY,
|
||||||
"true");
|
"true");
|
||||||
else
|
else
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "lib/routemap.h"
|
#include "lib/routemap.h"
|
||||||
#include "bgpd/bgpd.h"
|
#include "bgpd/bgpd.h"
|
||||||
#include "bgpd/bgp_routemap_nb.h"
|
#include "bgpd/bgp_routemap_nb.h"
|
||||||
|
#include "bgpd/bgp_ecommunity.h"
|
||||||
|
|
||||||
/* Add bgp route map rule. */
|
/* Add bgp route map rule. */
|
||||||
static int bgp_route_match_add(struct route_map_index *index,
|
static int bgp_route_match_add(struct route_map_index *index,
|
||||||
@ -2592,12 +2593,6 @@ lib_route_map_entry_set_action_rmap_set_action_comm_list_name_destroy(
|
|||||||
return NB_OK;
|
return NB_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum e_community_lb_type {
|
|
||||||
EXPLICIT_BANDWIDTH,
|
|
||||||
CUMULATIVE_BANDWIDTH,
|
|
||||||
COMPUTED_BANDWIDTH
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath:
|
* XPath:
|
||||||
* /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
|
* /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:extcommunity-lb
|
||||||
@ -2607,7 +2602,7 @@ lib_route_map_entry_set_action_rmap_set_action_extcommunity_lb_finish(
|
|||||||
struct nb_cb_apply_finish_args *args)
|
struct nb_cb_apply_finish_args *args)
|
||||||
{
|
{
|
||||||
struct routemap_hook_context *rhc;
|
struct routemap_hook_context *rhc;
|
||||||
int lb_type;
|
enum ecommunity_lb_type lb_type;
|
||||||
char str[VTY_BUFSIZ];
|
char str[VTY_BUFSIZ];
|
||||||
uint16_t bandwidth;
|
uint16_t bandwidth;
|
||||||
|
|
||||||
|
@ -354,6 +354,8 @@ DECLARE_QOBJ_TYPE(route_map);
|
|||||||
(strmatch(A, "frr-bgp-route-map:set-extcommunity-rt"))
|
(strmatch(A, "frr-bgp-route-map:set-extcommunity-rt"))
|
||||||
#define IS_SET_EXTCOMMUNITY_SOO(A) \
|
#define IS_SET_EXTCOMMUNITY_SOO(A) \
|
||||||
(strmatch(A, "frr-bgp-route-map:set-extcommunity-soo"))
|
(strmatch(A, "frr-bgp-route-map:set-extcommunity-soo"))
|
||||||
|
#define IS_SET_EXTCOMMUNITY_LB(A) \
|
||||||
|
(strmatch(A, "frr-bgp-route-map:set-extcommunity-lb"))
|
||||||
#define IS_SET_AGGREGATOR(A) \
|
#define IS_SET_AGGREGATOR(A) \
|
||||||
(strmatch(A, "frr-bgp-route-map:aggregator"))
|
(strmatch(A, "frr-bgp-route-map:aggregator"))
|
||||||
#define IS_SET_AS_PREPEND(A) \
|
#define IS_SET_AS_PREPEND(A) \
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "lib/command.h"
|
#include "lib/command.h"
|
||||||
#include "lib/northbound_cli.h"
|
#include "lib/northbound_cli.h"
|
||||||
#include "lib/routemap.h"
|
#include "lib/routemap.h"
|
||||||
|
#include "bgpd/bgp_ecommunity.h"
|
||||||
|
|
||||||
#ifndef VTYSH_EXTRACT_PL
|
#ifndef VTYSH_EXTRACT_PL
|
||||||
#include "lib/routemap_cli_clippy.c"
|
#include "lib/routemap_cli_clippy.c"
|
||||||
@ -1194,6 +1195,34 @@ void route_map_action_show(struct vty *vty, struct lyd_node *dnode,
|
|||||||
yang_dnode_get_string(
|
yang_dnode_get_string(
|
||||||
dnode,
|
dnode,
|
||||||
"./rmap-set-action/frr-bgp-route-map:extcommunity-soo"));
|
"./rmap-set-action/frr-bgp-route-map:extcommunity-soo"));
|
||||||
|
} else if (IS_SET_EXTCOMMUNITY_LB(action)) {
|
||||||
|
enum ecommunity_lb_type lb_type;
|
||||||
|
char str[VTY_BUFSIZ];
|
||||||
|
uint16_t bandwidth;
|
||||||
|
|
||||||
|
lb_type = yang_dnode_get_enum(
|
||||||
|
dnode,
|
||||||
|
"./rmap-set-action/frr-bgp-route-map:extcommunity-lb/lb-type");
|
||||||
|
switch (lb_type) {
|
||||||
|
case EXPLICIT_BANDWIDTH:
|
||||||
|
bandwidth = yang_dnode_get_uint16(
|
||||||
|
dnode,
|
||||||
|
"./rmap-set-action/frr-bgp-route-map:extcommunity-lb/bandwidth");
|
||||||
|
snprintf(str, sizeof(str), "%d", bandwidth);
|
||||||
|
break;
|
||||||
|
case CUMULATIVE_BANDWIDTH:
|
||||||
|
snprintf(str, sizeof(str), "%s", "cumulative");
|
||||||
|
break;
|
||||||
|
case COMPUTED_BANDWIDTH:
|
||||||
|
snprintf(str, sizeof(str), "%s", "num-multipaths");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yang_dnode_get_bool(
|
||||||
|
dnode,
|
||||||
|
"./rmap-set-action/frr-bgp-route-map:extcommunity-lb/two-octet-as-specific"))
|
||||||
|
strlcat(str, " non-transitive", sizeof(str));
|
||||||
|
|
||||||
|
vty_out(vty, " set extcommunity bandwidth %s\n", str);
|
||||||
} else if (IS_SET_AGGREGATOR(action)) {
|
} else if (IS_SET_AGGREGATOR(action)) {
|
||||||
vty_out(vty, " set aggregator as %s %s\n",
|
vty_out(vty, " set aggregator as %s %s\n",
|
||||||
yang_dnode_get_string(
|
yang_dnode_get_string(
|
||||||
|
Loading…
Reference in New Issue
Block a user