-/* $OpenBSD: frontend.c,v 1.45 2024/04/23 22:11:59 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.46 2024/05/17 06:50:14 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
#include <sys/uio.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/route.h>
u_int8_t nd_opt_pref64[12];
};
+struct nd_opt_source_link_addr {
+ u_int8_t nd_opt_source_link_addr_type;
+ u_int8_t nd_opt_source_link_addr_len;
+ struct ether_addr nd_opt_source_link_addr_hw_addr;
+};
+
TAILQ_HEAD(, ra_iface) ra_interfaces;
__dead void frontend_shutdown(void);
build_packet(struct ra_iface *ra_iface)
{
struct nd_router_advert *ra;
+ struct nd_opt_source_link_addr *ndopt_source_link_addr;
struct nd_opt_mtu *ndopt_mtu;
struct nd_opt_prefix_info *ndopt_pi;
struct ra_iface_conf *ra_iface_conf;
struct ra_rdnss_conf *ra_rdnss;
struct ra_dnssl_conf *ra_dnssl;
struct ra_pref64_conf *pref64;
+ struct ifaddrs *ifap, *ifa;
+ struct sockaddr_dl *sdl;
size_t len, label_len;
uint8_t *p, buf[RA_MAX_SIZE];
char *label_start, *label_end;
ra_options_conf = &ra_iface_conf->ra_options;
len = sizeof(*ra);
+ if (ra_iface_conf->ra_options.source_link_addr)
+ len += sizeof(*ndopt_source_link_addr);
if (ra_options_conf->mtu > 0)
len += sizeof(*ndopt_mtu);
len += sizeof(*ndopt_pi) * ra_iface->prefix_count;
ra->nd_ra_retransmit = htonl(ra_options_conf->retrans_timer);
p += sizeof(*ra);
+ if (ra_iface_conf->ra_options.source_link_addr) {
+ ndopt_source_link_addr = (struct nd_opt_source_link_addr *)p;
+ ndopt_source_link_addr->nd_opt_source_link_addr_type =
+ ND_OPT_SOURCE_LINKADDR;
+ ndopt_source_link_addr->nd_opt_source_link_addr_len = 1;
+ if (getifaddrs(&ifap) != 0) {
+ ifap = NULL;
+ log_warn("getifaddrs");
+ }
+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL ||
+ ifa->ifa_addr->sa_family != AF_LINK)
+ continue;
+ if (strcmp(ra_iface->name, ifa->ifa_name) != 0)
+ continue;
+ sdl = (struct sockaddr_dl *)ifa->ifa_addr;
+ if (sdl->sdl_type != IFT_ETHER ||
+ sdl->sdl_alen != ETHER_ADDR_LEN)
+ continue;
+ memcpy(&ndopt_source_link_addr->
+ nd_opt_source_link_addr_hw_addr,
+ LLADDR(sdl), ETHER_ADDR_LEN);
+ break;
+ }
+ if (ifap != NULL) {
+ freeifaddrs(ifap);
+ p += sizeof(*ndopt_source_link_addr);
+ } else
+ len -= sizeof(*ndopt_source_link_addr);
+ }
+
if (ra_options_conf->mtu > 0) {
ndopt_mtu = (struct nd_opt_mtu *)p;
ndopt_mtu->nd_opt_mtu_type = ND_OPT_MTU;
-/* $OpenBSD: parse.y,v 1.22 2024/04/23 22:11:59 florian Exp $ */
+/* $OpenBSD: parse.y,v 1.23 2024/05/17 06:50:14 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
%token CONFIGURATION OTHER LIFETIME REACHABLE TIME RETRANS TIMER
%token AUTO PREFIX VALID PREFERENCE PREFERRED LIFETIME ONLINK AUTONOMOUS
%token ADDRESS_CONFIGURATION DNS NAMESERVER SEARCH MTU NAT64 HIGH MEDIUM LOW
+%token SOURCE LINK_LAYER
%token <v.string> STRING
%token <v.number> NUMBER
| RETRANS TIMER NUMBER {
ra_options->retrans_timer = $3;
}
+ | SOURCE LINK_LAYER ADDRESS yesno {
+ ra_options->source_link_addr = $4;
+ }
| MTU NUMBER {
ra_options->mtu = $2;
}
{"interface", RA_IFACE},
{"lifetime", LIFETIME},
{"limit", LIMIT},
+ {"link-layer", LINK_LAYER},
{"low", LOW},
{"managed", MANAGED},
{"medium", MEDIUM},
{"retrans", RETRANS},
{"router", ROUTER},
{"search", SEARCH},
+ {"source", SOURCE},
{"time", TIME},
{"timer", TIMER},
{"valid", VALID},
-/* $OpenBSD: printconf.c,v 1.8 2024/04/23 22:11:59 florian Exp $ */
+/* $OpenBSD: printconf.c,v 1.9 2024/05/17 06:50:14 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
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);
+ printf("%ssource link-layer address %s\n", indent,
+ yesno(ra_options->source_link_addr));
if (ra_options->mtu > 0)
printf("%smtu %u\n", indent, ra_options->mtu);
-/* $OpenBSD: rad.c,v 1.29 2023/04/19 12:58:16 jsg Exp $ */
+/* $OpenBSD: rad.c,v 1.30 2024/05/17 06:50:14 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
xconf->ra_options.router_lifetime = ADV_DEFAULT_LIFETIME;
xconf->ra_options.reachable_time = 0;
xconf->ra_options.retrans_timer = 0;
+ xconf->ra_options.source_link_addr = 1;
xconf->ra_options.mtu = 0;
xconf->ra_options.rdns_lifetime = DEFAULT_RDNS_LIFETIME;
SIMPLEQ_INIT(&xconf->ra_options.ra_rdnss_list);
-.\" $OpenBSD: rad.conf.5,v 1.23 2024/04/23 22:17:49 florian Exp $
+.\" $OpenBSD: rad.conf.5,v 1.24 2024/05/17 06:50:14 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 23 2024 $
+.Dd $Mdocdate: May 17 2024 $
.Dt RAD.CONF 5
.Os
.Sh NAME
.\" XXX
.\" .It Ic retrans timer Ar number
.\" XXX
+.It Ic source link-layer address Pq Ic yes Ns | Ns Ic no
+Add a source link-layer address option to router advertisement messages, to
+communicate the link-layer address of the sending interface.
+The default is yes.
.El
.Sh INTERFACES
A list of interfaces or interface groups to send advertisements on:
-/* $OpenBSD: rad.h,v 1.26 2024/04/23 22:11:59 florian Exp $ */
+/* $OpenBSD: rad.h,v 1.27 2024/05/17 06:50:14 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
int router_lifetime; /* default router lifetime */
uint32_t reachable_time;
uint32_t retrans_timer;
+ int source_link_addr; /* source link-layer address */
uint32_t mtu;
uint32_t rdns_lifetime;
SIMPLEQ_HEAD(, ra_rdnss_conf) ra_rdnss_list;