-/* $OpenBSD: dhcpleased.c,v 1.24 2022/03/21 04:35:41 dlg Exp $ */
+/* $OpenBSD: dhcpleased.c,v 1.25 2022/07/23 09:29:20 florian Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
#include <net/if.h>
#include <net/route.h>
+#include <net/if_dl.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/in_var.h>
struct sockaddr_in *ifa, int rtm_flags)
{
struct rt_msghdr rtm;
+ struct sockaddr_dl ifp;
struct sockaddr_rtlabel rl;
- struct iovec iov[12];
+ struct iovec iov[14];
long pad = 0;
int iovcnt = 0, padlen;
rtm.rtm_tableid = rdomain;
rtm.rtm_seq = ++rtm_seq;
rtm.rtm_priority = RTP_NONE;
- rtm.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK | RTA_LABEL;
+ rtm.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK | RTA_IFP |
+ RTA_LABEL;
rtm.rtm_flags = RTF_UP | RTF_STATIC | RTF_MPATH | rtm_flags;
if (ifa)
rtm.rtm_msglen += padlen;
}
+ memset(&ifp, 0, sizeof(ifp));
+ ifp.sdl_len = sizeof(struct sockaddr_dl);
+ ifp.sdl_family = AF_LINK;
+ ifp.sdl_index = if_index;
+ iov[iovcnt].iov_base = &ifp;
+ iov[iovcnt++].iov_len = sizeof(ifp);
+ rtm.rtm_msglen += sizeof(ifp);
+ padlen = ROUNDUP(sizeof(ifp)) - sizeof(ifp);
+ if (padlen > 0) {
+ iov[iovcnt].iov_base = &pad;
+ iov[iovcnt++].iov_len = padlen;
+ rtm.rtm_msglen += padlen;
+ }
+
if (ifa) {
iov[iovcnt].iov_base = ifa;
iov[iovcnt++].iov_len = ifa->sin_len;