From f8cfafdad48e0dc7b482215b1c8f1a753a8e9aa4 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 3 Sep 2015 06:50:16 -0700 Subject: [PATCH] Fix neighbor coming up without an as specified Ticket: CM-7012 Reviwed by: CCR-3451 Testing: See bug When you specify a neighbor and don't specify a remote-as the neighbor relationship will still come up with ipv6 unnumbered if you have RA configured on the interface. --- bgpd/bgp_packet.c | 12 +++++++++++- bgpd/bgp_vty.c | 7 ++++++- bgpd/bgpd.c | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 6bc0ef5c06..8531f37d78 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1011,7 +1011,17 @@ bgp_open_receive (struct peer *peer, bgp_size_t size) } /* Check neighbor as number. */ - if (peer->as_type == AS_INTERNAL) + if (peer->as_type == AS_UNSPECIFIED) + { + if (bgp_debug_neighbor_events(peer)) + zlog_debug("%s bad OPEN, remote AS is unspecified currently", peer->host); + bgp_notify_send_with_data(peer, + BGP_NOTIFY_OPEN_ERR, + BGP_NOTIFY_OPEN_BAD_PEER_AS, + notify_data_remote_as, 2); + return -1; + } + else if (peer->as_type == AS_INTERNAL) { if (remote_as != peer->bgp->as) { diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 3a7b82b446..58b8f14919 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9498,7 +9498,12 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js } else { - vty_out (vty, "remote AS %u, ", p->as); + if ((p->as_type == AS_SPECIFIED) || + (p->as_type == AS_EXTERNAL) || + (p->as_type == AS_INTERNAL)) + vty_out (vty, "remote AS %u, ", p->as); + else + vty_out (vty, "remote AS Unspecified, "); vty_out (vty, "local AS %u%s%s, ", p->change_local_as ? p->change_local_as : p->local_as, CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 8b5211ed5a..9bb95c5176 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1371,9 +1371,9 @@ peer_conf_interface_get(struct bgp *bgp, const char *conf_if, afi_t afi, { if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) && afi == AFI_IP && safi == SAFI_UNICAST) - peer = peer_create (NULL, conf_if, bgp, bgp->as, AS_SPECIFIED, 0, 0, 0); + peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, 0, 0); else - peer = peer_create (NULL, conf_if, bgp, bgp->as, AS_SPECIFIED, 0, afi, safi); + peer = peer_create (NULL, conf_if, bgp, bgp->as, 0, AS_UNSPECIFIED, afi, safi); if (peer && v6only) SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); -- 2.39.5