Sat Oct 1 17:17:21 2016 UTC ()
Default netmask to /32 for INET on POINTOPOINT links if not specified.


(roy)
diff -r1.185 -r1.186 src/sys/netinet/in.c

cvs diff -r1.185 -r1.186 src/sys/netinet/in.c (expand / switch to unified diff)

--- src/sys/netinet/in.c 2016/09/29 15:18:18 1.185
+++ src/sys/netinet/in.c 2016/10/01 17:17:20 1.186
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: in.c,v 1.185 2016/09/29 15:18:18 roy Exp $ */ 1/* $NetBSD: in.c,v 1.186 2016/10/01 17:17:20 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -81,27 +81,27 @@ @@ -81,27 +81,27 @@
81 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 81 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
82 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 82 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 83 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 84 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 85 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * SUCH DAMAGE. 88 * SUCH DAMAGE.
89 * 89 *
90 * @(#)in.c 8.4 (Berkeley) 1/9/95 90 * @(#)in.c 8.4 (Berkeley) 1/9/95
91 */ 91 */
92 92
93#include <sys/cdefs.h> 93#include <sys/cdefs.h>
94__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.185 2016/09/29 15:18:18 roy Exp $"); 94__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.186 2016/10/01 17:17:20 roy Exp $");
95 95
96#include "arp.h" 96#include "arp.h"
97 97
98#ifdef _KERNEL_OPT 98#ifdef _KERNEL_OPT
99#include "opt_inet.h" 99#include "opt_inet.h"
100#include "opt_inet_conf.h" 100#include "opt_inet_conf.h"
101#include "opt_mrouting.h" 101#include "opt_mrouting.h"
102#endif 102#endif
103 103
104#include <sys/param.h> 104#include <sys/param.h>
105#include <sys/ioctl.h> 105#include <sys/ioctl.h>
106#include <sys/errno.h> 106#include <sys/errno.h>
107#include <sys/kernel.h> 107#include <sys/kernel.h>
@@ -1112,27 +1112,29 @@ in_ifinit(struct ifnet *ifp, struct in_i @@ -1112,27 +1112,29 @@ in_ifinit(struct ifnet *ifp, struct in_i
1112 if (hostIsNew) 1112 if (hostIsNew)
1113 in_scrubaddr(ia); 1113 in_scrubaddr(ia);
1114 else if (scrub) 1114 else if (scrub)
1115 in_scrubprefix(ia); 1115 in_scrubprefix(ia);
1116 ia->ia_ifa.ifa_addr = sintosa(&ia->ia_addr); 1116 ia->ia_ifa.ifa_addr = sintosa(&ia->ia_addr);
1117 ia->ia_ifa.ifa_dstaddr = sintosa(&ia->ia_dstaddr); 1117 ia->ia_ifa.ifa_dstaddr = sintosa(&ia->ia_dstaddr);
1118 ia->ia4_flags = newflags; 1118 ia->ia4_flags = newflags;
1119 } 1119 }
1120 1120
1121 /* Add the local route to the address */ 1121 /* Add the local route to the address */
1122 in_ifaddlocal(&ia->ia_ifa); 1122 in_ifaddlocal(&ia->ia_ifa);
1123 1123
1124 i = ia->ia_addr.sin_addr.s_addr; 1124 i = ia->ia_addr.sin_addr.s_addr;
1125 if (IN_CLASSA(i)) 1125 if (ifp->if_flags & IFF_POINTOPOINT)
 1126 ia->ia_netmask = INADDR_BROADCAST; /* default to /32 */
 1127 else if (IN_CLASSA(i))
1126 ia->ia_netmask = IN_CLASSA_NET; 1128 ia->ia_netmask = IN_CLASSA_NET;
1127 else if (IN_CLASSB(i)) 1129 else if (IN_CLASSB(i))
1128 ia->ia_netmask = IN_CLASSB_NET; 1130 ia->ia_netmask = IN_CLASSB_NET;
1129 else 1131 else
1130 ia->ia_netmask = IN_CLASSC_NET; 1132 ia->ia_netmask = IN_CLASSC_NET;
1131 /* 1133 /*
1132 * The subnet mask usually includes at least the standard network part, 1134 * The subnet mask usually includes at least the standard network part,
1133 * but may may be smaller in the case of supernetting. 1135 * but may may be smaller in the case of supernetting.
1134 * If it is set, we believe it. 1136 * If it is set, we believe it.
1135 */ 1137 */
1136 if (ia->ia_subnetmask == 0) { 1138 if (ia->ia_subnetmask == 0) {
1137 ia->ia_subnetmask = ia->ia_netmask; 1139 ia->ia_subnetmask = ia->ia_netmask;
1138 ia->ia_sockmask.sin_addr.s_addr = ia->ia_subnetmask; 1140 ia->ia_sockmask.sin_addr.s_addr = ia->ia_subnetmask;