diff options
author | Russ White <russ@riw.us> | 2017-07-27 21:59:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 21:59:24 +0200 |
commit | 90f03597d9681162c360d61994b2a6ea036fdd26 (patch) | |
tree | 05ac157fb329a98b9d6003a095bcaa3962249e8f | |
parent | Merge pull request #859 from donaldsharp/bgp_ll_global (diff) | |
parent | bgpd: attribute-unchanged issues with peer-groups (diff) | |
download | frr-90f03597d9681162c360d61994b2a6ea036fdd26.tar.xz frr-90f03597d9681162c360d61994b2a6ea036fdd26.zip |
Merge pull request #861 from dwalton76/bgpd-attr-unchanged
bgpd: attribute-unchanged issues with peer-groups
-rw-r--r-- | bgpd/bgp_vty.c | 37 | ||||
-rw-r--r-- | bgpd/bgpd.c | 34 |
2 files changed, 48 insertions, 23 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 8ae015173..65a1473f7 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -4201,8 +4201,15 @@ DEFUN (neighbor_attr_unchanged, "Med attribute\n") { int idx = 0; - char *peer = argv[1]->arg; + char *peer_str = argv[1]->arg; + struct peer *peer; u_int16_t flags = 0; + afi_t afi = bgp_node_afi(vty); + safi_t safi = bgp_node_safi(vty); + + peer = peer_and_group_lookup_vty(vty, peer_str); + if (!peer) + return CMD_WARNING_CONFIG_FAILED; if (argv_find(argv, argc, "as-path", &idx)) SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); @@ -4213,15 +4220,35 @@ DEFUN (neighbor_attr_unchanged, if (argv_find(argv, argc, "med", &idx)) SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); - if (!flags) // no flags means all of them! - { + /* no flags means all of them! */ + if (!flags) { SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); + } else { + if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) && + peer_af_flag_check(peer, afi, safi, + PEER_FLAG_AS_PATH_UNCHANGED)) { + peer_af_flag_unset_vty(vty, peer_str, afi, safi, + PEER_FLAG_AS_PATH_UNCHANGED); + } + + if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) && + peer_af_flag_check(peer, afi, safi, + PEER_FLAG_NEXTHOP_UNCHANGED)) { + peer_af_flag_unset_vty(vty, peer_str, afi, safi, + PEER_FLAG_NEXTHOP_UNCHANGED); + } + + if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) && + peer_af_flag_check(peer, afi, safi, + PEER_FLAG_MED_UNCHANGED)) { + peer_af_flag_unset_vty(vty, peer_str, afi, safi, + PEER_FLAG_MED_UNCHANGED); + } } - return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), - bgp_node_safi(vty), flags); + return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); } ALIAS_HIDDEN( diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 3453da665..a0e2d6749 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6926,36 +6926,34 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, bgp_config_write_filter(vty, peer, afi, safi, write); /* atribute-unchanged. */ - if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED) - || CHECK_FLAG(peer->af_flags[afi][safi], - PEER_FLAG_NEXTHOP_UNCHANGED) - || CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) { - if (peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_AS_PATH_UNCHANGED) - && peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_NEXTHOP_UNCHANGED) - && peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_MED_UNCHANGED)) { - afi_header_vty_out( - vty, afi, safi, write, - " neighbor %s attribute-unchanged\n", addr); - } else { + if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) || + peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) || + peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { + + if (!peer_group_active(peer) || + peergroup_af_flag_check(peer, afi, safi, + PEER_FLAG_AS_PATH_UNCHANGED) || + peergroup_af_flag_check(peer, afi, safi, + PEER_FLAG_NEXTHOP_UNCHANGED) || + peergroup_af_flag_check(peer, afi, safi, + PEER_FLAG_MED_UNCHANGED)) { + afi_header_vty_out( vty, afi, safi, write, " neighbor %s attribute-unchanged%s%s%s\n", addr, - peergroup_af_flag_check( + peer_af_flag_check( peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) ? " as-path" : "", - peergroup_af_flag_check( + peer_af_flag_check( peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) ? " next-hop" : "", - peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_MED_UNCHANGED) + peer_af_flag_check(peer, afi, safi, + PEER_FLAG_MED_UNCHANGED) ? " med" : ""); } |