bgpd: Convert remaining string output to our internal types

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2021-03-09 19:50:42 -05:00
parent b58b399c5b
commit c0d72166ee
9 changed files with 79 additions and 179 deletions

View File

@ -2133,19 +2133,11 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
}
stream_get(&attr->mp_nexthop_local, s, IPV6_MAX_BYTELEN);
if (!IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_local)) {
char buf1[INET6_ADDRSTRLEN];
char buf2[INET6_ADDRSTRLEN];
if (bgp_debug_update(peer, NULL, NULL, 1))
zlog_debug(
"%s sent next-hops %s and %s. Ignoring non-LL value",
peer->host,
inet_ntop(AF_INET6,
&attr->mp_nexthop_global,
buf1, INET6_ADDRSTRLEN),
inet_ntop(AF_INET6,
&attr->mp_nexthop_local, buf2,
INET6_ADDRSTRLEN));
"%s sent next-hops %pI6 and %pI6. Ignoring non-LL value",
peer->host, &attr->mp_nexthop_global,
&attr->mp_nexthop_local);
attr->mp_nexthop_len = IPV6_MAX_BYTELEN;
}
@ -2344,16 +2336,10 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
/* Extract the Rmac, if any */
if (bgp_attr_rmac(attr, &attr->rmac)) {
if (bgp_debug_update(peer, NULL, NULL, 1) &&
bgp_mac_exist(&attr->rmac)) {
char buf1[ETHER_ADDR_STRLEN];
zlog_debug("%s: router mac %s is self mac",
__func__,
prefix_mac2str(&attr->rmac, buf1,
sizeof(buf1)));
}
if (bgp_debug_update(peer, NULL, NULL, 1)
&& bgp_mac_exist(&attr->rmac))
zlog_debug("%s: router mac %pEA is self mac", __func__,
&attr->rmac);
}
/* Get the tunnel type from encap extended community */

View File

