summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2010-04-22 08:21:18 +0000
committerclaudio <claudio@openbsd.org>2010-04-22 08:21:18 +0000
commit60ff1b21e511c2a46638d07136002b63d04b5b1a (patch)
tree9b28eb003e63b50e8a532f0a489c3425a8397278
parentCorrect the BGP4MP subtypes according to draft-ietf-grow-mrt-11. (diff)
downloadwireguard-openbsd-60ff1b21e511c2a46638d07136002b63d04b5b1a.tar.xz
wireguard-openbsd-60ff1b21e511c2a46638d07136002b63d04b5b1a.zip
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).
-rw-r--r--usr.sbin/bgpd/mrt.c14
1 files 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 <claudio@openbsd.org>
@@ -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;