diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2007-03-05 13:58:00 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2007-03-05 13:58:00 +0000 |
commit | b05d0b601a37c784bdf76a1876a18395924e9426 (patch) | |
tree | bbef4099e6c1b17d3d0c40c15da91d15e3ef5d81 /usr.sbin | |
parent | c603e1ed21588a911fae221916a52a328e2a5a21 (diff) |
in prefix_aggregate(), when we look at two neighbor prefixes, see wether
they can be expressed as one with shorter prefixlen. if so, adjust the
first prefix accordingly and return 1 so the second gets removed.
shrinks the ruleset for my AS from 19533 to 16892 rules.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpctl/irr_prefix.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.sbin/bgpctl/irr_prefix.c b/usr.sbin/bgpctl/irr_prefix.c index 7f9beacdaef..2e68096915b 100644 --- a/usr.sbin/bgpctl/irr_prefix.c +++ b/usr.sbin/bgpctl/irr_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: irr_prefix.c,v 1.6 2007/03/05 13:45:52 henning Exp $ */ +/* $OpenBSD: irr_prefix.c,v 1.7 2007/03/05 13:57:59 henning Exp $ */ /* * Copyright (c) 2007 Henning Brauer <henning@openbsd.org> @@ -165,6 +165,17 @@ prefix_aggregate(struct irr_prefix *a, const struct irr_prefix *b) if ((a->addr.in.s_addr & mask) == (b->addr.in.s_addr & mask)) return (1); + /* see wether we can fold them in one */ + if (a->len == b->len && a->len > 1) { + mask = htonl(0xffffffff << (32 - (a->len - 1))); + if ((a->addr.in.s_addr & mask) == + (b->addr.in.s_addr & mask)) { + a->len--; + a->addr.in.s_addr &= mask; + return (1); + } + } + return (0); } |