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