From 863ecfc78538657e51f1ec67441aec32261aa405 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 20 Nov 2018 17:38:19 +0100 Subject: The MRT protocol The new MRT protocol is responsible for periodic RIB table dumps in the MRT format (RFC 6396). Also the existing code for BGP4MP MRT dumps is refactored and splitted between BGP to MRT protocols, will be more integrated into MRT in the future. Example: protocol mrt { table "*"; filename "%N_%F_%T.mrt"; period 60; } It is partially based on the old MRT code from Pavel Tvrdik. --- proto/bgp/attrs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'proto/bgp/attrs.c') diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index dc267fdb..dcc4a273 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -285,15 +285,20 @@ bgp_encode_next_hop(struct bgp_write_state *s, eattr *a, byte *buf, uint size) * store it and encode it later by AFI-specific hooks. */ - if ((s->channel->afi == BGP_AF_IPV4) && !s->channel->ext_next_hop) + if (!s->mp_reach) { - ASSERT(a->u.ptr->length == sizeof(ip_addr)); + // ASSERT(a->u.ptr->length == sizeof(ip_addr)); + + /* FIXME: skip IPv6 next hops for IPv4 routes during MRT dump */ + ip_addr *addr = (void *) a->u.ptr->data; + if ((a->u.ptr->length != sizeof(ip_addr)) || !ipa_is_ip4(*addr)) + return 0; if (size < (3+4)) return -1; bgp_put_attr_hdr3(buf, BA_NEXT_HOP, a->flags, 4); - put_ip4(buf+3, ipa_to_ip4( *(ip_addr *) a->u.ptr->data )); + put_ip4(buf+3, ipa_to_ip4(*addr)); return 3+4; } @@ -946,6 +951,7 @@ bgp_encode_attr(struct bgp_write_state *s, eattr *a, byte *buf, uint size) * * The bgp_encode_attrs() function takes a list of extended attributes * and converts it to its BGP representation (a part of an Update message). + * BGP write state may be fake when called from MRT protocol. * * Result: Length of the attribute block generated or -1 if not enough space. */ -- cgit v1.2.3