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 {
|
} else {
|
||||||
source = p->su_local;
|
source = p->connection->su_local;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update peer's source/destination addresses. */
|
/* 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. */
|
/* Configure session with basic BGP peer data. */
|
||||||
if (p->connection->su.sa.sa_family == AF_INET)
|
if (p->connection->su.sa.sa_family == AF_INET)
|
||||||
bfd_sess_set_ipv4_addrs(p->bfd_config->session,
|
bfd_sess_set_ipv4_addrs(p->bfd_config->session,
|
||||||
p->su_local ? &p->su_local->sin.sin_addr
|
p->connection->su_local
|
||||||
: NULL,
|
? &p->connection->su_local->sin.sin_addr
|
||||||
|
: NULL,
|
||||||
&p->connection->su.sin.sin_addr);
|
&p->connection->su.sin.sin_addr);
|
||||||
else
|
else
|
||||||
bfd_sess_set_ipv6_addrs(p->bfd_config->session,
|
bfd_sess_set_ipv6_addrs(p->bfd_config->session,
|
||||||
p->su_local
|
p->connection->su_local
|
||||||
? &p->su_local->sin6.sin6_addr
|
? &p->connection->su_local->sin6.sin6_addr
|
||||||
: NULL,
|
: NULL,
|
||||||
&p->connection->su.sin6.sin6_addr);
|
&p->connection->su.sin6.sin6_addr);
|
||||||
|
|
||||||
|
|
|
@ -496,29 +496,29 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
|
||||||
/* Local Address (16 bytes) */
|
/* Local Address (16 bytes) */
|
||||||
if (is_locrib)
|
if (is_locrib)
|
||||||
stream_put(s, 0, 16);
|
stream_put(s, 0, 16);
|
||||||
else if (peer->su_local->sa.sa_family == AF_INET6)
|
else if (peer->connection->su_local->sa.sa_family == AF_INET6)
|
||||||
stream_put(s, &peer->su_local->sin6.sin6_addr, 16);
|
stream_put(s, &peer->connection->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_INET) {
|
||||||
stream_putl(s, 0);
|
stream_putl(s, 0);
|
||||||
stream_putl(s, 0);
|
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 */
|
/* Local Port, Remote Port */
|
||||||
if (!peer->su_local || is_locrib)
|
if (!peer->connection->su_local || is_locrib)
|
||||||
stream_putw(s, 0);
|
stream_putw(s, 0);
|
||||||
else if (peer->su_local->sa.sa_family == AF_INET6)
|
else if (peer->connection->su_local->sa.sa_family == AF_INET6)
|
||||||
stream_putw(s, htons(peer->su_local->sin6.sin6_port));
|
stream_putw(s, htons(peer->connection->su_local->sin6.sin6_port));
|
||||||
else if (peer->su_local->sa.sa_family == AF_INET)
|
else if (peer->connection->su_local->sa.sa_family == AF_INET)
|
||||||
stream_putw(s, htons(peer->su_local->sin.sin_port));
|
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);
|
stream_putw(s, 0);
|
||||||
else if (peer->su_remote->sa.sa_family == AF_INET6)
|
else if (peer->connection->su_remote->sa.sa_family == AF_INET6)
|
||||||
stream_putw(s, htons(peer->su_remote->sin6.sin6_port));
|
stream_putw(s, htons(peer->connection->su_remote->sin6.sin6_port));
|
||||||
else if (peer->su_remote->sa.sa_family == AF_INET)
|
else if (peer->connection->su_remote->sa.sa_family == AF_INET)
|
||||||
stream_putw(s, htons(peer->su_remote->sin.sin_port));
|
stream_putw(s, htons(peer->connection->su_remote->sin.sin_port));
|
||||||
|
|
||||||
/* TODO craft message with fields & capabilities for loc-rib */
|
/* TODO craft message with fields & capabilities for loc-rib */
|
||||||
static const uint8_t dummy_open[] = {
|
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,
|
stream_put(obuf, &peer->connection->su.sin.sin_addr,
|
||||||
IPV4_MAX_BYTELEN);
|
IPV4_MAX_BYTELEN);
|
||||||
|
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
stream_put(obuf, &peer->su_local->sin.sin_addr,
|
stream_put(obuf, &peer->connection->su_local->sin.sin_addr,
|
||||||
IPV4_MAX_BYTELEN);
|
IPV4_MAX_BYTELEN);
|
||||||
else
|
else
|
||||||
stream_put(obuf, empty, IPV4_MAX_BYTELEN);
|
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,
|
stream_put(obuf, &peer->connection->su.sin6.sin6_addr,
|
||||||
IPV6_MAX_BYTELEN);
|
IPV6_MAX_BYTELEN);
|
||||||
|
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
stream_put(obuf, &peer->su_local->sin6.sin6_addr,
|
stream_put(obuf, &peer->connection->su_local->sin6.sin6_addr,
|
||||||
IPV6_MAX_BYTELEN);
|
IPV6_MAX_BYTELEN);
|
||||||
else
|
else
|
||||||
stream_put(obuf, empty, IPV6_MAX_BYTELEN);
|
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 (bgp_debug_neighbor_events(peer)) {
|
||||||
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
|
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
|
||||||
zlog_debug("%s open active, local address %pSU",
|
zlog_debug("%s open active, local address %pSU", peer->host,
|
||||||
peer->host, peer->su_local);
|
connection->su_local);
|
||||||
else
|
else
|
||||||
zlog_debug("%s passive open", peer->host);
|
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 (bgp_debug_neighbor_events(peer)) {
|
||||||
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
|
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
|
||||||
zlog_debug("%s open active, local address %pSU",
|
zlog_debug("%s open active, local address %pSU", peer->host,
|
||||||
peer->host, peer->su_local);
|
connection->su_local);
|
||||||
else
|
else
|
||||||
zlog_debug("%s passive open", peer->host);
|
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;
|
struct peer *peer = connection->peer;
|
||||||
|
|
||||||
bgp_updatesockname(connection);
|
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 */
|
/* if connect initiated, then dest port and dest addresses are well known */
|
||||||
peer->su_remote = sockunion_dup(&connection->su);
|
connection->su_remote = sockunion_dup(&connection->su);
|
||||||
if (sockunion_family(peer->su_remote) == AF_INET)
|
if (sockunion_family(connection->su_remote) == AF_INET)
|
||||||
peer->su_remote->sin.sin_port = htons(peer->port);
|
connection->su_remote->sin.sin_port = htons(peer->port);
|
||||||
else if (sockunion_family(peer->su_remote) == AF_INET6)
|
else if (sockunion_family(connection->su_remote) == AF_INET6)
|
||||||
peer->su_remote->sin6.sin6_port = htons(peer->port);
|
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)
|
void bgp_updatesockname(struct peer_connection *connection)
|
||||||
{
|
{
|
||||||
struct peer *peer = connection->peer;
|
if (connection->su_local) {
|
||||||
|
sockunion_free(connection->su_local);
|
||||||
if (peer->su_local) {
|
connection->su_local = NULL;
|
||||||
sockunion_free(peer->su_local);
|
|
||||||
peer->su_local = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer->su_remote) {
|
if (connection->su_remote) {
|
||||||
sockunion_free(peer->su_remote);
|
sockunion_free(connection->su_remote);
|
||||||
peer->su_remote = NULL;
|
connection->su_remote = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer->su_local = sockunion_getsockname(connection->fd);
|
connection->su_local = sockunion_getsockname(connection->fd);
|
||||||
peer->su_remote = sockunion_getpeername(connection->fd);
|
connection->su_remote = sockunion_getpeername(connection->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* After TCP connection is established. Get local address and port. */
|
/* After TCP connection is established. Get local address and port. */
|
||||||
|
@ -886,15 +884,13 @@ int bgp_getsockname(struct peer_connection *connection)
|
||||||
|
|
||||||
bgp_updatesockname(connection);
|
bgp_updatesockname(connection);
|
||||||
|
|
||||||
if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
|
if (!bgp_zebra_nexthop_set(connection->su_local, connection->su_remote, &peer->nexthop,
|
||||||
&peer->nexthop, peer)) {
|
peer)) {
|
||||||
flog_err(
|
flog_err(EC_BGP_NH_UPD,
|
||||||
EC_BGP_NH_UPD,
|
"%s: nexthop_set failed, local: %pSUp remote: %pSUp update_if: %s resetting connection - intf %s",
|
||||||
"%s: nexthop_set failed, local: %pSUp remote: %pSUp update_if: %s resetting connection - intf %s",
|
peer->host, connection->su_local, connection->su_remote,
|
||||||
peer->host, peer->su_local, peer->su_remote,
|
peer->update_if ? peer->update_if : "(None)",
|
||||||
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 -1;
|
||||||
}
|
}
|
||||||
return 0;
|
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 */
|
/* 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;
|
*reason = bgp_path_selection_local_configured;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_exist->su_remote == NULL) {
|
if (peer_exist->connection->su_remote == NULL) {
|
||||||
*reason = bgp_path_selection_local_configured;
|
*reason = bgp_path_selection_local_configured;
|
||||||
return 1;
|
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) {
|
if (ret == 1) {
|
||||||
*reason = bgp_path_selection_neighbor_ip;
|
*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) {
|
|| type == bgp_show_type_damp_neighbor) {
|
||||||
union sockunion *su = output_arg;
|
union sockunion *su = output_arg;
|
||||||
|
|
||||||
if (pi->peer == NULL
|
if (pi->peer == NULL || pi->peer->connection->su_remote == NULL ||
|
||||||
|| pi->peer->su_remote == NULL
|
!sockunion_same(pi->peer->connection->su_remote, su))
|
||||||
|| !sockunion_same(pi->peer->su_remote, su))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type == bgp_show_type_cidr_only) {
|
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);
|
BATTR_RMAP_NEXTHOP_UNCHANGED);
|
||||||
} else if (rins->peer_address) {
|
} else if (rins->peer_address) {
|
||||||
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) &&
|
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) &&
|
||||||
peer->su_remote &&
|
peer->connection->su_remote &&
|
||||||
sockunion_family(peer->su_remote) == AF_INET) {
|
sockunion_family(peer->connection->su_remote) == AF_INET) {
|
||||||
path->attr->nexthop.s_addr =
|
path->attr->nexthop.s_addr = sockunion2ip(peer->connection->su_remote);
|
||||||
sockunion2ip(peer->su_remote);
|
|
||||||
SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP));
|
SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP));
|
||||||
} else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
|
} else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
|
||||||
/* The next hop value will be set as part of
|
/* 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;
|
path = object;
|
||||||
peer = path->peer;
|
peer = path->peer;
|
||||||
|
|
||||||
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) &&
|
if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) && peer->connection->su_remote &&
|
||||||
peer->su_remote && sockunion_family(peer->su_remote) == AF_INET6) {
|
sockunion_family(peer->connection->su_remote) == AF_INET6) {
|
||||||
peer_address = peer->su_remote->sin6.sin6_addr;
|
peer_address = peer->connection->su_remote->sin6.sin6_addr;
|
||||||
/* Set next hop value and length in attribute. */
|
/* Set next hop value and length in attribute. */
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
|
if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
|
||||||
path->attr->mp_nexthop_local = 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_setfield(L, -2, "last_readtime");
|
||||||
lua_pushinteger(L, peer->resettime);
|
lua_pushinteger(L, peer->resettime);
|
||||||
lua_setfield(L, -2, "last_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_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_setfield(L, -2, "remote_address");
|
||||||
lua_pushinteger(L, peer->cap);
|
lua_pushinteger(L, peer->cap);
|
||||||
lua_setfield(L, -2, "capabilities");
|
lua_setfield(L, -2, "capabilities");
|
||||||
|
|
|
@ -266,25 +266,23 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length,
|
||||||
case BGPPEERNEGOTIATEDVERSION:
|
case BGPPEERNEGOTIATEDVERSION:
|
||||||
return SNMP_INTEGER(BGP_VERSION_4);
|
return SNMP_INTEGER(BGP_VERSION_4);
|
||||||
case BGPPEERLOCALADDR:
|
case BGPPEERLOCALADDR:
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
return SNMP_IPADDRESS(peer->su_local->sin.sin_addr);
|
return SNMP_IPADDRESS(peer->connection->su_local->sin.sin_addr);
|
||||||
else
|
else
|
||||||
return SNMP_IPADDRESS(bgp_empty_addr);
|
return SNMP_IPADDRESS(bgp_empty_addr);
|
||||||
case BGPPEERLOCALPORT:
|
case BGPPEERLOCALPORT:
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
return SNMP_INTEGER(
|
return SNMP_INTEGER(ntohs(peer->connection->su_local->sin.sin_port));
|
||||||
ntohs(peer->su_local->sin.sin_port));
|
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(0);
|
return SNMP_INTEGER(0);
|
||||||
case BGPPEERREMOTEADDR:
|
case BGPPEERREMOTEADDR:
|
||||||
if (peer->su_remote)
|
if (peer->connection->su_remote)
|
||||||
return SNMP_IPADDRESS(peer->su_remote->sin.sin_addr);
|
return SNMP_IPADDRESS(peer->connection->su_remote->sin.sin_addr);
|
||||||
else
|
else
|
||||||
return SNMP_IPADDRESS(bgp_empty_addr);
|
return SNMP_IPADDRESS(bgp_empty_addr);
|
||||||
case BGPPEERREMOTEPORT:
|
case BGPPEERREMOTEPORT:
|
||||||
if (peer->su_remote)
|
if (peer->connection->su_remote)
|
||||||
return SNMP_INTEGER(
|
return SNMP_INTEGER(ntohs(peer->connection->su_remote->sin.sin_port));
|
||||||
ntohs(peer->su_remote->sin.sin_port));
|
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(0);
|
return SNMP_INTEGER(0);
|
||||||
case BGPPEERREMOTEAS:
|
case BGPPEERREMOTEAS:
|
||||||
|
|
|
@ -208,49 +208,42 @@ static uint8_t *bgpv2PeerTable(struct variable *v, oid name[], size_t *length,
|
||||||
case BGP4V2_PEER_INSTANCE:
|
case BGP4V2_PEER_INSTANCE:
|
||||||
return SNMP_INTEGER(peer->bgp->vrf_id);
|
return SNMP_INTEGER(peer->bgp->vrf_id);
|
||||||
case BGP4V2_PEER_LOCAL_ADDR_TYPE:
|
case BGP4V2_PEER_LOCAL_ADDR_TYPE:
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
return SNMP_INTEGER(peer->su_local->sa.sa_family ==
|
return SNMP_INTEGER(peer->connection->su_local->sa.sa_family == AF_INET
|
||||||
AF_INET
|
|
||||||
? AFI_IP
|
? AFI_IP
|
||||||
: AFI_IP6);
|
: AFI_IP6);
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(0);
|
return SNMP_INTEGER(0);
|
||||||
case BGP4V2_PEER_LOCAL_ADDR:
|
case BGP4V2_PEER_LOCAL_ADDR:
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
if (peer->su_local->sa.sa_family == AF_INET)
|
if (peer->connection->su_local->sa.sa_family == AF_INET)
|
||||||
return SNMP_IPADDRESS(
|
return SNMP_IPADDRESS(peer->connection->su_local->sin.sin_addr);
|
||||||
peer->su_local->sin.sin_addr);
|
|
||||||
else
|
else
|
||||||
return SNMP_IP6ADDRESS(
|
return SNMP_IP6ADDRESS(peer->connection->su_local->sin6.sin6_addr);
|
||||||
peer->su_local->sin6.sin6_addr);
|
|
||||||
else
|
else
|
||||||
return SNMP_IPADDRESS(bgp_empty_addr);
|
return SNMP_IPADDRESS(bgp_empty_addr);
|
||||||
case BGP4V2_PEER_REMOTE_ADDR_TYPE:
|
case BGP4V2_PEER_REMOTE_ADDR_TYPE:
|
||||||
if (peer->su_remote)
|
if (peer->connection->su_remote)
|
||||||
return SNMP_INTEGER(peer->su_remote->sa.sa_family ==
|
return SNMP_INTEGER(peer->connection->su_remote->sa.sa_family == AF_INET
|
||||||
AF_INET
|
|
||||||
? AFI_IP
|
? AFI_IP
|
||||||
: AFI_IP6);
|
: AFI_IP6);
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(0);
|
return SNMP_INTEGER(0);
|
||||||
case BGP4V2_PEER_REMOTE_ADDR:
|
case BGP4V2_PEER_REMOTE_ADDR:
|
||||||
if (peer->su_remote)
|
if (peer->connection->su_remote)
|
||||||
if (peer->su_remote->sa.sa_family == AF_INET)
|
if (peer->connection->su_remote->sa.sa_family == AF_INET)
|
||||||
return SNMP_IPADDRESS(
|
return SNMP_IPADDRESS(peer->connection->su_remote->sin.sin_addr);
|
||||||
peer->su_remote->sin.sin_addr);
|
|
||||||
else
|
else
|
||||||
return SNMP_IP6ADDRESS(
|
return SNMP_IP6ADDRESS(peer->connection->su_remote->sin6.sin6_addr);
|
||||||
peer->su_remote->sin6.sin6_addr);
|
|
||||||
else
|
else
|
||||||
return SNMP_IPADDRESS(bgp_empty_addr);
|
return SNMP_IPADDRESS(bgp_empty_addr);
|
||||||
case BGP4V2_PEER_LOCAL_PORT:
|
case BGP4V2_PEER_LOCAL_PORT:
|
||||||
if (peer->su_local)
|
if (peer->connection->su_local)
|
||||||
if (peer->su_local->sa.sa_family == AF_INET)
|
if (peer->connection->su_local->sa.sa_family == AF_INET)
|
||||||
return SNMP_INTEGER(
|
return SNMP_INTEGER(ntohs(peer->connection->su_local->sin.sin_port));
|
||||||
ntohs(peer->su_local->sin.sin_port));
|
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(
|
return SNMP_INTEGER(
|
||||||
ntohs(peer->su_local->sin6.sin6_port));
|
ntohs(peer->connection->su_local->sin6.sin6_port));
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(0);
|
return SNMP_INTEGER(0);
|
||||||
case BGP4V2_PEER_LOCAL_AS:
|
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:
|
case BGP4V2_PEER_LOCAL_IDENTIFIER:
|
||||||
return SNMP_IPADDRESS(peer->local_id);
|
return SNMP_IPADDRESS(peer->local_id);
|
||||||
case BGP4V2_PEER_REMOTE_PORT:
|
case BGP4V2_PEER_REMOTE_PORT:
|
||||||
if (peer->su_remote)
|
if (peer->connection->su_remote)
|
||||||
if (peer->su_remote->sa.sa_family == AF_INET)
|
if (peer->connection->su_remote->sa.sa_family == AF_INET)
|
||||||
return SNMP_INTEGER(
|
return SNMP_INTEGER(
|
||||||
ntohs(peer->su_remote->sin.sin_port));
|
ntohs(peer->connection->su_remote->sin.sin_port));
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(
|
return SNMP_INTEGER(
|
||||||
ntohs(peer->su_remote->sin6.sin6_port));
|
ntohs(peer->connection->su_remote->sin6.sin6_port));
|
||||||
else
|
else
|
||||||
return SNMP_INTEGER(0);
|
return SNMP_INTEGER(0);
|
||||||
case BGP4V2_PEER_REMOTE_AS:
|
case BGP4V2_PEER_REMOTE_AS:
|
||||||
|
|
|
@ -15845,15 +15845,15 @@ CPP_NOTICE("Remove `gracefulRestartCapability` JSON field")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Local address. */
|
/* Local address. */
|
||||||
if (p->su_local) {
|
if (p->connection->su_local) {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_addf(json_neigh, "hostLocal", "%pSU",
|
json_object_string_addf(json_neigh, "hostLocal", "%pSU",
|
||||||
p->su_local);
|
p->connection->su_local);
|
||||||
json_object_int_add(json_neigh, "portLocal",
|
json_object_int_add(json_neigh, "portLocal",
|
||||||
ntohs(p->su_local->sin.sin_port));
|
ntohs(p->connection->su_local->sin.sin_port));
|
||||||
} else
|
} else
|
||||||
vty_out(vty, "Local host: %pSU, Local port: %d\n",
|
vty_out(vty, "Local host: %pSU, Local port: %d\n", p->connection->su_local,
|
||||||
p->su_local, ntohs(p->su_local->sin.sin_port));
|
ntohs(p->connection->su_local->sin.sin_port));
|
||||||
} else {
|
} else {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_add(json_neigh, "hostLocal",
|
json_object_string_add(json_neigh, "hostLocal",
|
||||||
|
@ -15863,16 +15863,16 @@ CPP_NOTICE("Remove `gracefulRestartCapability` JSON field")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remote address. */
|
/* Remote address. */
|
||||||
if (p->su_remote) {
|
if (p->connection->su_remote) {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_addf(json_neigh, "hostForeign",
|
json_object_string_addf(json_neigh, "hostForeign", "%pSU",
|
||||||
"%pSU", p->su_remote);
|
p->connection->su_remote);
|
||||||
json_object_int_add(json_neigh, "portForeign",
|
json_object_int_add(json_neigh, "portForeign",
|
||||||
ntohs(p->su_remote->sin.sin_port));
|
ntohs(p->connection->su_remote->sin.sin_port));
|
||||||
} else
|
} else
|
||||||
vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n",
|
vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n",
|
||||||
p->su_remote,
|
p->connection->su_remote,
|
||||||
ntohs(p->su_remote->sin.sin_port));
|
ntohs(p->connection->su_remote->sin.sin_port));
|
||||||
} else {
|
} else {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_add(json_neigh, "hostForeign",
|
json_object_string_add(json_neigh, "hostForeign",
|
||||||
|
@ -15882,7 +15882,7 @@ CPP_NOTICE("Remove `gracefulRestartCapability` JSON field")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nexthop display. */
|
/* Nexthop display. */
|
||||||
if (p->su_local) {
|
if (p->connection->su_local) {
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
json_object_string_addf(json_neigh, "nexthop", "%pI4",
|
json_object_string_addf(json_neigh, "nexthop", "%pI4",
|
||||||
&p->nexthop.v4);
|
&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;
|
*ifindex = path->attr->nh_ifindex;
|
||||||
} else {
|
} else {
|
||||||
/* Workaround for Cisco's nexthop bug. */
|
/* Workaround for Cisco's nexthop bug. */
|
||||||
if (IN6_IS_ADDR_UNSPECIFIED(
|
if (IN6_IS_ADDR_UNSPECIFIED(&path->attr->mp_nexthop_global) &&
|
||||||
&path->attr->mp_nexthop_global)
|
path->peer->connection->su_remote &&
|
||||||
&& path->peer->su_remote
|
path->peer->connection->su_remote->sa.sa_family == AF_INET6) {
|
||||||
&& path->peer->su_remote->sa.sa_family
|
nexthop = &path->peer->connection->su_remote->sin6.sin6_addr;
|
||||||
== AF_INET6) {
|
|
||||||
nexthop =
|
|
||||||
&path->peer->su_remote->sin6.sin6_addr;
|
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(nexthop))
|
if (IN6_IS_ADDR_LINKLOCAL(nexthop))
|
||||||
*ifindex = path->peer->nexthop.ifp
|
*ifindex = path->peer->nexthop.ifp
|
||||||
->ifindex;
|
->ifindex;
|
||||||
|
|
12
bgpd/bgpd.c
12
bgpd/bgpd.c
|
@ -2768,14 +2768,14 @@ int peer_delete(struct peer *peer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Local and remote addresses. */
|
/* Local and remote addresses. */
|
||||||
if (peer->su_local) {
|
if (peer->connection->su_local) {
|
||||||
sockunion_free(peer->su_local);
|
sockunion_free(peer->connection->su_local);
|
||||||
peer->su_local = NULL;
|
peer->connection->su_local = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer->su_remote) {
|
if (peer->connection->su_remote) {
|
||||||
sockunion_free(peer->su_remote);
|
sockunion_free(peer->connection->su_remote);
|
||||||
peer->su_remote = NULL;
|
peer->connection->su_remote = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free filter related memory. */
|
/* Free filter related memory. */
|
||||||
|
|
|
@ -1258,6 +1258,9 @@ struct peer_connection {
|
||||||
union sockunion su;
|
union sockunion su;
|
||||||
#define BGP_CONNECTION_SU_UNSPEC(connection) \
|
#define BGP_CONNECTION_SU_UNSPEC(connection) \
|
||||||
(connection->su.sa.sa_family == AF_UNSPEC)
|
(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 struct peer_connection *bgp_peer_connection_new(struct peer *peer);
|
||||||
extern void bgp_peer_connection_free(struct peer_connection **connection);
|
extern void bgp_peer_connection_free(struct peer_connection **connection);
|
||||||
|
@ -1350,8 +1353,6 @@ struct peer {
|
||||||
char *update_if;
|
char *update_if;
|
||||||
union sockunion *update_source;
|
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. */
|
bool shared_network; /* Is this peer shared same network. */
|
||||||
struct bgp_nexthop nexthop; /* Nexthop */
|
struct bgp_nexthop nexthop; /* Nexthop */
|
||||||
|
|
||||||
|
|
|
@ -1931,8 +1931,8 @@ static void rfapiBgpInfoAttachSorted(struct agg_node *rn,
|
||||||
if (VNC_DEBUG(IMPORT_BI_ATTACH)) {
|
if (VNC_DEBUG(IMPORT_BI_ATTACH)) {
|
||||||
vnc_zlog_debug_verbose("%s: info_new->peer=%p", __func__,
|
vnc_zlog_debug_verbose("%s: info_new->peer=%p", __func__,
|
||||||
info_new->peer);
|
info_new->peer);
|
||||||
vnc_zlog_debug_verbose("%s: info_new->peer->su_remote=%p",
|
vnc_zlog_debug_verbose("%s: info_new->peer->su_remote=%p", __func__,
|
||||||
__func__, info_new->peer->su_remote);
|
info_new->peer->connection->su_remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (prev = NULL, next = rn->info; next;
|
for (prev = NULL, next = rn->info; next;
|
||||||
|
|
Loading…
Reference in a new issue