Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Remove #ifndef __vax__.



details:   https://anonhg.NetBSD.org/src/rev/a7c9c8f435ac
branches:  trunk
changeset: 831943:a7c9c8f435ac
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Apr 21 13:22:06 2018 +0000

description:
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@

diffstat:

 sys/netinet/ip_output.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 63afb5169b97 -r a7c9c8f435ac sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Sat Apr 21 12:38:17 2018 +0000
+++ b/sys/netinet/ip_output.c   Sat Apr 21 13:22:06 2018 +0000
@@ -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 @@
        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 @@
        }
        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)



Home | Main Index | Thread Index | Old Index