]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_zebra.c
bgpd: Allow peering via 127.0.0.0/8
[mirror_frr.git] / bgpd / bgp_zebra.c
index d05768da05145889941e4c7addb47899968ad44a..346b3c90fd8fa93ba477bdfa35f07d5c94d37d70 100644 (file)
@@ -834,6 +834,13 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
                                                      peer->bgp->vrf_id);
        }
 
+       /* Handle peerings via loopbacks. For instance, peer between
+        * 127.0.0.1 and 127.0.0.2. In short, allow peering with self
+        * via 127.0.0.0/8.
+        */
+       if (!ifp && cmd_allow_reserved_ranges_get())
+               ifp = if_get_vrf_loopback(peer->bgp->vrf_id);
+
        if (!ifp) {
                /*
                 * BGP views do not currently get proper data
@@ -2596,8 +2603,8 @@ static int bgp_zebra_route_notify_owner(int command, struct zclient *zclient,
        }
 
        /* Find the bgp route node */
-       dest = bgp_afi_node_lookup(bgp->rib[afi][safi], afi, safi, &p,
-                                  &bgp->vrf_prd);
+       dest = bgp_safi_node_lookup(bgp->rib[afi][safi], safi, &p,
+                                   &bgp->vrf_prd);
        if (!dest)
                return -1;
 
@@ -3748,16 +3755,22 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
        struct zapi_cap api;
        int ret = BGP_GR_SUCCESS;
 
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("%s: Sending %sable for %s", __func__,
+                          disable ? "dis" : "en", bgp->name_pretty);
+
        if (zclient == NULL) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("zclient invalid");
+                       zlog_debug("%s: %s zclient invalid", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
        /* Check if the client is connected */
        if ((zclient->sock < 0) || (zclient->t_connect)) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("client not connected");
+                       zlog_debug("%s: %s client not connected", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
@@ -3776,7 +3789,8 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
 
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
            == ZCLIENT_SEND_FAILURE) {
-               zlog_err("error sending capability");
+               zlog_err("%s: %s error sending capability", __func__,
+                        bgp->name_pretty);
                ret = BGP_GR_FAILURE;
        } else {
                if (disable)
@@ -3785,7 +3799,8 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
                        bgp->present_zebra_gr_state = ZEBRA_GR_ENABLE;
 
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("send capabilty success");
+                       zlog_debug("%s: %s send capabilty success", __func__,
+                                  bgp->name_pretty);
                ret = BGP_GR_SUCCESS;
        }
        return ret;
@@ -3794,32 +3809,41 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
 /* Send route update pesding or completed status to RIB for the
  * specific AFI, SAFI
  */
-int bgp_zebra_update(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type)
+int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
+                    enum zserv_client_capabilities type)
 {
        struct zapi_cap api = {0};
 
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("%s: %s afi: %u safi: %u Command %s", __func__,
+                          bgp->name_pretty, afi, safi,
+                          zserv_gr_client_cap_string(type));
+
        if (zclient == NULL) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("zclient == NULL, invalid");
+                       zlog_debug("%s: %s zclient == NULL, invalid", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
        /* Check if the client is connected */
        if ((zclient->sock < 0) || (zclient->t_connect)) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("client not connected");
+                       zlog_debug("%s: %s client not connected", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
        api.afi = afi;
        api.safi = safi;
-       api.vrf_id = vrf_id;
+       api.vrf_id = bgp->vrf_id;
        api.cap = type;
 
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
            == ZCLIENT_SEND_FAILURE) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("error sending capability");
+                       zlog_debug("%s: %s error sending capability", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
        return BGP_GR_SUCCESS;
@@ -3831,6 +3855,10 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
 {
        struct zapi_cap api;
 
+       if (BGP_DEBUG(zebra, ZEBRA))
+               zlog_debug("%s: %s Timer Update to %u", __func__,
+                          bgp->name_pretty, bgp->rib_stale_time);
+
        if (zclient == NULL) {
                if (BGP_DEBUG(zebra, ZEBRA))
                        zlog_debug("zclient invalid");
@@ -3840,7 +3868,8 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
        /* Check if the client is connected */
        if ((zclient->sock < 0) || (zclient->t_connect)) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("client not connected");
+                       zlog_debug("%s: %s client not connected", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
 
@@ -3851,11 +3880,11 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
        if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
            == ZCLIENT_SEND_FAILURE) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("error sending capability");
+                       zlog_debug("%s: %s error sending capability", __func__,
+                                  bgp->name_pretty);
                return BGP_GR_FAILURE;
        }
-       if (BGP_DEBUG(zebra, ZEBRA))
-               zlog_debug("send capabilty success");
+
        return BGP_GR_SUCCESS;
 }