From 8bd9b930c320f09d3b3792b5f991cf702e9d55be Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 16 Apr 2013 17:40:44 +0200 Subject: Fixes a bug in IPv6 BGP next hop processing. BGP next hop attributes with empty link-local IPv6 addresses were not handled properly. Thanks to Sergey Popovich for the bugfix. --- proto/bgp/packets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'proto/bgp/packets.c') diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index cfa37fb5..f2e03f87 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -820,7 +820,7 @@ bgp_set_next_hop(struct bgp_proto *p, rta *a) ip_addr *nexthop = (ip_addr *) nh->u.ptr->data; #ifdef IPV6 - int second = (nh->u.ptr->length == NEXT_HOP_LENGTH); + int second = (nh->u.ptr->length == NEXT_HOP_LENGTH) && ipa_nonzero(nexthop[1]); /* First address should not be link-local, but may be zero in direct mode */ if (ipa_has_link_scope(*nexthop)) -- cgit v1.2.3 From 572c6440432e3138ea622cfb5a4ef7580d77ef4a Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 29 Apr 2013 22:08:05 +0200 Subject: Fixes a crash when mrtdump is enabled and interface goes away. Thanks to Peter Christensen for the bugfix. --- proto/bgp/packets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'proto/bgp/packets.c') diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index f2e03f87..bf52c8cd 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -58,7 +58,7 @@ mrt_put_bgp4_hdr(byte *buf, struct bgp_conn *conn, int as4) buf+=4; } - put_u16(buf+0, p->neigh ? p->neigh->iface->index : 0); + put_u16(buf+0, (p->neigh && p->neigh->iface) ? p->neigh->iface->index : 0); put_u16(buf+2, BGP_AF); buf+=4; buf = ipa_put_addr(buf, conn->sk ? conn->sk->daddr : IPA_NONE); -- cgit v1.2.3 From ac5745134847c044b21c311e5ab11d92d05bacc1 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 25 Jul 2013 13:55:24 +0200 Subject: Implements RFC 6608 Subcodes for BGP FSM Error. --- proto/bgp/bgp.h | 2 ++ proto/bgp/packets.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'proto/bgp/packets.c') diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index 13c7fd80..77a36715 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -254,6 +254,8 @@ void bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsi #define BS_ESTABLISHED 5 #define BS_CLOSE 6 /* Used during transition to BS_IDLE */ +#define BS_MAX 7 + /* BGP start states * * Used in PS_START for fine-grained specification of starting state. diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index bf52c8cd..9d85cbc9 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -24,6 +24,13 @@ static struct rate_limit rl_rcv_update, rl_snd_update; +/* Table for state -> RFC 6608 FSM error subcodes */ +static byte fsm_err_subcode[BS_MAX] = { + [BS_OPENSENT] = 1, + [BS_OPENCONFIRM] = 2, + [BS_ESTABLISHED] = 3 +}; + /* * MRT Dump format is not semantically specified. * We will use these values in appropriate fields: @@ -720,7 +727,7 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, int len) /* Check state */ if (conn->state != BS_OPENSENT) - { bgp_error(conn, 5, 0, NULL, 0); return; } + { bgp_error(conn, 5, fsm_err_subcode[conn->state], NULL, 0); return; } /* Check message contents */ if (len < 29 || len != 29 + pkt[28]) @@ -1060,7 +1067,7 @@ bgp_rx_update(struct bgp_conn *conn, byte *pkt, int len) bgp_conn_enter_established_state(conn); if (conn->state != BS_ESTABLISHED) - { bgp_error(conn, 5, 0, NULL, 0); return; } + { bgp_error(conn, 5, fsm_err_subcode[conn->state], NULL, 0); return; } bgp_start_timer(conn->hold_timer, conn->hold_time); /* Find parts of the packet and check sizes */ @@ -1122,7 +1129,10 @@ static struct { { 3, 10, "Invalid network field" }, { 3, 11, "Malformed AS_PATH" }, { 4, 0, "Hold timer expired" }, - { 5, 0, "Finite state machine error" }, + { 5, 0, "Finite state machine error" }, /* Subcodes are according to [RFC6608] */ + { 5, 1, "Unexpected message in OpenSent state" }, + { 5, 2, "Unexpected message in OpenConfirm state" }, + { 5, 3, "Unexpected message in Established state" }, { 6, 0, "Cease" }, /* Subcodes are according to [RFC4486] */ { 6, 1, "Maximum number of prefixes reached" }, { 6, 2, "Administrative shutdown" }, @@ -1253,7 +1263,7 @@ bgp_rx_keepalive(struct bgp_conn *conn) case BS_ESTABLISHED: break; default: - bgp_error(conn, 5, 0, NULL, 0); + bgp_error(conn, 5, fsm_err_subcode[conn->state], NULL, 0); } } @@ -1265,7 +1275,7 @@ bgp_rx_route_refresh(struct bgp_conn *conn, byte *pkt, int len) BGP_TRACE(D_PACKETS, "Got ROUTE-REFRESH"); if (conn->state != BS_ESTABLISHED) - { bgp_error(conn, 5, 0, NULL, 0); return; } + { bgp_error(conn, 5, fsm_err_subcode[conn->state], NULL, 0); return; } if (!p->cf->enable_refresh) { bgp_error(conn, 1, 3, pkt+18, 1); return; } -- cgit v1.2.3