@ -592,9 +592,6 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
{
struct stream *s;
int ipa_len;
char buf1[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
char buf3[INET6_ADDRSTRLEN];
static struct in_addr zero_remote_vtep_ip;
/* Check socket. */
@ -649,14 +646,10 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
if (bgp_debug_zebra(NULL))
zlog_debug(
"Tx %s MACIP, VNI %u MAC %s IP %s flags 0x%x seq %u remote VTEP %s",
"Tx %s MACIP, VNI %u MAC %pEA IP %pIA flags 0x%x seq %u remote VTEP %pI4",
add ? "ADD" : "DEL", vpn->vni,
prefix_mac2str(&p->prefix.macip_addr.mac,
buf1, sizeof(buf1)),
ipaddr2str(&p->prefix.macip_addr.ip,
buf3, sizeof(buf3)), flags, seq,
inet_ntop(AF_INET, &remote_vtep_ip, buf2,
sizeof(buf2)));
&p->prefix.macip_addr.mac, &p->prefix.macip_addr.ip,
flags, seq, &remote_vtep_ip);
return zclient_send_message(zclient);
}
@ -1319,16 +1312,11 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
vrf_id_to_name(bgp_vrf->vrf_id), evp);
}
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
zlog_debug("VRF %s type-5 route evp %pFX RMAC %s nexthop %s",
vrf_id_to_name(bgp_vrf->vrf_id), evp,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
inet_ntop(AF_INET, &attr.nexthop, buf2,
INET_ADDRSTRLEN));
}
if (bgp_debug_zebra(NULL))
zlog_debug(
"VRF %s type-5 route evp %pFX RMAC %pEA nexthop %pI4",
vrf_id_to_name(bgp_vrf->vrf_id), evp, &attr.rmac,
&attr.nexthop);
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
@ -1725,16 +1713,13 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
}
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
char buf3[ESI_STR_LEN];
zlog_debug(
"VRF %s vni %u type-2 route evp %pFX RMAC %s nexthop %pI4 esi %s",
"VRF %s vni %u type-2 route evp %pFX RMAC %pEA nexthop %pI4 esi %s",
vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
: " ",
vpn->vni, p,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
&attr.mp_nexthop_global_in,
vpn->vni, p, &attr.rmac, &attr.mp_nexthop_global_in,
esi_to_str(esi, buf3, sizeof(buf3)));
}
/* router mac is only needed for type-2 routes here. */
@ -2004,16 +1989,13 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
seq = mac_mobility_seqnum(local_pi->attr);
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
char buf3[ESI_STR_LEN];
zlog_debug(
"VRF %s vni %u evp %pFX RMAC %s nexthop %pI4 esi %s esf 0x%x from %s",
"VRF %s vni %u evp %pFX RMAC %pEA nexthop %pI4 esi %s esf 0x%x from %s",
vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
: " ",
vpn->vni, evp,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
&attr.mp_nexthop_global_in,
vpn->vni, evp, &attr.rmac, &attr.mp_nexthop_global_in,
esi_to_str(&attr.esi, buf3, sizeof(buf3)),
attr.es_flags, caller);
}
@ -5300,18 +5282,14 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
/* Create EVPN type-2 route and schedule for processing. */
build_evpn_type2_prefix(&p, mac, ip);
if (update_evpn_route(bgp, vpn, &p, flags, seq, esi)) {
char buf[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
flog_err(
EC_BGP_EVPN_ROUTE_CREATE,
"%u:Failed to create Type-2 route, VNI %u %s MAC %s IP %s (flags: 0x%x)",
"%u:Failed to create Type-2 route, VNI %u %s MAC %pEA IP %pIA (flags: 0x%x)",
bgp->vrf_id, vpn->vni,
CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY)
? "sticky gateway"
: "",
prefix_mac2str(mac, buf, sizeof(buf)),
ipaddr2str(ip, buf2, sizeof(buf2)), flags);
mac, ip, flags);
return -1;
}
@ -5396,23 +5374,16 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id,
if (is_zero_mac(&bgp_vrf->evpn_info->pip_rmac_static))
memcpy(&bgp_vrf->evpn_info->pip_rmac, svi_rmac, ETH_ALEN);
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
char buf1[ETHER_ADDR_STRLEN];
char buf2[ETHER_ADDR_STRLEN];
if (bgp_debug_zebra(NULL))
zlog_debug(
"VRF %s vni %u pip %s RMAC %pEA sys RMAC %pEA static RMAC %pEA is_anycast_mac %s",
vrf_id_to_name(bgp_vrf->vrf_id), bgp_vrf->l3vni,
bgp_vrf->evpn_info->advertise_pip ? "enable"
: "disable",
&bgp_vrf->rmac, &bgp_vrf->evpn_info->pip_rmac,
&bgp_vrf->evpn_info->pip_rmac_static,
is_anycast_mac ? "Enable" : "Disable");
zlog_debug("VRF %s vni %u pip %s RMAC %s sys RMAC %s static RMAC %s is_anycast_mac %s",
vrf_id_to_name(bgp_vrf->vrf_id),
bgp_vrf->l3vni,
bgp_vrf->evpn_info->advertise_pip ? "enable"
: "disable",
prefix_mac2str(&bgp_vrf->rmac, buf, sizeof(buf)),
prefix_mac2str(&bgp_vrf->evpn_info->pip_rmac,
buf1, sizeof(buf1)),
prefix_mac2str(&bgp_vrf->evpn_info->pip_rmac_static,
buf2, sizeof(buf2)),
is_anycast_mac ? "Enable" : "Disable");
}
/* set the right filter - are we using l3vni only for prefix routes? */
if (filter) {
SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY);

View File

@ -1556,13 +1556,9 @@ static int bgp_connect_success(struct peer *peer)
bgp_reads_on(peer);
if (bgp_debug_neighbor_events(peer)) {
char buf1[SU_ADDRSTRLEN];
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
zlog_debug("%s open active, local address %s",
peer->host,
sockunion2str(peer->su_local, buf1,
SU_ADDRSTRLEN));
zlog_debug("%s open active, local address %pSU",
peer->host, peer->su_local);
else
zlog_debug("%s passive open", peer->host);
}
@ -1598,13 +1594,9 @@ static int bgp_connect_success_w_delayopen(struct peer *peer)
bgp_reads_on(peer);
if (bgp_debug_neighbor_events(peer)) {
char buf1[SU_ADDRSTRLEN];
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_ACCEPT_PEER))
zlog_debug("%s open active, local address %s",
peer->host,
sockunion2str(peer->su_local, buf1,
SU_ADDRSTRLEN));
zlog_debug("%s open active, local address %pSU",
peer->host, peer->su_local);
else
zlog_debug("%s passive open", peer->host);
}

View File

@ -420,27 +420,19 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
/* Check address. */
if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) {
if (IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)) {
char buf[BUFSIZ];
flog_err(
EC_BGP_UPDATE_RCV,
"%s: IPv6 labeled-unicast NLRI is link-local address %s, ignoring",
peer->host,
inet_ntop(AF_INET6, &p.u.prefix6, buf,
BUFSIZ));
"%s: IPv6 labeled-unicast NLRI is link-local address %pI6, ignoring",
peer->host, &p.u.prefix6);
continue;
}
if (IN6_IS_ADDR_MULTICAST(&p.u.prefix6)) {
char buf[BUFSIZ];
flog_err(
EC_BGP_UPDATE_RCV,
"%s: IPv6 unicast NLRI is multicast address %s, ignoring",
peer->host,
inet_ntop(AF_INET6, &p.u.prefix6, buf,
BUFSIZ));
"%s: IPv6 unicast NLRI is multicast address %pI6, ignoring",
peer->host, &p.u.prefix6);
continue;
}

View File

@ -519,7 +519,6 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
struct listnode *mp_node, *mp_next_node;
struct bgp_path_info *cur_mpath, *new_mpath, *next_mpath, *prev_mpath;
int mpath_changed, debug;
char nh_buf[2][INET6_ADDRSTRLEN];
bool all_paths_lb;
char path_buf[PATH_ADDPATH_STR_BUFFER];
@ -630,14 +629,10 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
cur_mpath, path_buf,
sizeof(path_buf));
zlog_debug(
"%pRN: remove mpath %s nexthop %s, cur count %d",
"%pRN: remove mpath %s nexthop %pI4, cur count %d",
bgp_dest_to_rnode(dest),
path_buf,
inet_ntop(AF_INET,
&cur_mpath->attr
->nexthop,
nh_buf[0],
sizeof(nh_buf[0])),
&cur_mpath->attr->nexthop,
mpath_count);
}
}
@ -664,12 +659,9 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
bgp_path_info_path_with_addpath_rx_str(
cur_mpath, path_buf, sizeof(path_buf));
zlog_debug(
"%pRN: remove mpath %s nexthop %s, cur count %d",
"%pRN: remove mpath %s nexthop %pI4, cur count %d",
bgp_dest_to_rnode(dest), path_buf,
inet_ntop(AF_INET,
&cur_mpath->attr->nexthop,
nh_buf[0], sizeof(nh_buf[0])),
mpath_count);
&cur_mpath->attr->nexthop, mpath_count);
}
cur_mpath = next_mpath;
} else {
@ -715,14 +707,10 @@ void bgp_path_info_mpath_update(struct bgp_dest *dest,
new_mpath, path_buf,
sizeof(path_buf));
zlog_debug(
"%pRN: add mpath %s nexthop %s, cur count %d",
"%pRN: add mpath %s nexthop %pI4, cur count %d",
bgp_dest_to_rnode(dest),
path_buf,
inet_ntop(AF_INET,
&new_mpath->attr
->nexthop,
nh_buf[0],
sizeof(nh_buf[0])),
&new_mpath->attr->nexthop,
mpath_count);
}
}

View File

@ -233,7 +233,6 @@ int bgp_md5_unset(struct peer *peer)
int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
{
char buf[INET_ADDRSTRLEN];
int ret = 0;
/* In case of peer is EBGP, we should set TTL for this connection. */
@ -242,11 +241,8 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
if (ret) {
flog_err(
EC_LIB_SOCKET,
"%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d",
__func__,
inet_ntop(AF_INET, &peer->remote_id, buf,
sizeof(buf)),
errno);
"%s: Can't set TxTTL on peer (rtrid %pI4) socket, err = %d",
__func__, &peer->remote_id, errno);
return ret;
}
} else if (peer->gtsm_hops) {
@ -258,11 +254,8 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
if (ret) {
flog_err(
EC_LIB_SOCKET,
"%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d",
__func__,
inet_ntop(AF_INET, &peer->remote_id, buf,
sizeof(buf)),
errno);
"%s: Can't set TxTTL on peer (rtrid %pI4) socket, err = %d",
__func__, &peer->remote_id, errno);
return ret;
}
ret = sockopt_minttl(peer->su.sa.sa_family, bgp_sock,
@ -270,11 +263,8 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
if (ret) {
flog_err(
EC_LIB_SOCKET,
"%s: Can't set MinTTL on peer (rtrid %s) socket, err = %d",
__func__,
inet_ntop(AF_INET, &peer->remote_id, buf,
sizeof(buf)),
errno);
"%s: Can't set MinTTL on peer (rtrid %pI4) socket, err = %d",
__func__, &peer->remote_id, errno);
return ret;
}
}

View File

@ -5255,26 +5255,18 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* Check address. */
if (afi == AFI_IP6 && safi == SAFI_UNICAST) {
if (IN6_IS_ADDR_LINKLOCAL(&p.u.prefix6)) {
char buf[BUFSIZ];
flog_err(
EC_BGP_UPDATE_RCV,
"%s: IPv6 unicast NLRI is link-local address %s, ignoring",
peer->host,
inet_ntop(AF_INET6, &p.u.prefix6, buf,
BUFSIZ));
"%s: IPv6 unicast NLRI is link-local address %pI6, ignoring",
peer->host, &p.u.prefix6);
continue;
}
if (IN6_IS_ADDR_MULTICAST(&p.u.prefix6)) {
char buf[BUFSIZ];
flog_err(
EC_BGP_UPDATE_RCV,
"%s: IPv6 unicast NLRI is multicast address %s, ignoring",
peer->host,
inet_ntop(AF_INET6, &p.u.prefix6, buf,
BUFSIZ));
"%s: IPv6 unicast NLRI is multicast address %pI6, ignoring",
peer->host, &p.u.prefix6);
continue;
}

View File

@ -350,8 +350,6 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
struct stream *s = NULL;
bpacket_attr_vec *vec;
struct peer *peer;
char buf[BUFSIZ];
char buf2[BUFSIZ];
struct bgp_filter *filter;
s = stream_dup(pkt->buffer);
@ -568,25 +566,24 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
if (nhlen == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
|| nhlen == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
zlog_debug(
"u%" PRIu64 ":s%" PRIu64" %s send UPDATE w/ mp_nexthops %s, %s%s",
"u%" PRIu64 ":s%" PRIu64
" %s send UPDATE w/ mp_nexthops %pI6, %pI6%s",
PAF_SUBGRP(paf)->update_group->id,
PAF_SUBGRP(paf)->id, peer->host,
inet_ntop(AF_INET6, mod_v6nhg, buf,
BUFSIZ),
inet_ntop(AF_INET6, mod_v6nhl, buf2,
BUFSIZ),
mod_v6nhg, mod_v6nhl,
(nhlen == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL
? " and RD"
: ""));
else
zlog_debug("u%" PRIu64 ":s%" PRIu64" %s send UPDATE w/ mp_nexthop %s%s",
PAF_SUBGRP(paf)->update_group->id,
PAF_SUBGRP(paf)->id, peer->host,
inet_ntop(AF_INET6, mod_v6nhg, buf,
BUFSIZ),
(nhlen == BGP_ATTR_NHLEN_VPNV6_GLOBAL
? " and RD"
: ""));
zlog_debug(
"u%" PRIu64 ":s%" PRIu64
" %s send UPDATE w/ mp_nexthop %pI6%s",
PAF_SUBGRP(paf)->update_group->id,
PAF_SUBGRP(paf)->id, peer->host,
mod_v6nhg,
(nhlen == BGP_ATTR_NHLEN_VPNV6_GLOBAL
? " and RD"
: ""));
}
} else if (paf->afi == AFI_L2VPN) {
struct in_addr v4nh, *mod_v4nh;

View File

@ -942,12 +942,9 @@ static bool bgp_table_map_apply(struct route_map *map, const struct prefix *p,
if (bgp_debug_zebra(p)) {
if (p->family == AF_INET) {
char buf[2][INET_ADDRSTRLEN];
zlog_debug(
"Zebra rmap deny: IPv4 route %pFX nexthop %s",
p,
inet_ntop(AF_INET, &path->attr->nexthop, buf[1],
sizeof(buf[1])));
"Zebra rmap deny: IPv4 route %pFX nexthop %pI4",
p, &path->attr->nexthop);
}
if (p->family == AF_INET6) {
char buf[2][INET6_ADDRSTRLEN];
@ -2742,14 +2739,12 @@ static int bgp_zebra_process_local_es_evi(ZAPI_CALLBACK_ARGS)
static int bgp_zebra_process_local_l3vni(ZAPI_CALLBACK_ARGS)
{
int filter = 0;
char buf[ETHER_ADDR_STRLEN];
vni_t l3vni = 0;
struct ethaddr svi_rmac, vrr_rmac = {.octet = {0} };
struct in_addr originator_ip;
struct stream *s;
ifindex_t svi_ifindex;
bool is_anycast_mac = false;
char buf1[ETHER_ADDR_STRLEN];
memset(&svi_rmac, 0, sizeof(struct ethaddr));
memset(&originator_ip, 0, sizeof(struct in_addr));
@ -2764,13 +2759,12 @@ static int bgp_zebra_process_local_l3vni(ZAPI_CALLBACK_ARGS)
is_anycast_mac = stream_getl(s);
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx L3-VNI ADD VRF %s VNI %u RMAC svi-mac %s vrr-mac %s filter %s svi-if %u",
vrf_id_to_name(vrf_id), l3vni,
prefix_mac2str(&svi_rmac, buf, sizeof(buf)),
prefix_mac2str(&vrr_rmac, buf1,
sizeof(buf1)),
filter ? "prefix-routes-only" : "none",
svi_ifindex);
zlog_debug(
"Rx L3-VNI ADD VRF %s VNI %u RMAC svi-mac %pEA vrr-mac %pEA filter %s svi-if %u",
vrf_id_to_name(vrf_id), l3vni, &svi_rmac,
&vrr_rmac,
filter ? "prefix-routes-only" : "none",
svi_ifindex);
bgp_evpn_local_l3vni_add(l3vni, vrf_id, &svi_rmac, &vrr_rmac,
originator_ip, filter, svi_ifindex,
@ -2830,8 +2824,6 @@ static int bgp_zebra_process_local_macip(ZAPI_CALLBACK_ARGS)
struct ethaddr mac;
struct ipaddr ip;
int ipa_len;
char buf[ETHER_ADDR_STRLEN];
char buf1[INET6_ADDRSTRLEN];
uint8_t flags = 0;
uint32_t seqnum = 0;
int state = 0;
@ -2871,11 +2863,11 @@ static int bgp_zebra_process_local_macip(ZAPI_CALLBACK_ARGS)
return 0;
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%u:Recv MACIP %s f 0x%x MAC %s IP %s VNI %u seq %u state %d ESI %s",
vrf_id, (cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del",
flags, prefix_mac2str(&mac, buf, sizeof(buf)),
ipaddr2str(&ip, buf1, sizeof(buf1)), vni, seqnum,
state, esi_to_str(&esi, buf2, sizeof(buf2)));
zlog_debug(
"%u:Recv MACIP %s f 0x%x MAC %pEA IP %pI4 VNI %u seq %u state %d ESI %s",
vrf_id, (cmd == ZEBRA_MACIP_ADD) ? "Add" : "Del", flags,
&mac, &ip, vni, seqnum, state,
esi_to_str(&esi, buf2, sizeof(buf2)));
if (cmd == ZEBRA_MACIP_ADD)
return bgp_evpn_local_macip_add(bgp, vni, &mac, &ip,