Wed Mar 10 22:28:27 2021 UTC ()
byte-flipping a random number is not very useful.


(christos)
diff -r1.226 -r1.227 src/sys/netinet6/ip6_output.c

cvs diff -r1.226 -r1.227 src/sys/netinet6/ip6_output.c (expand / switch to unified diff)

--- src/sys/netinet6/ip6_output.c 2020/09/08 14:12:57 1.226
+++ src/sys/netinet6/ip6_output.c 2021/03/10 22:28:26 1.227
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ip6_output.c,v 1.226 2020/09/08 14:12:57 christos Exp $ */ 1/* $NetBSD: ip6_output.c,v 1.227 2021/03/10 22:28:26 christos Exp $ */
2/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ 2/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
3 3
4/* 4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 * 60 *
61 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 61 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.226 2020/09/08 14:12:57 christos Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.227 2021/03/10 22:28:26 christos Exp $");
66 66
67#ifdef _KERNEL_OPT 67#ifdef _KERNEL_OPT
68#include "opt_inet.h" 68#include "opt_inet.h"
69#include "opt_inet6.h" 69#include "opt_inet6.h"
70#include "opt_ipsec.h" 70#include "opt_ipsec.h"
71#endif 71#endif
72 72
73#include <sys/param.h> 73#include <sys/param.h>
74#include <sys/malloc.h> 74#include <sys/malloc.h>
75#include <sys/mbuf.h> 75#include <sys/mbuf.h>
76#include <sys/errno.h> 76#include <sys/errno.h>
77#include <sys/socket.h> 77#include <sys/socket.h>
78#include <sys/socketvar.h> 78#include <sys/socketvar.h>
@@ -879,27 +879,27 @@ ip6_output( @@ -879,27 +879,27 @@ ip6_output(
879 if (mtu < IPV6_MMTU) { 879 if (mtu < IPV6_MMTU) {
880 /* path MTU cannot be less than IPV6_MMTU */ 880 /* path MTU cannot be less than IPV6_MMTU */
881 IP6_STATINC(IP6_STAT_CANTFRAG); 881 IP6_STATINC(IP6_STAT_CANTFRAG);
882 error = EMSGSIZE; 882 error = EMSGSIZE;
883 in6_ifstat_inc(ifp, ifs6_out_fragfail); 883 in6_ifstat_inc(ifp, ifs6_out_fragfail);
884 goto bad; 884 goto bad;
885 } else if (ip6->ip6_plen == 0) { 885 } else if (ip6->ip6_plen == 0) {
886 /* jumbo payload cannot be fragmented */ 886 /* jumbo payload cannot be fragmented */
887 IP6_STATINC(IP6_STAT_CANTFRAG); 887 IP6_STATINC(IP6_STAT_CANTFRAG);
888 error = EMSGSIZE; 888 error = EMSGSIZE;
889 in6_ifstat_inc(ifp, ifs6_out_fragfail); 889 in6_ifstat_inc(ifp, ifs6_out_fragfail);
890 goto bad; 890 goto bad;
891 } else { 891 } else {
892 const u_int32_t id = htonl(ip6_randomid()); 892 const uint32_t id = ip6_randomid();
893 struct mbuf **mnext, *m_frgpart; 893 struct mbuf **mnext, *m_frgpart;
894 const int hlen = unfragpartlen; 894 const int hlen = unfragpartlen;
895 struct ip6_frag *ip6f; 895 struct ip6_frag *ip6f;
896 u_char nextproto; 896 u_char nextproto;
897 897
898 if (mtu > IPV6_MAXPACKET) 898 if (mtu > IPV6_MAXPACKET)
899 mtu = IPV6_MAXPACKET; 899 mtu = IPV6_MAXPACKET;
900 900
901 /* 901 /*
902 * Must be able to put at least 8 bytes per fragment. 902 * Must be able to put at least 8 bytes per fragment.
903 */ 903 */
904 len = (mtu - hlen - sizeof(struct ip6_frag)) & ~7; 904 len = (mtu - hlen - sizeof(struct ip6_frag)) & ~7;
905 if (len < 8) { 905 if (len < 8) {