From 05198c12f48c9d4a65ee6d1d4117bd8067a71131 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 27 Aug 2009 19:01:04 +0200 Subject: Some cleanups. --- proto/bgp/packets.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'proto/bgp/packets.c') diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index ae4906e..49c2add 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -488,7 +488,6 @@ bgp_parse_capabilities(struct bgp_conn *conn, byte *opt, int len) { struct bgp_proto *p = conn->bgp; int cl; - u32 as; while (len > 0) { @@ -570,7 +569,6 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) { struct bgp_conn *other; struct bgp_proto *p = conn->bgp; - struct bgp_config *cf = p->cf; unsigned hold; u16 base_as; u32 id; -- cgit v1.2.3 From 54fe0d9230be440d9f627ff7f94a202e6117e1b9 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 18 Sep 2009 13:59:04 +0200 Subject: Fixes setting of IP addresses to route attributes (NEXT_HOP). --- proto/bgp/packets.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'proto/bgp/packets.c') diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 49c2add..482b707 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -234,7 +234,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) { struct bgp_proto *p = conn->bgp; struct bgp_bucket *buck; - int size; + int size, second; int remains = BGP_MAX_PACKET_LENGTH - BGP_HEADER_LENGTH - 4; byte *w, *tmp, *tstart; ip_addr *ipp, ip, ip_ll; @@ -292,7 +292,9 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) nh = ea_find(buck->eattrs, EA_CODE(EAP_BGP, BA_NEXT_HOP)); ASSERT(nh); - /* We have two addresses here in 'nh'. Really. */ + /* We have two addresses here in 'nh'. Really. + Unless NEXT_HOP was modified by filter */ + second = (nh->u.ptr->length == NEXT_HOP_LENGTH); ipp = (ip_addr *) nh->u.ptr->data; ip = ipp[0]; ip_ll = IPA_NONE; @@ -316,7 +318,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf) n = neigh_find(&p->p, &ip, 0); if (n && n->iface == p->neigh->iface) { - if (ipa_nonzero(ipp[1])) + if (second && ipa_nonzero(ipp[1])) ip_ll = ipp[1]; else { -- cgit v1.2.3 From a5bf5f781cf921bd1e092b7f9ae6ccdbf7424428 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 24 Sep 2009 23:14:44 +0200 Subject: Show bad peer AS number in log in decimal. --- proto/bgp/packets.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'proto/bgp/packets.c') diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 482b707..d126fe5 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -602,7 +602,17 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) log(L_WARN "%s: Peer advertised inconsistent AS numbers", p->p.name); if (conn->advertised_as != p->remote_as) - { bgp_error(conn, 2, 2, (byte *) &(conn->advertised_as), -4); return; } + { + if (conn->peer_as4_support) + { + u32 val = htonl(conn->advertised_as); + bgp_error(conn, 2, 2, (byte *) &val, 4); + } + else + bgp_error(conn, 2, 2, pkt+20, 2); + + return; + } /* Check the other connection */ other = (conn == &p->outgoing_conn) ? &p->incoming_conn : &p->outgoing_conn; @@ -974,11 +984,19 @@ bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsigned { *t++ = ':'; *t++ = ' '; + + if ((code == 2) && (subcode == 2) && ((len == 2) || (len == 4))) + { + /* Bad peer AS - we would like to print the AS */ + t += bsprintf(t, "%d", (len == 2) ? get_u16(data) : get_u32(data)); + goto done; + } if (len > 16) len = 16; for (i=0; ip.name, msg, name, argbuf); } -- cgit v1.2.3