-/* $OpenBSD: frontend.c,v 1.44 2024/02/11 21:29:12 bluhm Exp $ */
+/* $OpenBSD: frontend.c,v 1.45 2024/04/23 22:11:59 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
else if (ra_options_conf->dfr) {
ra->nd_ra_router_lifetime =
htons(ra_options_conf->router_lifetime);
+ /*
+ * RFC 4191
+ * If the Router Lifetime is zero, the preference value MUST be
+ * set to (00) by the sender and MUST be ignored by the
+ * receiver.
+ */
+ if (ra_options_conf->router_lifetime > 0)
+ ra->nd_ra_flags_reserved |= ra_options_conf->rtpref;
}
ra->nd_ra_reachable = htonl(ra_options_conf->reachable_time);
ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer);
-/* $OpenBSD: parse.y,v 1.21 2022/10/15 13:27:45 florian Exp $ */
+/* $OpenBSD: parse.y,v 1.22 2024/04/23 22:11:59 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
#include <sys/stat.h>
#include <netinet/in.h>
+#include <netinet/icmp6.h>
#include <net/if.h>
#include <arpa/inet.h>
%token RA_IFACE YES NO INCLUDE ERROR
%token DEFAULT ROUTER HOP LIMIT MANAGED ADDRESS
%token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER
-%token AUTO PREFIX VALID PREFERRED LIFETIME ONLINK AUTONOMOUS
-%token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU NAT64
+%token AUTO PREFIX VALID PREFERENCE PREFERRED LIFETIME ONLINK AUTONOMOUS
+%token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU NAT64 HIGH MEDIUM LOW
%token <v.string> STRING
%token <v.number> NUMBER
| ROUTER LIFETIME NUMBER {
ra_options->router_lifetime = $3;
}
+ | ROUTER PREFERENCE HIGH {
+ ra_options->rtpref = ND_RA_FLAG_RTPREF_HIGH;
+ }
+ | ROUTER PREFERENCE MEDIUM {
+ ra_options->rtpref = ND_RA_FLAG_RTPREF_MEDIUM;
+ }
+ | ROUTER PREFERENCE LOW {
+ ra_options->rtpref = ND_RA_FLAG_RTPREF_LOW;
+ }
| REACHABLE TIME NUMBER {
ra_options->reachable_time = $3;
}
{"configuration", CONFIGURATION},
{"default", DEFAULT},
{"dns", DNS},
+ {"high", HIGH},
{"hop", HOP},
{"include", INCLUDE},
{"interface", RA_IFACE},
{"lifetime", LIFETIME},
{"limit", LIMIT},
+ {"low", LOW},
{"managed", MANAGED},
+ {"medium", MEDIUM},
{"mtu", MTU},
{"nameserver", NAMESERVER},
{"nat64", NAT64},
{"no", NO},
{"on-link", ONLINK},
{"other", OTHER},
+ {"preference", PREFERENCE},
{"preferred", PREFERRED},
{"prefix", PREFIX},
{"reachable", REACHABLE},
-/* $OpenBSD: printconf.c,v 1.7 2022/10/15 13:26:15 florian Exp $ */
+/* $OpenBSD: printconf.c,v 1.8 2024/04/23 22:11:59 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
#include <sys/uio.h>
#include <netinet/in.h>
+#include <netinet/icmp6.h>
#include <net/if.h>
#include <arpa/inet.h>
#include "rad.h"
const char* yesno(int);
+const char* rtpref(int);
void print_ra_options(const char*, const struct ra_options_conf*);
void print_prefix_options(const char*, const struct ra_prefix_conf*);
return flag ? "yes" : "no";
}
+const char*
+rtpref(int rtpref)
+{
+ switch (rtpref & ND_RA_FLAG_RTPREF_MASK) {
+ case ND_RA_FLAG_RTPREF_HIGH:
+ return "high";
+ case ND_RA_FLAG_RTPREF_MEDIUM:
+ return "medium";
+ case ND_RA_FLAG_RTPREF_LOW:
+ return "low";
+ default:
+ return "invalid";
+ }
+
+}
+
void
print_ra_options(const char *indent, const struct ra_options_conf *ra_options)
{
printf("%smanaged address configuration %s\n", indent,
yesno(ra_options->m_flag));
printf("%sother configuration %s\n", indent, yesno(ra_options->o_flag));
+ printf("%srouter preference %s\n", indent, rtpref(ra_options->rtpref));
printf("%srouter lifetime %d\n", indent, ra_options->router_lifetime);
printf("%sreachable time %u\n", indent, ra_options->reachable_time);
printf("%sretrans timer %u\n", indent, ra_options->retrans_timer);
-.\" $OpenBSD: rad.conf.5,v 1.21 2023/04/27 16:56:52 phessler Exp $
+.\" $OpenBSD: rad.conf.5,v 1.22 2024/04/23 22:11:59 florian Exp $
.\"
.\" Copyright (c) 2018 Florian Obser <florian@openbsd.org>
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 27 2023 $
+.Dd $Mdocdate: April 23 2024 $
.Dt RAD.CONF 5
.Os
.Sh NAME
The number of seconds this router is a valid default router after receiving
a router advertisement message.
The default is 1800 seconds.
+.It Ic router preference Pq Ic high Ns | Ns Ic medium Ns | Ns Ic low
+Indicates whether to prefer this router over other default routers.
+The default is medium.
.\" .It Ic reachable time Ar number
.\" XXX
.\" .It Ic retrans timer Ar number
-/* $OpenBSD: rad.h,v 1.25 2023/04/27 16:56:52 phessler Exp $ */
+/* $OpenBSD: rad.h,v 1.26 2024/04/23 22:11:59 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
int cur_hl; /* current hop limit */
int m_flag; /* managed address conf flag */
int o_flag; /* other conf flag */
+ int rtpref; /* router preference */
int router_lifetime; /* default router lifetime */
uint32_t reachable_time;
uint32_t retrans_timer;