summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
authorremi <remi@openbsd.org>2018-12-29 16:04:31 +0000
committerremi <remi@openbsd.org>2018-12-29 16:04:31 +0000
commitd1e43ac212307baf9d9eb7e807b12e1ee23cd2a6 (patch)
tree867fcbdea3a7c10c1d1f5fb47ee34fa88f79d7d8 /usr.sbin/ospf6d
parentRemove the hand-rolled maximum segment size handling in sximmc(4) (diff)
downloadwireguard-openbsd-d1e43ac212307baf9d9eb7e807b12e1ee23cd2a6.tar.xz
wireguard-openbsd-d1e43ac212307baf9d9eb7e807b12e1ee23cd2a6.zip
Add config option fib-priority to set a custom prio for routes ospf6d
inserts into the kernel routing table. OK denis@
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/kroute.c22
-rw-r--r--usr.sbin/ospf6d/ospf6d.c4
-rw-r--r--usr.sbin/ospf6d/ospf6d.conf.59
-rw-r--r--usr.sbin/ospf6d/ospf6d.h5
-rw-r--r--usr.sbin/ospf6d/parse.y16
-rw-r--r--usr.sbin/ospf6d/printconf.c4
6 files changed, 40 insertions, 20 deletions
diff --git a/usr.sbin/ospf6d/kroute.c b/usr.sbin/ospf6d/kroute.c
index 9bec21a00d3..fa1bf228533 100644
--- a/usr.sbin/ospf6d/kroute.c
+++ b/usr.sbin/ospf6d/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.58 2018/07/12 13:45:03 remi Exp $ */
+/* $OpenBSD: kroute.c,v 1.59 2018/12/29 16:04:31 remi Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -45,6 +45,7 @@ struct {
u_int32_t rtseq;
pid_t pid;
int fib_sync;
+ u_int8_t fib_prio;
int fd;
struct event ev;
u_int rdomain;
@@ -95,13 +96,14 @@ RB_PROTOTYPE(kroute_tree, kroute_node, entry, kroute_compare)
RB_GENERATE(kroute_tree, kroute_node, entry, kroute_compare)
int
-kr_init(int fs, u_int rdomain)
+kr_init(int fs, u_int rdomain, u_int8_t fib_prio)
{
int opt = 0, rcvbuf, default_rcvbuf;
socklen_t optlen;
kr_state.fib_sync = fs;
kr_state.rdomain = rdomain;
+ kr_state.fib_prio = fib_prio;
if ((kr_state.fd = socket(AF_ROUTE,
SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, AF_INET6)) == -1) {
@@ -218,7 +220,7 @@ kr_change_fib(struct kroute_node *kr, struct kroute *kroute, int krcount,
kn->r.nexthop = kroute[i].nexthop;
kn->r.scope = kroute[i].scope;
kn->r.flags = kroute[i].flags | F_OSPFD_INSERTED;
- kn->r.priority = RTP_OSPF;
+ kn->r.priority = kr_state.fib_prio;
kn->r.ext_tag = kroute[i].ext_tag;
rtlabel_unref(kn->r.rtlabel); /* for RTM_CHANGE */
kn->r.rtlabel = kroute[i].rtlabel;
@@ -242,7 +244,7 @@ kr_change(struct kroute *kroute, int krcount)
kroute->rtlabel = rtlabel_tag2id(kroute->ext_tag);
- kr = kroute_find(&kroute->prefix, kroute->prefixlen, RTP_OSPF);
+ kr = kroute_find(&kroute->prefix, kroute->prefixlen, kr_state.fib_prio);
if (kr != NULL && kr->next == NULL && krcount == 1) {
/*
* single path OSPF route.
@@ -272,7 +274,7 @@ kr_change(struct kroute *kroute, int krcount)
int
kr_delete_fib(struct kroute_node *kr)
{
- if (kr->r.priority != RTP_OSPF)
+ if (kr->r.priority != kr_state.fib_prio)
log_warn("kr_delete_fib: %s/%d has wrong priority %d",
log_in6addr(&kr->r.prefix), kr->r.prefixlen,
kr->r.priority);
@@ -292,7 +294,7 @@ kr_delete(struct kroute *kroute)
struct kroute_node *kr, *nkr;
if ((kr = kroute_find(&kroute->prefix, kroute->prefixlen,
- RTP_OSPF)) == NULL)
+ kr_state.fib_prio)) == NULL)
return (0);
while (kr != NULL) {
@@ -324,7 +326,7 @@ kr_fib_couple(void)
kr_state.fib_sync = 1;
RB_FOREACH(kr, kroute_tree, &krt)
- if (kr->r.priority == RTP_OSPF)
+ if (kr->r.priority == kr_state.fib_prio)
for (kn = kr; kn != NULL; kn = kn->next)
send_rtmsg(kr_state.fd, RTM_ADD, &kn->r);
@@ -341,7 +343,7 @@ kr_fib_decouple(void)
return;
RB_FOREACH(kr, kroute_tree, &krt)
- if (kr->r.priority == RTP_OSPF)
+ if (kr->r.priority == kr_state.fib_prio)
for (kn = kr; kn != NULL; kn = kn->next)
send_rtmsg(kr_state.fd, RTM_DELETE, &kn->r);
@@ -1013,7 +1015,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute)
bzero(&hdr, sizeof(hdr));
hdr.rtm_version = RTM_VERSION;
hdr.rtm_type = action;
- hdr.rtm_priority = RTP_OSPF;
+ hdr.rtm_priority = kr_state.fib_prio;
hdr.rtm_tableid = kr_state.rdomain; /* rtableid */
if (action == RTM_CHANGE)
hdr.rtm_fmask = RTF_REJECT|RTF_BLACKHOLE;
@@ -1241,7 +1243,7 @@ fetchtable(void)
break;
}
- if (rtm->rtm_priority == RTP_OSPF) {
+ if (rtm->rtm_priority == kr_state.fib_prio) {
send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r);
free(kr);
} else {
diff --git a/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c
index 3edab2973d4..db57f4bb406 100644
--- a/usr.sbin/ospf6d/ospf6d.c
+++ b/usr.sbin/ospf6d/ospf6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.c,v 1.40 2018/10/30 16:52:19 remi Exp $ */
+/* $OpenBSD: ospf6d.c,v 1.41 2018/12/29 16:04:31 remi Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -280,7 +280,7 @@ main(int argc, char *argv[])
fatal("unveil");
if (kr_init(!(ospfd_conf->flags & OSPFD_FLAG_NO_FIB_UPDATE),
- ospfd_conf->rdomain) == -1)
+ ospfd_conf->rdomain, ospfd_conf->fib_priority) == -1)
fatalx("kr_init failed");
event_dispatch();
diff --git a/usr.sbin/ospf6d/ospf6d.conf.5 b/usr.sbin/ospf6d/ospf6d.conf.5
index fec29b8693a..1071b7e991b 100644
--- a/usr.sbin/ospf6d/ospf6d.conf.5
+++ b/usr.sbin/ospf6d/ospf6d.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ospf6d.conf.5,v 1.17 2018/07/12 18:45:13 jmc Exp $
+.\" $OpenBSD: ospf6d.conf.5,v 1.18 2018/12/29 16:04:31 remi Exp $
.\"
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -17,7 +17,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: July 12 2018 $
+.Dd $Mdocdate: December 29 2018 $
.Dt OSPF6D.CONF 5
.Os
.Sh NAME
@@ -83,6 +83,11 @@ interface.
The only settings that can be set globally and not overruled are listed below.
.Pp
.Bl -tag -width Ds -compact
+.It Ic fib-priority Ar prio
+Set the routing priority to
+.Ar prio .
+The default is 32.
+.Pp
.It Xo
.Ic fib-update
.Pq Ic yes Ns | Ns Ic no
diff --git a/usr.sbin/ospf6d/ospf6d.h b/usr.sbin/ospf6d/ospf6d.h
index 38193ff23b6..c34fa715d03 100644
--- a/usr.sbin/ospf6d/ospf6d.h
+++ b/usr.sbin/ospf6d/ospf6d.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6d.h,v 1.38 2018/09/01 19:21:10 remi Exp $ */
+/* $OpenBSD: ospf6d.h,v 1.39 2018/12/29 16:04:31 remi Exp $ */
/*
* Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org>
@@ -386,6 +386,7 @@ struct ospfd_conf {
int flags;
u_int8_t border;
u_int8_t redistribute;
+ u_int8_t fib_priority;
u_int rdomain;
char *csock;
};
@@ -537,7 +538,7 @@ u_int16_t in_cksum(void *, size_t);
u_int16_t iso_cksum(void *, u_int16_t, u_int16_t);
/* kroute.c */
-int kr_init(int, u_int);
+int kr_init(int, u_int, u_int8_t);
int kr_change(struct kroute *, int);
int kr_delete(struct kroute *);
void kr_shutdown(void);
diff --git a/usr.sbin/ospf6d/parse.y b/usr.sbin/ospf6d/parse.y
index 19f8abb8414..603c94c2442 100644
--- a/usr.sbin/ospf6d/parse.y
+++ b/usr.sbin/ospf6d/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.40 2018/11/01 00:18:44 sashan Exp $ */
+/* $OpenBSD: parse.y,v 1.41 2018/12/29 16:04:31 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <net/route.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -122,8 +123,8 @@ typedef struct {
%}
-%token AREA INTERFACE ROUTERID FIBUPDATE REDISTRIBUTE RTLABEL RDOMAIN
-%token STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
+%token AREA INTERFACE ROUTERID FIBPRIORITY FIBUPDATE REDISTRIBUTE RTLABEL
+%token RDOMAIN STUB ROUTER SPFDELAY SPFHOLDTIME EXTTAG
%token METRIC PASSIVE
%token HELLOINTERVAL TRANSMITDELAY
%token RETRANSMITINTERVAL ROUTERDEADTIME ROUTERPRIORITY
@@ -214,6 +215,13 @@ conf_main : ROUTERID STRING {
}
free($2);
}
+ | FIBPRIORITY NUMBER {
+ if ($2 <= RTP_NONE || $2 > RTP_MAX) {
+ yyerror("invalid fib-priority");
+ YYERROR;
+ }
+ conf->fib_priority = $2;
+ }
| FIBUPDATE yesno {
if ($2 == 0)
conf->flags |= OSPFD_FLAG_NO_FIB_UPDATE;
@@ -613,6 +621,7 @@ lookup(char *s)
{"demote", DEMOTE},
{"depend", DEPEND},
{"external-tag", EXTTAG},
+ {"fib-priority", FIBPRIORITY},
{"fib-update", FIBUPDATE},
{"hello-interval", HELLOINTERVAL},
{"include", INCLUDE},
@@ -1008,6 +1017,7 @@ parse_config(char *filename, int opts)
conf->spf_delay = DEFAULT_SPF_DELAY;
conf->spf_hold_time = DEFAULT_SPF_HOLDTIME;
conf->spf_state = SPF_IDLE;
+ conf->fib_priority = RTP_OSPF;
if ((file = pushfile(filename,
!(conf->opts & OSPFD_OPT_NOACTION))) == NULL) {
diff --git a/usr.sbin/ospf6d/printconf.c b/usr.sbin/ospf6d/printconf.c
index a67a072d484..5b7951bd1f9 100644
--- a/usr.sbin/ospf6d/printconf.c
+++ b/usr.sbin/ospf6d/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.7 2018/07/12 13:45:03 remi Exp $ */
+/* $OpenBSD: printconf.c,v 1.8 2018/12/29 16:04:31 remi Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -45,6 +45,8 @@ print_mainconf(struct ospfd_conf *conf)
else
printf("fib-update yes\n");
+ printf("fib-priority %hhu\n", conf->fib_priority);
+
if (conf->rdomain)
printf("rdomain %d\n", conf->rdomain);