summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospfd/ospfd.c
diff options
context:
space:
mode:
authorremi <remi@openbsd.org>2019-01-15 22:18:10 +0000
committerremi <remi@openbsd.org>2019-01-15 22:18:10 +0000
commit17e34b32ed8c08ec67ab2ae29cfec42b0710ec9d (patch)
tree7b231e27ce568553352acc5f84acadd6c8ad84b6 /usr.sbin/ospfd/ospfd.c
parentMake otus(4) modify its DMA_TRIGGER register with readable macros (diff)
downloadwireguard-openbsd-17e34b32ed8c08ec67ab2ae29cfec42b0710ec9d.tar.xz
wireguard-openbsd-17e34b32ed8c08ec67ab2ae29cfec42b0710ec9d.zip
For external LSAs the type (1 or 2) is encoded in the metric field. Do not
overwrite this when using "redistribute X set type 2 depend on ifX" and ifX is down. Problem reported for ospfd by Igor Podlesny. ok benno@
Diffstat (limited to 'usr.sbin/ospfd/ospfd.c')
-rw-r--r--usr.sbin/ospfd/ospfd.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c
index 1aa7cde3248..d01a2fa66b8 100644
--- a/usr.sbin/ospfd/ospfd.c
+++ b/usr.sbin/ospfd/ospfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.c,v 1.104 2019/01/14 16:50:56 florian Exp $ */
+/* $OpenBSD: ospfd.c,v 1.105 2019/01/15 22:18:10 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -564,7 +564,8 @@ ospf_redistribute(struct kroute *kr, u_int32_t *metric)
switch (r->type & ~REDIST_NO) {
case REDIST_LABEL:
if (kr->rtlabel == r->label) {
- *metric = depend_ok ? r->metric : MAX_METRIC;
+ *metric = depend_ok ? r->metric :
+ r->metric | MAX_METRIC;
return (r->type & REDIST_NO ? 0 : 1);
}
break;
@@ -579,7 +580,8 @@ ospf_redistribute(struct kroute *kr, u_int32_t *metric)
if (kr->flags & F_DYNAMIC)
continue;
if (kr->flags & F_STATIC) {
- *metric = depend_ok ? r->metric : MAX_METRIC;
+ *metric = depend_ok ? r->metric :
+ r->metric | MAX_METRIC;
return (r->type & REDIST_NO ? 0 : 1);
}
break;
@@ -589,7 +591,8 @@ ospf_redistribute(struct kroute *kr, u_int32_t *metric)
if (kr->flags & F_DYNAMIC)
continue;
if (kr->flags & F_CONNECTED) {
- *metric = depend_ok ? r->metric : MAX_METRIC;
+ *metric = depend_ok ? r->metric :
+ r->metric | MAX_METRIC;
return (r->type & REDIST_NO ? 0 : 1);
}
break;
@@ -601,7 +604,7 @@ ospf_redistribute(struct kroute *kr, u_int32_t *metric)
r->mask.s_addr == INADDR_ANY) {
if (is_default) {
*metric = depend_ok ? r->metric :
- MAX_METRIC;
+ r->metric | MAX_METRIC;
return (r->type & REDIST_NO ? 0 : 1);
} else
return (0);
@@ -610,13 +613,15 @@ ospf_redistribute(struct kroute *kr, u_int32_t *metric)
if ((kr->prefix.s_addr & r->mask.s_addr) ==
(r->addr.s_addr & r->mask.s_addr) &&
kr->prefixlen >= mask2prefixlen(r->mask.s_addr)) {
- *metric = depend_ok ? r->metric : MAX_METRIC;
+ *metric = depend_ok ? r->metric :
+ r->metric | MAX_METRIC;
return (r->type & REDIST_NO ? 0 : 1);
}
break;
case REDIST_DEFAULT:
if (is_default) {
- *metric = depend_ok ? r->metric : MAX_METRIC;
+ *metric = depend_ok ? r->metric :
+ r->metric | MAX_METRIC;
return (r->type & REDIST_NO ? 0 : 1);
}
break;