summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-08-10 13:02:09 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-08-10 13:02:09 +0000
commit8babc5b23252c7e76e17692fe161aae7ab7cd71f (patch)
treebff104a2696e1ce7d6e0e71ef13cc74fdadba1e9 /usr.sbin
parentf8e38e32bed384b5e3285f0135e86c32d6ec684d (diff)
switch nexthop in struct filter_set form struct in_addr to struct bgpd_addr
OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.h20
-rw-r--r--usr.sbin/bgpd/parse.y10
-rw-r--r--usr.sbin/bgpd/printconf.c4
-rw-r--r--usr.sbin/bgpd/rde.c9
-rw-r--r--usr.sbin/bgpd/rde.h8
-rw-r--r--usr.sbin/bgpd/rde_filter.c13
-rw-r--r--usr.sbin/bgpd/rde_rib.c9
7 files changed, 34 insertions, 39 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 8fe5562dbe9..86db0da8171 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.139 2004/08/06 12:04:08 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.140 2004/08/10 13:02:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -157,17 +157,15 @@ enum enforce_as {
};
struct filter_set {
- u_int16_t flags;
- u_int32_t localpref;
- u_int32_t med;
- /*XXX this nexthop thing should be changed to one bgpd_addr */
- struct in_addr nexthop;
- struct in6_addr nexthop6;
- u_int8_t prepend;
- char pftable[PFTABLE_LEN];
+ u_int16_t flags;
+ u_int32_t localpref;
+ u_int32_t med;
+ struct bgpd_addr nexthop;
+ u_int8_t prepend;
+ char pftable[PFTABLE_LEN];
struct {
- int as;
- int type;
+ int as;
+ int type;
} community;
};
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 39bccecec21..a1c02b09478 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.131 2004/08/05 18:40:44 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.132 2004/08/10 13:02:08 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1083,13 +1083,7 @@ filter_set_opt : LOCALPREF number {
$$.med = $2;
}
| NEXTHOP address {
- if ($2.af == AF_INET) {
- $$.flags = SET_NEXTHOP;
- $$.nexthop.s_addr = $2.v4.s_addr;
- } else {
- yyerror("king bula sez: AF_INET only for now");
- YYERROR;
- }
+ memcpy(&$$.nexthop, &$2, sizeof($$.nexthop));
}
| NEXTHOP BLACKHOLE {
$$.flags |= SET_NEXTHOP_BLACKHOLE;
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index c868009a190..0309f85e373 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.25 2004/08/02 12:30:15 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.26 2004/08/10 13:02:08 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -78,7 +78,7 @@ print_set(struct filter_set *set)
if (set->flags & SET_MED)
printf("med %u ", set->med);
if (set->flags & SET_NEXTHOP)
- printf("nexthop %s ", inet_ntoa(set->nexthop));
+ printf("nexthop %s ", log_addr(&set->nexthop));
if (set->flags & SET_NEXTHOP_REJECT)
printf("nexthop reject ");
if (set->flags & SET_NEXTHOP_BLACKHOLE)
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index e56d5b78237..220b5666ac2 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.139 2004/08/06 12:04:08 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.140 2004/08/10 13:02:08 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -685,7 +685,7 @@ rde_update_dispatch(struct imsg *imsg)
}
/* apply default overrides */
- rde_apply_set(asp, &peer->conf.attrset);
+ rde_apply_set(asp, &peer->conf.attrset, AF_INET);
/* parse nlri prefix */
while (nlri_len > 0) {
@@ -760,6 +760,9 @@ rde_update_dispatch(struct imsg *imsg)
mpp += pos;
mplen -= pos;
+ /* apply default overrides */
+ rde_apply_set(asp, &peer->conf.attrset, AF_INET6);
+
switch (afi) {
case AFI_IPv6:
while (mplen > 0) {
@@ -1961,7 +1964,7 @@ network_add(struct network_config *nc, int flagstatic)
/* the nexthop is unset unless a default set overrides it */
/* apply default overrides */
- rde_apply_set(asp, &nc->attrset);
+ rde_apply_set(asp, &nc->attrset, nc->prefix.af);
if (flagstatic)
path_update(&peerself, asp, &nc->prefix, nc->prefixlen);
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index 31bf9393ada..08400f32a74 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.52 2004/08/10 12:57:18 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.53 2004/08/10 13:02:08 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -308,7 +308,8 @@ void prefix_network_clean(struct rde_peer *, time_t);
void nexthop_init(u_int32_t);
void nexthop_shutdown(void);
-void nexthop_modify(struct rde_aspath *, struct bgpd_addr *, int);
+void nexthop_modify(struct rde_aspath *, struct bgpd_addr *, int,
+ sa_family_t);
void nexthop_link(struct rde_aspath *);
void nexthop_unlink(struct rde_aspath *);
void nexthop_update(struct kroute_nexthop *);
@@ -342,7 +343,8 @@ void pt_dump(void (*)(struct pt_entry *, void *), void *,
/* rde_filter.c */
enum filter_actions rde_filter(struct rde_peer *, struct rde_aspath *,
struct bgpd_addr *, u_int8_t, enum directions);
-void rde_apply_set(struct rde_aspath *, struct filter_set *);
+void rde_apply_set(struct rde_aspath *, struct filter_set *,
+ sa_family_t);
int rde_filter_community(struct rde_aspath *, int, int);
#endif /* __RDE_H__ */
diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c
index 585272f6faa..33f2c5f8ef7 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.17 2004/08/10 12:57:18 claudio Exp $ */
+/* $OpenBSD: rde_filter.c,v 1.18 2004/08/10 13:02:08 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -45,7 +45,7 @@ rde_filter(struct rde_peer *peer, struct rde_aspath *asp,
f->peer.peerid != peer->conf.id)
continue;
if (rde_filter_match(f, asp, prefix, prefixlen)) {
- rde_apply_set(asp, &f->set);
+ rde_apply_set(asp, &f->set, prefix->af);
if (f->action != ACTION_NONE)
action = f->action;
if (f->quick)
@@ -56,9 +56,8 @@ rde_filter(struct rde_peer *peer, struct rde_aspath *asp,
}
void
-rde_apply_set(struct rde_aspath *asp, struct filter_set *set)
+rde_apply_set(struct rde_aspath *asp, struct filter_set *set, sa_family_t af)
{
- struct bgpd_addr addr;
struct aspath *new;
u_int16_t as;
@@ -72,11 +71,7 @@ rde_apply_set(struct rde_aspath *asp, struct filter_set *set)
asp->med = set->med;
}
- /* XXX and uglier */
- bzero(&addr, sizeof(addr));
- addr.af = AF_INET;
- addr.v4.s_addr = set->nexthop.s_addr;
- nexthop_modify(asp, &addr, set->flags);
+ nexthop_modify(asp, &set->nexthop, set->flags, af);
if (set->flags & SET_PREPEND) {
as = rde_local_as();
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index ed127353780..2d3281129ee 100644
--- a/usr.sbin/bgpd/rde_rib.c
+++ b/usr.sbin/bgpd/rde_rib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.55 2004/08/06 12:04:08 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.56 2004/08/10 13:02:08 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -732,7 +732,8 @@ nexthop_update(struct kroute_nexthop *msg)
}
void
-nexthop_modify(struct rde_aspath *asp, struct bgpd_addr *nexthop, int flags)
+nexthop_modify(struct rde_aspath *asp, struct bgpd_addr *nexthop, int flags,
+ sa_family_t af)
{
struct nexthop *nh;
@@ -740,8 +741,10 @@ nexthop_modify(struct rde_aspath *asp, struct bgpd_addr *nexthop, int flags)
asp->flags |= F_NEXTHOP_REJECT;
if (flags & SET_NEXTHOP_BLACKHOLE)
asp->flags |= F_NEXTHOP_BLACKHOLE;
- if (!(flags & SET_NEXTHOP))
+ if (!(flags & SET_NEXTHOP) ||
+ af != nexthop->af)
return;
+
nh = nexthop_get(nexthop, NULL);
nexthop_unlink(asp);
asp->nexthop = nh;