From 21600ddc4d29cc4f7a7bd3cc380640899078e232 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Thu, 22 Apr 2010 08:21:19 +0000 Subject: Depending on capa.neg.as4byte (bgp session is using 4-byte AS number extension) we need to switch between _AS4 and non _AS4 types. The non _AS4 mrt types are totaly confused by 4-byte AS_PATH attributes since they expect 2-byte ones (and vice versa). Problem found and fix tested by Xiaoliang Zhao (xzhao at cernet edu cn). --- usr.sbin/bgpd/mrt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index 22de447f335..6fee4d2bd0d 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.66 2009/12/01 14:28:05 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.67 2010/04/22 08:21:18 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -85,12 +85,16 @@ mrt_dump_bgp_msg(struct mrt *mrt, void *pkg, u_int16_t pkglen, { struct buf *buf; int incoming = 0; + u_int16_t subtype = BGP4MP_MESSAGE; + + if (peer->capa.neg.as4byte) + subtype = BGP4MP_MESSAGE_AS4; /* get the direction of the message to swap address and AS fields */ if (mrt->type == MRT_ALL_IN || mrt->type == MRT_UPDATE_IN) incoming = 1; - if (mrt_dump_hdr_se(&buf, peer, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE, + if (mrt_dump_hdr_se(&buf, peer, MSG_PROTOCOL_BGP4MP, subtype, pkglen, incoming) == -1) return; @@ -108,8 +112,12 @@ mrt_dump_state(struct mrt *mrt, u_int16_t old_state, u_int16_t new_state, struct peer *peer) { struct buf *buf; + u_int16_t subtype = BGP4MP_STATE_CHANGE; + + if (peer->capa.neg.as4byte) + subtype = BGP4MP_STATE_CHANGE_AS4; - if (mrt_dump_hdr_se(&buf, peer, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE, + if (mrt_dump_hdr_se(&buf, peer, MSG_PROTOCOL_BGP4MP, subtype, 2 * sizeof(short), 0) == -1) return; -- cgit v1.2.3