diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-10-15 07:43:03 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-10-15 07:43:03 +0000 |
commit | 0ea88f09f4e1ba3b8f4a9e389cc475b90c9ea2db (patch) | |
tree | 92daef68b88ec7ae5b2029993ed0f9462d3c09dd /usr.sbin/bgpd/rde.c | |
parent | e2f89031c7d8036ed93386b26fb751e34a9d225f (diff) |
Add a few more wanrings to the UPDATE parser. Mainly to warn when
attributes are ignored or UPDATEs are invalidated and withdrawn.
While there use % to check if a attribute is a multiple of X.
OK henning@, sthen@
Diffstat (limited to 'usr.sbin/bgpd/rde.c')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index f47c44eeb1c..ef35bcadae4 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.298 2010/09/02 14:03:21 sobrado Exp $ */ +/* $OpenBSD: rde.c,v 1.299 2010/10/15 07:43:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1489,6 +1489,8 @@ bad_flags: */ if ((flags & ATTR_PARTIAL) == 0) goto bad_len; + log_peer_warnx(&peer->conf, "bad AGGREGATOR, " + "partial attribute ignored"); plen += attr_len; break; } @@ -1509,7 +1511,7 @@ bad_flags: /* 4-byte ready server take the default route */ goto optattr; case ATTR_COMMUNITIES: - if ((attr_len & 0x3) != 0) { + if (attr_len % 4 != 0) { /* * mark update as bad and withdraw all routes as per * draft-ietf-idr-optional-transitive-00.txt @@ -1517,15 +1519,16 @@ bad_flags: */ if ((flags & ATTR_PARTIAL) == 0) goto bad_len; - else - a->flags |= F_ATTR_PARSE_ERR; + a->flags |= F_ATTR_PARSE_ERR; + log_peer_warnx(&peer->conf, "bad COMMUNITIES, " + "path invalidated and prefix withdrawn"); } if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE, ATTR_PARTIAL)) goto bad_flags; goto optattr; case ATTR_EXT_COMMUNITIES: - if ((attr_len & 0x7) != 0) { + if (attr_len % 8 != 0) { /* * mark update as bad and withdraw all routes as per * draft-ietf-idr-optional-transitive-00.txt @@ -1533,8 +1536,9 @@ bad_flags: */ if ((flags & ATTR_PARTIAL) == 0) goto bad_len; - else - a->flags |= F_ATTR_PARSE_ERR; + a->flags |= F_ATTR_PARSE_ERR; + log_peer_warnx(&peer->conf, "bad EXT_COMMUNITIES, " + "path invalidated and prefix withdrawn"); } if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE, ATTR_PARTIAL)) @@ -1547,7 +1551,7 @@ bad_flags: goto bad_flags; goto optattr; case ATTR_CLUSTER_LIST: - if ((attr_len & 0x3) != 0) + if (attr_len % 4 != 0) goto bad_len; if (!CHECK_FLAGS(flags, ATTR_OPTIONAL, 0)) goto bad_flags; @@ -1585,7 +1589,8 @@ bad_flags: /* see ATTR_AGGREGATOR ... */ if ((flags & ATTR_PARTIAL) == 0) goto bad_len; - /* we should add a warning here */ + log_peer_warnx(&peer->conf, "bad AS4_AGGREGATOR, " + "partial attribute ignored"); plen += attr_len; break; } @@ -1611,6 +1616,8 @@ bad_flags: */ if (flags & ATTR_PARTIAL) { a->flags |= F_ATTR_PARSE_ERR; + log_peer_warnx(&peer->conf, "bad AS4_PATH, " + "path invalidated and prefix withdrawn"); goto optattr; } else { rde_update_err(peer, ERR_UPDATE, ERR_UPD_ASPATH, @@ -1940,10 +1947,16 @@ rde_as4byte_fixup(struct rde_peer *peer, struct rde_aspath *a) if (rde_as4byte(peer)) { /* NEW session using 4-byte ASNs */ - if (nasp) + if (nasp) { + log_peer_warnx(&peer->conf, "uses 4-byte ASN " + "but sent AS4_PATH attribute."); attr_free(a, nasp); - if (naggr) + } + if (naggr) { + log_peer_warnx(&peer->conf, "uses 4-byte ASN " + "but sent AS4_AGGREGATOR attribute."); attr_free(a, naggr); + } return; } /* OLD session using 2-byte ASNs */ |