]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_network.c
*: remove the configuration lock from all daemons
[mirror_frr.git] / bgpd / bgp_network.c
index 37838d514b36278046075647ebe5c077a971848b..e15b8f4ec38c356d7a418872e23fdc0d3d81bf47 100644 (file)
@@ -36,6 +36,7 @@
 #include "filter.h"
 #include "ns.h"
 #include "lib_errors.h"
+#include "nexthop.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_open.h"
@@ -44,6 +45,7 @@
 #include "bgpd/bgp_debug.h"
 #include "bgpd/bgp_errors.h"
 #include "bgpd/bgp_network.h"
+#include "bgpd/bgp_zebra.h"
 
 extern struct zebra_privs_t bgpd_privs;
 
@@ -222,10 +224,9 @@ static int bgp_get_instance_for_inc_conn(int sock, struct bgp **bgp_inst)
        rc = getsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, name, &name_len);
        if (rc != 0) {
 #if defined(HAVE_CUMULUS)
-               flog_err(
-                       EC_LIB_SOCKET,
-                       "[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d",
-                       safe_strerror(errno), sock);
+               flog_err(EC_LIB_SOCKET,
+                        "[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d",
+                        safe_strerror(errno), sock);
                return -1;
 #endif
        }
@@ -405,7 +406,6 @@ static int bgp_accept(struct thread *thread)
 
        peer = peer_create(&su, peer1->conf_if, peer1->bgp, peer1->local_as,
                           peer1->as, peer1->as_type, 0, 0, NULL);
-       peer->su = su;
        hash_release(peer->bgp->peerhash, peer);
        hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
 
@@ -619,15 +619,12 @@ int bgp_getsockname(struct peer *peer)
        if (!peer->su_remote)
                return -1;
 
-       if (bgp_nexthop_set(peer->su_local, peer->su_remote, &peer->nexthop,
-                           peer)) {
-#if defined(HAVE_CUMULUS)
-               flog_err(
-                       EC_BGP_NH_UPD,
-                       "%s: nexthop_set failed, resetting connection - intf %p",
-                       peer->host, peer->nexthop.ifp);
+       if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
+                                  &peer->nexthop, peer)) {
+               flog_err(EC_BGP_NH_UPD,
+                        "%s: nexthop_set failed, resetting connection - intf %p",
+                        peer->host, peer->nexthop.ifp);
                return -1;
-#endif
        }
        return 0;
 }
@@ -665,8 +662,7 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,
 
        ret = listen(sock, SOMAXCONN);
        if (ret < 0) {
-               flog_err_sys(EC_LIB_SOCKET, "listen: %s",
-                            safe_strerror(errno));
+               flog_err_sys(EC_LIB_SOCKET, "listen: %s", safe_strerror(errno));
                return ret;
        }
 
@@ -712,7 +708,11 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)
                             gai_strerror(ret));
                return -1;
        }
-
+       if (bgp_option_check(BGP_OPT_NO_ZEBRA) &&
+           bgp->vrf_id != VRF_DEFAULT) {
+               freeaddrinfo(ainfo_save);
+               return -1;
+       }
        count = 0;
        for (ainfo = ainfo_save; ainfo; ainfo = ainfo->ai_next) {
                int sock;