summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-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