sync code with last fixes and improvements from OpenBSD
This commit is contained in:
parent
f960599e67
commit
691f97cc10
215 changed files with 1520 additions and 11518 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_ethersubr.c,v 1.290 2023/07/06 19:46:53 kn Exp $ */
|
||||
/* $OpenBSD: if_ethersubr.c,v 1.291 2023/07/27 20:21:25 jan Exp $ */
|
||||
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -1040,6 +1040,7 @@ ether_extract_headers(struct mbuf *mp, struct ether_extracted *ext)
|
|||
uint64_t hlen;
|
||||
int hoff;
|
||||
uint8_t ipproto;
|
||||
uint16_t ether_type;
|
||||
|
||||
/* Return NULL if header was not recognized. */
|
||||
memset(ext, 0, sizeof(*ext));
|
||||
|
@ -1048,9 +1049,20 @@ ether_extract_headers(struct mbuf *mp, struct ether_extracted *ext)
|
|||
return;
|
||||
|
||||
ext->eh = mtod(mp, struct ether_header *);
|
||||
switch (ntohs(ext->eh->ether_type)) {
|
||||
ether_type = ntohs(ext->eh->ether_type);
|
||||
hlen = sizeof(*ext->eh);
|
||||
|
||||
#if NVLAN > 0
|
||||
if (ether_type == ETHERTYPE_VLAN) {
|
||||
ext->evh = mtod(mp, struct ether_vlan_header *);
|
||||
ether_type = ntohs(ext->evh->evl_proto);
|
||||
hlen = sizeof(*ext->evh);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (ether_type) {
|
||||
case ETHERTYPE_IP:
|
||||
m = m_getptr(mp, sizeof(*ext->eh), &hoff);
|
||||
m = m_getptr(mp, hlen, &hoff);
|
||||
if (m == NULL || m->m_len - hoff < sizeof(*ext->ip4))
|
||||
return;
|
||||
ext->ip4 = (struct ip *)(mtod(m, caddr_t) + hoff);
|
||||
|
@ -1064,7 +1076,7 @@ ether_extract_headers(struct mbuf *mp, struct ether_extracted *ext)
|
|||
break;
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6:
|
||||
m = m_getptr(mp, sizeof(*ext->eh), &hoff);
|
||||
m = m_getptr(mp, hlen, &hoff);
|
||||
if (m == NULL || m->m_len - hoff < sizeof(*ext->ip6))
|
||||
return;
|
||||
ext->ip6 = (struct ip6_hdr *)(mtod(m, caddr_t) + hoff);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: rtsock.c,v 1.367 2023/06/26 07:52:18 claudio Exp $ */
|
||||
/* $OpenBSD: rtsock.c,v 1.369 2023/07/28 09:33:16 mvs Exp $ */
|
||||
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -690,7 +690,7 @@ route_output(struct mbuf *m, struct socket *so)
|
|||
u_char vers, type;
|
||||
|
||||
if (m == NULL || ((m->m_len < sizeof(int32_t)) &&
|
||||
(m = m_pullup(m, sizeof(int32_t))) == 0))
|
||||
(m = m_pullup(m, sizeof(int32_t))) == NULL))
|
||||
return (ENOBUFS);
|
||||
if ((m->m_flags & M_PKTHDR) == 0)
|
||||
panic("route_output");
|
||||
|
@ -705,7 +705,8 @@ route_output(struct mbuf *m, struct socket *so)
|
|||
sounlock(so);
|
||||
|
||||
len = m->m_pkthdr.len;
|
||||
if (len < offsetof(struct rt_msghdr, rtm_hdrlen) + 1 ||
|
||||
if (len < offsetof(struct rt_msghdr, rtm_hdrlen) +
|
||||
sizeof(rtm->rtm_hdrlen) ||
|
||||
len != mtod(m, struct rt_msghdr *)->rtm_msglen) {
|
||||
error = EINVAL;
|
||||
goto fail;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue