]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: su_remote and su_local are properties of the connection
authorDonald Sharp <sharpd@nvidia.com>
Tue, 17 Dec 2024 20:56:19 +0000 (15:56 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 10 Jan 2025 15:07:11 +0000 (10:07 -0500)
su_local and su_remote in the peer can change based upon
if we are initiating the remote connection or receiving it.
As such we need to treat it as a property of the connection.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
15 files changed:
bgpd/bgp_bfd.c
bgpd/bgp_bmp.c
bgpd/bgp_dump.c
bgpd/bgp_fsm.c
bgpd/bgp_network.c
bgpd/bgp_route.c
bgpd/bgp_routemap.c
bgpd/bgp_script.c
bgpd/bgp_snmp_bgp4.c
bgpd/bgp_snmp_bgp4v2.c
bgpd/bgp_vty.c
bgpd/bgp_zebra.c
bgpd/bgpd.c
bgpd/bgpd.h
bgpd/rfapi/rfapi_import.c

index 50b00d21b195f3e485a11cc1a3fd361e75d7d3d5..78759ae2b6075acaddac86a24d71a91dec75612f 100644 (file)
@@ -188,7 +188,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
                        }
                }
        } else {
-               source = p->su_local;
+               source = p->connection->su_local;
        }
 
        /* Update peer's source/destination addresses. */
@@ -316,13 +316,14 @@ void bgp_peer_configure_bfd(struct peer *p, bool manual)
        /* Configure session with basic BGP peer data. */
        if (p->connection->su.sa.sa_family == AF_INET)
                bfd_sess_set_ipv4_addrs(p->bfd_config->session,
-                                       p->su_local ? &p->su_local->sin.sin_addr
-                                                   : NULL,
+                                       p->connection->su_local
+                                               ? &p->connection->su_local->sin.sin_addr
+                                               : NULL,
                                        &p->connection->su.sin.sin_addr);
        else
                bfd_sess_set_ipv6_addrs(p->bfd_config->session,
-                                       p->su_local
-                                               ? &p->su_local->sin6.sin6_addr
+                                       p->connection->su_local
+                                               ? &p->connection->su_local->sin6.sin6_addr
                                                : NULL,
                                        &p->connection->su.sin6.sin6_addr);
 
index 036bece35970db19c7c875158ffff3414d0aa42c..ccbf7dcd305e54d5b4759ceaa4bbd3e555a38f5f 100644 (file)
@@ -496,29 +496,29 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
                /* Local Address (16 bytes) */
                if (is_locrib)
                        stream_put(s, 0, 16);
