}
}
} else {
- source = p->su_local;
+ source = p->connection->su_local;
}
/* Update peer's source/destination addresses. */
/* 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);
/* 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[] = {
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);
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);
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);
}
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);
}
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);
}
}
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. */
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;
}
/* 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;
|| 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) {
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
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;
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");
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:
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:
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:
}
/* 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",
}
/* 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",
}
/* 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);
*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;
}
/* 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. */
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);
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 */
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;