aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2021-04-10 15:25:24 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2021-04-10 15:31:16 +0000
commit7f5f3fcc32bfa553faa007579dfcaed84be3b047 (patch)
tree80103a139b3a8c4f4d7422750abb36efa9719b7d
parent4d9128da54f8f8e2a29190ffb18880c4f116a205 (diff)
downloadsrc-7f5f3fcc32bfa553faa007579dfcaed84be3b047.tar.gz
src-7f5f3fcc32bfa553faa007579dfcaed84be3b047.zip
Fix direct route installation with net/bird.
Slighly relax the gateway validation rules imposed by the 2fe5a79425c7, by requiring only first 8 bytes (everyhing before sdl_data to be present in the AF_LINK gateway. Reported by: olivier
-rw-r--r--sys/net/rtsock.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 12e485f917c8..c0996d318fb2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1381,20 +1381,21 @@ cleanup_xaddrs_gateway(struct rt_addrinfo *info)
#endif
case AF_LINK:
{
- struct sockaddr_dl_short *gw_sdl;
+ struct sockaddr_dl *gw_sdl;
- gw_sdl = (struct sockaddr_dl_short *)gw;
- if (gw_sdl->sdl_len < sizeof(struct sockaddr_dl_short)) {
+ size_t sdl_min_len = offsetof(struct sockaddr_dl, sdl_data);
+ gw_sdl = (struct sockaddr_dl *)gw;
+ if (gw_sdl->sdl_len < sdl_min_len) {
printf("gw sdl_len too small\n");
return (EINVAL);
}
const struct sockaddr_dl_short sdl = {
.sdl_family = AF_LINK,
- .sdl_len = sizeof(struct sockaddr_dl_short),
+ .sdl_len = sdl_min_len,
.sdl_index = gw_sdl->sdl_index,
};
- *gw_sdl = sdl;
+ memcpy(gw_sdl, &sdl, sdl_min_len);
break;
}
}