-               else if (peer->su_local->sa.sa_family == AF_INET6)
-                       stream_put(s, &peer->su_local->sin6.sin6_addr, 16);
-               else if (peer->su_local->sa.sa_family == AF_INET) {
+               else if (peer->connection->su_local->sa.sa_family == AF_INET6)
+                       stream_put(s, &peer->connection->su_local->sin6.sin6_addr, 16);
+               else if (peer->connection->su_local->sa.sa_family == AF_INET) {
                        stream_putl(s, 0);
                        stream_putl(s, 0);
                        stream_putl(s, 0);
-                       stream_put_in_addr(s, &peer->su_local->sin.sin_addr);
+                       stream_put_in_addr(s, &peer->connection->su_local->sin.sin_addr);
                }
 
                /* Local Port, Remote Port */
-               if (!peer->su_local || is_locrib)
+               if (!peer->connection->su_local || is_locrib)
                        stream_putw(s, 0);
-               else if (peer->su_local->sa.sa_family == AF_INET6)
-                       stream_putw(s, htons(peer->su_local->sin6.sin6_port));
-               else if (peer->su_local->sa.sa_family == AF_INET)
-                       stream_putw(s, htons(peer->su_local->sin.sin_port));
+               else if (peer->connection->su_local->sa.sa_family == AF_INET6)
+                       stream_putw(s, htons(peer->connection->su_local->sin6.sin6_port));
+               else if (peer->connection->su_local->sa.sa_family == AF_INET)
+                       stream_putw(s, htons(peer->connection->su_local->sin.sin_port));
 
-               if (!peer->su_remote || is_locrib)
+               if (!peer->connection->su_remote || is_locrib)
                        stream_putw(s, 0);
-               else if (peer->su_remote->sa.sa_family == AF_INET6)
-                       stream_putw(s, htons(peer->su_remote->sin6.sin6_port));
-               else if (peer->su_remote->sa.sa_family == AF_INET)
-                       stream_putw(s, htons(peer->su_remote->sin.sin_port));
+               else if (peer->connection->su_remote->sa.sa_family == AF_INET6)
+                       stream_putw(s, htons(peer->connection->su_remote->sin6.sin6_port));
+               else if (peer->connection->su_remote->sa.sa_family == AF_INET)
+                       stream_putw(s, htons(peer->connection->su_remote->sin.sin_port));
 
                /* TODO craft message with fields & capabilities for loc-rib */
                static const uint8_t dummy_open[] = {
index 53b52124822e90f3dfb19e2f65c71c8542131ed6..e71835d1cf8141616d95f7bb4462c0aebf4dbdef 100644 (file)
@@ -480,8 +480,8 @@ static void bgp_dump_common(struct stream *obuf, struct peer *peer,
                stream_put(obuf, &peer->connection->su.sin.sin_addr,
                           IPV4_MAX_BYTELEN);
 
-               if (peer->su_local)
-                       stream_put(obuf, &peer->su_local->sin.sin_addr,
+               if (peer->connection->su_local)
+                       stream_put(obuf, &peer->connection->su_local->sin.sin_addr,
                                   IPV4_MAX_BYTELEN);
                else
                        stream_put(obuf, empty, IPV4_MAX_BYTELEN);
@@ -494,8 +494,8 @@ static void bgp_dump_common(struct stream *obuf, struct peer *peer,
                stream_put(obuf, &peer->connection->su.sin6.sin6_addr,
                           IPV6_MAX_BYTELEN);
 
-               if (peer->su_local)
-                       stream_put(obuf, &peer->su_local->sin6.sin6_addr,
+               if (peer->connection->su_local)
+                       stream_put(obuf, &peer->connection->su_local->sin6.sin6_addr,
                                   IPV6_MAX_BYTELEN);
                else
                        stream_put(obuf, empty, IPV6_MAX_BYTELEN);
index 3389f9afd9c052c6daed43830550cf0d6027cb36..8097f5317d179ef6a0644cde9d99e59c753d561e 100644 (file)
@@ -1722,8 +1722,8 @@ bgp_connect_success(struct peer_connection *connection)
 
        if (bgp_debug_neighbor_events(peer)) {
                if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
-                       zlog_debug("%s open active, local address %pSU",
-                                  peer->host, peer->su_local);
+                       zlog_debug("%s open active, local address %pSU", peer->host,
+                                  connection->su_local);
                else
                        zlog_debug("%s passive open", peer->host);
        }
@@ -1768,8 +1768,8 @@ bgp_connect_success_w_delayopen(struct peer_connection *connection)
 
        if (bgp_debug_neighbor_events(peer)) {
                if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
-                       zlog_debug("%s open active, local address %pSU",
-                                  peer->host, peer->su_local);
+                       zlog_debug("%s open active, local address %pSU", peer->host,
+                                  connection->su_local);
                else
                        zlog_debug("%s passive open", peer->host);
        }
@@ -1820,13 +1820,13 @@ static void bgp_connect_in_progress_update_connection(struct peer_connection *co
        struct peer *peer = connection->peer;
 
        bgp_updatesockname(connection);
-       if (!peer->su_remote && !BGP_CONNECTION_SU_UNSPEC(connection)) {
+       if (!connection->su_remote && !BGP_CONNECTION_SU_UNSPEC(connection)) {
                /* if connect initiated, then dest port and dest addresses are well known */
-               peer->su_remote = sockunion_dup(&connection->su);
-               if (sockunion_family(peer->su_remote) == AF_INET)
-                       peer->su_remote->sin.sin_port = htons(peer->port);
-               else if (sockunion_family(peer->su_remote) == AF_INET6)
-                       peer->su_remote->sin6.sin6_port = htons(peer->port);
+               connection->su_remote = sockunion_dup(&connection->su);
+               if (sockunion_family(connection->su_remote) == AF_INET)
+                       connection->su_remote->sin.sin_port = htons(peer->port);
+               else if (sockunion_family(connection->su_remote) == AF_INET6)
+                       connection->su_remote->sin6.sin6_port = htons(peer->port);
        }
 }
 
index 35ceb9d99b0c03f4723d59a28be12afc57862ea3..e4984ea46e5be47879faa554678716b93b47c677 100644 (file)
@@ -863,20 +863,18 @@ enum connect_result bgp_connect(struct peer_connection *connection)
 
 void bgp_updatesockname(struct peer_connection *connection)
 {
-       struct peer *peer = connection->peer;
-
-       if (peer->su_local) {
-               sockunion_free(peer->su_local);
-               peer->su_local = NULL;
+       if (connection->su_local) {
+               sockunion_free(connection->su_local);
+               connection->su_local = NULL;
        }
 
-       if (peer->su_remote) {
-               sockunion_free(peer->su_remote);
-               peer->su_remote = NULL;
+       if (connection->su_remote) {
+               sockunion_free(connection->su_remote);
+               connection->su_remote = NULL;
        }
 
-       peer->su_local = sockunion_getsockname(connection->fd);
-       peer->su_remote = sockunion_getpeername(connection->fd);
+       connection->su_local = sockunion_getsockname(connection->fd);
+       connection->su_remote = sockunion_getpeername(connection->fd);
 }
 
 /* After TCP connection is established.  Get local address and port. */
@@ -886,15 +884,13 @@ int bgp_getsockname(struct peer_connection *connection)
 
        bgp_updatesockname(connection);
 
-       if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
-                                  &peer->nexthop, peer)) {
-               flog_err(
-                       EC_BGP_NH_UPD,
-                       "%s: nexthop_set failed, local: %pSUp remote: %pSUp update_if: %s resetting connection - intf %s",
-                       peer->host, peer->su_local, peer->su_remote,
-                       peer->update_if ? peer->update_if : "(None)",
-                       peer->nexthop.ifp ? peer->nexthop.ifp->name
-                                         : "(Unknown)");
+       if (!bgp_zebra_nexthop_set(connection->su_local, connection->su_remote, &peer->nexthop,
+                                  peer)) {
+               flog_err(EC_BGP_NH_UPD,
+                        "%s: nexthop_set failed, local: %pSUp remote: %pSUp update_if: %s resetting connection - intf %s",
+                        peer->host, connection->su_local, connection->su_remote,
+                        peer->update_if ? peer->update_if : "(None)",
+                        peer->nexthop.ifp ? peer->nexthop.ifp->name : "(Unknown)");
                return -1;
        }
        return 0;
index f520c2e2bc843694e5f3be239e09d09eeae6a594..dcbb888ca4db95da11e61527fc06e6cdd34fc57b 100644 (file)
@@ -1576,17 +1576,17 @@ int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
        }
 
        /* locally configured routes to advertise do not have su_remote */
-       if (peer_new->su_remote == NULL) {
+       if (peer_new->connection->su_remote == NULL) {
                *reason = bgp_path_selection_local_configured;
                return 0;
        }
 
-       if (peer_exist->su_remote == NULL) {
+       if (peer_exist->connection->su_remote == NULL) {
                *reason = bgp_path_selection_local_configured;
                return 1;
        }
 
-       ret = sockunion_cmp(peer_new->su_remote, peer_exist->su_remote);
+       ret = sockunion_cmp(peer_new->connection->su_remote, peer_exist->connection->su_remote);
 
        if (ret == 1) {
                *reason = bgp_path_selection_neighbor_ip;
@@ -12003,9 +12003,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa
                            || type == bgp_show_type_damp_neighbor) {
                                union sockunion *su = output_arg;
 
-                               if (pi->peer == NULL
-                                   || pi->peer->su_remote == NULL
-                                   || !sockunion_same(pi->peer->su_remote, su))
+                               if (pi->peer == NULL || pi->peer->connection->su_remote == NULL ||
+                                   !sockunion_same(pi->peer->connection->su_remote, su))
                                        continue;
                        }
                        if (type == bgp_show_type_cidr_only) {
index f0bc84ce36c0ad2f4b0cac5d13998e4631ac1161..d8d1fa5ddc5e585f5ade28a87842ffaa4b69a036 100644 (file)
@@ -2066,10 +2066,9 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix, void *object)
                         BATTR_RMAP_NEXTHOP_UNCHANGED);
        } else if (rins->peer_address) {
                if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) &&
-                   peer->su_remote &&
-                   sockunion_family(peer->su_remote) == AF_INET) {
-                       path->attr->nexthop.s_addr =
-                               sockunion2ip(peer->su_remote);
+                   peer->connection->su_remote &&
+                   sockunion_family(peer->connection->su_remote) == AF_INET) {
+                       path->attr->nexthop.s_addr = sockunion2ip(peer->connection->su_remote);
                        SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP));
                } else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
                        /* The next hop value will be set as part of
@@ -4143,9 +4142,9 @@ route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx, void *object)
        path = object;
        peer = path->peer;
 
-       if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) &&
-           peer->su_remote && sockunion_family(peer->su_remote) == AF_INET6) {
-               peer_address = peer->su_remote->sin6.sin6_addr;
+       if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) && peer->connection->su_remote &&
+           sockunion_family(peer->connection->su_remote) == AF_INET6) {
+               peer_address = peer->connection->su_remote->sin6.sin6_addr;
                /* Set next hop value and length in attribute. */
                if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
                        path->attr->mp_nexthop_local = peer_address;
index b37385812efb6592c58416f187e07d7f44250655..4874813bed9e7f3f18e9db1b3de99affa92b62ea 100644 (file)
@@ -37,9 +37,9 @@ void lua_pushpeer(lua_State *L, const struct peer *peer)
        lua_setfield(L, -2, "last_readtime");
        lua_pushinteger(L, peer->resettime);
        lua_setfield(L, -2, "last_resettime");
-       lua_pushsockunion(L, peer->su_local);
+       lua_pushsockunion(L, peer->connection->su_local);
        lua_setfield(L, -2, "local_address");
-       lua_pushsockunion(L, peer->su_remote);
+       lua_pushsockunion(L, peer->connection->su_remote);
        lua_setfield(L, -2, "remote_address");
        lua_pushinteger(L, peer->cap);
        lua_setfield(L, -2, "capabilities");
index 755777c167898f630a8833b65d6b6e963b455397..32430f42a8718a484f4cef76e6ee807e5c1a0cae 100644 (file)
@@ -266,25 +266,23 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length,
        case BGPPEERNEGOTIATEDVERSION:
                return SNMP_INTEGER(BGP_VERSION_4);
        case BGPPEERLOCALADDR:
-               if (peer->su_local)
-                       return SNMP_IPADDRESS(peer->su_local->sin.sin_addr);
+               if (peer->connection->su_local)
+                       return SNMP_IPADDRESS(peer->connection->su_local->sin.sin_addr);
                else
                        return SNMP_IPADDRESS(bgp_empty_addr);
        case BGPPEERLOCALPORT:
-               if (peer->su_local)
-                       return SNMP_INTEGER(
-                               ntohs(peer->su_local->sin.sin_port));
+               if (peer->connection->su_local)
+                       return SNMP_INTEGER(ntohs(peer->connection->su_local->sin.sin_port));
                else
                        return SNMP_INTEGER(0);
        case BGPPEERREMOTEADDR:
-               if (peer->su_remote)
-                       return SNMP_IPADDRESS(peer->su_remote->sin.sin_addr);
+               if (peer->connection->su_remote)
+                       return SNMP_IPADDRESS(peer->connection->su_remote->sin.sin_addr);
                else
                        return SNMP_IPADDRESS(bgp_empty_addr);
        case BGPPEERREMOTEPORT:
-               if (peer->su_remote)
-                       return SNMP_INTEGER(
-                               ntohs(peer->su_remote->sin.sin_port));
+               if (peer->connection->su_remote)
+                       return SNMP_INTEGER(ntohs(peer->connection->su_remote->sin.sin_port));
                else
                        return SNMP_INTEGER(0);
        case BGPPEERREMOTEAS:
index 5f36e2987670f809329e8e8cc7ef3a8a0a8f9532..724eefe60108b66a334e06daab749a23413fed08 100644 (file)
@@ -208,49 +208,42 @@ static uint8_t *bgpv2PeerTable(struct variable *v, oid name[], size_t *length,
        case BGP4V2_PEER_INSTANCE:
                return SNMP_INTEGER(peer->bgp->vrf_id);
        case BGP4V2_PEER_LOCAL_ADDR_TYPE:
-               if (peer->su_local)
-                       return SNMP_INTEGER(peer->su_local->sa.sa_family ==
-                                                           AF_INET
+               if (peer->connection->su_local)
+                       return SNMP_INTEGER(peer->connection->su_local->sa.sa_family == AF_INET
                                                    ? AFI_IP
                                                    : AFI_IP6);
                else
                        return SNMP_INTEGER(0);
        case BGP4V2_PEER_LOCAL_ADDR:
-               if (peer->su_local)
-                       if (peer->su_local->sa.sa_family == AF_INET)
-                               return SNMP_IPADDRESS(
-                                       peer->su_local->sin.sin_addr);
+               if (peer->connection->su_local)
+                       if (peer->connection->su_local->sa.sa_family == AF_INET)
+                               return SNMP_IPADDRESS(peer->connection->su_local->sin.sin_addr);
                        else
-                               return SNMP_IP6ADDRESS(
-                                       peer->su_local->sin6.sin6_addr);
+                               return SNMP_IP6ADDRESS(peer->connection->su_local->sin6.sin6_addr);
                else
                        return SNMP_IPADDRESS(bgp_empty_addr);
        case BGP4V2_PEER_REMOTE_ADDR_TYPE:
-               if (peer->su_remote)
-                       return SNMP_INTEGER(peer->su_remote->sa.sa_family ==
-                                                           AF_INET
+               if (peer->connection->su_remote)
+                       return SNMP_INTEGER(peer->connection->su_remote->sa.sa_family == AF_INET
                                                    ? AFI_IP
                                                    : AFI_IP6);
                else
                        return SNMP_INTEGER(0);
        case BGP4V2_PEER_REMOTE_ADDR:
-               if (peer->su_remote)
-                       if (peer->su_remote->sa.sa_family == AF_INET)
-                               return SNMP_IPADDRESS(
-                                       peer->su_remote->sin.sin_addr);
+               if (peer->connection->su_remote)
+                       if (peer->connection->su_remote->sa.sa_family == AF_INET)
+                               return SNMP_IPADDRESS(peer->connection->su_remote->sin.sin_addr);
                        else
-                               return SNMP_IP6ADDRESS(
-                                       peer->su_remote->sin6.sin6_addr);
+                               return SNMP_IP6ADDRESS(peer->connection->su_remote->sin6.sin6_addr);
                else
                        return SNMP_IPADDRESS(bgp_empty_addr);
        case BGP4V2_PEER_LOCAL_PORT:
-               if (peer->su_local)
-                       if (peer->su_local->sa.sa_family == AF_INET)
-                               return SNMP_INTEGER(
-                                       ntohs(peer->su_local->sin.sin_port));
+               if (peer->connection->su_local)
+                       if (peer->connection->su_local->sa.sa_family == AF_INET)
+                               return SNMP_INTEGER(ntohs(peer->connection->su_local->sin.sin_port));
                        else
                                return SNMP_INTEGER(
-                                       ntohs(peer->su_local->sin6.sin6_port));
+                                       ntohs(peer->connection->su_local->sin6.sin6_port));
                else
                        return SNMP_INTEGER(0);
        case BGP4V2_PEER_LOCAL_AS:
@@ -258,13 +251,13 @@ static uint8_t *bgpv2PeerTable(struct variable *v, oid name[], size_t *length,
        case BGP4V2_PEER_LOCAL_IDENTIFIER:
                return SNMP_IPADDRESS(peer->local_id);
        case BGP4V2_PEER_REMOTE_PORT:
-               if (peer->su_remote)
-                       if (peer->su_remote->sa.sa_family == AF_INET)
+               if (peer->connection->su_remote)
+                       if (peer->connection->su_remote->sa.sa_family == AF_INET)
                                return SNMP_INTEGER(
-                                       ntohs(peer->su_remote->sin.sin_port));
+                                       ntohs(peer->connection->su_remote->sin.sin_port));
                        else
                                return SNMP_INTEGER(
-                                       ntohs(peer->su_remote->sin6.sin6_port));
+                                       ntohs(peer->connection->su_remote->sin6.sin6_port));
                else
                        return SNMP_INTEGER(0);
        case BGP4V2_PEER_REMOTE_AS:
index 56b06106f3341e02cd8832ddf93c3d5dd395a2f8..b991ca4c58c92706e4667d979226247f500f97ae 100644 (file)
@@ -15845,15 +15845,15 @@ CPP_NOTICE("Remove `gracefulRestartCapability` JSON field")
        }
 
        /* Local address. */
-       if (p->su_local) {
+       if (p->connection->su_local) {
                if (use_json) {
                        json_object_string_addf(json_neigh, "hostLocal", "%pSU",
-                                               p->su_local);
+                                               p->connection->su_local);
                        json_object_int_add(json_neigh, "portLocal",
-                                           ntohs(p->su_local->sin.sin_port));
+                                           ntohs(p->connection->su_local->sin.sin_port));
                } else
-                       vty_out(vty, "Local host: %pSU, Local port: %d\n",
-                               p->su_local, ntohs(p->su_local->sin.sin_port));
+                       vty_out(vty, "Local host: %pSU, Local port: %d\n", p->connection->su_local,
+                               ntohs(p->connection->su_local->sin.sin_port));
        } else {
                if (use_json) {
                        json_object_string_add(json_neigh, "hostLocal",
@@ -15863,16 +15863,16 @@ CPP_NOTICE("Remove `gracefulRestartCapability` JSON field")
        }
 
        /* Remote address. */
-       if (p->su_remote) {
+       if (p->connection->su_remote) {
                if (use_json) {
-                       json_object_string_addf(json_neigh, "hostForeign",
-                                               "%pSU", p->su_remote);
+                       json_object_string_addf(json_neigh, "hostForeign", "%pSU",
+                                               p->connection->su_remote);
                        json_object_int_add(json_neigh, "portForeign",
-                                           ntohs(p->su_remote->sin.sin_port));
+                                           ntohs(p->connection->su_remote->sin.sin_port));
                } else
                        vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n",
-                               p->su_remote,
-                               ntohs(p->su_remote->sin.sin_port));
+                               p->connection->su_remote,
+                               ntohs(p->connection->su_remote->sin.sin_port));
        } else {
                if (use_json) {
                        json_object_string_add(json_neigh, "hostForeign",
@@ -15882,7 +15882,7 @@ CPP_NOTICE("Remove `gracefulRestartCapability` JSON field")
        }
 
        /* Nexthop display. */
-       if (p->su_local) {
+       if (p->connection->su_local) {
                if (use_json) {
                        json_object_string_addf(json_neigh, "nexthop", "%pI4",
                                                &p->nexthop.v4);
index 7ad9ce472603d3954a0409c1833e740a188f4649..146630ec6b1d0437a96c891e0ae9adecb45df64f 100644 (file)
@@ -953,13 +953,10 @@ bgp_path_info_to_ipv6_nexthop(struct bgp_path_info *path, ifindex_t *ifindex)
                                *ifindex = path->attr->nh_ifindex;
                } else {
                        /* Workaround for Cisco's nexthop bug.  */
-                       if (IN6_IS_ADDR_UNSPECIFIED(
-                                   &path->attr->mp_nexthop_global)
-                           && path->peer->su_remote
-                           && path->peer->su_remote->sa.sa_family
-                                      == AF_INET6) {
-                               nexthop =
-                                       &path->peer->su_remote->sin6.sin6_addr;
+                       if (IN6_IS_ADDR_UNSPECIFIED(&path->attr->mp_nexthop_global) &&
+                           path->peer->connection->su_remote &&
+                           path->peer->connection->su_remote->sa.sa_family == AF_INET6) {
+                               nexthop = &path->peer->connection->su_remote->sin6.sin6_addr;
                                if (IN6_IS_ADDR_LINKLOCAL(nexthop))
                                        *ifindex = path->peer->nexthop.ifp
                                                           ->ifindex;
index 02333db1c267c9dbdbf86bd968f69aea45e0a772..20f4f7a8f891d5fcb417b2cdba7c430e306264dc 100644 (file)
@@ -2768,14 +2768,14 @@ int peer_delete(struct peer *peer)
        }
 
        /* Local and remote addresses. */
-       if (peer->su_local) {
-               sockunion_free(peer->su_local);
-               peer->su_local = NULL;
+       if (peer->connection->su_local) {
+               sockunion_free(peer->connection->su_local);
+               peer->connection->su_local = NULL;
        }
 
-       if (peer->su_remote) {
-               sockunion_free(peer->su_remote);
-               peer->su_remote = NULL;
+       if (peer->connection->su_remote) {
+               sockunion_free(peer->connection->su_remote);
+               peer->connection->su_remote = NULL;
        }
 
        /* Free filter related memory.  */
index 65b268c4eaff99e26caa1cad4948e7365de5e760..c72072852d1bfde4ceeb4ce42511b903b2bc4f99 100644 (file)
@@ -1258,6 +1258,9 @@ struct peer_connection {
        union sockunion su;
 #define BGP_CONNECTION_SU_UNSPEC(connection)                                   \
        (connection->su.sa.sa_family == AF_UNSPEC)
+
+       union sockunion *su_local;  /* Sockunion of local address. */
+       union sockunion *su_remote; /* Sockunion of remote address. */
 };
 extern struct peer_connection *bgp_peer_connection_new(struct peer *peer);
 extern void bgp_peer_connection_free(struct peer_connection **connection);
@@ -1350,8 +1353,6 @@ struct peer {
        char *update_if;
        union sockunion *update_source;
 
-       union sockunion *su_local;  /* Sockunion of local address.  */
-       union sockunion *su_remote; /* Sockunion of remote address.  */
        bool shared_network;        /* Is this peer shared same network. */
        struct bgp_nexthop nexthop; /* Nexthop */
 
index 44dfc88cf765b64371da6ebb4e9a50688bfb1f75..99d8bcfce44e6fc573a03a0363486c63bfb7921f 100644 (file)
@@ -1931,8 +1931,8 @@ static void rfapiBgpInfoAttachSorted(struct agg_node *rn,
        if (VNC_DEBUG(IMPORT_BI_ATTACH)) {
                vnc_zlog_debug_verbose("%s: info_new->peer=%p", __func__,
                                       info_new->peer);
-               vnc_zlog_debug_verbose("%s: info_new->peer->su_remote=%p",
-                                      __func__, info_new->peer->su_remote);
+               vnc_zlog_debug_verbose("%s: info_new->peer->su_remote=%p", __func__,
+                                      info_new->peer->connection->su_remote);
        }
 
        for (prev = NULL, next = rn->info; next;