summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_dump.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2009-03-13 09:43:28 +0100
committerDavid Lamparter <equinox@diac24.net>2010-02-03 05:23:17 +0100
commita0fa577ff5a95df8f7b49f0736ac96b34c5b3c86 (patch)
treeb8d0620056ffd77045071af56b66c0c190199147 /bgpd/bgp_dump.c
parent42a1488105379be37a5f4c39f7a99d1c53e092e3 (diff)
downloadquagga-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.
Diffstat (limited to 'bgpd/bgp_dump.c')
-rw-r--r--bgpd/bgp_dump.c10
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))
{