summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbket <bket@openbsd.org>2018-07-20 17:55:09 +0000
committerbket <bket@openbsd.org>2018-07-20 17:55:09 +0000
commitcea17583247ed477fefb77abd3a0f8de74d1755d (patch)
tree97380155ca2457dcd03b4acc2c483bf9a5677268
parentWe need to track the auto prefix in ra_prefix_conf otherwise we can't (diff)
downloadwireguard-openbsd-cea17583247ed477fefb77abd3a0f8de74d1755d.tar.xz
wireguard-openbsd-cea17583247ed477fefb77abd3a0f8de74d1755d.zip
Introduce MTU option.
The MTU option is used in Router Advertisement messages to ensure that all nodes on a link use the same MTU value in those cases where the link MTU is not well known. Feedback (thank you!) and OK from florian@
-rw-r--r--usr.sbin/rad/frontend.c14
-rw-r--r--usr.sbin/rad/parse.y8
-rw-r--r--usr.sbin/rad/printconf.c4
-rw-r--r--usr.sbin/rad/rad.c3
-rw-r--r--usr.sbin/rad/rad.conf.57
-rw-r--r--usr.sbin/rad/rad.h5
6 files changed, 33 insertions, 8 deletions
diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c
index b06fa43038c..d44701d7fde 100644
--- a/usr.sbin/rad/frontend.c
+++ b/usr.sbin/rad/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.11 2018/07/18 09:10:50 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.12 2018/07/20 17:55:09 bket Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -887,6 +887,7 @@ void
build_packet(struct ra_iface *ra_iface)
{
struct nd_router_advert *ra;
+ struct nd_opt_mtu *ndopt_mtu;
struct nd_opt_prefix_info *ndopt_pi;
struct ra_iface_conf *ra_iface_conf;
struct ra_options_conf *ra_options_conf;
@@ -904,6 +905,8 @@ build_packet(struct ra_iface *ra_iface)
ra_options_conf = &ra_iface_conf->ra_options;
len = sizeof(*ra);
+ if (ra_options_conf->mtu > 0)
+ len += sizeof(*ndopt_mtu);
len += sizeof(*ndopt_pi) * ra_iface->prefix_count;
if (ra_iface_conf->rdnss_count > 0)
len += sizeof(*ndopt_rdnss) + ra_iface_conf->rdnss_count *
@@ -940,6 +943,15 @@ build_packet(struct ra_iface *ra_iface)
ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer);
p += sizeof(*ra);
+ if (ra_options_conf->mtu > 0) {
+ ndopt_mtu = (struct nd_opt_mtu *)p;
+ ndopt_mtu->nd_opt_mtu_type = ND_OPT_MTU;
+ ndopt_mtu->nd_opt_mtu_len = 1;
+ ndopt_mtu->nd_opt_mtu_reserved = 0;
+ ndopt_mtu->nd_opt_mtu_mtu = htonl(ra_options_conf->mtu);
+ p += sizeof(*ndopt_mtu);
+ }
+
SIMPLEQ_FOREACH(ra_prefix_conf, &ra_iface->prefixes, entry) {
ndopt_pi = (struct nd_opt_prefix_info *)p;
memset(ndopt_pi, 0, sizeof(*ndopt_pi));
diff --git a/usr.sbin/rad/parse.y b/usr.sbin/rad/parse.y
index 70c3819e4a5..e0a4e1386a2 100644
--- a/usr.sbin/rad/parse.y
+++ b/usr.sbin/rad/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.5 2018/07/20 17:48:58 florian Exp $ */
+/* $OpenBSD: parse.y,v 1.6 2018/07/20 17:55:09 bket Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -115,7 +115,7 @@ typedef struct {
%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
+%token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU
%token <v.string> STRING
%token <v.number> NUMBER
@@ -209,6 +209,9 @@ ra_opt_block : DEFAULT ROUTER yesno {
| RETRANS TIMER NUMBER {
ra_options->retrans_timer = $3;
}
+ | MTU NUMBER {
+ ra_options->mtu = $2;
+ }
;
optnl : '\n' optnl /* zero or more newlines */
@@ -424,6 +427,7 @@ lookup(char *s)
{"lifetime", LIFETIME},
{"limit", LIMIT},
{"managed", MANAGED},
+ {"mtu", MTU},
{"nameserver", NAMESERVER},
{"no", NO},
{"on-link", ONLINK},
diff --git a/usr.sbin/rad/printconf.c b/usr.sbin/rad/printconf.c
index 1614fba0e04..1f9e1f72b1c 100644
--- a/usr.sbin/rad/printconf.c
+++ b/usr.sbin/rad/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.3 2018/07/20 13:17:02 florian Exp $ */
+/* $OpenBSD: printconf.c,v 1.4 2018/07/20 17:55:09 bket Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -54,6 +54,8 @@ print_ra_options(const char *indent, const struct ra_options_conf *ra_options)
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);
+ if (ra_options->mtu > 0)
+ printf("%smtu %u\n", indent, ra_options->mtu);
}
void
diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c
index 4652e1e0fb7..7885066a3ea 100644
--- a/usr.sbin/rad/rad.c
+++ b/usr.sbin/rad/rad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rad.c,v 1.9 2018/07/18 14:43:34 florian Exp $ */
+/* $OpenBSD: rad.c,v 1.10 2018/07/20 17:55:09 bket Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -716,6 +716,7 @@ config_new_empty(void)
xconf->ra_options.router_lifetime = 1800;
xconf->ra_options.reachable_time = 0;
xconf->ra_options.retrans_timer = 0;
+ xconf->ra_options.mtu = 0;
return (xconf);
}
diff --git a/usr.sbin/rad/rad.conf.5 b/usr.sbin/rad/rad.conf.5
index 36d100513b8..ee688343aed 100644
--- a/usr.sbin/rad/rad.conf.5
+++ b/usr.sbin/rad/rad.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rad.conf.5,v 1.7 2018/07/20 13:17:02 florian Exp $
+.\" $OpenBSD: rad.conf.5,v 1.8 2018/07/20 17:55:09 bket Exp $
.\"
.\" Copyright (c) 2018 Florian Obser <florian@openbsd.org>
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
@@ -87,6 +87,11 @@ The default is 1800 seconds.
.\" XXX
.\" .It Ic retrans timer Ar number
.\" XXX
+.It Ic mtu Ar bytes
+The MTU option is used in Router Advertisement messages to ensure that all
+nodes on a link use the same MTU value in those cases where the link MTU
+is not well known.
+The default is 0, meaning unspecified by this router.
.El
.Sh INTERFACES
A list of interfaces to send advertisments on:
diff --git a/usr.sbin/rad/rad.h b/usr.sbin/rad/rad.h
index db80d7c772d..a8b8ba116c4 100644
--- a/usr.sbin/rad/rad.h
+++ b/usr.sbin/rad/rad.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rad.h,v 1.11 2018/07/15 09:28:21 florian Exp $ */
+/* $OpenBSD: rad.h,v 1.12 2018/07/20 17:55:09 bket Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -76,7 +76,7 @@ enum imsg_type {
IMSG_SOCKET_IPC
};
-/* RFC 4861 Section 4.2 */
+/* RFC 4861 Sections 4.2 and 4.6.4 */
struct ra_options_conf {
int dfr; /* is default router? */
int cur_hl; /* current hop limit */
@@ -85,6 +85,7 @@ struct ra_options_conf {
int router_lifetime; /* default router lifetime */
uint32_t reachable_time;
uint32_t retrans_timer;
+ uint32_t mtu;
};
/* RFC 4861 Section 4.6.2 */