summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-12-18 15:51:38 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-12-18 15:51:38 +0000
commita2d857b386ce67105a5e6b313baa6c7fbf68d45f (patch)
tree2d9e843c761ac0f23c0351a2cedc52389fd1fbfa /usr.sbin
parent72acd1253a98e26198842a0b9f56858d381ad542 (diff)
Merge rde_filter_community() with community_match() and kill a useless
indirection.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/rde.c4
-rw-r--r--usr.sbin/bgpd/rde.h5
-rw-r--r--usr.sbin/bgpd/rde_attr.c17
-rw-r--r--usr.sbin/bgpd/rde_filter.c17
-rw-r--r--usr.sbin/bgpd/rde_update.c8
5 files changed, 22 insertions, 29 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 442032d202c..d0d9558e92b 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.277 2009/12/16 15:40:55 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.278 2009/12/18 15:51:37 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1938,7 +1938,7 @@ rde_dump_filter(struct prefix *p, struct ctl_show_rib_request *req)
!aspath_match(p->aspath->aspath, req->as.type, req->as.as))
return;
if (req->type == IMSG_CTL_SHOW_RIB_COMMUNITY &&
- !rde_filter_community(p->aspath, req->community.as,
+ !community_match(p->aspath, req->community.as,
req->community.type))
return;
rde_dump_rib_as(p, p->aspath, req->pid, req->flags);
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index eb8122fa6d1..c48ee243595 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.125 2009/12/16 15:40:55 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.126 2009/12/18 15:51:37 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -343,7 +343,7 @@ int aspath_loopfree(struct aspath *, u_int32_t);
int aspath_compare(struct aspath *, struct aspath *);
u_char *aspath_prepend(struct aspath *, u_int32_t, int, u_int16_t *);
int aspath_match(struct aspath *, enum as_spec, u_int32_t);
-int community_match(void *, u_int16_t, int, int);
+int community_match(struct rde_aspath *, int, int);
int community_set(struct rde_aspath *, int, int);
void community_delete(struct rde_aspath *, int, int);
int community_ext_set(struct rde_aspath *,
@@ -458,7 +458,6 @@ enum filter_actions rde_filter(u_int16_t, struct rde_aspath **,
struct rde_peer *, enum directions);
void rde_apply_set(struct rde_aspath *, struct filter_set_head *,
u_int8_t, struct rde_peer *, struct rde_peer *);
-int rde_filter_community(struct rde_aspath *, int, int);
int rde_filter_equal(struct filter_head *, struct filter_head *,
struct rde_peer *, enum directions);
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c
index 8aa418e1dc4..c83a3d2736d 100644
--- a/usr.sbin/bgpd/rde_attr.c
+++ b/usr.sbin/bgpd/rde_attr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_attr.c,v 1.80 2009/12/16 15:40:55 claudio Exp $ */
+/* $OpenBSD: rde_attr.c,v 1.81 2009/12/18 15:51:37 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -978,12 +978,19 @@ aspath_match(struct aspath *a, enum as_spec type, u_int32_t as)
int community_ext_conv(struct filter_extcommunity *, u_int16_t, u_int64_t *);
int
-community_match(void *data, u_int16_t len, int as, int type)
+community_match(struct rde_aspath *asp, int as, int type)
{
- u_int8_t *p = data;
- u_int16_t eas, etype;
+ struct attr *a;
+ u_int8_t *p;
+ u_int16_t eas, etype, len;
+
+ a = attr_optget(asp, ATTR_COMMUNITIES);
+ if (a == NULL)
+ /* no communities, no match */
+ return (0);
- len >>= 2; /* divide by four */
+ len = a->len / 4;
+ p = a->data;
for (; len > 0; len--) {
eas = *p++;
diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c
index a248dd68578..f6e3a179048 100644
--- a/usr.sbin/bgpd/rde_filter.c
+++ b/usr.sbin/bgpd/rde_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_filter.c,v 1.60 2009/12/16 15:40:55 claudio Exp $ */
+/* $OpenBSD: rde_filter.c,v 1.61 2009/12/18 15:51:37 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -299,7 +299,7 @@ rde_filter_match(struct filter_rule *f, struct rde_aspath *asp,
break;
}
- if (rde_filter_community(asp, as, type) == 0)
+ if (community_match(asp, as, type) == 0)
return (0);
}
@@ -374,19 +374,6 @@ rde_filter_match(struct filter_rule *f, struct rde_aspath *asp,
}
int
-rde_filter_community(struct rde_aspath *asp, int as, int type)
-{
- struct attr *a;
-
- a = attr_optget(asp, ATTR_COMMUNITIES);
- if (a == NULL)
- /* no communities, no match */
- return (0);
-
- return (community_match(a->data, a->len, as, type));
-}
-
-int
rde_filter_equal(struct filter_head *a, struct filter_head *b,
struct rde_peer *peer, enum directions dir)
{
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c
index 4418fc41aea..99c68862f86 100644
--- a/usr.sbin/bgpd/rde_update.c
+++ b/usr.sbin/bgpd/rde_update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_update.c,v 1.73 2009/12/08 14:03:40 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.74 2009/12/18 15:51:37 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -318,13 +318,13 @@ up_test_update(struct rde_peer *peer, struct prefix *p)
}
/* well known communities */
- if (rde_filter_community(p->aspath,
+ if (community_match(p->aspath,
COMMUNITY_WELLKNOWN, COMMUNITY_NO_ADVERTISE))
return (0);
- if (peer->conf.ebgp && rde_filter_community(p->aspath,
+ if (peer->conf.ebgp && community_match(p->aspath,
COMMUNITY_WELLKNOWN, COMMUNITY_NO_EXPORT))
return (0);
- if (peer->conf.ebgp && rde_filter_community(p->aspath,
+ if (peer->conf.ebgp && community_match(p->aspath,
COMMUNITY_WELLKNOWN, COMMUNITY_NO_EXPSUBCONFED))
return (0);