]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_nexthop.c
Merge pull request #4219 from bisdhdh/biswajitfrr_5
[mirror_frr.git] / bgpd / bgp_nexthop.c
index ea5e02d00ebf97133edea39eefaf40043d7aadc7..a8c507832cce14cf5ec1461cfc8e5ee35060903b 100644 (file)
@@ -505,6 +505,77 @@ int bgp_multiaccess_check_v4(struct in_addr nexthop, struct peer *peer)
        return (ret);
 }
 
+int bgp_multiaccess_check_v6(struct in6_addr nexthop, struct peer *peer)
+{
+       struct bgp_node *rn1;
+       struct bgp_node *rn2;
+       struct prefix p;
+       int ret;
+
+       p.family = AF_INET6;
+       p.prefixlen = IPV6_MAX_BITLEN;
+       p.u.prefix6 = nexthop;
+
+       rn1 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
+       if (!rn1)
+               return 0;
+
+       p.family = AF_INET6;
+       p.prefixlen = IPV6_MAX_BITLEN;
+       p.u.prefix6 = peer->su.sin6.sin6_addr;
+
+       rn2 = bgp_node_match(peer->bgp->connected_table[AFI_IP6], &p);
+       if (!rn2) {
+               bgp_unlock_node(rn1);
+               return 0;
+       }
+
+       ret = (rn1 == rn2) ? 1 : 0;
+
+       bgp_unlock_node(rn1);
+       bgp_unlock_node(rn2);
+
+       return ret;
+}
+
+int bgp_subgrp_multiaccess_check_v6(struct in6_addr nexthop,
+                       struct update_subgroup *subgrp)
+{
+       struct bgp_node *rn1 = NULL, *rn2 = NULL;
+       struct peer_af *paf = NULL;
+       struct prefix p = {0}, np = {0};
+       struct bgp *bgp = NULL;
+
+       np.family = AF_INET6;
+       np.prefixlen = IPV6_MAX_BITLEN;
+       np.u.prefix6 = nexthop;
+
+       p.family = AF_INET;
+       p.prefixlen = IPV6_MAX_BITLEN;
+
+       bgp = SUBGRP_INST(subgrp);
+       rn1 = bgp_node_match(bgp->connected_table[AFI_IP6], &np);
+       if (!rn1)
+               return 0;
+
+       SUBGRP_FOREACH_PEER (subgrp, paf) {
+
+               p.u.prefix6 = paf->peer->su.sin6.sin6_addr;
+               rn2 = bgp_node_match(bgp->connected_table[AFI_IP6], &p);
+               if (rn1 == rn2) {
+                       bgp_unlock_node(rn1);
+                       bgp_unlock_node(rn2);
+                       return 1;
+               }
+
+               if (rn2)
+                       bgp_unlock_node(rn2);
+       }
+
+       bgp_unlock_node(rn1);
+       return 0;
+}
+
 int bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,
                                    struct update_subgroup *subgrp)
 {