Remove #ifndef __vax__.

The check enforces a 4-byte-aligned size for the option mbuf. If the size
is not multiple of 4, the computation of ip_hl gets truncated in the
output path. There is no reason for this check not to be present on VAX.

While here add a KASSERT in ip_insertoptions to enforce the assumption.

Discussed briefly on tech-net@
This commit is contained in:
maxv 2018-04-21 13:22:06 +00:00
parent c35bf49041
commit 2b3801633e

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_output.c,v 1.302 2018/04/13 09:00:29 maxv Exp $ */ /* $NetBSD: ip_output.c,v 1.303 2018/04/21 13:22:06 maxv Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -91,7 +91,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.302 2018/04/13 09:00:29 maxv Exp $"); __KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.303 2018/04/21 13:22:06 maxv Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_inet.h" #include "opt_inet.h"
@ -1016,6 +1016,7 @@ ip_insertoptions(struct mbuf *m, struct mbuf *opt, int *phlen)
unsigned optlen; unsigned optlen;
optlen = opt->m_len - sizeof(p->ipopt_dst); optlen = opt->m_len - sizeof(p->ipopt_dst);
KASSERT(optlen % 4 == 0);
if (optlen + ntohs(ip->ip_len) > IP_MAXPACKET) if (optlen + ntohs(ip->ip_len) > IP_MAXPACKET)
return m; /* XXX should fail */ return m; /* XXX should fail */
if (!in_nullhost(p->ipopt_dst)) if (!in_nullhost(p->ipopt_dst))
@ -1577,10 +1578,10 @@ ip_pcbopts(struct inpcb *inp, const struct sockopt *sopt)
} }
cp = sopt->sopt_data; cp = sopt->sopt_data;
#ifndef __vax__ if (cnt % 4) {
if (cnt % sizeof(int32_t)) /* Must be 4-byte aligned, because there's no padding. */
return EINVAL; return EINVAL;
#endif }
m = m_get(M_DONTWAIT, MT_SOOPTS); m = m_get(M_DONTWAIT, MT_SOOPTS);
if (m == NULL) if (m == NULL)