mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-02 18:52:04 +00:00
bgpd: get rid of afi_header_vty_out() & co.
afi_header_vty_out() is easily replaced with vty_frame(), which means we can drop a whole batch of "int *write" args as well as the entirety of bgp_config_write_family_header(). => AFI/SAFI config writing is now a lot simpler. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
a8b828f3c3
commit
2b79110731
@ -48,11 +48,6 @@ struct vni_walk_ctx {
|
||||
struct in_addr vtep_ip;
|
||||
};
|
||||
|
||||
struct evpn_config_write {
|
||||
int write;
|
||||
struct vty *vty;
|
||||
};
|
||||
|
||||
#if defined(HAVE_CUMULUS)
|
||||
static void display_import_rt(struct vty *vty, struct irt_node *irt)
|
||||
{
|
||||
@ -1709,17 +1704,14 @@ static void evpn_unset_advertise_all_vni(struct bgp *bgp)
|
||||
}
|
||||
#endif /* HAVE_CUMULUS */
|
||||
|
||||
static void write_vni_config(struct vty *vty, struct bgpevpn *vpn, int *write)
|
||||
static void write_vni_config(struct vty *vty, struct bgpevpn *vpn)
|
||||
{
|
||||
char buf1[INET6_ADDRSTRLEN];
|
||||
afi_t afi = AFI_L2VPN;
|
||||
safi_t safi = SAFI_EVPN;
|
||||
char *ecom_str;
|
||||
struct listnode *node, *nnode;
|
||||
struct ecommunity *ecom;
|
||||
|
||||
if (is_vni_configured(vpn)) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
vty_out(vty, " vni %d\n", vpn->vni);
|
||||
if (is_rd_configured(vpn))
|
||||
vty_out(vty, " rd %s\n",
|
||||
@ -1755,10 +1747,10 @@ static void write_vni_config(struct vty *vty, struct bgpevpn *vpn, int *write)
|
||||
}
|
||||
|
||||
static void write_vni_config_for_entry(struct hash_backet *backet,
|
||||
struct evpn_config_write *cfg)
|
||||
struct vty *vty)
|
||||
{
|
||||
struct bgpevpn *vpn = (struct bgpevpn *)backet->data;
|
||||
write_vni_config(cfg->vty, vpn, &cfg->write);
|
||||
write_vni_config(vty, vpn);
|
||||
}
|
||||
|
||||
#if defined(HAVE_CUMULUS)
|
||||
@ -2741,29 +2733,19 @@ DEFUN (no_bgp_evpn_vni_rt_without_val,
|
||||
* Output EVPN configuration information.
|
||||
*/
|
||||
void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi, int *write)
|
||||
safi_t safi)
|
||||
{
|
||||
struct evpn_config_write cfg;
|
||||
|
||||
if (bgp->vnihash) {
|
||||
cfg.write = *write;
|
||||
cfg.vty = vty;
|
||||
if (bgp->vnihash)
|
||||
hash_iterate(bgp->vnihash,
|
||||
(void (*)(struct hash_backet *,
|
||||
void *))write_vni_config_for_entry,
|
||||
&cfg);
|
||||
*write = cfg.write;
|
||||
}
|
||||
vty);
|
||||
|
||||
if (bgp->advertise_all_vni) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
if (bgp->advertise_all_vni)
|
||||
vty_out(vty, " advertise-all-vni\n");
|
||||
}
|
||||
|
||||
if (bgp->advertise_gw_macip) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
if (bgp->advertise_gw_macip)
|
||||
vty_out(vty, " advertise-default-gw\n");
|
||||
}
|
||||
}
|
||||
|
||||
void bgp_ethernetvpn_init(void)
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define _FRR_BGP_EVPN_VTY_H
|
||||
|
||||
extern void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp,
|
||||
afi_t afi, safi_t safi, int *write);
|
||||
afi_t afi, safi_t safi);
|
||||
extern void bgp_ethernetvpn_init(void);
|
||||
|
||||
#define L2VPN_HELP_STR "Layer 2 Virtual Private Network\n"
|
||||
|
@ -4947,16 +4947,13 @@ static int bgp_table_map_unset(struct vty *vty, afi_t afi, safi_t safi,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int bgp_config_write_table_map(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi, int *write)
|
||||
void bgp_config_write_table_map(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
if (bgp->table_map[afi][safi].name) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
vty_out(vty, " table-map %s\n",
|
||||
bgp->table_map[afi][safi].name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFUN (bgp_table_map,
|
||||
@ -10978,8 +10975,8 @@ DEFUN (clear_ip_bgp_dampening_address_mask,
|
||||
}
|
||||
|
||||
/* also used for encap safi */
|
||||
static int bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
|
||||
afi_t afi, safi_t safi, int *write)
|
||||
static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
|
||||
afi_t afi, safi_t safi)
|
||||
{
|
||||
struct bgp_node *prn;
|
||||
struct bgp_node *rn;
|
||||
@ -11001,10 +10998,6 @@ static int bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
|
||||
p = &rn->p;
|
||||
prd = (struct prefix_rd *)&prn->p;
|
||||
|
||||
/* "address-family" display. */
|
||||
bgp_config_write_family_header(
|
||||
vty, afi, safi, write);
|
||||
|
||||
/* "network" configuration display. */
|
||||
prefix_rd2str(prd, rdbuf,
|
||||
RD_ADDRSTRLEN);
|
||||
@ -11030,11 +11023,10 @@ static int bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
|
||||
}
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
|
||||
afi_t afi, safi_t safi, int *write)
|
||||
static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
|
||||
afi_t afi, safi_t safi)
|
||||
{
|
||||
struct bgp_node *prn;
|
||||
struct bgp_node *rn;
|
||||
@ -11066,10 +11058,6 @@ static int bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
|
||||
p = &rn->p;
|
||||
prd = (struct prefix_rd *)&prn->p;
|
||||
|
||||
/* "address-family" display. */
|
||||
bgp_config_write_family_header(
|
||||
vty, afi, safi, write);
|
||||
|
||||
/* "network" configuration display. */
|
||||
prefix_rd2str(prd, rdbuf,
|
||||
RD_ADDRSTRLEN);
|
||||
@ -11094,13 +11082,12 @@ static int bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
|
||||
if (esi)
|
||||
XFREE(MTYPE_TMP, esi);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Configuration of static route announcement and aggregate
|
||||
information. */
|
||||
int bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi, int *write)
|
||||
void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
struct bgp_node *rn;
|
||||
struct prefix *p;
|
||||
@ -11108,12 +11095,15 @@ int bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
struct bgp_aggregate *bgp_aggregate;
|
||||
char buf[SU_ADDRSTRLEN];
|
||||
|
||||
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
|
||||
return bgp_config_write_network_vpn(vty, bgp, afi, safi, write);
|
||||
if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) {
|
||||
bgp_config_write_network_vpn(vty, bgp, afi, safi);
|
||||
return;
|
||||
}
|
||||
|
||||
if (afi == AFI_L2VPN && safi == SAFI_EVPN)
|
||||
return bgp_config_write_network_evpn(vty, bgp, afi, safi,
|
||||
write);
|
||||
if (afi == AFI_L2VPN && safi == SAFI_EVPN) {
|
||||
bgp_config_write_network_evpn(vty, bgp, afi, safi);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Network configuration. */
|
||||
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
|
||||
@ -11121,9 +11111,6 @@ int bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
if ((bgp_static = rn->info) != NULL) {
|
||||
p = &rn->p;
|
||||
|
||||
/* "address-family" display. */
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
|
||||
/* "network" configuration display. */
|
||||
if (bgp_option_check(BGP_OPT_CONFIG_CISCO)
|
||||
&& afi == AFI_IP) {
|
||||
@ -11175,9 +11162,6 @@ int bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
if ((bgp_aggregate = rn->info) != NULL) {
|
||||
p = &rn->p;
|
||||
|
||||
/* "address-family" display. */
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
|
||||
if (bgp_option_check(BGP_OPT_CONFIG_CISCO)
|
||||
&& afi == AFI_IP) {
|
||||
struct in_addr netmask;
|
||||
@ -11202,12 +11186,10 @@ int bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi, int *write)
|
||||
void bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
struct bgp_node *rn;
|
||||
struct bgp_distance *bdistance;
|
||||
@ -11219,7 +11201,6 @@ int bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
|| bgp->distance_ibgp[afi][safi] != ZEBRA_IBGP_DISTANCE_DEFAULT
|
||||
|| bgp->distance_local[afi][safi]
|
||||
!= ZEBRA_IBGP_DISTANCE_DEFAULT)) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
vty_out(vty, " distance bgp %d %d %d\n",
|
||||
bgp->distance_ebgp[afi][safi],
|
||||
bgp->distance_ibgp[afi][safi],
|
||||
@ -11231,15 +11212,12 @@ int bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
if ((bdistance = rn->info) != NULL) {
|
||||
char buf[PREFIX_STRLEN];
|
||||
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
vty_out(vty, " distance %d %s %s\n",
|
||||
bdistance->distance,
|
||||
prefix2str(&rn->p, buf, sizeof(buf)),
|
||||
bdistance->access_list ? bdistance->access_list
|
||||
: "");
|
||||
}
|
||||
|
||||
return *write;
|
||||
}
|
||||
|
||||
/* Allocate routing table structure and install commands. */
|
||||
|
@ -367,12 +367,9 @@ extern void bgp_process(struct bgp *, struct bgp_node *, afi_t, safi_t);
|
||||
* queue element with NULL bgp node.
|
||||
*/
|
||||
extern void bgp_add_eoiu_mark(struct bgp *);
|
||||
extern int bgp_config_write_table_map(struct vty *, struct bgp *, afi_t, safi_t,
|
||||
int *);
|
||||
extern int bgp_config_write_network(struct vty *, struct bgp *, afi_t, safi_t,
|
||||
int *);
|
||||
extern int bgp_config_write_distance(struct vty *, struct bgp *, afi_t, safi_t,
|
||||
int *);
|
||||
extern void bgp_config_write_table_map(struct vty *, struct bgp *, afi_t, safi_t);
|
||||
extern void bgp_config_write_network(struct vty *, struct bgp *, afi_t, safi_t);
|
||||
extern void bgp_config_write_distance(struct vty *, struct bgp *, afi_t, safi_t);
|
||||
|
||||
extern void bgp_aggregate_increment(struct bgp *, struct prefix *,
|
||||
struct bgp_info *, afi_t, safi_t);
|
||||
|
@ -1279,7 +1279,7 @@ static int bgp_update_delay_deconfig_vty(struct vty *vty)
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp)
|
||||
void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp)
|
||||
{
|
||||
if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) {
|
||||
vty_out(vty, " update-delay %d", bgp->v_update_delay);
|
||||
@ -1287,8 +1287,6 @@ int bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp)
|
||||
vty_out(vty, " %d", bgp->v_establish_wait);
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1342,12 +1340,10 @@ static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp)
|
||||
void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp)
|
||||
{
|
||||
if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
|
||||
vty_out(vty, " write-quanta %d\n", bgp->wpkt_quanta);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1374,12 +1370,10 @@ DEFUN (no_bgp_wpkt_quanta,
|
||||
return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0);
|
||||
}
|
||||
|
||||
int bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp)
|
||||
void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp)
|
||||
{
|
||||
if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
|
||||
vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1503,17 +1497,15 @@ ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd,
|
||||
"Number of paths\n"
|
||||
"Match the cluster length\n")
|
||||
|
||||
int bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi, int *write)
|
||||
void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
vty_out(vty, " maximum-paths %d\n",
|
||||
bgp->maxpaths[afi][safi].maxpaths_ebgp);
|
||||
}
|
||||
|
||||
if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) {
|
||||
bgp_config_write_family_header(vty, afi, safi, write);
|
||||
vty_out(vty, " maximum-paths ibgp %d",
|
||||
bgp->maxpaths[afi][safi].maxpaths_ibgp);
|
||||
if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags,
|
||||
@ -1521,8 +1513,6 @@ int bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
vty_out(vty, " equal-cluster-length");
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BGP timers. */
|
||||
@ -2459,7 +2449,7 @@ DEFUN (no_bgp_listen_range,
|
||||
return bgp_vty_return(vty, ret);
|
||||
}
|
||||
|
||||
int bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
|
||||
void bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
|
||||
{
|
||||
struct peer_group *group;
|
||||
struct listnode *node, *nnode, *rnode, *nrnode;
|
||||
@ -2482,8 +2472,6 @@ int bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -11041,14 +11029,14 @@ DEFUN (no_bgp_redistribute_ipv6,
|
||||
return bgp_redistribute_unset(bgp, AFI_IP6, type, 0);
|
||||
}
|
||||
|
||||
int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi, int *write)
|
||||
void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Unicast redistribution only. */
|
||||
if (safi != SAFI_UNICAST)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
||||
/* Redistribute BGP does not make sense. */
|
||||
@ -11062,11 +11050,6 @@ int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
continue;
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) {
|
||||
/* Display "address-family" when it is not yet
|
||||
* diplayed. */
|
||||
bgp_config_write_family_header(vty, afi, safi,
|
||||
write);
|
||||
|
||||
/* "redistribute" configuration. */
|
||||
vty_out(vty, " redistribute %s",
|
||||
zebra_route_string(i));
|
||||
@ -11082,7 +11065,6 @@ int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
}
|
||||
}
|
||||
}
|
||||
return *write;
|
||||
}
|
||||
|
||||
/* BGP node structure. */
|
||||
|
@ -46,10 +46,10 @@ struct bgp;
|
||||
extern void bgp_vty_init(void);
|
||||
extern const char *afi_safi_print(afi_t, safi_t);
|
||||
extern const char *afi_safi_json(afi_t, safi_t);
|
||||
extern int bgp_config_write_update_delay(struct vty *, struct bgp *);
|
||||
extern int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp);
|
||||
extern int bgp_config_write_listen(struct vty *vty, struct bgp *bgp);
|
||||
extern int bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp);
|
||||
extern void bgp_config_write_update_delay(struct vty *, struct bgp *);
|
||||
extern void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp);
|
||||
extern void bgp_config_write_listen(struct vty *vty, struct bgp *bgp);
|
||||
extern void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp);
|
||||
extern int bgp_vty_return(struct vty *vty, int ret);
|
||||
extern struct peer *peer_and_group_lookup_vty(struct vty *vty,
|
||||
const char *peer_str);
|
||||
|
@ -26,10 +26,10 @@
|
||||
extern void bgp_zebra_init(struct thread_master *master);
|
||||
extern void bgp_zebra_destroy(void);
|
||||
extern int bgp_if_update_all(void);
|
||||
extern int bgp_config_write_maxpaths(struct vty *, struct bgp *, afi_t, safi_t,
|
||||
int *);
|
||||
extern int bgp_config_write_redistribute(struct vty *, struct bgp *, afi_t,
|
||||
safi_t, int *);
|
||||
extern void bgp_config_write_maxpaths(struct vty *, struct bgp *, afi_t,
|
||||
safi_t);
|
||||
extern void bgp_config_write_redistribute(struct vty *, struct bgp *, afi_t,
|
||||
safi_t);
|
||||
extern void bgp_zebra_announce(struct bgp_node *, struct prefix *,
|
||||
struct bgp_info *, struct bgp *, afi_t, safi_t);
|
||||
extern void bgp_zebra_announce_table(struct bgp *, afi_t, safi_t);
|
||||
|
346
bgpd/bgpd.c
346
bgpd/bgpd.c
@ -6184,14 +6184,8 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, u_char use_json,
|
||||
return buf;
|
||||
}
|
||||
|
||||
#define afi_header_vty_out(vty, afi, safi, write, format, ...) \
|
||||
do { \
|
||||
bgp_config_write_family_header(vty, afi, safi, write); \
|
||||
vty_out(vty, format, ## __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
static void bgp_config_write_filter(struct vty *vty, struct peer *peer,
|
||||
afi_t afi, safi_t safi, int *write)
|
||||
afi_t afi, safi_t safi)
|
||||
{
|
||||
struct bgp_filter *filter;
|
||||
struct bgp_filter *gfilter = NULL;
|
||||
@ -6210,16 +6204,13 @@ static void bgp_config_write_filter(struct vty *vty, struct peer *peer,
|
||||
if (!gfilter || !gfilter->dlist[in].name
|
||||
|| strcmp(filter->dlist[in].name, gfilter->dlist[in].name)
|
||||
!= 0) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s distribute-list %s in\n", addr,
|
||||
filter->dlist[in].name);
|
||||
vty_out(vty, " neighbor %s distribute-list %s in\n",
|
||||
addr, filter->dlist[in].name);
|
||||
}
|
||||
|
||||
if (filter->dlist[out].name && !gfilter) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s distribute-list %s out\n",
|
||||
addr, filter->dlist[out].name);
|
||||
vty_out(vty, " neighbor %s distribute-list %s out\n", addr,
|
||||
filter->dlist[out].name);
|
||||
}
|
||||
|
||||
/* prefix-list. */
|
||||
@ -6227,19 +6218,17 @@ static void bgp_config_write_filter(struct vty *vty, struct peer *peer,
|
||||
if (!gfilter || !gfilter->plist[in].name
|
||||
|| strcmp(filter->plist[in].name, gfilter->plist[in].name)
|
||||
!= 0) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s prefix-list %s in\n",
|
||||
addr, filter->plist[in].name);
|
||||
vty_out(vty, " neighbor %s prefix-list %s in\n", addr,
|
||||
filter->plist[in].name);
|
||||
}
|
||||
|
||||
if (filter->plist[out].name)
|
||||
if (!gfilter || !gfilter->plist[out].name
|
||||
|| strcmp(filter->plist[out].name, gfilter->plist[out].name)
|
||||
!= 0) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s prefix-list %s out\n",
|
||||
addr, filter->plist[out].name);
|
||||
}
|
||||
if (filter->plist[out].name)
|
||||
if (!gfilter || !gfilter->plist[out].name
|
||||
|| strcmp(filter->plist[out].name, gfilter->plist[out].name)
|
||||
!= 0) {
|
||||
vty_out(vty, " neighbor %s prefix-list %s out\n", addr,
|
||||
filter->plist[out].name);
|
||||
}
|
||||
|
||||
/* route-map. */
|
||||
if (filter->map[RMAP_IN].name)
|
||||
@ -6247,9 +6236,8 @@ static void bgp_config_write_filter(struct vty *vty, struct peer *peer,
|
||||
|| strcmp(filter->map[RMAP_IN].name,
|
||||
gfilter->map[RMAP_IN].name)
|
||||
!= 0) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s route-map %s in\n",
|
||||
addr, filter->map[RMAP_IN].name);
|
||||
vty_out(vty, " neighbor %s route-map %s in\n", addr,
|
||||
filter->map[RMAP_IN].name);
|
||||
}
|
||||
|
||||
if (filter->map[RMAP_OUT].name)
|
||||
@ -6257,16 +6245,14 @@ static void bgp_config_write_filter(struct vty *vty, struct peer *peer,
|
||||
|| strcmp(filter->map[RMAP_OUT].name,
|
||||
gfilter->map[RMAP_OUT].name)
|
||||
!= 0) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s route-map %s out\n",
|
||||
addr, filter->map[RMAP_OUT].name);
|
||||
vty_out(vty, " neighbor %s route-map %s out\n", addr,
|
||||
filter->map[RMAP_OUT].name);
|
||||
}
|
||||
|
||||
/* unsuppress-map */
|
||||
if (filter->usmap.name && !gfilter) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s unsuppress-map %s\n", addr,
|
||||
filter->usmap.name);
|
||||
vty_out(vty, " neighbor %s unsuppress-map %s\n", addr,
|
||||
filter->usmap.name);
|
||||
}
|
||||
|
||||
/* filter-list. */
|
||||
@ -6274,15 +6260,13 @@ static void bgp_config_write_filter(struct vty *vty, struct peer *peer,
|
||||
if (!gfilter || !gfilter->aslist[in].name
|
||||
|| strcmp(filter->aslist[in].name, gfilter->aslist[in].name)
|
||||
!= 0) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s filter-list %s in\n",
|
||||
addr, filter->aslist[in].name);
|
||||
vty_out(vty, " neighbor %s filter-list %s in\n", addr,
|
||||
filter->aslist[in].name);
|
||||
}
|
||||
|
||||
if (filter->aslist[out].name && !gfilter) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s filter-list %s out\n", addr,
|
||||
filter->aslist[out].name);
|
||||
vty_out(vty, " neighbor %s filter-list %s out\n", addr,
|
||||
filter->aslist[out].name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6602,8 +6586,7 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
|
||||
|
||||
/* BGP peer configuration display function. */
|
||||
static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
struct peer *peer, afi_t afi, safi_t safi,
|
||||
int *write)
|
||||
struct peer *peer, afi_t afi, safi_t safi)
|
||||
{
|
||||
struct peer *g_peer = NULL;
|
||||
char *addr;
|
||||
@ -6626,36 +6609,29 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
/* If the peer-group is active but peer is not, print a 'no
|
||||
* activate' */
|
||||
if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" no neighbor %s activate\n", addr);
|
||||
vty_out(vty, " no neighbor %s activate\n", addr);
|
||||
}
|
||||
|
||||
/* If the peer-group is not active but peer is, print an
|
||||
'activate' */
|
||||
else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s activate\n", addr);
|
||||
vty_out(vty, " neighbor %s activate\n", addr);
|
||||
}
|
||||
} else {
|
||||
if (peer->afc[afi][safi]) {
|
||||
if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) {
|
||||
if (bgp_flag_check(bgp,
|
||||
BGP_FLAG_NO_DEFAULT_IPV4)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s activate\n",
|
||||
vty_out(vty, " neighbor %s activate\n",
|
||||
addr);
|
||||
}
|
||||
} else
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s activate\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s activate\n", addr);
|
||||
} else {
|
||||
if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) {
|
||||
if (!bgp_flag_check(bgp,
|
||||
BGP_FLAG_NO_DEFAULT_IPV4)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
vty_out(vty,
|
||||
" no neighbor %s activate\n",
|
||||
addr);
|
||||
}
|
||||
@ -6666,25 +6642,20 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
/* addpath TX knobs */
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_ADDPATH_TX_ALL_PATHS)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s addpath-tx-all-paths\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s addpath-tx-all-paths\n", addr);
|
||||
}
|
||||
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s addpath-tx-bestpath-per-AS\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s addpath-tx-bestpath-per-AS\n",
|
||||
addr);
|
||||
}
|
||||
|
||||
/* ORF capability. */
|
||||
if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM)
|
||||
|| peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_ORF_PREFIX_RM)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s capability orf prefix-list",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s capability orf prefix-list", addr);
|
||||
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_ORF_PREFIX_SM)
|
||||
@ -6702,57 +6673,46 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
/* Route reflector client. */
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_REFLECTOR_CLIENT)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s route-reflector-client\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s route-reflector-client\n", addr);
|
||||
}
|
||||
|
||||
/* next-hop-self force */
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_FORCE_NEXTHOP_SELF)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s next-hop-self force\n", addr);
|
||||
vty_out(vty, " neighbor %s next-hop-self force\n", addr);
|
||||
}
|
||||
|
||||
/* next-hop-self */
|
||||
if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s next-hop-self\n", addr);
|
||||
vty_out(vty, " neighbor %s next-hop-self\n", addr);
|
||||
}
|
||||
|
||||
/* remove-private-AS */
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s remove-private-AS all replace-AS\n",
|
||||
vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n",
|
||||
addr);
|
||||
}
|
||||
|
||||
else if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s remove-private-AS replace-AS\n", addr);
|
||||
vty_out(vty, " neighbor %s remove-private-AS replace-AS\n",
|
||||
addr);
|
||||
}
|
||||
|
||||
else if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s remove-private-AS all\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s remove-private-AS all\n", addr);
|
||||
}
|
||||
|
||||
else if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_REMOVE_PRIVATE_AS)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s remove-private-AS\n", addr);
|
||||
vty_out(vty, " neighbor %s remove-private-AS\n", addr);
|
||||
}
|
||||
|
||||
/* as-override */
|
||||
if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s as-override\n", addr);
|
||||
vty_out(vty, " neighbor %s as-override\n", addr);
|
||||
}
|
||||
|
||||
/* send-community print. */
|
||||
@ -6764,27 +6724,21 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
&& peergroup_af_flag_check(
|
||||
peer, afi, safi,
|
||||
PEER_FLAG_SEND_LARGE_COMMUNITY)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s send-community all\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s send-community all\n",
|
||||
addr);
|
||||
} else if (peergroup_af_flag_check(
|
||||
peer, afi, safi,
|
||||
PEER_FLAG_SEND_LARGE_COMMUNITY)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s send-community large\n", addr);
|
||||
vty_out(vty, " neighbor %s send-community large\n",
|
||||
addr);
|
||||
} else if (peergroup_af_flag_check(
|
||||
peer, afi, safi,
|
||||
PEER_FLAG_SEND_EXT_COMMUNITY)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s send-community extended\n",
|
||||
vty_out(vty, " neighbor %s send-community extended\n",
|
||||
addr);
|
||||
} else if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_SEND_COMMUNITY)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s send-community\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s send-community\n", addr);
|
||||
}
|
||||
} else {
|
||||
if (!peer_af_flag_check(peer, afi, safi,
|
||||
@ -6801,9 +6755,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
&& (!g_peer || peer_af_flag_check(
|
||||
g_peer, afi, safi,
|
||||
PEER_FLAG_SEND_LARGE_COMMUNITY))) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" no neighbor %s send-community all\n", addr);
|
||||
vty_out(vty, " no neighbor %s send-community all\n",
|
||||
addr);
|
||||
} else {
|
||||
if (!peer_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_SEND_LARGE_COMMUNITY)
|
||||
@ -6811,8 +6764,7 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
|| peer_af_flag_check(
|
||||
g_peer, afi, safi,
|
||||
PEER_FLAG_SEND_LARGE_COMMUNITY))) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
vty_out(vty,
|
||||
" no neighbor %s send-community large\n",
|
||||
addr);
|
||||
}
|
||||
@ -6823,8 +6775,7 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
|| peer_af_flag_check(
|
||||
g_peer, afi, safi,
|
||||
PEER_FLAG_SEND_EXT_COMMUNITY))) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
vty_out(vty,
|
||||
" no neighbor %s send-community extended\n",
|
||||
addr);
|
||||
}
|
||||
@ -6834,8 +6785,7 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
&& (!g_peer || peer_af_flag_check(
|
||||
g_peer, afi, safi,
|
||||
PEER_FLAG_SEND_COMMUNITY))) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
vty_out(vty,
|
||||
" no neighbor %s send-community\n",
|
||||
addr);
|
||||
}
|
||||
@ -6853,8 +6803,7 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
|| (peer->default_rmap[afi][safi].name
|
||||
&& strcmp(peer->default_rmap[afi][safi].name,
|
||||
g_peer->default_rmap[afi][safi].name))))) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s default-originate", addr);
|
||||
vty_out(vty, " neighbor %s default-originate", addr);
|
||||
if (peer->default_rmap[afi][safi].name)
|
||||
vty_out(vty, " route-map %s",
|
||||
peer->default_rmap[afi][safi].name);
|
||||
@ -6863,9 +6812,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
|
||||
/* Soft reconfiguration inbound. */
|
||||
if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s soft-reconfiguration inbound\n", addr);
|
||||
vty_out(vty, " neighbor %s soft-reconfiguration inbound\n",
|
||||
addr);
|
||||
}
|
||||
|
||||
/* maximum-prefix. */
|
||||
@ -6878,9 +6826,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
PEER_FLAG_MAX_PREFIX_WARNING)
|
||||
!= CHECK_FLAG(peer->af_flags[afi][safi],
|
||||
PEER_FLAG_MAX_PREFIX_WARNING)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s maximum-prefix %lu",
|
||||
addr, peer->pmax[afi][safi]);
|
||||
vty_out(vty, " neighbor %s maximum-prefix %lu", addr,
|
||||
peer->pmax[afi][safi]);
|
||||
if (peer->pmax_threshold[afi][safi]
|
||||
!= MAXIMUM_PREFIX_THRESHOLD_DEFAULT)
|
||||
vty_out(vty, " %u",
|
||||
@ -6897,16 +6844,13 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
/* Route server client. */
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_RSERVER_CLIENT)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s route-server-client\n", addr);
|
||||
vty_out(vty, " neighbor %s route-server-client\n", addr);
|
||||
}
|
||||
|
||||
/* Nexthop-local unchanged. */
|
||||
if (peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s nexthop-local unchanged\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr);
|
||||
}
|
||||
|
||||
/* allowas-in <1-10> */
|
||||
@ -6917,14 +6861,11 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
|| peer->allowas_in[afi][safi]
|
||||
!= g_peer->allowas_in[afi][safi]) {
|
||||
if (peer->allowas_in[afi][safi] == 3) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s allowas-in\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s allowas-in\n",
|
||||
addr);
|
||||
} else {
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
" neighbor %s allowas-in %d\n", addr,
|
||||
peer->allowas_in[afi][safi]);
|
||||
vty_out(vty, " neighbor %s allowas-in %d\n",
|
||||
addr, peer->allowas_in[afi][safi]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6935,9 +6876,7 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
if (!peer_group_active(peer)
|
||||
|| !peer_af_flag_check(g_peer, afi, safi,
|
||||
PEER_FLAG_ALLOWAS_IN_ORIGIN)) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s allowas-in origin\n",
|
||||
addr);
|
||||
vty_out(vty, " neighbor %s allowas-in origin\n", addr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6947,15 +6886,13 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
|| !peer_af_flag_check(g_peer, afi, safi, PEER_FLAG_WEIGHT)
|
||||
|| peer->weight[afi][safi] != g_peer->weight[afi][safi]) {
|
||||
if (peer->weight[afi][safi]) {
|
||||
afi_header_vty_out(vty, afi, safi, write,
|
||||
" neighbor %s weight %lu\n",
|
||||
addr,
|
||||
peer->weight[afi][safi]);
|
||||
vty_out(vty, " neighbor %s weight %lu\n", addr,
|
||||
peer->weight[afi][safi]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Filter. */
|
||||
bgp_config_write_filter(vty, peer, afi, safi, write);
|
||||
bgp_config_write_filter(vty, peer, afi, safi);
|
||||
|
||||
/* atribute-unchanged. */
|
||||
if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) ||
|
||||
@ -6970,8 +6907,7 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
peergroup_af_flag_check(peer, afi, safi,
|
||||
PEER_FLAG_MED_UNCHANGED)) {
|
||||
|
||||
afi_header_vty_out(
|
||||
vty, afi, safi, write,
|
||||
vty_out(vty,
|
||||
" neighbor %s attribute-unchanged%s%s%s\n",
|
||||
addr,
|
||||
peer_af_flag_check(
|
||||
@ -6992,64 +6928,52 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
|
||||
}
|
||||
}
|
||||
|
||||
/* Display "address-family" configuration header. */
|
||||
void bgp_config_write_family_header(struct vty *vty, afi_t afi, safi_t safi,
|
||||
int *write)
|
||||
{
|
||||
if (*write)
|
||||
return;
|
||||
|
||||
vty_out(vty, " !\n address-family ");
|
||||
|
||||
if (afi == AFI_IP) {
|
||||
if (safi == SAFI_UNICAST)
|
||||
vty_out(vty, "ipv4 unicast");
|
||||
else if (safi == SAFI_LABELED_UNICAST)
|
||||
vty_out(vty, "ipv4 labeled-unicast");
|
||||
else if (safi == SAFI_MULTICAST)
|
||||
vty_out(vty, "ipv4 multicast");
|
||||
else if (safi == SAFI_MPLS_VPN)
|
||||
vty_out(vty, "ipv4 vpn");
|
||||
else if (safi == SAFI_ENCAP)
|
||||
vty_out(vty, "ipv4 encap");
|
||||
} else if (afi == AFI_IP6) {
|
||||
if (safi == SAFI_UNICAST)
|
||||
vty_out(vty, "ipv6 unicast");
|
||||
else if (safi == SAFI_LABELED_UNICAST)
|
||||
vty_out(vty, "ipv6 labeled-unicast");
|
||||
else if (safi == SAFI_MULTICAST)
|
||||
vty_out(vty, "ipv6 multicast");
|
||||
else if (safi == SAFI_MPLS_VPN)
|
||||
vty_out(vty, "ipv6 vpn");
|
||||
else if (safi == SAFI_ENCAP)
|
||||
vty_out(vty, "ipv6 encap");
|
||||
} else if (afi == AFI_L2VPN) {
|
||||
if (safi == SAFI_EVPN)
|
||||
vty_out(vty, "l2vpn evpn");
|
||||
}
|
||||
vty_out(vty, "\n");
|
||||
|
||||
*write = 1;
|
||||
}
|
||||
|
||||
/* Address family based peer configuration display. */
|
||||
static int bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
safi_t safi)
|
||||
{
|
||||
int write = 0;
|
||||
struct peer *peer;
|
||||
struct peer_group *group;
|
||||
struct listnode *node, *nnode;
|
||||
|
||||
bgp_config_write_distance(vty, bgp, afi, safi, &write);
|
||||
|
||||
bgp_config_write_network(vty, bgp, afi, safi, &write);
|
||||
vty_frame(vty, " !\n address-family ");
|
||||
if (afi == AFI_IP) {
|
||||
if (safi == SAFI_UNICAST)
|
||||
vty_frame(vty, "ipv4 unicast");
|
||||
else if (safi == SAFI_LABELED_UNICAST)
|
||||
vty_frame(vty, "ipv4 labeled-unicast");
|
||||
else if (safi == SAFI_MULTICAST)
|
||||
vty_frame(vty, "ipv4 multicast");
|
||||
else if (safi == SAFI_MPLS_VPN)
|
||||
vty_frame(vty, "ipv4 vpn");
|
||||
else if (safi == SAFI_ENCAP)
|
||||
vty_frame(vty, "ipv4 encap");
|
||||
} else if (afi == AFI_IP6) {
|
||||
if (safi == SAFI_UNICAST)
|
||||
vty_frame(vty, "ipv6 unicast");
|
||||
else if (safi == SAFI_LABELED_UNICAST)
|
||||
vty_frame(vty, "ipv6 labeled-unicast");
|
||||
else if (safi == SAFI_MULTICAST)
|
||||
vty_frame(vty, "ipv6 multicast");
|
||||
else if (safi == SAFI_MPLS_VPN)
|
||||
vty_frame(vty, "ipv6 vpn");
|
||||
else if (safi == SAFI_ENCAP)
|
||||
vty_frame(vty, "ipv6 encap");
|
||||
} else if (afi == AFI_L2VPN) {
|
||||
if (safi == SAFI_EVPN)
|
||||
vty_frame(vty, "l2vpn evpn");
|
||||
}
|
||||
vty_frame(vty, "\n");
|
||||
|
||||
bgp_config_write_redistribute(vty, bgp, afi, safi, &write);
|
||||
bgp_config_write_distance(vty, bgp, afi, safi);
|
||||
|
||||
bgp_config_write_network(vty, bgp, afi, safi);
|
||||
|
||||
bgp_config_write_redistribute(vty, bgp, afi, safi);
|
||||
|
||||
for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group))
|
||||
bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi,
|
||||
&write);
|
||||
bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi);
|
||||
|
||||
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) {
|
||||
/* Skip dynamic neighbors. */
|
||||
@ -7058,20 +6982,16 @@ static int bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi,
|
||||
|
||||
/* Do not display doppelganger peers */
|
||||
if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
|
||||
bgp_config_write_peer_af(vty, bgp, peer, afi, safi,
|
||||
&write);
|
||||
bgp_config_write_peer_af(vty, bgp, peer, afi, safi);
|
||||
}
|
||||
|
||||
bgp_config_write_maxpaths(vty, bgp, afi, safi, &write);
|
||||
bgp_config_write_table_map(vty, bgp, afi, safi, &write);
|
||||
bgp_config_write_maxpaths(vty, bgp, afi, safi);
|
||||
bgp_config_write_table_map(vty, bgp, afi, safi);
|
||||
|
||||
if (safi == SAFI_EVPN)
|
||||
bgp_config_write_evpn_info(vty, bgp, afi, safi, &write);
|
||||
bgp_config_write_evpn_info(vty, bgp, afi, safi);
|
||||
|
||||
if (write)
|
||||
vty_out(vty, " exit-address-family\n");
|
||||
|
||||
return write;
|
||||
vty_endframe(vty, " exit-address-family\n");
|
||||
}
|
||||
|
||||
int bgp_config_write(struct vty *vty)
|
||||
@ -7099,11 +7019,11 @@ int bgp_config_write(struct vty *vty)
|
||||
vty_out(vty, "bgp route-map delay-timer %u\n",
|
||||
bm->rmap_update_timer);
|
||||
|
||||
if (write)
|
||||
vty_out(vty, "!\n");
|
||||
|
||||
/* BGP configuration. */
|
||||
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
|
||||
if (write)
|
||||
vty_out(vty, "!\n");
|
||||
|
||||
/* Router bgp ASN */
|
||||
vty_out(vty, "router bgp %u", bgp->as);
|
||||
|
||||
@ -7323,54 +7243,46 @@ int bgp_config_write(struct vty *vty)
|
||||
vty_out(vty, " no auto-summary\n");
|
||||
|
||||
/* IPv4 unicast configuration. */
|
||||
write +=
|
||||
bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST);
|
||||
|
||||
/* IPv4 multicast configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP,
|
||||
SAFI_MULTICAST);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST);
|
||||
|
||||
/* IPv4 labeled-unicast configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP,
|
||||
SAFI_LABELED_UNICAST);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST);
|
||||
|
||||
/* IPv4 VPN configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP,
|
||||
SAFI_MPLS_VPN);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN);
|
||||
|
||||
/* ENCAPv4 configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP);
|
||||
|
||||
/* IPv6 unicast configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP6,
|
||||
SAFI_UNICAST);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST);
|
||||
|
||||
/* IPv6 multicast configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP6,
|
||||
SAFI_MULTICAST);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST);
|
||||
|
||||
/* IPv6 labeled-unicast configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP6,
|
||||
SAFI_LABELED_UNICAST);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP6,
|
||||
SAFI_LABELED_UNICAST);
|
||||
|
||||
/* IPv6 VPN configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP6,
|
||||
SAFI_MPLS_VPN);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN);
|
||||
|
||||
/* ENCAPv6 configuration. */
|
||||
write += bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP);
|
||||
bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP);
|
||||
|
||||
/* EVPN configuration. */
|
||||
write +=
|
||||
bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN);
|
||||
bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN);
|
||||
|
||||
#if ENABLE_BGP_VNC
|
||||
write += bgp_rfapi_cfg_write(vty, bgp);
|
||||
bgp_rfapi_cfg_write(vty, bgp);
|
||||
#endif
|
||||
|
||||
write++;
|
||||
vty_out(vty, "!\n");
|
||||
}
|
||||
return write;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bgp_master_init(struct thread_master *master)
|
||||
|
@ -1234,7 +1234,6 @@ extern void peer_xfer_config(struct peer *dst, struct peer *src);
|
||||
extern char *peer_uptime(time_t, char *, size_t, u_char, json_object *);
|
||||
|
||||
extern int bgp_config_write(struct vty *);
|
||||
extern void bgp_config_write_family_header(struct vty *, afi_t, safi_t, int *);
|
||||
|
||||
extern void bgp_master_init(struct thread_master *master);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user