-/* $OpenBSD: kroute.c,v 1.108 2017/07/24 11:00:01 friehm Exp $ */
+/* $OpenBSD: kroute.c,v 1.109 2018/02/11 02:27:33 benno Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
}
int
-kr_init(int fs, u_int rdomain)
+kr_init(int fs, u_int rdomain, int redis_label_or_prefix)
{
int opt = 0, rcvbuf, default_rcvbuf;
socklen_t optlen;
+ int filter_prio = RTP_OSPF;
kr_state.fib_sync = fs;
kr_state.rdomain = rdomain;
&opt, sizeof(opt)) == -1)
log_warn("kr_init: setsockopt"); /* not fatal */
+ if (redis_label_or_prefix) {
+ filter_prio = 0;
+ log_info("%s: priority filter disabled", __func__);
+ } else
+ log_debug("%s: priority filter enabled", __func__);
+
+ if (setsockopt(kr_state.fd, AF_ROUTE, ROUTE_PRIOFILTER, &filter_prio,
+ sizeof(filter_prio)) == -1) {
+ log_warn("%s: setsockopt AF_ROUTE ROUTE_PRIOFILTER", __func__);
+ /* not fatal */
+ }
+
/* grow receive buffer, don't wanna miss messages */
optlen = sizeof(default_rcvbuf);
if (getsockopt(kr_state.fd, SOL_SOCKET, SO_RCVBUF,
}
void
-kr_reload(void)
+kr_reload(int redis_label_or_prefix)
{
struct kroute_node *kr, *kn;
u_int32_t dummy;
int r;
+ int filter_prio = RTP_OSPF;
+
+ /* update the priority filter */
+ if (redis_label_or_prefix) {
+ filter_prio = 0;
+ log_info("%s: priority filter disabled", __func__);
+ } else
+ log_debug("%s: priority filter enabled", __func__);
+
+ if (setsockopt(kr_state.fd, AF_ROUTE, ROUTE_PRIOFILTER, &filter_prio,
+ sizeof(filter_prio)) == -1) {
+ log_warn("%s: setsockopt AF_ROUTE ROUTE_PRIOFILTER", __func__);
+ /* not fatal */
+ }
+ /* update redistribute lists */
RB_FOREACH(kr, kroute_tree, &krt) {
for (kn = kr; kn; kn = kn->next) {
r = ospf_redistribute(&kn->r, &dummy);
-/* $OpenBSD: ospfd.c,v 1.96 2018/02/09 22:52:54 jca Exp $ */
+/* $OpenBSD: ospfd.c,v 1.97 2018/02/11 02:27:33 benno Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
event_add(&iev_rde->ev, NULL);
if (kr_init(!(ospfd_conf->flags & OSPFD_FLAG_NO_FIB_UPDATE),
- ospfd_conf->rdomain) == -1)
+ ospfd_conf->rdomain, ospfd_conf->redist_label_or_prefix) == -1)
fatalx("kr_init failed");
/* remove unneeded stuff from config */
merge_config(ospfd_conf, xconf);
/* update redistribute lists */
- kr_reload();
+ kr_reload(ospfd_conf->redist_label_or_prefix);
return (0);
}
SIMPLEQ_EMPTY(&xconf->redist_list))
rchange = 1;
conf->rfc1583compat = xconf->rfc1583compat;
+ conf->redist_label_or_prefix = xconf->redist_label_or_prefix;
if (ospfd_process == PROC_MAIN) {
/* main process does neither use areas nor interfaces */
-/* $OpenBSD: ospfd.h,v 1.99 2018/02/08 00:18:57 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.100 2018/02/11 02:27:33 benno Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
int spf_state;
int ospf_socket;
int flags;
+ int redist_label_or_prefix;
u_int8_t rfc1583compat;
u_int8_t border;
u_int8_t redistribute;
/* kroute.c */
int kif_init(void);
void kif_clear(void);
-int kr_init(int, u_int);
+int kr_init(int, u_int, int);
int kr_change(struct kroute *, int);
int kr_delete(struct kroute *);
void kr_shutdown(void);
void kr_show_route(struct imsg *);
void kr_ifinfo(char *, pid_t);
struct kif *kif_findname(char *, struct in_addr, struct kif_addr **);
-void kr_reload(void);
+void kr_reload(int);
u_int8_t mask2prefixlen(in_addr_t);
in_addr_t prefixlen2mask(u_int8_t);
-/* $OpenBSD: parse.y,v 1.85 2018/02/09 22:52:54 jca Exp $ */
+/* $OpenBSD: parse.y,v 1.86 2018/02/11 02:27:33 benno Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
if ($1)
r->type |= REDIST_NO;
+ else
+ conf->redist_label_or_prefix = 1;
r->metric = $6;
if ($7)
strlcpy(r->dependon, $7, sizeof(r->dependon));
r->type = REDIST_STATIC;
else if (!strcmp($3, "connected"))
r->type = REDIST_CONNECTED;
- else if (host($3, &r->addr, &r->mask))
+ else if (host($3, &r->addr, &r->mask)) {
r->type = REDIST_ADDR;
- else {
+ conf->redist_label_or_prefix = !$1;
+ } else {
yyerror("unknown redistribute type");
free($3);
free(r);
r->label = rtlabel_name2id($4);
if ($1)
r->type |= REDIST_NO;
+ else
+ conf->redist_label_or_prefix = 1;
r->metric = $5;
if ($6)
strlcpy(r->dependon, $6, sizeof(r->dependon));