summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-08-10 12:57:19 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-08-10 12:57:19 +0000
commitf8e38e32bed384b5e3285f0135e86c32d6ec684d (patch)
treef1349963244cb581ec31167960a669069b868384 /usr.sbin
parent6a4de4b00031c7c2329c4cffe68d7793d4eff9fb (diff)
Correctly set the MED in outgoing UPDATEs. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/rde.h15
-rw-r--r--usr.sbin/bgpd/rde_filter.c6
-rw-r--r--usr.sbin/bgpd/rde_update.c16
3 files changed, 23 insertions, 14 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index 16612845a3b..31bf9393ada 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.51 2004/08/06 12:04:08 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.52 2004/08/10 12:57:18 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -135,12 +135,13 @@ LIST_HEAD(prefix_head, prefix);
#define F_ATTR_NEXTHOP 0x004
#define F_ATTR_LOCALPREF 0x008
#define F_ATTR_MED 0x010
-#define F_ATTR_MP_REACH 0x020
-#define F_ATTR_MP_UNREACH 0x040
-#define F_PREFIX_ANNOUNCED 0x080
-#define F_NEXTHOP_REJECT 0x100
-#define F_NEXTHOP_BLACKHOLE 0x200
-#define F_ATTR_LINKED 0x400
+#define F_ATTR_MED_ANNOUNCE 0x020
+#define F_ATTR_MP_REACH 0x040
+#define F_ATTR_MP_UNREACH 0x080
+#define F_PREFIX_ANNOUNCED 0x100
+#define F_NEXTHOP_REJECT 0x200
+#define F_NEXTHOP_BLACKHOLE 0x400
+#define F_ATTR_LINKED 0x800
#define ORIGIN_IGP 0
#define ORIGIN_EGP 1
diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c
index 785176d0788..585272f6faa 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.16 2004/08/06 12:04:08 claudio Exp $ */
+/* $OpenBSD: rde_filter.c,v 1.17 2004/08/10 12:57:18 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -67,8 +67,10 @@ rde_apply_set(struct rde_aspath *asp, struct filter_set *set)
if (set->flags & SET_LOCALPREF)
asp->lpref = set->localpref;
- if (set->flags & SET_MED)
+ if (set->flags & SET_MED) {
+ asp->flags |= F_ATTR_MED | F_ATTR_MED_ANNOUNCE;
asp->med = set->med;
+ }
/* XXX and uglier */
bzero(&addr, sizeof(addr));
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c
index 6ba93082554..f561c62fffb 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.27 2004/08/06 12:04:08 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.28 2004/08/10 12:57:18 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -627,11 +627,17 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa,
wlen += r; len -= r;
/*
- * The MED of other peers MUST not be announced to others.
- * Currently we just dump it. Possibilities are setting the MED via
- * a filter or set it to local-pref. struct attr_flags probably needs
- * a med_in and a med_out field.
+ * The old MED from other peers MUST not be announced to others
+ * unless the MED is originating from us or the peer is a IBGP one.
*/
+ if (a->flags & F_ATTR_MED && (peer->conf.ebgp == 0 ||
+ a->flags & F_ATTR_MED_ANNOUNCE)) {
+ tmp32 = htonl(a->lpref);
+ if ((r = attr_write(up_attr_buf + wlen, len, ATTR_OPTIONAL,
+ ATTR_MED, &tmp32, 4)) == -1)
+ return (-1);
+ wlen += r; len -= r;
+ }
if (peer->conf.ebgp == 0) {
/* local preference, only valid for ibgp */