Module Name: src
Committed By: maxv
Date: Sat Apr 21 13:22:06 UTC 2018
Modified Files:
src/sys/netinet: ip_output.c
Log Message:
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@
To generate a diff of this commit:
cvs rdiff -u -r1.302 -r1.303 src/sys/netinet/ip_output.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.302 src/sys/netinet/ip_output.c:1.303
--- src/sys/netinet/ip_output.c:1.302 Fri Apr 13 09:00:29 2018
+++ src/sys/netinet/ip_output.c Sat Apr 21 13:22:06 2018
@@ -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.
@@ -91,7 +91,7 @@
*/
#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
#include "opt_inet.h"
@@ -1016,6 +1016,7 @@ ip_insertoptions(struct mbuf *m, struct
unsigned optlen;
optlen = opt->m_len - sizeof(p->ipopt_dst);
+ KASSERT(optlen % 4 == 0);
if (optlen + ntohs(ip->ip_len) > IP_MAXPACKET)
return m; /* XXX should fail */
if (!in_nullhost(p->ipopt_dst))
@@ -1577,10 +1578,10 @@ ip_pcbopts(struct inpcb *inp, const stru
}
cp = sopt->sopt_data;
-#ifndef __vax__
- if (cnt % sizeof(int32_t))
+ if (cnt % 4) {
+ /* Must be 4-byte aligned, because there's no padding. */
return EINVAL;
-#endif
+ }
m = m_get(M_DONTWAIT, MT_SOOPTS);
if (m == NULL)