forked from Mirror/frr
bgpd: su_remote and su_local are properties of the connection
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>
This commit is contained in:
parent
0e416ff157
commit
78fa9b6feb
|
@ -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
|
||||
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);
|
||||
|
||||
|
|
|
@ -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[] = {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
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, peer->su_local, peer->su_remote,
|
||||
peer->host, connection->su_local, connection->su_remote,
|
||||
peer->update_if ? peer->update_if : "(None)",
|
||||
peer->nexthop.ifp ? peer->nexthop.ifp->name
|
||||
: "(Unknown)");
|
||||
peer->nexthop.ifp ? peer->nexthop.ifp->name : "(Unknown)");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
12
bgpd/bgpd.c
12
bgpd/bgpd.c
|
@ -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. */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue