mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 16:29:32 +00:00
bgpd: Reformat bpacket_reformat_for_peer
This function was heavily indented, reformat to reduce indentation levels a bit. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
4b08a72ed1
commit
f041034e44
@ -397,10 +397,14 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
peer = PAF_PEER(paf);
|
||||
|
||||
vec = &pkt->arr.entries[BGP_ATTR_VEC_NH];
|
||||
if (CHECK_FLAG(vec->flags, BPKT_ATTRVEC_FLAGS_UPDATED)) {
|
||||
|
||||
if (!CHECK_FLAG(vec->flags, BPKT_ATTRVEC_FLAGS_UPDATED))
|
||||
return s;
|
||||
|
||||
uint8_t nhlen;
|
||||
afi_t nhafi;
|
||||
int route_map_sets_nh;
|
||||
|
||||
nhlen = stream_getc_from(s, vec->offset);
|
||||
filter = &peer->filter[paf->afi][paf->safi];
|
||||
|
||||
@ -415,8 +419,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
size_t offset_nh = vec->offset + 1;
|
||||
|
||||
route_map_sets_nh =
|
||||
(CHECK_FLAG(
|
||||
vec->flags,
|
||||
(CHECK_FLAG(vec->flags,
|
||||
BPKT_ATTRVEC_FLAGS_RMAP_IPV4_NH_CHANGED)
|
||||
|| CHECK_FLAG(
|
||||
vec->flags,
|
||||
@ -471,10 +474,8 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
mod_v4nh = &peer->nexthop.v4;
|
||||
nh_modified = 1;
|
||||
} else if (peer->sort == BGP_PEER_EBGP
|
||||
&& (bgp_multiaccess_check_v4(v4nh, peer)
|
||||
== 0)
|
||||
&& !CHECK_FLAG(
|
||||
vec->flags,
|
||||
&& (bgp_multiaccess_check_v4(v4nh, peer) == 0)
|
||||
&& !CHECK_FLAG(vec->flags,
|
||||
BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED)
|
||||
&& !peer_af_flag_check(
|
||||
peer, paf->afi, paf->safi,
|
||||
@ -507,19 +508,17 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
mod_v6nhl = &v6nhlocal;
|
||||
|
||||
route_map_sets_nh =
|
||||
(CHECK_FLAG(
|
||||
vec->flags,
|
||||
(CHECK_FLAG(vec->flags,
|
||||
BPKT_ATTRVEC_FLAGS_RMAP_IPV6_GNH_CHANGED)
|
||||
|| CHECK_FLAG(
|
||||
vec->flags,
|
||||
BPKT_ATTRVEC_FLAGS_RMAP_NH_PEER_ADDRESS));
|
||||
|
||||
/*
|
||||
* The logic here is rather similar to that for IPv4,
|
||||
* the
|
||||
* The logic here is rather similar to that for IPv4, the
|
||||
* additional work being to handle 1 or 2 nexthops.
|
||||
* Also, 3rd
|
||||
* party nexthop is not propagated for EBGP right now.
|
||||
* Also, 3rd party nexthop is not propagated for EBGP
|
||||
* right now.
|
||||
*/
|
||||
switch (nhlen) {
|
||||
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
|
||||
@ -564,8 +563,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
} else if (IN6_IS_ADDR_UNSPECIFIED(&v6nhglobal)) {
|
||||
mod_v6nhg = &peer->nexthop.v6_global;
|
||||
gnh_modified = 1;
|
||||
} else if (
|
||||
(peer->sort == BGP_PEER_EBGP)
|
||||
} else if ((peer->sort == BGP_PEER_EBGP)
|
||||
&& (!bgp_multiaccess_check_v6(v6nhglobal, peer))
|
||||
&& !CHECK_FLAG(vec->flags,
|
||||
BPKT_ATTRVEC_FLAGS_RMAP_NH_UNCHANGED)
|
||||
@ -578,7 +576,6 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
gnh_modified = 1;
|
||||
}
|
||||
|
||||
|
||||
if (nhlen == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
|
||||
|| nhlen == BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
|
||||
stream_get_from(&v6nhlocal, s, offset_nhlocal,
|
||||
@ -590,34 +587,29 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
}
|
||||
|
||||
if (gnh_modified)
|
||||
stream_put_in6_addr_at(s, offset_nhglobal,
|
||||
mod_v6nhg);
|
||||
stream_put_in6_addr_at(s, offset_nhglobal, mod_v6nhg);
|
||||
if (lnh_modified)
|
||||
stream_put_in6_addr_at(s, offset_nhlocal,
|
||||
mod_v6nhl);
|
||||
stream_put_in6_addr_at(s, offset_nhlocal, mod_v6nhl);
|
||||
|
||||
if (bgp_debug_update(peer, NULL, NULL, 0)) {
|
||||
if (nhlen == 32 || nhlen == 48)
|
||||
zlog_debug(
|
||||
"u%" PRIu64 ":s%" PRIu64
|
||||
" %s send UPDATE w/ mp_nexthops %s, %s%s",
|
||||
PAF_SUBGRP(paf)
|
||||
->update_group->id,
|
||||
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),
|
||||
inet_ntop(AF_INET6, mod_v6nhg, buf,
|
||||
BUFSIZ),
|
||||
inet_ntop(AF_INET6, mod_v6nhl, buf2,
|
||||
BUFSIZ),
|
||||
(nhlen == 48 ? " and RD" : ""));
|
||||
else
|
||||
zlog_debug(
|
||||
"u%" PRIu64 ":s%" PRIu64
|
||||
zlog_debug("u%" PRIu64 ":s%" PRIu64
|
||||
" %s send UPDATE w/ mp_nexthop %s%s",
|
||||
PAF_SUBGRP(paf)
|
||||
->update_group->id,
|
||||
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_v6nhg, buf,
|
||||
BUFSIZ),
|
||||
(nhlen == 24 ? " and RD" : ""));
|
||||
}
|
||||
} else if (paf->afi == AFI_L2VPN) {
|
||||
@ -634,8 +626,7 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
}
|
||||
|
||||
if (nh_modified)
|
||||
stream_put_in_addr_at(s, vec->offset + 1,
|
||||
mod_v4nh);
|
||||
stream_put_in_addr_at(s, vec->offset + 1, mod_v4nh);
|
||||
|
||||
if (bgp_debug_update(peer, NULL, NULL, 0))
|
||||
zlog_debug("u%" PRIu64 ":s%" PRIu64
|
||||
@ -644,7 +635,6 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
|
||||
PAF_SUBGRP(paf)->id, peer->host,
|
||||
inet_ntoa(*mod_v4nh));
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user