]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgpd.c
Merge branch 'master' into evpn-session-vrf
[mirror_frr.git] / bgpd / bgpd.c
index 8fcf417b3a2e11577be2e44d8557b688a768aa9f..17928d6850e02cb39c143f41be5710d5ab7da48b 100644 (file)
@@ -707,6 +707,7 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi)
 {
        struct peer_af *af;
        int afid;
+       struct bgp *bgp;
 
        if (!peer)
                return NULL;
@@ -715,6 +716,7 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi)
        if (afid >= BGP_AF_MAX)
                return NULL;
 
+       bgp = peer->bgp;
        assert(peer->peer_af_array[afid] == NULL);
 
        /* Allocate new peer af */
@@ -725,6 +727,7 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi)
        af->safi = safi;
        af->afid = afid;
        af->peer = peer;
+       bgp->af_peer_count[afi][safi]++;
 
        return af;
 }
@@ -747,6 +750,7 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)
 {
        struct peer_af *af;
        int afid;
+       struct bgp *bgp;
 
        if (!peer)
                return -1;
@@ -759,6 +763,7 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)
        if (!af)
                return -1;
 
+       bgp = peer->bgp;
        bgp_stop_announce_route_timer(af);
 
        if (PAF_SUBGRP(af)) {
@@ -768,8 +773,12 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)
                                   af->subgroup->id, peer->host);
        }
 
+
        update_subgroup_remove_peer(af->subgroup, af);
 
+       if (bgp->af_peer_count[afi][safi])
+               bgp->af_peer_count[afi][safi]--;
+
        peer->peer_af_array[afid] = NULL;
        XFREE(MTYPE_BGP_PEER_AF, af);
        return 0;
@@ -2714,7 +2723,7 @@ int peer_group_bind(struct bgp *bgp, union sockunion *su, struct peer *peer,
                        peer->sort = group->conf->sort;
                }
 
-               if (!group->conf->as) {
+               if (!group->conf->as && peer_sort(peer)) {
                        if (peer_sort(group->conf) != BGP_PEER_INTERNAL
                            && peer_sort(group->conf) != peer_sort(peer)) {
                                if (as)