diff options
author | David Lamparter <equinox@diac24.net> | 2009-03-13 09:43:28 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-03 05:23:17 +0100 |
commit | a0fa577ff5a95df8f7b49f0736ac96b34c5b3c86 (patch) | |
tree | b8d0620056ffd77045071af56b66c0c190199147 | |
parent | 42a1488105379be37a5f4c39f7a99d1c53e092e3 (diff) | |
download | quagga-a0fa577ff5a95df8f7b49f0736ac96b34c5b3c86.tar.bz2 quagga-a0fa577ff5a95df8f7b49f0736ac96b34c5b3c86.tar.xz |
bgpd: include "localhost" pseudo-peer in MRT dump
MRT dumps reference peers by 0-based index. However, index 0 is
also used for locally originated routes. Fix this by adding
"localhost" as 0th peer, so regular peers start at index 1.
-rw-r--r-- | bgpd/bgp_dump.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 8087a403..dd32164f 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -199,6 +199,7 @@ bgp_dump_routes_index_table(struct bgp *bgp) struct listnode *node; uint16_t peerno = 0; struct stream *obuf; + struct in_addr localhost = { htonl(INADDR_LOOPBACK) }; obuf = bgp_dump_obuf; stream_reset (obuf); @@ -221,8 +222,15 @@ bgp_dump_routes_index_table(struct bgp *bgp) } /* Peer count */ - stream_putw (obuf, listcount(bgp->peer)); + stream_putw (obuf, listcount(bgp->peer) + 1); + /* Peer #0 entry reflects locally originated routes */ + stream_putc (obuf, TABLE_DUMP_V2_PEER_INDEX_TABLE_AS4+TABLE_DUMP_V2_PEER_INDEX_TABLE_IP); + stream_put_in_addr (obuf, &bgp->router_id); + stream_put_in_addr (obuf, &localhost); + stream_putl (obuf, bgp->as); + + peerno++; /* Walk down all peers */ for(ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer)) { |