summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2011-09-21 08:59:02 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2011-09-21 08:59:02 +0000
commit73ea37c5bc18737eb684b52d8f91fadbcb48fb9d (patch)
treeb5a975e0aacb79274e1c4870c429f7f153c6ef22
parent2b21a27cbc1f88781c09bae3c4fdf6722e1650d9 (diff)
Fix nexthop_modify() to reset the flags when called. Until now
set nexthop-self was sticky and so later set nexthop <IP> were not applied. Problem found and fix tested by Tony Sarendal. OK henning@
-rw-r--r--usr.sbin/bgpd/rde.h3
-rw-r--r--usr.sbin/bgpd/rde_rib.c45
2 files changed, 26 insertions, 22 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index 38b8363b08e..4a11c6afb12 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.141 2011/09/20 21:19:06 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.142 2011/09/21 08:59:01 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -164,6 +164,7 @@ LIST_HEAD(prefix_head, prefix);
#define F_NEXTHOP_REJECT 0x02000
#define F_NEXTHOP_BLACKHOLE 0x04000
#define F_NEXTHOP_NOMODIFY 0x08000
+#define F_NEXTHOP_MASK 0x0f000
#define F_ATTR_PARSE_ERR 0x10000
#define F_ATTR_LINKED 0x20000
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index bbd472dfd1e..706ef5f382a 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.130 2011/09/20 21:19:06 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.131 2011/09/21 08:59:01 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -1106,31 +1106,34 @@ nexthop_modify(struct rde_aspath *asp, struct bgpd_addr *nexthop,
{
struct nexthop *nh;
- if (type == ACTION_SET_NEXTHOP_REJECT) {
- asp->flags |= F_NEXTHOP_REJECT;
+ if (type == ACTION_SET_NEXTHOP && aid != nexthop->aid)
return;
- }
- if (type == ACTION_SET_NEXTHOP_BLACKHOLE) {
+
+ asp->flags &= ~F_NEXTHOP_MASK;
+ switch (type) {
+ case ACTION_SET_NEXTHOP_REJECT:
+ asp->flags |= F_NEXTHOP_REJECT;
+ break;
+ case ACTION_SET_NEXTHOP_BLACKHOLE:
asp->flags |= F_NEXTHOP_BLACKHOLE;
- return;
- }
- if (type == ACTION_SET_NEXTHOP_NOMODIFY) {
+ break;
+ case ACTION_SET_NEXTHOP_NOMODIFY:
asp->flags |= F_NEXTHOP_NOMODIFY;
- return;
- }
- if (type == ACTION_SET_NEXTHOP_SELF) {
+ break;
+ case ACTION_SET_NEXTHOP_SELF:
asp->flags |= F_NEXTHOP_SELF;
- return;
+ break;
+ case ACTION_SET_NEXTHOP:
+ nh = nexthop_get(nexthop);
+ if (asp->flags & F_ATTR_LINKED)
+ nexthop_unlink(asp);
+ asp->nexthop = nh;
+ if (asp->flags & F_ATTR_LINKED)
+ nexthop_link(asp);
+ break;
+ default:
+ break;
}
- if (aid != nexthop->aid)
- return;
-
- nh = nexthop_get(nexthop);
- if (asp->flags & F_ATTR_LINKED)
- nexthop_unlink(asp);
- asp->nexthop = nh;
- if (asp->flags & F_ATTR_LINKED)
- nexthop_link(asp);
}
void