CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Fri Apr 19 05:04:06 UTC 2024 Modified Files: src/sys/netinet6: frag6.c Log Message: frag6: fix calculation of fragment length Because of the miscalculation, 32 bytes fragmented IPv6 packets have been wrongly dropped. See https://mail-index.netbsd.org/tech-net/2024/04/14/msg008741.html for more details. Patch from Yasuyuki KOZAKAI (with minor tweaks) To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/netinet6/frag6.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/netinet6/frag6.c diff -u src/sys/netinet6/frag6.c:1.77 src/sys/netinet6/frag6.c:1.78 --- src/sys/netinet6/frag6.c:1.77 Tue Aug 29 17:01:35 2023 +++ src/sys/netinet6/frag6.c Fri Apr 19 05:04:06 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: frag6.c,v 1.77 2023/08/29 17:01:35 christos Exp $ */ +/* $NetBSD: frag6.c,v 1.78 2024/04/19 05:04:06 ozaki-r Exp $ */ /* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.77 2023/08/29 17:01:35 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.78 2024/04/19 05:04:06 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -206,9 +206,10 @@ frag6_input(struct mbuf **mp, int *offp, * sizeof(struct ip6_frag) == 8 * sizeof(struct ip6_hdr) = 40 */ - if ((ip6f->ip6f_offlg & IP6F_MORE_FRAG) && - (((ntohs(ip6->ip6_plen) - offset) == 0) || - ((ntohs(ip6->ip6_plen) - offset) & 0x7) != 0)) { + frgpartlen = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - offset + - sizeof(struct ip6_frag); + if ((frgpartlen == 0) || + ((ip6f->ip6f_offlg & IP6F_MORE_FRAG) && (frgpartlen & 0x7) != 0)) { icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offsetof(struct ip6_hdr, ip6_plen)); in6_ifstat_inc(dstifp, ifs6_reass_fail); @@ -316,7 +317,6 @@ frag6_input(struct mbuf **mp, int *offp, * in size. If it would exceed, discard the fragment and return an * ICMP error. */ - frgpartlen = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) - offset; if (q6->ip6q_unfrglen >= 0) { /* The 1st fragment has already arrived. */ if (q6->ip6q_unfrglen + fragoff + frgpartlen > IPV6_MAXPACKET) {
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Fri Apr 19 05:04:06 UTC 2024 Modified Files: src/sys/netinet6: frag6.c Log Message: frag6: fix calculation of fragment length Because of the miscalculation, 32 bytes fragmented IPv6 packets have been wrongly dropped. See https://mail-index.netbsd.org/tech-net/2024/04/14/msg008741.html for more details. Patch from Yasuyuki KOZAKAI (with minor tweaks) To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/netinet6/frag6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: ozaki-r Date: Mon Nov 27 02:50:27 UTC 2023 Modified Files: src/sys/kern: uipc_mbuf.c Log Message: mbuf: avoid assertion failure when splitting mbuf cluster >From OpenBSD: commit 7b4d35e0a60ba1dd4daf4b1c2932020a22463a89 Author: bluhm Date: Fri Oct 20 16:25:15 2023 + Avoid assertion failure when splitting mbuf cluster. m_split() calls m_align() to initialize the data pointer of newly allocated mbuf. If the new mbuf will be converted to a cluster, this is not necessary. If additionally the new mbuf is larger than MLEN, this can lead to a panic. Only call m_align() when a valid m_data is needed. This is the case if we do not refecence the existing cluster, but memcpy() the data into the new mbuf. Reported-by: syzbot+0e6817f5877926f0e...@syzkaller.appspotmail.com OK claudio@ deraadt@ The issue is harmless if DIAGNOSTIC is not enabled. XXX pullup-10 XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.251 -r1.252 src/sys/kern/uipc_mbuf.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/kern/uipc_mbuf.c diff -u src/sys/kern/uipc_mbuf.c:1.251 src/sys/kern/uipc_mbuf.c:1.252 --- src/sys/kern/uipc_mbuf.c:1.251 Wed Apr 12 06:48:08 2023 +++ src/sys/kern/uipc_mbuf.c Mon Nov 27 02:50:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_mbuf.c,v 1.251 2023/04/12 06:48:08 riastradh Exp $ */ +/* $NetBSD: uipc_mbuf.c,v 1.252 2023/11/27 02:50:27 ozaki-r Exp $ */ /* * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.251 2023/04/12 06:48:08 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.252 2023/11/27 02:50:27 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_mbuftrace.h" @@ -1343,10 +1343,7 @@ m_split_internal(struct mbuf *m0, int le len_save = m0->m_pkthdr.len; m0->m_pkthdr.len = len0; - if (m->m_flags & M_EXT) - goto extpacket; - - if (remain > MHLEN) { + if ((m->m_flags & M_EXT) == 0 && remain > MHLEN) { /* m can't be the lead packet */ m_align(n, 0); n->m_len = 0; @@ -1357,8 +1354,6 @@ m_split_internal(struct mbuf *m0, int le return NULL; } return n; - } else { - m_align(n, remain); } } else if (remain == 0) { n = m->m_next; @@ -1369,14 +1364,13 @@ m_split_internal(struct mbuf *m0, int le if (n == NULL) return NULL; MCLAIM(n, m->m_owner); - m_align(n, remain); } -extpacket: if (m->m_flags & M_EXT) { n->m_data = m->m_data + len; MCLADDREFERENCE(m, n); } else { + m_align(n, remain); memcpy(mtod(n, void *), mtod(m, char *) + len, remain); }
CVS commit: src/sys/kern
Module Name:src Committed By: ozaki-r Date: Mon Nov 27 02:50:27 UTC 2023 Modified Files: src/sys/kern: uipc_mbuf.c Log Message: mbuf: avoid assertion failure when splitting mbuf cluster >From OpenBSD: commit 7b4d35e0a60ba1dd4daf4b1c2932020a22463a89 Author: bluhm Date: Fri Oct 20 16:25:15 2023 + Avoid assertion failure when splitting mbuf cluster. m_split() calls m_align() to initialize the data pointer of newly allocated mbuf. If the new mbuf will be converted to a cluster, this is not necessary. If additionally the new mbuf is larger than MLEN, this can lead to a panic. Only call m_align() when a valid m_data is needed. This is the case if we do not refecence the existing cluster, but memcpy() the data into the new mbuf. Reported-by: syzbot+0e6817f5877926f0e...@syzkaller.appspotmail.com OK claudio@ deraadt@ The issue is harmless if DIAGNOSTIC is not enabled. XXX pullup-10 XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.251 -r1.252 src/sys/kern/uipc_mbuf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Thu Aug 3 05:45:36 UTC 2023 Modified Files: src/sys/netinet6: ip6_output.c Log Message: in6: don't send any IPv6 packets over a disabled interface To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/netinet6/ip6_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/netinet6/ip6_output.c diff -u src/sys/netinet6/ip6_output.c:1.233 src/sys/netinet6/ip6_output.c:1.234 --- src/sys/netinet6/ip6_output.c:1.233 Mon Mar 20 09:15:52 2023 +++ src/sys/netinet6/ip6_output.c Thu Aug 3 05:45:36 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_output.c,v 1.233 2023/03/20 09:15:52 ozaki-r Exp $ */ +/* $NetBSD: ip6_output.c,v 1.234 2023/08/03 05:45:36 ozaki-r Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.233 2023/03/20 09:15:52 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.234 2023/08/03 05:45:36 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -171,6 +171,12 @@ ip6_if_output(struct ifnet * const ifp, } } + /* discard the packet if IPv6 operation is disabled on the interface */ + if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) { + m_freem(m); + return ENETDOWN; /* better error? */ + } + if ((ifp->if_flags & IFF_LOOPBACK) != 0) error = if_output_lock(ifp, origifp, m, sin6tocsa(dst), rt); else
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Thu Aug 3 05:45:36 UTC 2023 Modified Files: src/sys/netinet6: ip6_output.c Log Message: in6: don't send any IPv6 packets over a disabled interface To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/netinet6/ip6_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Thu Aug 3 05:44:22 UTC 2023 Modified Files: src/sys/netinet6: in6.c Log Message: in6: clear ND6_IFF_IFDISABLED to allow DAD again on link-up To generate a diff of this commit: cvs rdiff -u -r1.288 -r1.289 src/sys/netinet6/in6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Thu Aug 3 05:44:22 UTC 2023 Modified Files: src/sys/netinet6: in6.c Log Message: in6: clear ND6_IFF_IFDISABLED to allow DAD again on link-up To generate a diff of this commit: cvs rdiff -u -r1.288 -r1.289 src/sys/netinet6/in6.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/netinet6/in6.c diff -u src/sys/netinet6/in6.c:1.288 src/sys/netinet6/in6.c:1.289 --- src/sys/netinet6/in6.c:1.288 Mon Oct 24 14:15:19 2022 +++ src/sys/netinet6/in6.c Thu Aug 3 05:44:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: in6.c,v 1.288 2022/10/24 14:15:19 msaitoh Exp $ */ +/* $NetBSD: in6.c,v 1.289 2023/08/03 05:44:22 ozaki-r Exp $ */ /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.288 2022/10/24 14:15:19 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.289 2023/08/03 05:44:22 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2293,6 +2293,10 @@ in6_if_link_down(struct ifnet *ifp) } pserialize_read_exit(s); curlwp_bindx(bound); + + /* Clear ND6_IFF_IFDISABLED to allow DAD again on link-up. */ + if (ifp->if_afdata[AF_INET6] != NULL) + ND_IFINFO(ifp)->flags &= ~ND6_IFF_IFDISABLED; } void
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Thu Aug 3 04:24:55 UTC 2023 Modified Files: src/sys/netinet6: in6_src.c Log Message: in6: add missing rtcache_unref to in6_selectroute By default, this issue is harmless. However, if NET_MPSAFE is enabled, it could eventually lead to a kernel panic. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/netinet6/in6_src.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/netinet6/in6_src.c diff -u src/sys/netinet6/in6_src.c:1.91 src/sys/netinet6/in6_src.c:1.92 --- src/sys/netinet6/in6_src.c:1.91 Fri Nov 4 09:01:53 2022 +++ src/sys/netinet6/in6_src.c Thu Aug 3 04:24:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: in6_src.c,v 1.91 2022/11/04 09:01:53 ozaki-r Exp $ */ +/* $NetBSD: in6_src.c,v 1.92 2023/08/03 04:24:55 ozaki-r Exp $ */ /* $KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $ */ /* @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.91 2022/11/04 09:01:53 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.92 2023/08/03 04:24:55 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -709,6 +709,7 @@ in6_selectroute(struct sockaddr_in6 *dst if (count_discard) in6_ifstat_inc(rt->rt_ifp, ifs6_out_discard); error = EHOSTUNREACH; + rtcache_unref(rt, *ro); rt = NULL; } }
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Thu Aug 3 04:24:55 UTC 2023 Modified Files: src/sys/netinet6: in6_src.c Log Message: in6: add missing rtcache_unref to in6_selectroute By default, this issue is harmless. However, if NET_MPSAFE is enabled, it could eventually lead to a kernel panic. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/netinet6/in6_src.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Mon Jun 5 03:51:45 UTC 2023 Modified Files: src/sys/net: route.c Log Message: route: run workqueue kthreads with KERNEL_LOCK unless NET_MPSAFE Without KERNEL_LOCK, rt_timer_work and rt_free_work can run in parallel with other LWPs running in the network stack, which eventually results in say use-after-free of a deleted route. To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/sys/net/route.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/net/route.c diff -u src/sys/net/route.c:1.236 src/sys/net/route.c:1.237 --- src/sys/net/route.c:1.236 Thu Dec 22 13:54:57 2022 +++ src/sys/net/route.c Mon Jun 5 03:51:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.236 2022/12/22 13:54:57 riastradh Exp $ */ +/* $NetBSD: route.c,v 1.237 2023/06/05 03:51:45 ozaki-r Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.236 2022/12/22 13:54:57 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.237 2023/06/05 03:51:45 ozaki-r Exp $"); #include #ifdef RTFLUSH_DEBUG @@ -229,12 +229,14 @@ static krwlock_t rt_lock __cacheline_al #define RT_UNLOCK() rw_exit(_lock) #define RT_WLOCKED() rw_write_held(_lock) #define RT_ASSERT_WLOCK() KASSERT(rw_write_held(_lock)) +#define RT_WQ_FLAGS WQ_MPSAFE #else #define RT_RLOCK() do {} while (0) #define RT_WLOCK() do {} while (0) #define RT_UNLOCK() do {} while (0) #define RT_WLOCKED() true #define RT_ASSERT_WLOCK() do {} while (0) +#define RT_WQ_FLAGS 0 #endif static uint64_t rtcache_generation; @@ -477,7 +479,7 @@ rt_init(void) rt_psref_class = psref_class_create("rtentry", IPL_SOFTNET); error = workqueue_create(_free_global.wq, "rt_free", - rt_free_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + rt_free_work, NULL, PRI_SOFTNET, IPL_SOFTNET, RT_WQ_FLAGS); if (error) panic("%s: workqueue_create failed (%d)\n", __func__, error); @@ -1822,7 +1824,7 @@ rt_timer_init(void) LIST_INIT(_queue_head); callout_init(_timer_ch, CALLOUT_MPSAFE); error = workqueue_create(_timer_wq, "rt_timer", - rt_timer_work, NULL, PRI_SOFTNET, IPL_SOFTNET, WQ_MPSAFE); + rt_timer_work, NULL, PRI_SOFTNET, IPL_SOFTNET, RT_WQ_FLAGS); if (error) panic("%s: workqueue_create failed (%d)\n", __func__, error); callout_reset(_timer_ch, hz, rt_timer_timer, NULL);
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Mon Jun 5 03:51:45 UTC 2023 Modified Files: src/sys/net: route.c Log Message: route: run workqueue kthreads with KERNEL_LOCK unless NET_MPSAFE Without KERNEL_LOCK, rt_timer_work and rt_free_work can run in parallel with other LWPs running in the network stack, which eventually results in say use-after-free of a deleted route. To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/sys/net/route.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Wed Apr 19 02:43:40 UTC 2023 Modified Files: src/sys/netinet: ip_output.c Log Message: Revert "Fix panic on packet sending via a route with rt_ifa of AF_LINK." The fix is mistakenly upstreamed. To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 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.324 src/sys/netinet/ip_output.c:1.325 --- src/sys/netinet/ip_output.c:1.324 Mon Nov 21 09:51:13 2022 +++ src/sys/netinet/ip_output.c Wed Apr 19 02:43:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_output.c,v 1.324 2022/11/21 09:51:13 knakahara Exp $ */ +/* $NetBSD: ip_output.c,v 1.325 2023/04/19 02:43:40 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.324 2022/11/21 09:51:13 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.325 2023/04/19 02:43:40 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -531,15 +531,6 @@ ip_output(struct mbuf *m0, struct mbuf * if (in_nullhost(ip->ip_src)) { struct ifaddr *xifa; - /* If rt_ifa is AF_LINK, ia can be NULL. */ - if (ia == NULL) { - KASSERTMSG(rt->rt_ifa->ifa_addr->sa_family == AF_LINK, - "sa_family=%d", rt->rt_ifa->ifa_addr->sa_family); - IP_STATINC(IP_STAT_NOROUTE); - error = EHOSTUNREACH; - goto bad; - } - xifa = >ia_ifa; if (xifa->ifa_getifa != NULL) { ia4_release(ia, _ia); @@ -591,15 +582,6 @@ ip_output(struct mbuf *m0, struct mbuf * sendit: if ((flags & (IP_FORWARDING|IP_NOIPNEWID)) == 0) { - /* If rt_ifa is AF_LINK, ia can be NULL. */ - if (ia == NULL) { - KASSERTMSG(rt->rt_ifa->ifa_addr->sa_family == AF_LINK, - "sa_family=%d", rt->rt_ifa->ifa_addr->sa_family); - IP_STATINC(IP_STAT_NOROUTE); - error = EHOSTUNREACH; - goto bad; - } - if (m->m_pkthdr.len < IP_MINFRAGSIZE) { ip->ip_id = 0; } else if ((m->m_pkthdr.csum_flags & M_CSUM_TSOv4) == 0) {
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Wed Apr 19 02:43:40 UTC 2023 Modified Files: src/sys/netinet: ip_output.c Log Message: Revert "Fix panic on packet sending via a route with rt_ifa of AF_LINK." The fix is mistakenly upstreamed. To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 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.
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Wed Mar 22 03:17:18 UTC 2023 Modified Files: src/sys/netinet6: raw_ip6.c Log Message: in6: make sure a user-specified checksum field is within a packet >From OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/sys/netinet6/raw_ip6.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/netinet6/raw_ip6.c diff -u src/sys/netinet6/raw_ip6.c:1.182 src/sys/netinet6/raw_ip6.c:1.183 --- src/sys/netinet6/raw_ip6.c:1.182 Fri Nov 4 09:01:53 2022 +++ src/sys/netinet6/raw_ip6.c Wed Mar 22 03:17:18 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: raw_ip6.c,v 1.182 2022/11/04 09:01:53 ozaki-r Exp $ */ +/* $NetBSD: raw_ip6.c,v 1.183 2023/03/22 03:17:18 ozaki-r Exp $ */ /* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.182 2022/11/04 09:01:53 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.183 2023/03/22 03:17:18 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_ipsec.h" @@ -202,7 +202,16 @@ rip6_input(struct mbuf **mp, int *offp, continue; if (in6p_cksum(inp) != -1) { RIP6_STATINC(RIP6_STAT_ISUM); - if (in6_cksum(m, proto, *offp, + /* + * Although in6_cksum() does not need the position of + * the checksum field for verification, enforce that it + * is located within the packet. Userland has given + * a checksum offset, a packet too short for that is + * invalid. Avoid overflow with user supplied offset. + */ + if (m->m_pkthdr.len < *offp + 2 || + m->m_pkthdr.len - *offp - 2 < in6p_cksum(inp) || + in6_cksum(m, proto, *offp, m->m_pkthdr.len - *offp)) { RIP6_STATINC(RIP6_STAT_BADSUM); continue; @@ -470,7 +479,7 @@ rip6_output(struct mbuf *m, struct socke off = offsetof(struct icmp6_hdr, icmp6_cksum); else off = in6p_cksum(inp); - if (plen < off + 1) { + if (plen < 2 || plen - 2 < off) { error = EINVAL; goto bad; }
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Wed Mar 22 03:17:18 UTC 2023 Modified Files: src/sys/netinet6: raw_ip6.c Log Message: in6: make sure a user-specified checksum field is within a packet >From OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/sys/netinet6/raw_ip6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Mon Mar 20 09:15:52 UTC 2023 Modified Files: src/sys/netinet6: ip6_output.c Log Message: in6: reject setting negative values but -1 via setsockopt(IPV6_CHECKSUM) Same as OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.232 -r1.233 src/sys/netinet6/ip6_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/netinet6/ip6_output.c diff -u src/sys/netinet6/ip6_output.c:1.232 src/sys/netinet6/ip6_output.c:1.233 --- src/sys/netinet6/ip6_output.c:1.232 Fri Jan 27 09:33:43 2023 +++ src/sys/netinet6/ip6_output.c Mon Mar 20 09:15:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_output.c,v 1.232 2023/01/27 09:33:43 ozaki-r Exp $ */ +/* $NetBSD: ip6_output.c,v 1.233 2023/03/20 09:15:52 ozaki-r Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.232 2023/01/27 09:33:43 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.233 2023/03/20 09:15:52 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1984,8 +1984,12 @@ ip6_raw_ctloutput(int op, struct socket error = sockopt_getint(sopt, ); if (error) break; - if ((optval % 2) != 0) { -/* the API assumes even offset values */ + if (optval < -1 || + (optval > 0 && (optval % 2) != 0)) { +/* + * The API assumes non-negative even offset + * values or -1 as a special value. + */ error = EINVAL; } else if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Mon Mar 20 09:15:52 UTC 2023 Modified Files: src/sys/netinet6: ip6_output.c Log Message: in6: reject setting negative values but -1 via setsockopt(IPV6_CHECKSUM) Same as OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.232 -r1.233 src/sys/netinet6/ip6_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Jan 27 09:33:43 UTC 2023 Modified Files: src/sys/netinet6: ip6_output.c src/sys/netipsec: ipsec.c ipsec_input.c ipsec_output.c Log Message: ipsec: remove unnecessary splsoftnet Because the code of IPsec itself is already MP-safe. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/netinet6/ip6_output.c cvs rdiff -u -r1.177 -r1.178 src/sys/netipsec/ipsec.c cvs rdiff -u -r1.78 -r1.79 src/sys/netipsec/ipsec_input.c cvs rdiff -u -r1.85 -r1.86 src/sys/netipsec/ipsec_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Jan 27 09:33:43 UTC 2023 Modified Files: src/sys/netinet6: ip6_output.c src/sys/netipsec: ipsec.c ipsec_input.c ipsec_output.c Log Message: ipsec: remove unnecessary splsoftnet Because the code of IPsec itself is already MP-safe. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/netinet6/ip6_output.c cvs rdiff -u -r1.177 -r1.178 src/sys/netipsec/ipsec.c cvs rdiff -u -r1.78 -r1.79 src/sys/netipsec/ipsec_input.c cvs rdiff -u -r1.85 -r1.86 src/sys/netipsec/ipsec_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/netinet6/ip6_output.c diff -u src/sys/netinet6/ip6_output.c:1.231 src/sys/netinet6/ip6_output.c:1.232 --- src/sys/netinet6/ip6_output.c:1.231 Fri Oct 28 05:25:36 2022 +++ src/sys/netinet6/ip6_output.c Fri Jan 27 09:33:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ip6_output.c,v 1.231 2022/10/28 05:25:36 ozaki-r Exp $ */ +/* $NetBSD: ip6_output.c,v 1.232 2023/01/27 09:33:43 ozaki-r Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.231 2022/10/28 05:25:36 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.232 2023/01/27 09:33:43 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -484,9 +484,7 @@ ip6_output( #ifdef IPSEC if (needipsec) { - int s = splsoftnet(); error = ipsec6_process_packet(m, sp->req, flags); - splx(s); /* * Preserve KAME behaviour: ENOENT can be returned Index: src/sys/netipsec/ipsec.c diff -u src/sys/netipsec/ipsec.c:1.177 src/sys/netipsec/ipsec.c:1.178 --- src/sys/netipsec/ipsec.c:1.177 Thu Dec 8 08:07:07 2022 +++ src/sys/netipsec/ipsec.c Fri Jan 27 09:33:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ipsec.c,v 1.177 2022/12/08 08:07:07 knakahara Exp $ */ +/* $NetBSD: ipsec.c,v 1.178 2023/01/27 09:33:43 ozaki-r Exp $ */ /* $FreeBSD: ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */ /* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */ @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.177 2022/12/08 08:07:07 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.178 2023/01/27 09:33:43 ozaki-r Exp $"); /* * IPsec controller part. @@ -619,7 +619,7 @@ ipsec4_output(struct mbuf *m, struct inp { struct secpolicy *sp = NULL; u_long _mtu = 0; - int error, s; + int error; /* * Check the security policy (SP) for the packet and, if required, @@ -632,9 +632,7 @@ ipsec4_output(struct mbuf *m, struct inp if (ipsec_outdone(m)) { return 0; } - s = splsoftnet(); if (inp && ipsec_pcb_skip_ipsec(inp->inp_sp, IPSEC_DIR_OUTBOUND)) { - splx(s); return 0; } sp = ipsec_checkpolicy(m, IPSEC_DIR_OUTBOUND, flags, , inp); @@ -647,7 +645,6 @@ ipsec4_output(struct mbuf *m, struct inp * sp == NULL, error != 0discard packet, report error */ if (sp == NULL) { - splx(s); if (error) { /* * Hack: -EINVAL is used to signal that a packet @@ -684,7 +681,6 @@ ipsec4_output(struct mbuf *m, struct inp *mtu = _mtu; *natt_frag = true; KEY_SP_UNREF(); - splx(s); return 0; } @@ -698,7 +694,6 @@ ipsec4_output(struct mbuf *m, struct inp if (error == ENOENT) error = 0; KEY_SP_UNREF(); - splx(s); *done = true; return error; } @@ -707,11 +702,9 @@ int ipsec_ip_input_checkpolicy(struct mbuf *m, bool forward) { struct secpolicy *sp; - int error, s; + int error; - s = splsoftnet(); error = ipsec_in_reject(m, NULL); - splx(s); if (error) { return EINVAL; } @@ -724,14 +717,12 @@ ipsec_ip_input_checkpolicy(struct mbuf * * Peek at the outbound SP for this packet to determine if * it is a Fast Forward candidate. */ - s = splsoftnet(); sp = ipsec_checkpolicy(m, IPSEC_DIR_OUTBOUND, IP_FORWARDING, , NULL); if (sp != NULL) { m->m_flags &= ~M_CANFASTFWD; KEY_SP_UNREF(); } - splx(s); return 0; } @@ -1801,20 +1792,16 @@ ipsec6_check_policy(struct mbuf *m, stru int *needipsecp, int *errorp) { struct secpolicy *sp = NULL; - int s; int error = 0; int needipsec = 0; if (ipsec_outdone(m)) { goto skippolicycheck; } - s = splsoftnet(); if (inp && ipsec_pcb_skip_ipsec(inp->inp_sp, IPSEC_DIR_OUTBOUND)) { - splx(s); goto skippolicycheck; } sp = ipsec_checkpolicy(m, IPSEC_DIR_OUTBOUND, flags, , inp); - splx(s); /* * There are four return cases: Index: src/sys/netipsec/ipsec_input.c diff -u src/sys/netipsec/ipsec_input.c:1.78 src/sys/netipsec/ipsec_input.c:1.79 --- src/sys/netipsec/ipsec_input.c:1.78 Tue Aug 23 09:25:10 2022 +++ src/sys/netipsec/ipsec_input.c Fri Jan 27 09:33:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ipsec_input.c,v 1.78 2022/08/23 09:25:10 knakahara Exp $ */ +/* $NetBSD: ipsec_input.c,v 1.79 2023/01/27 09:33:43 ozaki-r Exp $ */ /* $FreeBSD: ipsec_input.c,v 1.2.4.2 2003/03/28
CVS commit: src/sys/kern
Module Name:src Committed By: ozaki-r Date: Fri Jan 27 09:28:41 UTC 2023 Modified Files: src/sys/kern: kern_lock.c kern_mutex.c kern_rwlock.c Log Message: Sprinkle __predict_{true,false} for panicstr checks To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/sys/kern/kern_lock.c cvs rdiff -u -r1.101 -r1.102 src/sys/kern/kern_mutex.c cvs rdiff -u -r1.66 -r1.67 src/sys/kern/kern_rwlock.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/kern/kern_lock.c diff -u src/sys/kern/kern_lock.c:1.181 src/sys/kern/kern_lock.c:1.182 --- src/sys/kern/kern_lock.c:1.181 Wed Oct 26 23:28:18 2022 +++ src/sys/kern/kern_lock.c Fri Jan 27 09:28:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lock.c,v 1.181 2022/10/26 23:28:18 riastradh Exp $ */ +/* $NetBSD: kern_lock.c,v 1.182 2023/01/27 09:28:41 ozaki-r Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.181 2022/10/26 23:28:18 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.182 2023/01/27 09:28:41 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_lockdebug.h" @@ -71,7 +71,7 @@ assert_sleepable(void) uint64_t pctr; bool idle; - if (panicstr != NULL) { + if (__predict_false(panicstr != NULL)) { return; } Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.101 src/sys/kern/kern_mutex.c:1.102 --- src/sys/kern/kern_mutex.c:1.101 Mon Dec 5 07:09:04 2022 +++ src/sys/kern/kern_mutex.c Fri Jan 27 09:28:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.101 2022/12/05 07:09:04 skrll Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.102 2023/01/27 09:28:41 ozaki-r Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.101 2022/12/05 07:09:04 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.102 2023/01/27 09:28:41 ozaki-r Exp $"); #include #include @@ -516,7 +516,7 @@ mutex_vector_enter(kmutex_t *mtx) MUTEX_ASSERT(mtx, !cpu_intr_p()); MUTEX_WANTLOCK(mtx); - if (panicstr == NULL) { + if (__predict_true(panicstr == NULL)) { KDASSERT(pserialize_not_in_read_section()); LOCKDEBUG_BARRIER(_lock, 1); } Index: src/sys/kern/kern_rwlock.c diff -u src/sys/kern/kern_rwlock.c:1.66 src/sys/kern/kern_rwlock.c:1.67 --- src/sys/kern/kern_rwlock.c:1.66 Sat Apr 9 23:46:19 2022 +++ src/sys/kern/kern_rwlock.c Fri Jan 27 09:28:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_rwlock.c,v 1.66 2022/04/09 23:46:19 riastradh Exp $ */ +/* $NetBSD: kern_rwlock.c,v 1.67 2023/01/27 09:28:41 ozaki-r Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019, 2020 @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.66 2022/04/09 23:46:19 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.67 2023/01/27 09:28:41 ozaki-r Exp $"); #include "opt_lockdebug.h" @@ -197,7 +197,7 @@ static void __noinline rw_abort(const char *func, size_t line, krwlock_t *rw, const char *msg) { - if (panicstr != NULL) + if (__predict_false(panicstr != NULL)) return; LOCKDEBUG_ABORT(func, line, rw, _lockops, msg); @@ -304,7 +304,7 @@ rw_vector_enter(krwlock_t *rw, const krw RW_ASSERT(rw, curthread != 0); RW_WANTLOCK(rw, op); - if (panicstr == NULL) { + if (__predict_true(panicstr == NULL)) { KDASSERT(pserialize_not_in_read_section()); LOCKDEBUG_BARRIER(_lock, 1); }
CVS commit: src/sys/kern
Module Name:src Committed By: ozaki-r Date: Fri Jan 27 09:28:41 UTC 2023 Modified Files: src/sys/kern: kern_lock.c kern_mutex.c kern_rwlock.c Log Message: Sprinkle __predict_{true,false} for panicstr checks To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/sys/kern/kern_lock.c cvs rdiff -u -r1.101 -r1.102 src/sys/kern/kern_mutex.c cvs rdiff -u -r1.66 -r1.67 src/sys/kern/kern_rwlock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Fri Jan 6 01:54:23 UTC 2023 Modified Files: src/sys/net: if_tap.c Log Message: tap: link up an interface cloned from /dev/tap Fix PR 57155 (partially) To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/net/if_tap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Fri Jan 6 01:54:23 UTC 2023 Modified Files: src/sys/net: if_tap.c Log Message: tap: link up an interface cloned from /dev/tap Fix PR 57155 (partially) To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/net/if_tap.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/net/if_tap.c diff -u src/sys/net/if_tap.c:1.127 src/sys/net/if_tap.c:1.128 --- src/sys/net/if_tap.c:1.127 Sun Apr 10 09:50:46 2022 +++ src/sys/net/if_tap.c Fri Jan 6 01:54:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.127 2022/04/10 09:50:46 andvar Exp $ */ +/* $NetBSD: if_tap.c,v 1.128 2023/01/06 01:54:22 ozaki-r Exp $ */ /* * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.127 2022/04/10 09:50:46 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.128 2023/01/06 01:54:22 ozaki-r Exp $"); #if defined(_KERNEL_OPT) @@ -735,6 +735,7 @@ tap_dev_cloner(struct lwp *l) } sc->sc_flags |= TAP_INUSE; + if_link_state_change(>sc_ec.ec_if, LINK_STATE_UP); return fd_clone(fp, fd, FREAD | FWRITE, _fileops, (void *)(intptr_t)device_unit(sc->sc_dev));
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Thu Dec 1 04:24:38 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi src/tests/net/net: Makefile Log Message: tests: fix Makefile and lists for MKRUMP=no Pointed out by Michael Scholz, thanks. To generate a diff of this commit: cvs rdiff -u -r1.1237 -r1.1238 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.28 -r1.29 src/tests/net/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1237 src/distrib/sets/lists/tests/mi:1.1238 --- src/distrib/sets/lists/tests/mi:1.1237 Wed Nov 30 06:07:51 2022 +++ src/distrib/sets/lists/tests/mi Thu Dec 1 04:24:37 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1237 2022/11/30 06:07:51 ozaki-r Exp $ +# $NetBSD: mi,v 1.1238 2022/12/01 04:24:37 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4285,7 +4285,7 @@ ./usr/tests/net/net/t_pktinfotests-net-tests compattestfile,atf ./usr/tests/net/net/t_pktinfo_send tests-net-tests atf,rump ./usr/tests/net/net/t_rawtests-net-tests atf,rump -./usr/tests/net/net/t_socket_afinet tests-net-tests compattestfile,atf +./usr/tests/net/net/t_socket_afinet tests-net-tests compattestfile,atf,rump ./usr/tests/net/net/t_tcptests-net-tests compattestfile,atf ./usr/tests/net/net/t_udptests-net-tests compattestfile,atf ./usr/tests/net/net/t_unixtests-net-tests compattestfile,atf Index: src/tests/net/net/Makefile diff -u src/tests/net/net/Makefile:1.28 src/tests/net/net/Makefile:1.29 --- src/tests/net/net/Makefile:1.28 Wed Nov 30 07:48:43 2022 +++ src/tests/net/net/Makefile Thu Dec 1 04:24:37 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.28 2022/11/30 07:48:43 ozaki-r Exp $ +# $NetBSD: Makefile,v 1.29 2022/12/01 04:24:37 ozaki-r Exp $ # .include @@ -11,9 +11,9 @@ TESTS_C+= t_mapped TESTS_C+= t_tcp TESTS_C+= t_udp TESTS_C+= t_pktinfo +.if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE) TESTS_C+= t_socket_afinet TESTS_C+= t_ip_reass -.if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE) TESTS_C+= t_pktinfo_send TESTS_C+= t_raw
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Thu Dec 1 04:24:38 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi src/tests/net/net: Makefile Log Message: tests: fix Makefile and lists for MKRUMP=no Pointed out by Michael Scholz, thanks. To generate a diff of this commit: cvs rdiff -u -r1.1237 -r1.1238 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.28 -r1.29 src/tests/net/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 07:48:43 UTC 2022 Modified Files: src/tests/net/net: Makefile Log Message: tests: restore a line removed accidentally To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/net/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/net/Makefile diff -u src/tests/net/net/Makefile:1.27 src/tests/net/net/Makefile:1.28 --- src/tests/net/net/Makefile:1.27 Wed Nov 30 06:07:51 2022 +++ src/tests/net/net/Makefile Wed Nov 30 07:48:43 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.27 2022/11/30 06:07:51 ozaki-r Exp $ +# $NetBSD: Makefile,v 1.28 2022/11/30 07:48:43 ozaki-r Exp $ # .include @@ -11,6 +11,7 @@ TESTS_C+= t_mapped TESTS_C+= t_tcp TESTS_C+= t_udp TESTS_C+= t_pktinfo +TESTS_C+= t_socket_afinet TESTS_C+= t_ip_reass .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE) TESTS_C+= t_pktinfo_send
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 07:48:43 UTC 2022 Modified Files: src/tests/net/net: Makefile Log Message: tests: restore a line removed accidentally To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/net/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:07:52 UTC 2022 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/tests/net/net: Makefile Log Message: tests: build and install t_ip_reass.c To generate a diff of this commit: cvs rdiff -u -r1.393 -r1.394 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1236 -r1.1237 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.26 -r1.27 src/tests/net/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.393 src/distrib/sets/lists/debug/mi:1.394 --- src/distrib/sets/lists/debug/mi:1.393 Tue Nov 22 17:35:45 2022 +++ src/distrib/sets/lists/debug/mi Wed Nov 30 06:07:51 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.393 2022/11/22 17:35:45 jakllsch Exp $ +# $NetBSD: mi,v 1.394 2022/11/30 06:07:51 ozaki-r Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib comp-sys-usr compatdir ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile @@ -2429,6 +2429,7 @@ ./usr/libdata/debug/usr/tests/net/mcast/mcast.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/mcast/t_mcast.debug tests-obsolete debug,atf,rump,obsolete ./usr/libdata/debug/usr/tests/net/net/t_bind.debug tests-net-debug debug,atf,compattestfile +./usr/libdata/debug/usr/tests/net/net/t_ip_reass.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/net/t_mapped.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/net/t_pktinfo.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/net/t_pktinfo_send.debug tests-net-debug debug,atf,rump Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1236 src/distrib/sets/lists/tests/mi:1.1237 --- src/distrib/sets/lists/tests/mi:1.1236 Fri Nov 25 08:43:15 2022 +++ src/distrib/sets/lists/tests/mi Wed Nov 30 06:07:51 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1236 2022/11/25 08:43:15 knakahara Exp $ +# $NetBSD: mi,v 1.1237 2022/11/30 06:07:51 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4276,6 +4276,7 @@ ./usr/tests/net/net/t_ipaddresstests-net-tests atf,rump ./usr/tests/net/net/t_ipv6_lifetime tests-net-tests atf,rump ./usr/tests/net/net/t_ipv6address tests-net-tests atf,rump +./usr/tests/net/net/t_ip_reasstests-net-tests atf,rump ./usr/tests/net/net/t_mappedtests-net-tests atf ./usr/tests/net/net/t_mtudisctests-net-tests atf,rump ./usr/tests/net/net/t_mtudisc6tests-net-tests atf,rump Index: src/tests/net/net/Makefile diff -u src/tests/net/net/Makefile:1.26 src/tests/net/net/Makefile:1.27 --- src/tests/net/net/Makefile:1.26 Thu Nov 17 08:45:36 2022 +++ src/tests/net/net/Makefile Wed Nov 30 06:07:51 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.26 2022/11/17 08:45:36 ozaki-r Exp $ +# $NetBSD: Makefile,v 1.27 2022/11/30 06:07:51 ozaki-r Exp $ # .include @@ -11,7 +11,7 @@ TESTS_C+= t_mapped TESTS_C+= t_tcp TESTS_C+= t_udp TESTS_C+= t_pktinfo -TESTS_C+= t_socket_afinet +TESTS_C+= t_ip_reass .if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE) TESTS_C+= t_pktinfo_send TESTS_C+= t_raw @@ -23,6 +23,10 @@ TESTS_SH_SRC_t_${name}= ../net_common.sh .endfor .endif +.PATH:${.CURDIR}/../../../lib/libc/gen +CPPFLAGS.sysctlbyname.c+= -DRUMP_ACTION +OBJS.t_ip_reass+= sysctlbyname.o + LDADD.t_pktinfo_send+= -lrumpnet_local -lrumpnet_netinet -lrumpnet_net LDADD.t_pktinfo_send+= -lrumpnet_shmif -lrumpnet LDADD.t_pktinfo_send+= ${LIBRUMPBASE} @@ -30,6 +34,8 @@ LDADD.t_raw+= -lrumpnet_local -lrumpnet_ LDADD.t_raw+= -lrumpnet ${LIBRUMPBASE} LDADD.t_socket_afinet+= -lrumpdev_bpf -lrumpdev -lrumpnet_netinet -lrumpnet_net LDADD.t_socket_afinet+= -lrumpnet_local -lrumpnet ${LIBRUMPBASE} +LDADD.t_ip_reass+= -lrumpdev_bpf -lrumpdev -lrumpnet_netinet -lrumpnet_net +LDADD.t_ip_reass+= -lrumpnet_local -lrumpnet ${LIBRUMPBASE} LDADD.t_mapped+= -lutil
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:07:52 UTC 2022 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/tests/net/net: Makefile Log Message: tests: build and install t_ip_reass.c To generate a diff of this commit: cvs rdiff -u -r1.393 -r1.394 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1236 -r1.1237 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.26 -r1.27 src/tests/net/net/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:06:36 UTC 2022 Modified Files: src/tests/net/net: t_ip_reass.c Log Message: tests: tweak t_ip_reass.c for NetBSD The test is modified to run on rump kernels. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/net/t_ip_reass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/net/t_ip_reass.c diff -u src/tests/net/net/t_ip_reass.c:1.1 src/tests/net/net/t_ip_reass.c:1.2 --- src/tests/net/net/t_ip_reass.c:1.1 Wed Nov 30 06:05:58 2022 +++ src/tests/net/net/t_ip_reass.c Wed Nov 30 06:06:36 2022 @@ -1,3 +1,5 @@ +/* $NetBSD: t_ip_reass.c,v 1.2 2022/11/30 06:06:36 ozaki-r Exp $ */ + /*- * Copyright (c) 2018 The FreeBSD Foundation * @@ -28,7 +30,13 @@ */ #include + +#ifdef __NetBSD__ +__RCSID("$NetBSD: t_ip_reass.c,v 1.2 2022/11/30 06:06:36 ozaki-r Exp $"); +#define USE_RUMPKERNEL 1 +#else __FBSDID("$FreeBSD$"); +#endif #include #include @@ -50,8 +58,25 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef USE_RUMPKERNEL +#include +#include +#include +#include "h_macros.h" + +#define ioctl rump_sys_ioctl +#define close rump_sys_close +#define write rump_sys_write +#endif + #include +#ifdef __NetBSD__ +struct ipstat { + uint64_t ips_ipstat[IP_NSTATS]; +}; +#endif + struct lopacket { u_int family; struct ip hdr; @@ -141,10 +166,15 @@ open_lobpf(in_addr_t *addrp) struct ifaddrs *ifa, *ifap; int error, fd; +#ifdef USE_RUMPKERNEL + rump_init(); + RL(fd = rump_sys_open("/dev/bpf", O_RDWR)); +#else fd = open("/dev/bpf0", O_RDWR); if (fd < 0 && errno == ENOENT) atf_tc_skip("no BPF device available"); ATF_REQUIRE_MSG(fd >= 0, "open(/dev/bpf0): %s", strerror(errno)); +#endif error = getifaddrs(); ATF_REQUIRE(error == 0); @@ -181,10 +211,21 @@ get_ipstat(struct ipstat *stat) ATF_REQUIRE(len == sizeof(*stat)); } +#ifdef __NetBSD__ #define CHECK_IP_COUNTER(oldp, newp, counter)\ - ATF_REQUIRE_MSG((oldp)->ips_ ## counter < (newp)->ips_ ## counter, \ + ATF_REQUIRE_MSG((oldp)->ips_ipstat[counter] < (newp)->ips_ipstat[counter], \ "ips_" #counter " wasn't incremented (%ju vs. %ju)", \ + (uintmax_t)old.ips_ipstat[counter], (uintmax_t)new.ips_ipstat[counter]); +#define fragdropped IP_STAT_FRAGDROPPED +#define toosmall IP_STAT_TOOSMALL +#define toolong IP_STAT_TOOLONG +#define badfrags IP_STAT_BADFRAGS +#else +#define CHECK_IP_COUNTER(oldp, newp, counter)\ + ATF_REQUIRE_MSG((oldp)->ips_ ## counter < (newp)->ips_ ## counter, \ + #counter " wasn't incremented (%ju vs. %ju)", \ (uintmax_t)old.ips_ ## counter, (uintmax_t)new.ips_## counter); +#endif /* * Make sure a fragment with MF set doesn't come after the last fragment of a @@ -306,14 +347,21 @@ ATF_TC_BODY(ip_reass__zero_length_fragme get_ipstat(); write_lopacket(fd, packet1); get_ipstat(); +#ifdef __NetBSD__ + CHECK_IP_COUNTER(, , badfrags); +#else CHECK_IP_COUNTER(, , toosmall); CHECK_IP_COUNTER(, , fragdropped); +#endif get_ipstat(); write_lopacket(fd, packet2); get_ipstat(); + /* NetBSD doesn't reject a packet of zero length w/o MF */ +#ifndef __NetBSD__ CHECK_IP_COUNTER(, , toosmall); CHECK_IP_COUNTER(, , fragdropped); +#endif error = close(fd); ATF_REQUIRE(error == 0); @@ -359,13 +407,17 @@ ATF_TC_BODY(ip_reass__large_fragment, tc write_lopacket(fd, packet1); get_ipstat(); CHECK_IP_COUNTER(, , toolong); +#ifndef __NetBSD__ CHECK_IP_COUNTER(, , fragdropped); +#endif get_ipstat(); write_lopacket(fd, packet2); get_ipstat(); CHECK_IP_COUNTER(, , toolong); +#ifndef __NetBSD__ CHECK_IP_COUNTER(, , fragdropped); +#endif error = close(fd); ATF_REQUIRE(error == 0);
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:06:36 UTC 2022 Modified Files: src/tests/net/net: t_ip_reass.c Log Message: tests: tweak t_ip_reass.c for NetBSD The test is modified to run on rump kernels. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/net/t_ip_reass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:05:58 UTC 2022 Added Files: src/tests/net/net: t_ip_reass.c Log Message: tests: import ip_reass_test.c from FreeBSD as t_ip_reass.c As of: commit 9ed1e4ecd4e9eb3bde16f52a937a6fa86a971638 Author: Mark Johnston Date: Tue Nov 20 18:13:18 2018 + Plug a trivial memory leak. CID:1396911 MFC with: r340485 To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/net/t_ip_reass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/net/t_ip_reass.c diff -u /dev/null src/tests/net/net/t_ip_reass.c:1.1 --- /dev/null Wed Nov 30 06:05:58 2022 +++ src/tests/net/net/t_ip_reass.c Wed Nov 30 06:05:58 2022 @@ -0,0 +1,383 @@ +/*- + * Copyright (c) 2018 The FreeBSD Foundation + * + * This software was developed by Mark Johnston under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in + *the documentation and/or other materials provided with the + *distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct lopacket { + u_int family; + struct ip hdr; + char payload[]; +}; + +static void +update_cksum(struct ip *ip) +{ + size_t i; + uint32_t cksum; + uint16_t *cksump; + + ip->ip_sum = 0; + cksump = (uint16_t *)ip; + for (cksum = 0, i = 0; i < sizeof(*ip) / sizeof(*cksump); cksump++, i++) + cksum += ntohs(*cksump); + cksum = (cksum >> 16) + (cksum & 0x); + cksum = ~(cksum + (cksum >> 16)); + ip->ip_sum = htons((uint16_t)cksum); +} + +static struct lopacket * +alloc_lopacket(in_addr_t dstaddr, size_t payloadlen) +{ + struct ip *ip; + struct lopacket *packet; + size_t pktlen; + + pktlen = sizeof(*packet) + payloadlen; + packet = malloc(pktlen); + ATF_REQUIRE(packet != NULL); + + memset(packet, 0, pktlen); + packet->family = AF_INET; + + ip = >hdr; + ip->ip_hl = sizeof(struct ip) >> 2; + ip->ip_v = 4; + ip->ip_tos = 0; + ip->ip_len = htons(sizeof(*ip) + payloadlen); + ip->ip_id = 0; + ip->ip_off = 0; + ip->ip_ttl = 1; + ip->ip_p = IPPROTO_IP; + ip->ip_sum = 0; + ip->ip_src.s_addr = dstaddr; + ip->ip_dst.s_addr = dstaddr; + update_cksum(ip); + + return (packet); +} + +static void +free_lopacket(struct lopacket *packet) +{ + + free(packet); +} + +static void +write_lopacket(int bpffd, struct lopacket *packet) +{ + struct timespec ts; + ssize_t n; + size_t len; + + len = sizeof(packet->family) + ntohs(packet->hdr.ip_len); + n = write(bpffd, packet, len); + ATF_REQUIRE_MSG(n >= 0, "packet write failed: %s", strerror(errno)); + ATF_REQUIRE_MSG((size_t)n == len, "wrote %zd bytes instead of %zu", + n, len); + + /* + * Loopback packets are dispatched asynchronously, give netisr some + * time. + */ + ts.tv_sec = 0; + ts.tv_nsec = 500; /* 5ms */ + (void)nanosleep(, NULL); +} + +static int +open_lobpf(in_addr_t *addrp) +{ + struct ifreq ifr; + struct ifaddrs *ifa, *ifap; + int error, fd; + + fd = open("/dev/bpf0", O_RDWR); + if (fd < 0 && errno == ENOENT) + atf_tc_skip("no BPF device available"); + ATF_REQUIRE_MSG(fd >= 0, "open(/dev/bpf0): %s", strerror(errno)); + + error = getifaddrs(); + ATF_REQUIRE(error == 0); + for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) + if ((ifa->ifa_flags & IFF_LOOPBACK) != 0 && + ifa->ifa_addr->sa_family == AF_INET) + break; + if (ifa == NULL) + atf_tc_skip("no loopback address found"); + + memset(, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ); + error = ioctl(fd,
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:05:58 UTC 2022 Added Files: src/tests/net/net: t_ip_reass.c Log Message: tests: import ip_reass_test.c from FreeBSD as t_ip_reass.c As of: commit 9ed1e4ecd4e9eb3bde16f52a937a6fa86a971638 Author: Mark Johnston Date: Tue Nov 20 18:13:18 2018 + Plug a trivial memory leak. CID:1396911 MFC with: r340485 To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/net/t_ip_reass.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man4
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:03:41 UTC 2022 Modified Files: src/share/man/man4: bpf.4 Log Message: man, bpf: support loopback interfaces for send To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/share/man/man4/bpf.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man4
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:03:41 UTC 2022 Modified Files: src/share/man/man4: bpf.4 Log Message: man, bpf: support loopback interfaces for send To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/share/man/man4/bpf.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/bpf.4 diff -u src/share/man/man4/bpf.4:1.64 src/share/man/man4/bpf.4:1.65 --- src/share/man/man4/bpf.4:1.64 Sun Oct 24 17:46:06 2021 +++ src/share/man/man4/bpf.4 Wed Nov 30 06:03:41 2022 @@ -1,6 +1,6 @@ .\" -*- nroff -*- .\" -.\" $NetBSD: bpf.4,v 1.64 2021/10/24 17:46:06 gutteridge Exp $ +.\" $NetBSD: bpf.4,v 1.65 2022/11/30 06:03:41 ozaki-r Exp $ .\" .\" Copyright (c) 1990, 1991, 1992, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -24,7 +24,7 @@ .\" This document is derived in part from the enet man page (enet.4) .\" distributed with 4.3BSD Unix. .\" -.Dd October 24, 2021 +.Dd November 30, 2022 .Dt BPF 4 .Os .Sh NAME @@ -75,7 +75,7 @@ A packet can be sent out on the network .Nm file descriptor. The writes are unbuffered, meaning only one packet can be processed per write. -Currently, only writes to Ethernet-based (including Wi-Fi) and SLIP +Currently, only writes to Ethernet-based (including Wi-Fi), SLIP and loopback links are supported. .Sh IOCTLS The
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:02:37 UTC 2022 Modified Files: src/sys/net: bpf.c Log Message: bpf: support sending packets on loopback interfaces Previously sending packets on a loopback interface via bpf failed because the packets are treated as AF_UNSPEC by bpf and the loopback interface couldn't handle such packets. This fix enables user programs to prepend a protocol family (AF_INET or AF_INET6) to a payload. bpf interprets it and treats a packet as so, not just AF_UNSPEC. The protocol family is encoded as 4 bytes, host byte order as per DLT_NULL in the specification(*). (*) https://www.tcpdump.org/linktypes.html Proposed on tech-net and tech-kern To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/net/bpf.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/net/bpf.c diff -u src/sys/net/bpf.c:1.248 src/sys/net/bpf.c:1.249 --- src/sys/net/bpf.c:1.248 Sat Nov 19 08:53:06 2022 +++ src/sys/net/bpf.c Wed Nov 30 06:02:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.248 2022/11/19 08:53:06 yamt Exp $ */ +/* $NetBSD: bpf.c,v 1.249 2022/11/30 06:02:37 ozaki-r Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.248 2022/11/19 08:53:06 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.249 2022/11/30 06:02:37 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_bpf.h" @@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.24 #include #include +#include #include #include @@ -244,7 +245,7 @@ static void bpf_freed(struct bpf_d *); static void bpf_free_filter(struct bpf_filter *); static void bpf_ifname(struct ifnet *, struct ifreq *); static void *bpf_mcpy(void *, const void *, size_t); -static int bpf_movein(struct uio *, int, uint64_t, +static int bpf_movein(struct ifnet *, struct uio *, int, uint64_t, struct mbuf **, struct sockaddr *, struct bpf_filter **); static void bpf_attachd(struct bpf_d *, struct bpf_if *); @@ -323,7 +324,7 @@ bpf_jit_freecode(bpfjit_func_t jcode) } static int -bpf_movein(struct uio *uio, int linktype, uint64_t mtu, struct mbuf **mp, +bpf_movein(struct ifnet *ifp, struct uio *uio, int linktype, uint64_t mtu, struct mbuf **mp, struct sockaddr *sockp, struct bpf_filter **wfilter) { struct mbuf *m, *m0, *n; @@ -385,7 +386,11 @@ bpf_movein(struct uio *uio, int linktype case DLT_NULL: sockp->sa_family = AF_UNSPEC; - hlen = 0; + if (ifp->if_type == IFT_LOOP) { + /* Set here to apply the following validations */ + hlen = sizeof(uint32_t); + } else + hlen = 0; align = 0; break; @@ -441,8 +446,15 @@ bpf_movein(struct uio *uio, int linktype } if (hlen != 0) { - /* move link level header in the top of mbuf to sa_data */ - memcpy(sockp->sa_data, mtod(m0, void *), hlen); + if (linktype == DLT_NULL && ifp->if_type == IFT_LOOP) { + uint32_t af; + /* the link header indicates the address family */ + memcpy(, mtod(m0, void *), sizeof(af)); + sockp->sa_family = af; + } else { + /* move link level header in the top of mbuf to sa_data */ + memcpy(sockp->sa_data, mtod(m0, void *), hlen); + } m0->m_data += hlen; m0->m_len -= hlen; } @@ -853,7 +865,7 @@ bpf_write(struct file *fp, off_t *offp, goto out; } - error = bpf_movein(uio, (int)bp->bif_dlt, ifp->if_mtu, , + error = bpf_movein(ifp, uio, (int)bp->bif_dlt, ifp->if_mtu, , (struct sockaddr *) , >bd_wfilter); if (error) goto out;
CVS commit: src/sys/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 30 06:02:37 UTC 2022 Modified Files: src/sys/net: bpf.c Log Message: bpf: support sending packets on loopback interfaces Previously sending packets on a loopback interface via bpf failed because the packets are treated as AF_UNSPEC by bpf and the loopback interface couldn't handle such packets. This fix enables user programs to prepend a protocol family (AF_INET or AF_INET6) to a payload. bpf interprets it and treats a packet as so, not just AF_UNSPEC. The protocol family is encoded as 4 bytes, host byte order as per DLT_NULL in the specification(*). (*) https://www.tcpdump.org/linktypes.html Proposed on tech-net and tech-kern To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/net/bpf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 09:58:42 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi Log Message: distrib: add missing ./usr/libdata/debug/usr/tests/net/inpcb To generate a diff of this commit: cvs rdiff -u -r1.1232 -r1.1233 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1232 src/distrib/sets/lists/tests/mi:1.1233 --- src/distrib/sets/lists/tests/mi:1.1232 Thu Nov 17 08:45:35 2022 +++ src/distrib/sets/lists/tests/mi Thu Nov 17 09:58:42 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1232 2022/11/17 08:45:35 ozaki-r Exp $ +# $NetBSD: mi,v 1.1233 2022/11/17 09:58:42 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -173,6 +173,7 @@ ./usr/libdata/debug/usr/tests/net/if_tap tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/if_vether tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/if_vlan tests-net-debug compattestfile,atf +./usr/libdata/debug/usr/tests/net/inpcb tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/in_cksum tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/ipsec tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/mcast tests-net-debug compattestfile,atf
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 09:58:42 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi Log Message: distrib: add missing ./usr/libdata/debug/usr/tests/net/inpcb To generate a diff of this commit: cvs rdiff -u -r1.1232 -r1.1233 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:45:36 UTC 2022 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net: Makefile src/tests/net/net: Makefile src/tests/net/tcp: Makefile Added Files: src/tests/net/inpcb: Makefile Log Message: tests: build and install added test files To generate a diff of this commit: cvs rdiff -u -r1.390 -r1.391 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1231 -r1.1232 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.195 -r1.196 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.40 -r1.41 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/Makefile cvs rdiff -u -r1.25 -r1.26 src/tests/net/net/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/net/tcp/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.390 src/distrib/sets/lists/debug/mi:1.391 --- src/distrib/sets/lists/debug/mi:1.390 Fri Nov 4 08:01:42 2022 +++ src/distrib/sets/lists/debug/mi Thu Nov 17 08:45:35 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.390 2022/11/04 08:01:42 ozaki-r Exp $ +# $NetBSD: mi,v 1.391 2022/11/17 08:45:35 ozaki-r Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib comp-sys-usr compatdir ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile @@ -2421,6 +2421,8 @@ ./usr/libdata/debug/usr/tests/net/if_tap/rump_open_tap.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/if_vlan/bpfopen.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/if_vlan/siocXmulti.debug tests-net-debug debug,atf,rump +./usr/libdata/debug/usr/tests/net/inpcb/broadcast_bind.debug tests-net-debug debug,atf,compattestfile +./usr/libdata/debug/usr/tests/net/inpcb/inpcb_bind.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/in_cksum/in_cksum.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/ipsec/natt_terminator.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/mcast/mcast.debug tests-net-debug debug,atf,rump @@ -2430,6 +2432,7 @@ ./usr/libdata/debug/usr/tests/net/net/t_pktinfo.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/net/t_pktinfo_send.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/net/t_raw.debug tests-net-debug debug,atf,rump +./usr/libdata/debug/usr/tests/net/net/t_socket_afinet.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/net/t_tcp.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/net/t_udp.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/net/t_unix.debug tests-net-debug debug,atf,compattestfile @@ -2438,6 +2441,7 @@ ./usr/libdata/debug/usr/tests/net/sys/t_rfc6056.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/sys/t_socketpair.debug tests-obsolete obsolete,compattestfile ./usr/libdata/debug/usr/tests/net/tcp/tcp_shutdown.debug tests-net-debug debug,atf,rump +./usr/libdata/debug/usr/tests/net/tcp/t_tcp_connect_port.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/rump/modautoload/t_modautoload.debug tests-syscall-debug debug,atf,rump ./usr/libdata/debug/usr/tests/rump/rumpkern/h_client/h_forkcli.debug tests-syscall-debug debug,atf,rump ./usr/libdata/debug/usr/tests/rump/rumpkern/h_client/h_reboot.debug tests-obsolete obsolete Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1231 src/distrib/sets/lists/tests/mi:1.1232 --- src/distrib/sets/lists/tests/mi:1.1231 Thu Nov 17 06:40:38 2022 +++ src/distrib/sets/lists/tests/mi Thu Nov 17 08:45:35 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1231 2022/11/17 06:40:38 chs Exp $ +# $NetBSD: mi,v 1.1232 2022/11/17 08:45:35 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4204,6 +4204,13 @@ ./usr/tests/net/if_wg/t_interoperability tests-net-tests atf,rump ./usr/tests/net/if_wg/t_misctests-net-tests atf,rump ./usr/tests/net/if_wg/t_tunneltests-net-tests atf,rump +./usr/tests/net/inpcb tests-net-tests compattestfile,atf +./usr/tests/net/inpcb/Atffiletests-net-tests atf,rump +./usr/tests/net/inpcb/Kyuafiletests-net-tests atf,rump,kyua +./usr/tests/net/inpcb/broadcast_bind tests-net-tests atf,rump +./usr/tests/net/inpcb/inpcb_bind tests-net-tests atf,rump +./usr/tests/net/inpcb/t_broadcast_bind tests-net-tests atf,rump +./usr/tests/net/inpcb/t_inpcb_bind tests-net-tests atf,rump ./usr/tests/net/in_cksumtests-net-tests compattestfile,atf ./usr/tests/net/in_cksum/Atffile tests-net-tests compattestfile,atf
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:45:36 UTC 2022 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net: Makefile src/tests/net/net: Makefile src/tests/net/tcp: Makefile Added Files: src/tests/net/inpcb: Makefile Log Message: tests: build and install added test files To generate a diff of this commit: cvs rdiff -u -r1.390 -r1.391 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1231 -r1.1232 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.195 -r1.196 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.40 -r1.41 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/Makefile cvs rdiff -u -r1.25 -r1.26 src/tests/net/net/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/net/tcp/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:42:56 UTC 2022 Added Files: src/tests/net/inpcb: t_broadcast_bind.sh Log Message: tests: add t_broadcast_bind.sh To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/t_broadcast_bind.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/inpcb/t_broadcast_bind.sh diff -u /dev/null src/tests/net/inpcb/t_broadcast_bind.sh:1.1 --- /dev/null Thu Nov 17 08:42:56 2022 +++ src/tests/net/inpcb/t_broadcast_bind.sh Thu Nov 17 08:42:56 2022 @@ -0,0 +1,75 @@ +# $NetBSD: t_broadcast_bind.sh,v 1.1 2022/11/17 08:42:56 ozaki-r Exp $ +# +# Copyright (c) 2022 Internet Initiative Japan Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +#notice, this list of conditions and the following disclaimer in the +#documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +SOCK=unix://broadcast_bind +BUS=./bus + +DEBUG=${DEBUG:-false} +NAME="broadcast_bind" + +test_broadcast_bind_basic() +{ + #local insfx=$(jot -s '.' -r 2 0 255) + local insfx="0.0" + local inaddr="10.$insfx.10" + local badaddr="10.$insfx.22" + local bcaddr="10.$insfx.255" + local prog="$(atf_get_srcdir)/broadcast_bind" + + rump_server_start $SOCK + rump_server_add_iface $SOCK shmif0 $BUS + + export RUMP_SERVER=$SOCK + atf_check -s exit:0 rump.ifconfig shmif0 $inaddr/24 + atf_check -s exit:0 $HIJACKING $prog $inaddr $badaddr $bcaddr +} + +add_test() +{ + local name="${NAME}_$1" + local desc="$2" + + atf_test_case "${name}" cleanup + eval "${name}_head() { + atf_set descr \"${desc}\" + atf_set require.progs rump_server + } + ${name}_body() { + test_${name} + } + ${name}_cleanup() { + \$DEBUG && dump + cleanup + }" + atf_add_test_case "${name}" +} + +atf_init_test_cases() +{ + + add_test basic "bind(2)ing with broadcast and inexistant addresses" +}
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:42:56 UTC 2022 Added Files: src/tests/net/inpcb: t_broadcast_bind.sh Log Message: tests: add t_broadcast_bind.sh To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/t_broadcast_bind.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:42:06 UTC 2022 Modified Files: src/tests/net/inpcb: broadcast_bind.c Log Message: tests: tweak broadcast_bind.c for NetBSD To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/inpcb/broadcast_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/inpcb/broadcast_bind.c diff -u src/tests/net/inpcb/broadcast_bind.c:1.1 src/tests/net/inpcb/broadcast_bind.c:1.2 --- src/tests/net/inpcb/broadcast_bind.c:1.1 Thu Nov 17 08:41:16 2022 +++ src/tests/net/inpcb/broadcast_bind.c Thu Nov 17 08:42:06 2022 @@ -1,3 +1,4 @@ +/* $NetBSD: broadcast_bind.c,v 1.2 2022/11/17 08:42:06 ozaki-r Exp $ */ /* $OpenBSD: broadcast_bind.c,v 1.2 2015/12/02 20:45:00 mpi Exp $ */ /* @@ -30,7 +31,7 @@ #include -int +static int test_bind(char *paddr, struct in_addr *addr, u_int16_t port, int type, int expected_errno) { @@ -100,7 +101,11 @@ main(int argc, char *argv[]) rc = 0; rc |= test_bind(argv[1], _addr, port, SOCK_STREAM, 0); rc |= test_bind(argv[2], _addr, port, SOCK_STREAM, EADDRNOTAVAIL); +#ifdef __NetBSD__ + rc |= test_bind(argv[3], _addr, port, SOCK_STREAM, 0); +#else rc |= test_bind(argv[3], _addr, port, SOCK_STREAM, EADDRNOTAVAIL); +#endif rc |= test_bind(argv[2], _addr, port, SOCK_STREAM, EADDRNOTAVAIL); rc |= test_bind(argv[3], _addr, port, SOCK_DGRAM, 0);
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:42:06 UTC 2022 Modified Files: src/tests/net/inpcb: broadcast_bind.c Log Message: tests: tweak broadcast_bind.c for NetBSD To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/inpcb/broadcast_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:41:16 UTC 2022 Added Files: src/tests/net/inpcb: broadcast_bind.c Log Message: tests: import broadcast_bind.c from OpenBSD As of $OpenBSD: broadcast_bind.c,v 1.2 2015/12/02 20:45:00 mpi Exp $ To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/broadcast_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/inpcb/broadcast_bind.c diff -u /dev/null src/tests/net/inpcb/broadcast_bind.c:1.1 --- /dev/null Thu Nov 17 08:41:16 2022 +++ src/tests/net/inpcb/broadcast_bind.c Thu Nov 17 08:41:16 2022 @@ -0,0 +1,109 @@ +/* $OpenBSD: broadcast_bind.c,v 1.2 2015/12/02 20:45:00 mpi Exp $ */ + +/* + * Copyright (c) 2015 Vincent Gross + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + + +int +test_bind(char *paddr, struct in_addr *addr, u_int16_t port, int type, +int expected_errno) +{ + int s, rc; + struct sockaddr_in sin; + + memset(, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_len = sizeof(sin); + sin.sin_port = htons(port); + memcpy(_addr, addr, sizeof(*addr)); + + s = socket(PF_INET, type, 0); + if (s < 0) { + warn("socket(PF_INET, %d, 0)", type); + return (1); + } + + rc = bind(s, (struct sockaddr *), sin.sin_len); + if ((rc == 0 && expected_errno == 0) || + (rc != 0 && expected_errno == errno)) { + close(s); + return (0); + } + + warn("bind(%s,%d) (type %d) expected %d, got %d", paddr, port, type, + expected_errno, errno); + close(s); + + return (1); +} + +int +main(int argc, char *argv[]) +{ + int rc; + struct in_addr uc_addr, err_addr, bc_addr; + int port = 3; + + if (argc != 4) + errx(1, "needs 2 arguments: "); + + rc = inet_pton(AF_INET, argv[1], _addr); + if (rc != 1) { + if (rc) + err(1, "inet_pton(unicast)"); + else + errx(1, "inet_pton(unicast): error parsing %s", + argv[1]); + } + rc = inet_pton(AF_INET, argv[2], _addr); + if (rc != 1) { + if (rc) + err(1, "inet_pton(error)"); + else + errx(1, "inet_pton(error): error parsing %s", argv[2]); + } + rc = inet_pton(AF_INET, argv[3], _addr); + if (rc != 1) { + if (rc) + err(1, "inet_pton(broadcast)"); + else + errx(1, "inet_pton(broadcast): error parsing %s", + argv[3]); + } + + rc = 0; + rc |= test_bind(argv[1], _addr, port, SOCK_STREAM, 0); + rc |= test_bind(argv[2], _addr, port, SOCK_STREAM, EADDRNOTAVAIL); + rc |= test_bind(argv[3], _addr, port, SOCK_STREAM, EADDRNOTAVAIL); + + rc |= test_bind(argv[2], _addr, port, SOCK_STREAM, EADDRNOTAVAIL); + rc |= test_bind(argv[3], _addr, port, SOCK_DGRAM, 0); + + return (rc); +}
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:41:16 UTC 2022 Added Files: src/tests/net/inpcb: broadcast_bind.c Log Message: tests: import broadcast_bind.c from OpenBSD As of $OpenBSD: broadcast_bind.c,v 1.2 2015/12/02 20:45:00 mpi Exp $ To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/broadcast_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:40:24 UTC 2022 Added Files: src/tests/net/inpcb: t_inpcb_bind.sh Log Message: tests: add t_inpcb_bind.sh To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/t_inpcb_bind.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/inpcb/t_inpcb_bind.sh diff -u /dev/null src/tests/net/inpcb/t_inpcb_bind.sh:1.1 --- /dev/null Thu Nov 17 08:40:24 2022 +++ src/tests/net/inpcb/t_inpcb_bind.sh Thu Nov 17 08:40:23 2022 @@ -0,0 +1,89 @@ +# $NetBSD: t_inpcb_bind.sh,v 1.1 2022/11/17 08:40:23 ozaki-r Exp $ +# +# Copyright (c) 2022 Internet Initiative Japan Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +#notice, this list of conditions and the following disclaimer in the +#documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +SOCK=unix://inpcb_bind +BUS=./bus + +DEBUG=${DEBUG:-false} +NAME="inpcb_bind" + +test_inpcb_bind_ipv4() +{ + local addr="10.0.0.10" + local port=23000 + local prog="$(atf_get_srcdir)/inpcb_bind" + + rump_server_start $SOCK + rump_server_add_iface $SOCK shmif0 $BUS + + export RUMP_SERVER=$SOCK + atf_check -s exit:0 rump.ifconfig shmif0 $addr/24 + atf_check -s exit:0 -o ignore $HIJACKING $prog $addr $port + atf_check -s exit:0 -o ignore $HIJACKING $prog 224.0.2.1 $port $addr +} + +test_inpcb_bind_ipv6() +{ + local addr="fc00::10" + local port=23000 + local prog="$(atf_get_srcdir)/inpcb_bind" + + rump_server_start $SOCK netinet6 + rump_server_add_iface $SOCK shmif0 $BUS + + export RUMP_SERVER=$SOCK + atf_check -s exit:0 rump.ifconfig shmif0 inet6 $addr/64 + atf_check -s exit:0 -o ignore $HIJACKING $prog $addr $port + atf_check -s exit:0 -o ignore $HIJACKING $prog ff1e::123 $port $addr +} + +add_test() +{ + local name="${NAME}_$1" + local desc="$2" + + atf_test_case "${name}" cleanup + eval "${name}_head() { + atf_set descr \"${desc}\" + atf_set require.progs rump_server + } + ${name}_body() { + test_${name} + } + ${name}_cleanup() { + \$DEBUG && dump + cleanup + }" + atf_add_test_case "${name}" +} + +atf_init_test_cases() +{ + + add_test ipv4 "tests for inpcb_bind (ipv4)" + add_test ipv6 "tests for inpcb_bind (ipv6)" +}
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:40:24 UTC 2022 Added Files: src/tests/net/inpcb: t_inpcb_bind.sh Log Message: tests: add t_inpcb_bind.sh To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/t_inpcb_bind.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:38:58 UTC 2022 Modified Files: src/tests/net/inpcb: inpcb_bind.c Log Message: tests: make inpcb_bind.c buildable To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/inpcb/inpcb_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/inpcb/inpcb_bind.c diff -u src/tests/net/inpcb/inpcb_bind.c:1.1 src/tests/net/inpcb/inpcb_bind.c:1.2 --- src/tests/net/inpcb/inpcb_bind.c:1.1 Thu Nov 17 08:38:08 2022 +++ src/tests/net/inpcb/inpcb_bind.c Thu Nov 17 08:38:58 2022 @@ -1,3 +1,4 @@ +/* $NetBSD: inpcb_bind.c,v 1.2 2022/11/17 08:38:58 ozaki-r Exp $ */ /* $OpenBSD: runtest.c,v 1.7 2022/04/10 14:08:35 claudio Exp $ */ /* * Copyright (c) 2015 Vincent Gross @@ -29,12 +30,11 @@ #include #include -int +static int runtest(int *sockp, struct addrinfo *ai, int reuseaddr, int reuseport, void *mreq, int expected) { int error, optval; - struct ip_mreq imr; *sockp = socket(ai->ai_family, ai->ai_socktype, 0); if (*sockp == -1) { @@ -106,7 +106,7 @@ runtest(int *sockp, struct addrinfo *ai, return (0); } -void +static void cleanup(int *fds, int num_fds) { while (num_fds-- > 0) @@ -114,7 +114,7 @@ cleanup(int *fds, int num_fds) err(2, "unable to clean up sockets, aborting"); } -int +static int unicast_testsuite(struct addrinfo *local, struct addrinfo *any) { int test_rc, rc, *s; @@ -180,12 +180,11 @@ unicast_testsuite(struct addrinfo *local return (test_rc); } -int +static int mcast_reuse_testsuite(struct addrinfo *local, void *mr) { int test_rc, rc, *s; int sockets[6]; - int testnum = 1; test_rc = 0; rc = 0; s = sockets; @@ -266,13 +265,12 @@ mcast_reuse_testsuite(struct addrinfo *l return (test_rc); } -int +static int mcast6_testsuite(struct addrinfo *local, struct ipv6_mreq *local_mreq, struct addrinfo *any, struct ipv6_mreq *any_mreq) { int test_rc, rc, *s; int sockets[4]; - int testnum = 1; test_rc = 0; rc = 0; s = sockets; @@ -350,11 +348,10 @@ main(int argc, char *argv[]) char *baddr_s, *bport_s, *bmifa_s; struct addrinfo hints, *baddr, *any, *mifa; struct ifaddrs *ifap, *curifa; - struct ip_mreq local_imr, any_imr; + struct ip_mreq local_imr; struct ipv6_mreq local_i6mr, any_i6mr; struct sockaddr_in *sin; struct sockaddr_in6 *sin6; - int *s; memset(, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST | AI_NUMERICSERV | \ @@ -373,7 +370,7 @@ main(int argc, char *argv[]) if ((error = getaddrinfo(NULL, bport_s, , ))) errx(2, "getaddrinfo(NULL,%s): %s", bport_s, gai_strerror(error)); - any->ai_canonname = "*"; + any->ai_canonname = strdup("*"); switch (baddr->ai_family) { case AF_INET:
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:38:58 UTC 2022 Modified Files: src/tests/net/inpcb: inpcb_bind.c Log Message: tests: make inpcb_bind.c buildable To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/inpcb/inpcb_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:38:08 UTC 2022 Added Files: src/tests/net/inpcb: inpcb_bind.c Log Message: tests: import in_pcbbind/runtest.c from OpenBSD as inpcb_bind.c As of $OpenBSD: runtest.c,v 1.7 2022/04/10 14:08:35 claudio Exp $ To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/inpcb_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/inpcb/inpcb_bind.c diff -u /dev/null src/tests/net/inpcb/inpcb_bind.c:1.1 --- /dev/null Thu Nov 17 08:38:08 2022 +++ src/tests/net/inpcb/inpcb_bind.c Thu Nov 17 08:38:08 2022 @@ -0,0 +1,455 @@ +/* $OpenBSD: runtest.c,v 1.7 2022/04/10 14:08:35 claudio Exp $ */ +/* + * Copyright (c) 2015 Vincent Gross + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +int +runtest(int *sockp, struct addrinfo *ai, int reuseaddr, int reuseport, +void *mreq, int expected) +{ + int error, optval; + struct ip_mreq imr; + + *sockp = socket(ai->ai_family, ai->ai_socktype, 0); + if (*sockp == -1) { + warn("%s : socket()", ai->ai_canonname); + return (3); + } + + if (reuseaddr) { + optval = 1; + error = setsockopt(*sockp, SOL_SOCKET, SO_REUSEADDR, + , sizeof(int)); + if (error) { + warn("%s : setsockopt(SO_REUSEADDR)", ai->ai_canonname); + return (2); + } + } + + if (reuseport) { + optval = 1; + error = setsockopt(*sockp, SOL_SOCKET, SO_REUSEPORT, + , sizeof(int)); + if (error) { + warn("%s : setsockopt(SO_REUSEPORT)", ai->ai_canonname); + return (2); + } + } + + if (mreq) { + switch (ai->ai_family) { + case AF_INET6: + error = setsockopt(*sockp, IPPROTO_IPV6, IPV6_JOIN_GROUP, + mreq, sizeof(struct ipv6_mreq)); + if (error) { +warn("%s : setsockopt(IPV6_JOIN_GROUP)", +ai->ai_canonname); +return (2); + } + break; + case AF_INET: + error = setsockopt(*sockp, IPPROTO_IP, IP_ADD_MEMBERSHIP, + mreq, sizeof(struct ip_mreq)); + if (error) { +warn("%s : setsockopt(IP_ADD_MEMBERSHIP)", +ai->ai_canonname); +return (2); + } + break; + default: + warnx("%s : trying to join multicast group in unknown AF", + ai->ai_canonname); + return (2); + } + } + + + error = bind(*sockp, ai->ai_addr, ai->ai_addrlen); + if (error && (expected == 0 || expected != errno)) { + warn("bind(%s,%s,%s)", ai->ai_canonname, + reuseaddr ? "REUSEADDR" : "", reuseport ? "REUSEPORT" : ""); + return (1); + } + if (error == 0 && expected != 0) { + warnx("bind(%s,%s,%s) succeeded, expected : %s", ai->ai_canonname, + reuseaddr ? "REUSEADDR" : "", reuseport ? "REUSEPORT" : "", + strerror(expected)); + return (1); + } + + return (0); +} + +void +cleanup(int *fds, int num_fds) +{ + while (num_fds-- > 0) + if (close(*fds++) && errno != EBADF) + err(2, "unable to clean up sockets, aborting"); +} + +int +unicast_testsuite(struct addrinfo *local, struct addrinfo *any) +{ + int test_rc, rc, *s; + int sockets[4]; + + test_rc = 0; + rc = 0; s = sockets; + rc |= runtest(s++, local, 0, 0, NULL, 0); + rc |= runtest(s++, any, 0, 0, NULL, EADDRINUSE); + rc |= runtest(s++, any, 1, 0, NULL, 0); + cleanup(sockets, 3); + test_rc |= rc; + if (rc) + warnx("%s : test #%d failed", __func__, 1); + + rc = 0; s = sockets; + rc |= runtest(s++, any, 0, 0, NULL, 0); + rc |= runtest(s++, local, 0, 0, NULL, EADDRINUSE); + rc |= runtest(s++, local, 1, 0, NULL, 0); + cleanup(sockets, 3); + test_rc |= rc; + if (rc) + warnx("%s : test #%d failed", __func__, 2); + + rc = 0; s = sockets; + rc |= runtest(s++, local, 0, 1, NULL, 0); + rc |= runtest(s++, local, 0, 1, NULL, 0); + rc |= runtest(s++, local, 1, 0, NULL, EADDRINUSE); + rc |= runtest(s++, local, 0, 0, NULL, EADDRINUSE); + cleanup(sockets, 4); + test_rc |= rc; + if (rc) + warnx("%s : test #%d failed", __func__, 3); + + rc = 0; s = sockets; + rc |= runtest(s++, any, 0, 1, NULL, 0); + rc |= runtest(s++, any, 0, 1, NULL, 0); + rc |= runtest(s++, any, 1, 0, NULL, EADDRINUSE); + rc |= runtest(s++, any, 0, 0, NULL, EADDRINUSE); + cleanup(sockets, 4); + test_rc |= rc; + if (rc) +
CVS commit: src/tests/net/inpcb
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:38:08 UTC 2022 Added Files: src/tests/net/inpcb: inpcb_bind.c Log Message: tests: import in_pcbbind/runtest.c from OpenBSD as inpcb_bind.c As of $OpenBSD: runtest.c,v 1.7 2022/04/10 14:08:35 claudio Exp $ To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/inpcb/inpcb_bind.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/tcp
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:36:54 UTC 2022 Modified Files: src/tests/net/tcp: t_tcp_connect_port.c Log Message: tests: make t_tcp_connect_port.c run on rump kernel To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/tcp/t_tcp_connect_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/tcp/t_tcp_connect_port.c diff -u src/tests/net/tcp/t_tcp_connect_port.c:1.1 src/tests/net/tcp/t_tcp_connect_port.c:1.2 --- src/tests/net/tcp/t_tcp_connect_port.c:1.1 Thu Nov 17 08:36:00 2022 +++ src/tests/net/tcp/t_tcp_connect_port.c Thu Nov 17 08:36:54 2022 @@ -1,3 +1,5 @@ +/* $NetBSD: t_tcp_connect_port.c,v 1.2 2022/11/17 08:36:54 ozaki-r Exp $ */ + /*- * SPDX-License-Identifier: BSD-2-Clause * @@ -27,7 +29,12 @@ */ #include +#ifdef __NetBSD__ +__RCSID("$NetBSD: t_tcp_connect_port.c,v 1.2 2022/11/17 08:36:54 ozaki-r Exp $"); +#define USE_RUMPKERNEL 1 +#else __FBSDID("$FreeBSD$"); +#endif #include #include @@ -45,6 +52,21 @@ __FBSDID("$FreeBSD$"); #include +#ifdef USE_RUMPKERNEL +#include +#include + +#define socket rump_sys_socket +#define bind rump_sys_bind +#define listen rump_sys_listen +#define accept rump_sys_accept +#define connect rump_sys_connect +#define write rump_sys_write +#define close rump_sys_close +#define setsockopt rump_sys_setsockopt +#define getsockname rump_sys_getsockname +#endif /* USE_RUMPKERNEL */ + #define SYSCTLBAKFILE "tmp.net.inet.ip.portrange.randomized" /* @@ -54,6 +76,9 @@ __FBSDID("$FreeBSD$"); static void disable_random_ports(void) { +#ifdef USE_RUMPKERNEL + rump_init(); /* XXX */ +#else int error, fd, random_new, random_save; size_t sysctlsz; @@ -112,6 +137,7 @@ restore_sysctl: NULL, _save, sysctlsz); atf_tc_skip("Error setting sysctl"); } +#endif /* USE_RUMPKERNEL */ } /* @@ -120,6 +146,7 @@ restore_sysctl: static void restore_random_ports(void) { +#ifndef USE_RUMPKERNEL int error, fd, random_save; /* Open the backup file, read the contents, close it, and delete it. */ @@ -152,6 +179,7 @@ restore_random_ports(void) if (error) warn("sysctlbyname(\"net.inet.ip.portrange.randomized\") " "failed while restoring value"); +#endif /* USE_RUMPKERNEL */ } /* @@ -271,7 +299,9 @@ ATF_TC_HEAD(basic_ipv4, tc) { atf_tc_set_md_var(tc, "require.user", "root"); +#ifndef USE_RUMPKERNEL atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects"); +#endif atf_tc_set_md_var(tc, "descr", "Check automatic local port assignment during TCP connect calls"); } @@ -300,7 +330,9 @@ ATF_TC_HEAD(basic_ipv6, tc) { atf_tc_set_md_var(tc, "require.user", "root"); +#ifndef USE_RUMPKERNEL atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects"); +#endif atf_tc_set_md_var(tc, "descr", "Check automatic local port assignment during TCP connect calls"); }
CVS commit: src/tests/net/tcp
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:36:54 UTC 2022 Modified Files: src/tests/net/tcp: t_tcp_connect_port.c Log Message: tests: make t_tcp_connect_port.c run on rump kernel To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/tcp/t_tcp_connect_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/tcp
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:36:00 UTC 2022 Added Files: src/tests/net/tcp: t_tcp_connect_port.c Log Message: tests: import tcp_connect_port_test.c from FreeBSD as t_tcp_connect_port.c As of: commit 36c52a52eecf1ed0232f9e138564009a85de76c2 Author: Jonathan T. Looney Date: Sat Nov 14 15:44:28 2020 + Add a regression test for the port-selection behavior fixed in r367680. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/tcp/t_tcp_connect_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/tcp/t_tcp_connect_port.c diff -u /dev/null src/tests/net/tcp/t_tcp_connect_port.c:1.1 --- /dev/null Thu Nov 17 08:36:00 2022 +++ src/tests/net/tcp/t_tcp_connect_port.c Thu Nov 17 08:36:00 2022 @@ -0,0 +1,334 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Netflix, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in + *the documentation and/or other materials provided with the + *distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#define SYSCTLBAKFILE "tmp.net.inet.ip.portrange.randomized" + +/* + * Check if port allocation is randomized. If so, update it. Save the old + * value of the sysctl so it can be updated later. + */ +static void +disable_random_ports(void) +{ + int error, fd, random_new, random_save; + size_t sysctlsz; + + /* + * Pre-emptively unlink our restoration file, so we will do no + * restoration on error. + */ + unlink(SYSCTLBAKFILE); + + /* + * Disable the net.inet.ip.portrange.randomized sysctl. Save the + * old value so we can restore it, if necessary. + */ + random_new = 0; + sysctlsz = sizeof(random_save); + error = sysctlbyname("net.inet.ip.portrange.randomized", _save, + , _new, sizeof(random_new)); + if (error) { + warn("sysctlbyname(\"net.inet.ip.portrange.randomized\") " + "failed"); + atf_tc_skip("Unable to set sysctl"); + } + if (sysctlsz != sizeof(random_save)) { + fprintf(stderr, "Error: unexpected sysctl value size " + "(expected %zu, actual %zu)\n", sizeof(random_save), + sysctlsz); + goto restore_sysctl; + } + + /* Open the backup file, write the contents, and close it. */ + fd = open(SYSCTLBAKFILE, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, + S_IRUSR|S_IWUSR); + if (fd < 0) { + warn("error opening sysctl backup file"); + goto restore_sysctl; + } + error = write(fd, _save, sizeof(random_save)); + if (error < 0) { + warn("error writing saved value to sysctl backup file"); + goto cleanup_and_restore; + } + if (error != (int)sizeof(random_save)) { + fprintf(stderr, + "Error writing saved value to sysctl backup file: " + "(expected %zu, actual %d)\n", sizeof(random_save), error); + goto cleanup_and_restore; + } + error = close(fd); + if (error) { + warn("error closing sysctl backup file"); +cleanup_and_restore: + (void)close(fd); + (void)unlink(SYSCTLBAKFILE); +restore_sysctl: + (void)sysctlbyname("net.inet.ip.portrange.randomized", NULL, + NULL, _save, sysctlsz); + atf_tc_skip("Error setting sysctl"); + } +} + +/* + * Restore the sysctl value from the backup file and delete the backup file. + */ +static void +restore_random_ports(void) +{ + int error, fd, random_save; + + /* Open the backup file, read the contents, close it, and delete it. */ + fd = open(SYSCTLBAKFILE, O_RDONLY); + if (fd < 0) { + warn("error opening sysctl backup file"); + return; + } + error = read(fd, _save, sizeof(random_save)); + if (error < 0) { + warn("error reading saved value from sysctl backup file");
CVS commit: src/tests/net/tcp
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:36:00 UTC 2022 Added Files: src/tests/net/tcp: t_tcp_connect_port.c Log Message: tests: import tcp_connect_port_test.c from FreeBSD as t_tcp_connect_port.c As of: commit 36c52a52eecf1ed0232f9e138564009a85de76c2 Author: Jonathan T. Looney Date: Sat Nov 14 15:44:28 2020 + Add a regression test for the port-selection behavior fixed in r367680. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/tcp/t_tcp_connect_port.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:34:39 UTC 2022 Modified Files: src/tests/net/net: t_socket_afinet.c Log Message: tests: make t_socket_afinet.c run on rump kernel To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/net/t_socket_afinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/net/t_socket_afinet.c diff -u src/tests/net/net/t_socket_afinet.c:1.1 src/tests/net/net/t_socket_afinet.c:1.2 --- src/tests/net/net/t_socket_afinet.c:1.1 Thu Nov 17 08:33:27 2022 +++ src/tests/net/net/t_socket_afinet.c Thu Nov 17 08:34:39 2022 @@ -1,3 +1,5 @@ +/* $NetBSD: t_socket_afinet.c,v 1.2 2022/11/17 08:34:39 ozaki-r Exp $ */ + /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * @@ -26,7 +28,12 @@ */ #include +#ifdef __NetBSD__ +__RCSID("$NetBSD: t_socket_afinet.c,v 1.2 2022/11/17 08:34:39 ozaki-r Exp $"); +#define USE_RUMPKERNEL 1 +#else __FBSDID("$FreeBSD$"); +#endif #include #include @@ -35,11 +42,30 @@ __FBSDID("$FreeBSD$"); #include +#ifdef USE_RUMPKERNEL +#include +#include + +#define socket rump_sys_socket +#define bind rump_sys_bind +#define listen rump_sys_listen +#define connect rump_sys_connect +#define write rump_sys_write +#define poll rump_sys_poll +#define close rump_sys_close + +#define RUMP_INIT() rump_init() +#else +#define RUMP_INIT() do { } while (0) +#endif + ATF_TC_WITHOUT_HEAD(socket_afinet); ATF_TC_BODY(socket_afinet, tc) { int sd; + RUMP_INIT(); + sd = socket(PF_INET, SOCK_DGRAM, 0); ATF_CHECK(sd >= 0); @@ -52,6 +78,12 @@ ATF_TC_BODY(socket_afinet_bind_zero, tc) int sd, rc; struct sockaddr_in sin; + RUMP_INIT(); + +#ifdef __NetBSD__ + atf_tc_expect_fail("NetBSD doesn't allow sin_family == 0 (sin_len == 0 too)"); +#endif + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) atf_tc_skip("doesn't work when mac_portacl(4) loaded (https://bugs.freebsd.org/238781)"); @@ -76,6 +108,8 @@ ATF_TC_BODY(socket_afinet_bind_ok, tc) int sd, rc; struct sockaddr_in sin; + RUMP_INIT(); + sd = socket(PF_INET, SOCK_DGRAM, 0); ATF_CHECK(sd >= 0); @@ -90,6 +124,7 @@ ATF_TC_BODY(socket_afinet_bind_ok, tc) close(sd); } +#ifdef POLLRDHUP ATF_TC_WITHOUT_HEAD(socket_afinet_poll_no_rdhup); ATF_TC_BODY(socket_afinet_poll_no_rdhup, tc) { @@ -98,6 +133,8 @@ ATF_TC_BODY(socket_afinet_poll_no_rdhup, struct pollfd pfd; int one = 1; + RUMP_INIT(); + /* Verify that we don't expose POLLRDHUP if not requested. */ /* Server setup. */ @@ -158,6 +195,8 @@ ATF_TC_BODY(socket_afinet_poll_rdhup, tc char buffer; int one = 1; + RUMP_INIT(); + /* Verify that server sees POLLRDHUP if it asks for it. */ /* Server setup. */ @@ -227,6 +266,7 @@ ATF_TC_BODY(socket_afinet_poll_rdhup, tc close(ss2); close(ss); } +#endif /* POLLRDHUP */ ATF_TP_ADD_TCS(tp) { @@ -234,8 +274,10 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, socket_afinet); ATF_TP_ADD_TC(tp, socket_afinet_bind_zero); ATF_TP_ADD_TC(tp, socket_afinet_bind_ok); +#ifdef POLLRDHUP ATF_TP_ADD_TC(tp, socket_afinet_poll_no_rdhup); ATF_TP_ADD_TC(tp, socket_afinet_poll_rdhup); +#endif return atf_no_error(); }
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:34:39 UTC 2022 Modified Files: src/tests/net/net: t_socket_afinet.c Log Message: tests: make t_socket_afinet.c run on rump kernel To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/net/t_socket_afinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:33:27 UTC 2022 Added Files: src/tests/net/net: t_socket_afinet.c Log Message: tests: import socket_afinet.c from FreeBSD as t_socket_afinet.c As of: commit 32efde896e19d229ee2cf09fe7e6ab0fbf6e Author: Thomas Munro Date: Wed Apr 28 21:31:38 2021 +1200 poll(2): Add POLLRDHUP. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/net/t_socket_afinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/net/net/t_socket_afinet.c diff -u /dev/null src/tests/net/net/t_socket_afinet.c:1.1 --- /dev/null Thu Nov 17 08:33:27 2022 +++ src/tests/net/net/t_socket_afinet.c Thu Nov 17 08:33:27 2022 @@ -0,0 +1,241 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Bjoern A. Zeeb + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include + +ATF_TC_WITHOUT_HEAD(socket_afinet); +ATF_TC_BODY(socket_afinet, tc) +{ + int sd; + + sd = socket(PF_INET, SOCK_DGRAM, 0); + ATF_CHECK(sd >= 0); + + close(sd); +} + +ATF_TC_WITHOUT_HEAD(socket_afinet_bind_zero); +ATF_TC_BODY(socket_afinet_bind_zero, tc) +{ + int sd, rc; + struct sockaddr_in sin; + + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("doesn't work when mac_portacl(4) loaded (https://bugs.freebsd.org/238781)"); + + sd = socket(PF_INET, SOCK_DGRAM, 0); + ATF_CHECK(sd >= 0); + + bzero(, sizeof(sin)); + /* + * For AF_INET we do not check the family in in_pcbbind_setup(9), + * sa_len gets set from the syscall argument in getsockaddr(9), + * so we bind to 0:0. + */ + rc = bind(sd, (struct sockaddr *), sizeof(sin)); + ATF_CHECK_EQ(0, rc); + + close(sd); +} + +ATF_TC_WITHOUT_HEAD(socket_afinet_bind_ok); +ATF_TC_BODY(socket_afinet_bind_ok, tc) +{ + int sd, rc; + struct sockaddr_in sin; + + sd = socket(PF_INET, SOCK_DGRAM, 0); + ATF_CHECK(sd >= 0); + + bzero(, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_len = sizeof(sin); + sin.sin_port = htons(); + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + rc = bind(sd, (struct sockaddr *), sizeof(sin)); + ATF_CHECK_EQ(0, rc); + + close(sd); +} + +ATF_TC_WITHOUT_HEAD(socket_afinet_poll_no_rdhup); +ATF_TC_BODY(socket_afinet_poll_no_rdhup, tc) +{ + int ss, ss2, cs, rc; + struct sockaddr_in sin; + struct pollfd pfd; + int one = 1; + + /* Verify that we don't expose POLLRDHUP if not requested. */ + + /* Server setup. */ + ss = socket(PF_INET, SOCK_STREAM, 0); + ATF_CHECK(ss >= 0); + rc = setsockopt(ss, SOL_SOCKET, SO_REUSEPORT, , sizeof(one)); + ATF_CHECK_EQ(0, rc); + bzero(, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_len = sizeof(sin); + sin.sin_port = htons(); + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + rc = bind(ss, (struct sockaddr *), sizeof(sin)); + ATF_CHECK_EQ(0, rc); + rc = listen(ss, 1); + ATF_CHECK_EQ(0, rc); + + /* Client connects, server accepts. */ + cs = socket(PF_INET, SOCK_STREAM, 0); + ATF_CHECK(cs >= 0); + rc = connect(cs, (struct sockaddr *), sizeof(sin)); + ATF_CHECK_EQ(0, rc); + ss2 = accept(ss, NULL, NULL); + ATF_CHECK(ss2 >= 0); + + /* Server can write, sees only POLLOUT. */ + pfd.fd = ss2; + pfd.events = POLLIN | POLLOUT; + rc = poll(, 1, 0); + ATF_CHECK_EQ(1, rc); + ATF_CHECK_EQ(POLLOUT, pfd.revents); + + /* Client closes socket! */ + rc = close(cs); + ATF_CHECK_EQ(0, rc); + + /* + * Server now sees POLLIN, but not POLLRDHUP because we didn't ask. + * Need non-zero timeout to wait for the FIN to arrive and trigger the + * socket to become readable. + */ + pfd.fd = ss2;
CVS commit: src/tests/net/net
Module Name:src Committed By: ozaki-r Date: Thu Nov 17 08:33:27 UTC 2022 Added Files: src/tests/net/net: t_socket_afinet.c Log Message: tests: import socket_afinet.c from FreeBSD as t_socket_afinet.c As of: commit 32efde896e19d229ee2cf09fe7e6ab0fbf6e Author: Thomas Munro Date: Wed Apr 28 21:31:38 2021 +1200 poll(2): Add POLLRDHUP. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/net/net/t_socket_afinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys
On Tue, Nov 15, 2022 at 11:29 AM Ryota Ozaki wrote: > > On Mon, Nov 14, 2022 at 8:52 PM Roy Marples wrote: > > > > On 14/11/2022 11:04, Martin Husemann wrote: > > > This clearly is a layering/abstraction violation and would have been > > > good to discuss upfront. > > > > > > Where do you make use of that information? What about other packet > > > injection > > > paths? > > > > The next commit uses it in if_arp to ensure that the DaD probe sending > > interface > > hardware address matches the sending hardware address in the ARP packet as > > specified in RFC 5227 section 1.1 > > > > I couldn't think of a better way of achieving this. > > RFC 5227 says senders must follow the spec but doesn't say receivers' > check is must IIUC. > > I don't think it is a good idea to increase the mbuf size just for > broken clients. > I think it is better to make the strict check optional (by sysctl or > something) and use mtag, > so the change doesn't impact on most of us. Well... another possible option is to unionize l2_* with pattr_*. This is possible (IIUC) because l2_* are used only on receiving packets while pattr_* are used only on sending packets. Am I missing something? ozaki-r
Re: CVS commit: src/sys
On Mon, Nov 14, 2022 at 8:52 PM Roy Marples wrote: > > On 14/11/2022 11:04, Martin Husemann wrote: > > This clearly is a layering/abstraction violation and would have been > > good to discuss upfront. > > > > Where do you make use of that information? What about other packet injection > > paths? > > The next commit uses it in if_arp to ensure that the DaD probe sending > interface > hardware address matches the sending hardware address in the ARP packet as > specified in RFC 5227 section 1.1 > > I couldn't think of a better way of achieving this. RFC 5227 says senders must follow the spec but doesn't say receivers' check is must IIUC. I don't think it is a good idea to increase the mbuf size just for broken clients. I think it is better to make the strict check optional (by sysctl or something) and use mtag, so the change doesn't impact on most of us. ozaki-r
CVS commit: src/sys/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:06:25 UTC 2022 Modified Files: src/sys/sys: param.h Log Message: Bump the version for function renames of inpcb Welcome to 9.99.105 To generate a diff of this commit: cvs rdiff -u -r1.717 -r1.718 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.717 src/sys/sys/param.h:1.718 --- src/sys/sys/param.h:1.717 Fri Oct 28 08:16:57 2022 +++ src/sys/sys/param.h Fri Nov 4 09:06:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.717 2022/10/28 08:16:57 ozaki-r Exp $ */ +/* $NetBSD: param.h,v 1.718 2022/11/04 09:06:25 ozaki-r Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 999010400 /* NetBSD 9.99.104 */ +#define __NetBSD_Version__ 999010500 /* NetBSD 9.99.105 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src/sys/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:06:25 UTC 2022 Modified Files: src/sys/sys: param.h Log Message: Bump the version for function renames of inpcb Welcome to 9.99.105 To generate a diff of this commit: cvs rdiff -u -r1.717 -r1.718 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:05:41 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: ipcb: add/update the description of functions >From rmind-smpnet patches To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/netinet/in_pcb.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/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.201 src/sys/netinet/in_pcb.c:1.202 --- src/sys/netinet/in_pcb.c:1.201 Fri Nov 4 09:05:04 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:05:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.201 2022/11/04 09:05:04 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.202 2022/11/04 09:05:41 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.201 2022/11/04 09:05:04 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.202 2022/11/04 09:05:41 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -192,6 +192,10 @@ inpcb_init(struct inpcbtable *table, int RUN_ONCE(, inpcb_poolinit); } +/* + * inpcb_create: construct a new PCB and associated with a given socket. + * Sets the PCB state to INP_ATTACHED and makes PCB globally visible. + */ int inpcb_create(struct socket *so, void *v) { @@ -462,6 +466,14 @@ inpcb_bind_port(struct inpcb *inp, struc return 0; } +/* + * inpcb_bind: assign a local IP address and port number to the PCB. + * + * If the address is not a wildcard, verify that it corresponds to a + * local interface. If a port is specified and it is privileged, then + * check the permission. Check whether the address or port is in use, + * and if so, whether we can re-use them. + */ int inpcb_bind(void *v, struct sockaddr_in *sin, struct lwp *l) { @@ -501,10 +513,11 @@ inpcb_bind(void *v, struct sockaddr_in * } /* - * Connect from a socket to a specified address. - * Both address and port must be specified in argument sin. - * If don't have a local address for this socket yet, - * then pick one. + * inpcb_connect: connect from a socket to a specified address, i.e., + * assign a foreign IP address and port number to the PCB. + * + * Both address and port must be specified in the name argument. + * If there is no local address for this socket yet, then pick one. */ int inpcb_connect(void *v, struct sockaddr_in *sin, struct lwp *l) @@ -638,6 +651,11 @@ inpcb_connect(void *v, struct sockaddr_i return 0; } +/* + * inpcb_disconnect: remove any foreign IP/port association. + * + * Note: destroys the PCB if socket was closed. + */ void inpcb_disconnect(void *v) { @@ -657,6 +675,9 @@ inpcb_disconnect(void *v) inpcb_destroy(inp); } +/* + * inpcb_destroy: destroy PCB as well as the associated socket. + */ void inpcb_destroy(void *v) { @@ -706,6 +727,9 @@ inpcb_destroy(void *v) mutex_enter(softnet_lock); /* reacquire the softnet_lock */ } +/* + * inpcb_fetch_sockaddr: fetch the local IP address and port number. + */ void inpcb_fetch_sockaddr(struct inpcb *inp, struct sockaddr_in *sin) { @@ -716,6 +740,9 @@ inpcb_fetch_sockaddr(struct inpcb *inp, sockaddr_in_init(sin, _laddr(inp), inp->inp_lport); } +/* + * inpcb_fetch_peeraddr: fetch the foreign IP address and port number. + */ void inpcb_fetch_peeraddr(struct inpcb *inp, struct sockaddr_in *sin) { @@ -727,13 +754,14 @@ inpcb_fetch_peeraddr(struct inpcb *inp, } /* - * Pass some notification to all connections of a protocol - * associated with address dst. The local address and/or port numbers - * may be specified to limit the search. The "usual action" will be - * taken, depending on the ctlinput cmd. The caller must filter any - * cmds that are uninteresting (e.g., no error in the map). - * Call the protocol specific routine (if any) to report - * any errors for each matching socket. + * inpcb_notify: pass some notification to all connections of a protocol + * associated with destination address. The local address and/or port + * numbers may be specified to limit the search. The "usual action" will + * be taken, depending on the command. + * + * The caller must filter any commands that are not interesting (e.g., + * no error in the map). Call the protocol specific routine (if any) to + * report any errors for each matching socket. * * Must be called at splsoftnet. */ @@ -859,10 +887,10 @@ inpcb_purgeif(struct inpcbtable *table, } /* - * Check for alternatives when higher level complains - * about service problems. For now, invalidate cached - * routing information. If the route was created dynamically - * (by a redirect), time to try a default gateway again. + * inpcb_losing: check for alternatives when higher level complains about + * service problems. For now, invalidate cached routing information. + * If the route was created dynamically (by a redirect), time to
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:05:41 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: ipcb: add/update the description of functions >From rmind-smpnet patches To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/sys/netinet/in_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:05:04 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: replace leading white spaces with tabs To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 src/sys/netinet/in_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:05:04 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: replace leading white spaces with tabs To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 src/sys/netinet/in_pcb.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/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.200 src/sys/netinet/in_pcb.c:1.201 --- src/sys/netinet/in_pcb.c:1.200 Fri Nov 4 09:04:27 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:05:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.200 2022/11/04 09:04:27 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.201 2022/11/04 09:05:04 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.200 2022/11/04 09:04:27 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.201 2022/11/04 09:05:04 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -619,15 +619,15 @@ inpcb_connect(void *v, struct sockaddr_i in4p_faddr(inp) = sin->sin_addr; inp->inp_fport = sin->sin_port; -/* Late bind, if needed */ + /* Late bind, if needed */ if (inp->inp_bindportonsend) { - struct sockaddr_in lsin = *((const struct sockaddr_in *) + struct sockaddr_in lsin = *((const struct sockaddr_in *) inp->inp_socket->so_proto->pr_domain->dom_sa_any); lsin.sin_addr = in4p_laddr(inp); lsin.sin_port = 0; if ((error = inpcb_bind_port(inp, , l->l_cred)) != 0) - return error; + return error; } inpcb_set_state(inp, INP_CONNECTED);
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:04:27 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c src/sys/netinet6: in6_pcb.c Log Message: inpcb: get rid of parentheses for return value To generate a diff of this commit: cvs rdiff -u -r1.199 -r1.200 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.176 -r1.177 src/sys/netinet6/in6_pcb.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/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.199 src/sys/netinet/in_pcb.c:1.200 --- src/sys/netinet/in_pcb.c:1.199 Fri Nov 4 09:03:56 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:04:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.199 2022/11/04 09:03:56 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.200 2022/11/04 09:04:27 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.199 2022/11/04 09:03:56 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.200 2022/11/04 09:04:27 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -211,7 +211,7 @@ inpcb_create(struct socket *so, void *v) inp = pool_cache_get(in4pcb_pool_cache, PR_NOWAIT); #endif if (inp == NULL) - return (ENOBUFS); + return ENOBUFS; if (soaf(so) == AF_INET) memset(inp, 0, sizeof(struct in4pcb)); #ifdef INET6 @@ -260,7 +260,7 @@ inpcb_create(struct socket *so, void *v) inp_lhash); inpcb_set_state(inp, INP_ATTACHED); splx(s); - return (0); + return 0; } static int @@ -291,7 +291,7 @@ inpcb_set_port(struct sockaddr_in *sin, error = kauth_authorize_network(cred, KAUTH_NETWORK_BIND, req, so, sin, NULL); if (error) - return (EACCES); + return EACCES; /* * Use RFC6056 randomized port selection @@ -306,7 +306,7 @@ inpcb_set_port(struct sockaddr_in *sin, inp->inp_lport = lport; inpcb_set_state(inp, INP_BOUND); - return (0); + return 0; } int @@ -318,7 +318,7 @@ inpcb_bindableaddr(const struct inpcb *i int s; if (sin->sin_family != AF_INET) - return (EAFNOSUPPORT); + return EAFNOSUPPORT; s = pserialize_read_enter(); if (IN_MULTICAST(sin->sin_addr.s_addr)) { @@ -382,7 +382,7 @@ inpcb_bind_port(struct inpcb *inp, struc if (sin->sin_port == 0) { error = inpcb_set_port(sin, inp, cred); if (error) - return (error); + return error; } else { struct inpcb *t; vestigial_inpcb_t vestige; @@ -405,13 +405,13 @@ inpcb_bind_port(struct inpcb *inp, struc error = kauth_authorize_network(cred, KAUTH_NETWORK_BIND, req, so, sin, NULL); if (error) - return (EACCES); + return EACCES; #ifdef INET6 in6_in_2_v4mapin6(>sin_addr, ); t6 = in6pcb_lookup_local(table, , sin->sin_port, wild, ); if (t6 && (reuseport & t6->inp_socket->so_options) == 0) - return (EADDRINUSE); + return EADDRINUSE; if (!t6 && vestige.valid) { if (!!reuseport != !!vestige.reuse_port) { return EADDRINUSE; @@ -432,7 +432,7 @@ inpcb_bind_port(struct inpcb *inp, struc !in_nullhost(in4p_laddr(t)) || (t->inp_socket->so_options & SO_REUSEPORT) == 0) && (so->so_uidinfo->ui_uid != t->inp_socket->so_uidinfo->ui_uid)) { -return (EADDRINUSE); +return EADDRINUSE; } if (!t && vestige.valid) { if ((!in_nullhost(sin->sin_addr) @@ -445,7 +445,7 @@ inpcb_bind_port(struct inpcb *inp, struc } t = inpcb_lookup_local(table, sin->sin_addr, sin->sin_port, wild, ); if (t && (reuseport & t->inp_socket->so_options) == 0) - return (EADDRINUSE); + return EADDRINUSE; if (!t && vestige.valid && !(reuseport && vestige.reuse_port)) @@ -459,7 +459,7 @@ inpcb_bind_port(struct inpcb *inp, struc LIST_INSERT_HEAD(INPCBHASH_PORT(table, inp->inp_lport), inp, inp_lhash); - return (0); + return 0; } int @@ -470,14 +470,14 @@ inpcb_bind(void *v, struct sockaddr_in * int error; if (inp->inp_af != AF_INET) - return (EINVAL); + return EINVAL; if (inp->inp_lport || !in_nullhost(in4p_laddr(inp))) - return (EINVAL); + return EINVAL; if (NULL != sin) { if (sin->sin_len != sizeof(*sin)) - return (EINVAL); + return EINVAL; } else { lsin = *((const struct sockaddr_in *) inp->inp_socket->so_proto->pr_domain->dom_sa_any); @@ -487,17 +487,17 @@ inpcb_bind(void *v, struct sockaddr_in * /* Bind address. */ error = inpcb_bind_addr(inp, sin, l->l_cred); if (error) - return (error); + return error; /* Bind port. */ error = inpcb_bind_port(inp, sin, l->l_cred); if (error) { in4p_laddr(inp).s_addr = INADDR_ANY; - return (error); + return error; } - return (0); + return 0; } /* @@ -515,14 +515,14 @@ inpcb_connect(void *v, struct sockaddr_i struct in_addr laddr; if (inp->inp_af != AF_INET) - return (EINVAL); + return EINVAL; if (sin->sin_len != sizeof (*sin)) - return (EINVAL); + return EINVAL; if
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:04:27 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c src/sys/netinet6: in6_pcb.c Log Message: inpcb: get rid of parentheses for return value To generate a diff of this commit: cvs rdiff -u -r1.199 -r1.200 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.176 -r1.177 src/sys/netinet6/in6_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:03:56 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: use NULL To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/sys/netinet/in_pcb.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/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.198 src/sys/netinet/in_pcb.c:1.199 --- src/sys/netinet/in_pcb.c:1.198 Fri Nov 4 09:03:20 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:03:56 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.198 2022/11/04 09:03:20 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.199 2022/11/04 09:03:56 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.198 2022/11/04 09:03:20 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.199 2022/11/04 09:03:56 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -747,7 +747,7 @@ inpcb_notify(struct inpcbtable *table, s in_port_t fport = fport_arg, lport = lport_arg; int nmatch; - if (in_nullhost(faddr) || notify == 0) + if (in_nullhost(faddr) || notify == NULL) return (0); nmatch = 0; @@ -773,7 +773,7 @@ inpcb_notifyall(struct inpcbtable *table { struct inpcb *inp; - if (in_nullhost(faddr) || notify == 0) + if (in_nullhost(faddr) || notify == NULL) return; TAILQ_FOREACH(inp, >inpt_queue, inp_queue) {
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:03:56 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: use NULL To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/sys/netinet/in_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:03:20 UTC 2022 Modified Files: src/sys/netinet: in.c in_pcb.c in_pcb.h src/sys/netinet6: in6_pcb.c Log Message: inpcb: use in_port_t for port numbers To generate a diff of this commit: cvs rdiff -u -r1.243 -r1.244 src/sys/netinet/in.c cvs rdiff -u -r1.197 -r1.198 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.75 -r1.76 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.175 -r1.176 src/sys/netinet6/in6_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:03:20 UTC 2022 Modified Files: src/sys/netinet: in.c in_pcb.c in_pcb.h src/sys/netinet6: in6_pcb.c Log Message: inpcb: use in_port_t for port numbers To generate a diff of this commit: cvs rdiff -u -r1.243 -r1.244 src/sys/netinet/in.c cvs rdiff -u -r1.197 -r1.198 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.75 -r1.76 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.175 -r1.176 src/sys/netinet6/in6_pcb.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/in.c diff -u src/sys/netinet/in.c:1.243 src/sys/netinet/in.c:1.244 --- src/sys/netinet/in.c:1.243 Tue Sep 20 02:23:37 2022 +++ src/sys/netinet/in.c Fri Nov 4 09:03:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.243 2022/09/20 02:23:37 knakahara Exp $ */ +/* $NetBSD: in.c,v 1.244 2022/11/04 09:03:20 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.243 2022/09/20 02:23:37 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.244 2022/11/04 09:03:20 ozaki-r Exp $"); #include "arp.h" @@ -1861,7 +1861,7 @@ in_selectsrc(struct sockaddr_in *sin, st ia = ifatoia(ifa); } if (ia == NULL) { - u_int16_t fport = sin->sin_port; + in_port_t fport = sin->sin_port; struct ifaddr *ifa; int s; Index: src/sys/netinet/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.197 src/sys/netinet/in_pcb.c:1.198 --- src/sys/netinet/in_pcb.c:1.197 Fri Nov 4 09:02:38 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:03:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.197 2022/11/04 09:02:38 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.198 2022/11/04 09:03:20 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.197 2022/11/04 09:02:38 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.198 2022/11/04 09:03:20 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -187,7 +187,7 @@ inpcb_init(struct inpcbtable *table, int table->inpt_connecthashtbl = hashinit(connecthashsize, HASH_LIST, true, >inpt_connecthash); table->inpt_lastlow = IPPORT_RESERVEDMAX; - table->inpt_lastport = (u_int16_t)anonportmax; + table->inpt_lastport = (in_port_t)anonportmax; RUN_ONCE(, inpcb_poolinit); } @@ -268,8 +268,8 @@ inpcb_set_port(struct sockaddr_in *sin, { struct inpcbtable *table = inp->inp_table; struct socket *so = inp->inp_socket; - u_int16_t *lastport; - u_int16_t lport = 0; + in_port_t *lastport; + in_port_t lport = 0; enum kauth_network_req req; int error; @@ -744,7 +744,7 @@ inpcb_notify(struct inpcbtable *table, s { struct inpcbhead *head; struct inpcb *inp; - u_int16_t fport = fport_arg, lport = lport_arg; + in_port_t fport = fport_arg, lport = lport_arg; int nmatch; if (in_nullhost(faddr) || notify == 0) @@ -926,7 +926,7 @@ inpcb_lookup_local(struct inpcbtable *ta struct inpcb *match = NULL; int matchwild = 3; int wildcard; - u_int16_t lport = lport_arg; + in_port_t lport = lport_arg; if (vp) vp->valid = 0; @@ -1034,7 +1034,7 @@ inpcb_lookup(struct inpcbtable *table, { struct inpcbhead *head; struct inpcb *inp; - u_int16_t fport = fport_arg, lport = lport_arg; + in_port_t fport = fport_arg, lport = lport_arg; if (vp) vp->valid = 0; @@ -1080,7 +1080,7 @@ inpcb_lookup_bound(struct inpcbtable *ta { struct inpcbhead *head; struct inpcb *inp; - u_int16_t lport = lport_arg; + in_port_t lport = lport_arg; head = INPCBHASH_BIND(table, laddr, lport); LIST_FOREACH(inp, head, inp_hash) { Index: src/sys/netinet/in_pcb.h diff -u src/sys/netinet/in_pcb.h:1.75 src/sys/netinet/in_pcb.h:1.76 --- src/sys/netinet/in_pcb.h:1.75 Fri Nov 4 09:01:53 2022 +++ src/sys/netinet/in_pcb.h Fri Nov 4 09:03:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.h,v 1.75 2022/11/04 09:01:53 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.h,v 1.76 2022/11/04 09:03:20 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -101,8 +101,8 @@ struct inpcb { struct inpcbtable *inp_table; struct inpcbpolicy *inp_sp; /* security policy */ struct route inp_route; /* placeholder for routing entry */ - u_int16_t inp_fport; /* foreign port */ - u_int16_t inp_lport; /* local port */ + in_port_t inp_fport; /* foreign port */ + in_port_t inp_lport; /* local port */ int inp_flags; /* generic IP/datagram flags */ struct mbuf *inp_options; /* IP options */ bool inp_bindportonsend; @@ -232,8 +232,8 @@ struct inpcbtable { u_long inpt_porthash; u_long inpt_bindhash; u_long inpt_connecthash; - u_int16_t inpt_lastport; - u_int16_t inpt_lastlow; + in_port_t inpt_lastport; + in_port_t inpt_lastlow; struct vestigial_hooks *vestige; }; Index: src/sys/netinet6/in6_pcb.c diff -u src/sys/netinet6/in6_pcb.c:1.175
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:02:38 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: use pool_cache instead of pool To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 src/sys/netinet/in_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:02:38 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: use pool_cache instead of pool To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 src/sys/netinet/in_pcb.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/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.196 src/sys/netinet/in_pcb.c:1.197 --- src/sys/netinet/in_pcb.c:1.196 Fri Nov 4 09:01:53 2022 +++ src/sys/netinet/in_pcb.c Fri Nov 4 09:02:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.196 2022/11/04 09:01:53 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.197 2022/11/04 09:02:38 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.196 2022/11/04 09:01:53 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.197 2022/11/04 09:02:38 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -156,20 +156,20 @@ int anonportmax = IPPORT_ANONMAX; int lowportmin = IPPORT_RESERVEDMIN; int lowportmax = IPPORT_RESERVEDMAX; -static struct pool in4pcb_pool; +static pool_cache_t in4pcb_pool_cache; #ifdef INET6 -static struct pool in6pcb_pool; +static pool_cache_t in6pcb_pool_cache; #endif static int inpcb_poolinit(void) { - pool_init(_pool, sizeof(struct in4pcb), 0, 0, 0, "in4pcbpl", NULL, - IPL_NET); + in4pcb_pool_cache = pool_cache_init(sizeof(struct in4pcb), coherency_unit, + 0, 0, "in4pcbpl", NULL, IPL_NET, NULL, NULL, NULL); #ifdef INET6 - pool_init(_pool, sizeof(struct in6pcb), 0, 0, 0, "in6pcbpl", NULL, - IPL_NET); + in6pcb_pool_cache = pool_cache_init(sizeof(struct in6pcb), coherency_unit, + 0, 0, "in6pcbpl", NULL, IPL_NET, NULL, NULL, NULL); #endif return 0; } @@ -203,22 +203,26 @@ inpcb_create(struct socket *so, void *v) KASSERT(soaf(so) == AF_INET || soaf(so) == AF_INET6); if (soaf(so) == AF_INET) - inp = pool_get(_pool, PR_NOWAIT|PR_ZERO); + inp = pool_cache_get(in4pcb_pool_cache, PR_NOWAIT); else - inp = pool_get(_pool, PR_NOWAIT|PR_ZERO); + inp = pool_cache_get(in6pcb_pool_cache, PR_NOWAIT); #else KASSERT(soaf(so) == AF_INET); - inp = pool_get(_pool, PR_NOWAIT|PR_ZERO); + inp = pool_cache_get(in4pcb_pool_cache, PR_NOWAIT); #endif if (inp == NULL) return (ENOBUFS); + if (soaf(so) == AF_INET) + memset(inp, 0, sizeof(struct in4pcb)); +#ifdef INET6 + else + memset(inp, 0, sizeof(struct in6pcb)); +#endif inp->inp_af = soaf(so); inp->inp_table = table; inp->inp_socket = so; inp->inp_portalgo = PORTALGO_DEFAULT; inp->inp_bindportonsend = false; - inp->inp_overudp_cb = NULL; - inp->inp_overudp_arg = NULL; if (inp->inp_af == AF_INET) { in4p_errormtu(inp) = -1; @@ -237,12 +241,12 @@ inpcb_create(struct socket *so, void *v) if (error != 0) { #ifdef INET6 if (inp->inp_af == AF_INET) -pool_put(_pool, inp); +pool_cache_put(in4pcb_pool_cache, inp); else -pool_put(_pool, inp); +pool_cache_put(in6pcb_pool_cache, inp); #else KASSERT(inp->inp_af == AF_INET); - pool_put(_pool, inp); + pool_cache_put(in4pcb_pool_cache, inp); #endif return error; } @@ -692,12 +696,12 @@ inpcb_destroy(void *v) #ifdef INET6 if (inp->inp_af == AF_INET) - pool_put(_pool, inp); + pool_cache_put(in4pcb_pool_cache, inp); else - pool_put(_pool, inp); + pool_cache_put(in6pcb_pool_cache, inp); #else KASSERT(inp->inp_af == AF_INET); - pool_put(_pool, inp); + pool_cache_put(in4pcb_pool_cache, inp); #endif mutex_enter(softnet_lock); /* reacquire the softnet_lock */ }
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:01:54 UTC 2022 Modified Files: src/sys/dist/pf/net: pf.c src/sys/netinet: dccp_usrreq.c in_pcb.c in_pcb.h portalgo.c sctp_output.c tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c tcp_usrreq.c src/sys/netinet6: dccp6_usrreq.c in6_pcb.c in6_src.c raw_ip6.c sctp6_usrreq.c udp6_usrreq.c Log Message: inpcb: rename functions to in6pcb_* To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/dist/pf/net/pf.c cvs rdiff -u -r1.25 -r1.26 src/sys/netinet/dccp_usrreq.c cvs rdiff -u -r1.195 -r1.196 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.74 -r1.75 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.14 -r1.15 src/sys/netinet/portalgo.c cvs rdiff -u -r1.32 -r1.33 src/sys/netinet/sctp_output.c cvs rdiff -u -r1.437 -r1.438 src/sys/netinet/tcp_input.c cvs rdiff -u -r1.217 -r1.218 src/sys/netinet/tcp_output.c cvs rdiff -u -r1.295 -r1.296 src/sys/netinet/tcp_subr.c cvs rdiff -u -r1.5 -r1.6 src/sys/netinet/tcp_syncache.c cvs rdiff -u -r1.237 -r1.238 src/sys/netinet/tcp_usrreq.c cvs rdiff -u -r1.14 -r1.15 src/sys/netinet6/dccp6_usrreq.c cvs rdiff -u -r1.174 -r1.175 src/sys/netinet6/in6_pcb.c cvs rdiff -u -r1.90 -r1.91 src/sys/netinet6/in6_src.c cvs rdiff -u -r1.181 -r1.182 src/sys/netinet6/raw_ip6.c cvs rdiff -u -r1.23 -r1.24 src/sys/netinet6/sctp6_usrreq.c cvs rdiff -u -r1.153 -r1.154 src/sys/netinet6/udp6_usrreq.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/dist/pf/net/pf.c diff -u src/sys/dist/pf/net/pf.c:1.86 src/sys/dist/pf/net/pf.c:1.87 --- src/sys/dist/pf/net/pf.c:1.86 Fri Nov 4 09:00:58 2022 +++ src/sys/dist/pf/net/pf.c Fri Nov 4 09:01:53 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pf.c,v 1.86 2022/11/04 09:00:58 ozaki-r Exp $ */ +/* $NetBSD: pf.c,v 1.87 2022/11/04 09:01:53 ozaki-r Exp $ */ /* $OpenBSD: pf.c,v 1.552.2.1 2007/11/27 16:37:57 henning Exp $ */ /* @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.86 2022/11/04 09:00:58 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.87 2022/11/04 09:01:53 ozaki-r Exp $"); #include "pflog.h" @@ -2802,11 +2802,11 @@ pf_socket_lookup(int direction, struct p #define in_pcbhashlookup(tbl, saddr, sport, daddr, dport) \ inpcb_lookup(tbl, saddr, sport, daddr, dport, NULL) #define in6_pcbhashlookup(tbl, saddr, sport, daddr, dport) \ -in6_pcblookup_connect(tbl, saddr, sport, daddr, dport, 0, NULL) +in6pcb_lookup(tbl, saddr, sport, daddr, dport, 0, NULL) #define in_pcblookup_listen(tbl, addr, port, zero) \ inpcb_lookup_bound(tbl, addr, port) #define in6_pcblookup_listen(tbl, addr, port, zero) \ -in6_pcblookup_bind(tbl, addr, port, zero) +in6pcb_lookup_bound(tbl, addr, port, zero) #endif #ifdef INET Index: src/sys/netinet/dccp_usrreq.c diff -u src/sys/netinet/dccp_usrreq.c:1.25 src/sys/netinet/dccp_usrreq.c:1.26 --- src/sys/netinet/dccp_usrreq.c:1.25 Fri Nov 4 09:00:58 2022 +++ src/sys/netinet/dccp_usrreq.c Fri Nov 4 09:01:53 2022 @@ -1,5 +1,5 @@ /* $KAME: dccp_usrreq.c,v 1.67 2005/11/03 16:05:04 nishida Exp $ */ -/* $NetBSD: dccp_usrreq.c,v 1.25 2022/11/04 09:00:58 ozaki-r Exp $ */ +/* $NetBSD: dccp_usrreq.c,v 1.26 2022/11/04 09:01:53 ozaki-r Exp $ */ /* * Copyright (c) 2003 Joacim Häggmark, Magnus Erixzon, Nils-Erik Mattsson @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.25 2022/11/04 09:00:58 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.26 2022/11/04 09:01:53 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -337,11 +337,11 @@ dccp_input(struct mbuf *m, int off, int */ #ifdef INET6 if (isipv6) { - inp = in6_pcblookup_connect(, >ip6_src, + inp = in6pcb_lookup(, >ip6_src, dh->dh_sport, >ip6_dst, dh->dh_dport, 0, 0); if (inp == NULL) { /* XXX stats increment? */ - inp = in6_pcblookup_bind(, >ip6_dst, + inp = in6pcb_lookup_bound(, >ip6_dst, dh->dh_dport, 0); } } else @@ -1779,8 +1779,8 @@ dccp_doconnect(struct socket *so, struct if (inp->inp_lport == 0) { #ifdef INET6 if (isipv6) { - DCCP_DEBUG((LOG_INFO, "Running in6_pcbbind!\n")); - error = in6_pcbbind(inp, NULL, l); + DCCP_DEBUG((LOG_INFO, "Running in6pcb_bind!\n")); + error = in6pcb_bind(inp, NULL, l); } else #endif /* INET6 */ { @@ -1794,8 +1794,8 @@ dccp_doconnect(struct socket *so, struct #ifdef INET6 if (isipv6) { - error = in6_pcbconnect(inp, (struct sockaddr_in6 *)nam, l); - DCCP_DEBUG((LOG_INFO, "in6_pcbconnect=%d\n",error)); + error = in6pcb_connect(inp, (struct sockaddr_in6 *)nam, l); + DCCP_DEBUG((LOG_INFO, "in6pcb_connect=%d\n",error)); } else #endif error = inpcb_connect(inp, (struct sockaddr_in *)nam, l); @@ -2133,7 +2133,7 @@ dccp_newdccpcb(int family, void *aux) in4p_ip(inp).ip_ttl = ip_defttl; break; case PF_INET6: - in6p_ip6(inp).ip6_hlim =
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:01:54 UTC 2022 Modified Files: src/sys/dist/pf/net: pf.c src/sys/netinet: dccp_usrreq.c in_pcb.c in_pcb.h portalgo.c sctp_output.c tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c tcp_usrreq.c src/sys/netinet6: dccp6_usrreq.c in6_pcb.c in6_src.c raw_ip6.c sctp6_usrreq.c udp6_usrreq.c Log Message: inpcb: rename functions to in6pcb_* To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/dist/pf/net/pf.c cvs rdiff -u -r1.25 -r1.26 src/sys/netinet/dccp_usrreq.c cvs rdiff -u -r1.195 -r1.196 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.74 -r1.75 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.14 -r1.15 src/sys/netinet/portalgo.c cvs rdiff -u -r1.32 -r1.33 src/sys/netinet/sctp_output.c cvs rdiff -u -r1.437 -r1.438 src/sys/netinet/tcp_input.c cvs rdiff -u -r1.217 -r1.218 src/sys/netinet/tcp_output.c cvs rdiff -u -r1.295 -r1.296 src/sys/netinet/tcp_subr.c cvs rdiff -u -r1.5 -r1.6 src/sys/netinet/tcp_syncache.c cvs rdiff -u -r1.237 -r1.238 src/sys/netinet/tcp_usrreq.c cvs rdiff -u -r1.14 -r1.15 src/sys/netinet6/dccp6_usrreq.c cvs rdiff -u -r1.174 -r1.175 src/sys/netinet6/in6_pcb.c cvs rdiff -u -r1.90 -r1.91 src/sys/netinet6/in6_src.c cvs rdiff -u -r1.181 -r1.182 src/sys/netinet6/raw_ip6.c cvs rdiff -u -r1.23 -r1.24 src/sys/netinet6/sctp6_usrreq.c cvs rdiff -u -r1.153 -r1.154 src/sys/netinet6/udp6_usrreq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:00:59 UTC 2022 Modified Files: src/sys/dist/pf/net: pf.c src/sys/net: if_wg.c src/sys/netcan: can.c src/sys/netinet: dccp_usrreq.c in_pcb.c in_pcb.h ip_output.c portalgo.c raw_ip.c sctp_usrreq.c tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c tcp_timer.c tcp_usrreq.c tcp_vtw.c udp_usrreq.c src/sys/netinet6: in6_pcb.c raw_ip6.c udp6_usrreq.c src/sys/netipsec: ipsec.c Log Message: inpcb: rename functions to inpcb_* Inspired by rmind-smpnet patches. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/dist/pf/net/pf.c cvs rdiff -u -r1.70 -r1.71 src/sys/net/if_wg.c cvs rdiff -u -r1.12 -r1.13 src/sys/netcan/can.c cvs rdiff -u -r1.24 -r1.25 src/sys/netinet/dccp_usrreq.c cvs rdiff -u -r1.194 -r1.195 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.73 -r1.74 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.322 -r1.323 src/sys/netinet/ip_output.c cvs rdiff -u -r1.13 -r1.14 src/sys/netinet/portalgo.c cvs rdiff -u -r1.183 -r1.184 src/sys/netinet/raw_ip.c cvs rdiff -u -r1.22 -r1.23 src/sys/netinet/sctp_usrreq.c cvs rdiff -u -r1.436 -r1.437 src/sys/netinet/tcp_input.c cvs rdiff -u -r1.216 -r1.217 src/sys/netinet/tcp_output.c cvs rdiff -u -r1.294 -r1.295 src/sys/netinet/tcp_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/netinet/tcp_syncache.c cvs rdiff -u -r1.98 -r1.99 src/sys/netinet/tcp_timer.c cvs rdiff -u -r1.236 -r1.237 src/sys/netinet/tcp_usrreq.c cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/tcp_vtw.c cvs rdiff -u -r1.263 -r1.264 src/sys/netinet/udp_usrreq.c cvs rdiff -u -r1.173 -r1.174 src/sys/netinet6/in6_pcb.c cvs rdiff -u -r1.180 -r1.181 src/sys/netinet6/raw_ip6.c cvs rdiff -u -r1.152 -r1.153 src/sys/netinet6/udp6_usrreq.c cvs rdiff -u -r1.174 -r1.175 src/sys/netipsec/ipsec.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/dist/pf/net/pf.c diff -u src/sys/dist/pf/net/pf.c:1.85 src/sys/dist/pf/net/pf.c:1.86 --- src/sys/dist/pf/net/pf.c:1.85 Fri Oct 28 05:20:08 2022 +++ src/sys/dist/pf/net/pf.c Fri Nov 4 09:00:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pf.c,v 1.85 2022/10/28 05:20:08 ozaki-r Exp $ */ +/* $NetBSD: pf.c,v 1.86 2022/11/04 09:00:58 ozaki-r Exp $ */ /* $OpenBSD: pf.c,v 1.552.2.1 2007/11/27 16:37:57 henning Exp $ */ /* @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.85 2022/10/28 05:20:08 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.86 2022/11/04 09:00:58 ozaki-r Exp $"); #include "pflog.h" @@ -2455,7 +2455,7 @@ pf_get_sport(sa_family_t af, u_int8_t pr /* * port search; start random, step; - * similar 2 portloop in in_pcbbind + * similar 2 portloop in inpcb_bind */ if (!(proto == IPPROTO_TCP || proto == IPPROTO_UDP || proto == IPPROTO_ICMP)) { @@ -2800,11 +2800,11 @@ pf_socket_lookup(int direction, struct p #ifdef __NetBSD__ #define in_pcbhashlookup(tbl, saddr, sport, daddr, dport) \ -in_pcblookup_connect(tbl, saddr, sport, daddr, dport, NULL) +inpcb_lookup(tbl, saddr, sport, daddr, dport, NULL) #define in6_pcbhashlookup(tbl, saddr, sport, daddr, dport) \ in6_pcblookup_connect(tbl, saddr, sport, daddr, dport, 0, NULL) #define in_pcblookup_listen(tbl, addr, port, zero) \ -in_pcblookup_bind(tbl, addr, port) +inpcb_lookup_bound(tbl, addr, port) #define in6_pcblookup_listen(tbl, addr, port, zero) \ in6_pcblookup_bind(tbl, addr, port, zero) #endif Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.70 src/sys/net/if_wg.c:1.71 --- src/sys/net/if_wg.c:1.70 Fri Oct 28 05:20:08 2022 +++ src/sys/net/if_wg.c Fri Nov 4 09:00:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.70 2022/10/28 05:20:08 ozaki-r Exp $ */ +/* $NetBSD: if_wg.c,v 1.71 2022/11/04 09:00:58 ozaki-r Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.70 2022/10/28 05:20:08 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.71 2022/11/04 09:00:58 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -3266,7 +3266,7 @@ wg_socreate(struct wg_softc *wg, int af, so->so_upcallarg = wg; so->so_upcall = wg_so_upcall; so->so_rcv.sb_flags |= SB_UPCALL; - in_pcb_register_overudp_cb(sotoinpcb(so), wg_overudp_cb, wg); + inpcb_register_overudp_cb(sotoinpcb(so), wg_overudp_cb, wg); sounlock(so); *sop = so; Index: src/sys/netcan/can.c diff -u src/sys/netcan/can.c:1.12 src/sys/netcan/can.c:1.13 --- src/sys/netcan/can.c:1.12 Sat Sep 3 02:07:32 2022 +++ src/sys/netcan/can.c Fri Nov 4 09:00:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: can.c,v 1.12 2022/09/03 02:07:32 thorpej Exp $ */ +/* $NetBSD: can.c,v 1.13 2022/11/04 09:00:58 ozaki-r Exp $ */ /*- * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__K
CVS commit: src/sys
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 09:00:59 UTC 2022 Modified Files: src/sys/dist/pf/net: pf.c src/sys/net: if_wg.c src/sys/netcan: can.c src/sys/netinet: dccp_usrreq.c in_pcb.c in_pcb.h ip_output.c portalgo.c raw_ip.c sctp_usrreq.c tcp_input.c tcp_output.c tcp_subr.c tcp_syncache.c tcp_timer.c tcp_usrreq.c tcp_vtw.c udp_usrreq.c src/sys/netinet6: in6_pcb.c raw_ip6.c udp6_usrreq.c src/sys/netipsec: ipsec.c Log Message: inpcb: rename functions to inpcb_* Inspired by rmind-smpnet patches. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/dist/pf/net/pf.c cvs rdiff -u -r1.70 -r1.71 src/sys/net/if_wg.c cvs rdiff -u -r1.12 -r1.13 src/sys/netcan/can.c cvs rdiff -u -r1.24 -r1.25 src/sys/netinet/dccp_usrreq.c cvs rdiff -u -r1.194 -r1.195 src/sys/netinet/in_pcb.c cvs rdiff -u -r1.73 -r1.74 src/sys/netinet/in_pcb.h cvs rdiff -u -r1.322 -r1.323 src/sys/netinet/ip_output.c cvs rdiff -u -r1.13 -r1.14 src/sys/netinet/portalgo.c cvs rdiff -u -r1.183 -r1.184 src/sys/netinet/raw_ip.c cvs rdiff -u -r1.22 -r1.23 src/sys/netinet/sctp_usrreq.c cvs rdiff -u -r1.436 -r1.437 src/sys/netinet/tcp_input.c cvs rdiff -u -r1.216 -r1.217 src/sys/netinet/tcp_output.c cvs rdiff -u -r1.294 -r1.295 src/sys/netinet/tcp_subr.c cvs rdiff -u -r1.4 -r1.5 src/sys/netinet/tcp_syncache.c cvs rdiff -u -r1.98 -r1.99 src/sys/netinet/tcp_timer.c cvs rdiff -u -r1.236 -r1.237 src/sys/netinet/tcp_usrreq.c cvs rdiff -u -r1.23 -r1.24 src/sys/netinet/tcp_vtw.c cvs rdiff -u -r1.263 -r1.264 src/sys/netinet/udp_usrreq.c cvs rdiff -u -r1.173 -r1.174 src/sys/netinet6/in6_pcb.c cvs rdiff -u -r1.180 -r1.181 src/sys/netinet6/raw_ip6.c cvs rdiff -u -r1.152 -r1.153 src/sys/netinet6/udp6_usrreq.c cvs rdiff -u -r1.174 -r1.175 src/sys/netipsec/ipsec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 08:01:42 UTC 2022 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net/tcp: Makefile Added Files: src/tests/net/tcp: t_tcp_shutdown.sh tcp_shutdown.c Log Message: tests: add tests for invalid extra operations on a shutdown socket The tests cover some error paths that normally happen. To generate a diff of this commit: cvs rdiff -u -r1.389 -r1.390 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1226 -r1.1227 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.194 -r1.195 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.1 -r1.2 src/tests/net/tcp/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/tcp/t_tcp_shutdown.sh \ src/tests/net/tcp/tcp_shutdown.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 08:01:42 UTC 2022 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net/tcp: Makefile Added Files: src/tests/net/tcp: t_tcp_shutdown.sh tcp_shutdown.c Log Message: tests: add tests for invalid extra operations on a shutdown socket The tests cover some error paths that normally happen. To generate a diff of this commit: cvs rdiff -u -r1.389 -r1.390 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1226 -r1.1227 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.194 -r1.195 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.1 -r1.2 src/tests/net/tcp/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/tcp/t_tcp_shutdown.sh \ src/tests/net/tcp/tcp_shutdown.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.389 src/distrib/sets/lists/debug/mi:1.390 --- src/distrib/sets/lists/debug/mi:1.389 Sun Aug 28 07:30:41 2022 +++ src/distrib/sets/lists/debug/mi Fri Nov 4 08:01:42 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.389 2022/08/28 07:30:41 christos Exp $ +# $NetBSD: mi,v 1.390 2022/11/04 08:01:42 ozaki-r Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib comp-sys-usr compatdir ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile @@ -2437,6 +2437,7 @@ ./usr/libdata/debug/usr/tests/net/sys/t_listen.debug tests-obsolete obsolete,compattestfile ./usr/libdata/debug/usr/tests/net/sys/t_rfc6056.debug tests-net-debug debug,atf,compattestfile ./usr/libdata/debug/usr/tests/net/sys/t_socketpair.debug tests-obsolete obsolete,compattestfile +./usr/libdata/debug/usr/tests/net/tcp/tcp_shutdown.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/rump/modautoload/t_modautoload.debug tests-syscall-debug debug,atf,rump ./usr/libdata/debug/usr/tests/rump/rumpkern/h_client/h_forkcli.debug tests-syscall-debug debug,atf,rump ./usr/libdata/debug/usr/tests/rump/rumpkern/h_client/h_reboot.debug tests-obsolete obsolete Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1226 src/distrib/sets/lists/tests/mi:1.1227 --- src/distrib/sets/lists/tests/mi:1.1226 Fri Nov 4 07:54:27 2022 +++ src/distrib/sets/lists/tests/mi Fri Nov 4 08:01:42 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1226 2022/11/04 07:54:27 ozaki-r Exp $ +# $NetBSD: mi,v 1.1227 2022/11/04 08:01:42 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -178,6 +178,7 @@ ./usr/libdata/debug/usr/tests/net/mcast tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/net tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/net/sys tests-net-debug compattestfile,atf +./usr/libdata/debug/usr/tests/net/tcp tests-net-debug compattestfile,atf ./usr/libdata/debug/usr/tests/rump tests-syscall-debug compattestfile,atf ./usr/libdata/debug/usr/tests/rump/modautoload tests-syscall-debug compattestfile,atf ./usr/libdata/debug/usr/tests/rump/rumpkern tests-syscall-debug compattestfile,atf @@ -4286,7 +4287,9 @@ ./usr/tests/net/tcp tests-net-tests compattestfile,atf ./usr/tests/net/tcp/Atffiletests-net-tests atf,rump ./usr/tests/net/tcp/Kyuafiletests-net-tests atf,rump,kyua +./usr/tests/net/tcp/tcp_shutdown tests-net-tests atf,rump ./usr/tests/net/tcp/t_tcp_nctests-net-tests atf,rump +./usr/tests/net/tcp/t_tcp_shutdown tests-net-tests atf,rump ./usr/tests/net/wireguardtests-obsolete obsolete ./usr/tests/net/wireguard/Atffile tests-obsolete obsolete ./usr/tests/net/wireguard/Kyuafile tests-obsolete obsolete Index: src/etc/mtree/NetBSD.dist.tests diff -u src/etc/mtree/NetBSD.dist.tests:1.194 src/etc/mtree/NetBSD.dist.tests:1.195 --- src/etc/mtree/NetBSD.dist.tests:1.194 Wed Nov 2 09:37:56 2022 +++ src/etc/mtree/NetBSD.dist.tests Fri Nov 4 08:01:42 2022 @@ -1,4 +1,4 @@ -# $NetBSD: NetBSD.dist.tests,v 1.194 2022/11/02 09:37:56 ozaki-r Exp $ +# $NetBSD: NetBSD.dist.tests,v 1.195 2022/11/04 08:01:42 ozaki-r Exp $ ./usr/libdata/debug/usr/tests ./usr/libdata/debug/usr/tests/atf @@ -158,6 +158,7 @@ ./usr/libdata/debug/usr/tests/net/mcast ./usr/libdata/debug/usr/tests/net/net ./usr/libdata/debug/usr/tests/net/sys +./usr/libdata/debug/usr/tests/net/tcp ./usr/libdata/debug/usr/tests/rump ./usr/libdata/debug/usr/tests/rump/modautoload ./usr/libdata/debug/usr/tests/rump/rumpkern Index: src/tests/net/tcp/Makefile diff -u src/tests/net/tcp/Makefile:1.1 src/tests/net/tcp/Makefile:1.2 --- src/tests/net/tcp/Makefile:1.1 Wed Nov 2 09:37:56 2022 +++ src/tests/net/tcp/Makefile Fri Nov 4 08:01:42 2022 @@ -1,13 +1,17 @@ -# $NetBSD: Makefile,v 1.1 2022/11/02 09:37:56 ozaki-r Exp $ +# $NetBSD: Makefile,v 1.2 2022/11/04 08:01:42
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 07:54:28 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi Log Message: sets: fix wrong keywords for tests/net/tcp To generate a diff of this commit: cvs rdiff -u -r1.1225 -r1.1226 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1225 src/distrib/sets/lists/tests/mi:1.1226 --- src/distrib/sets/lists/tests/mi:1.1225 Wed Nov 2 09:37:56 2022 +++ src/distrib/sets/lists/tests/mi Fri Nov 4 07:54:27 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1225 2022/11/02 09:37:56 ozaki-r Exp $ +# $NetBSD: mi,v 1.1226 2022/11/04 07:54:27 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4284,9 +4284,9 @@ ./usr/tests/net/sys/t_rfc6056tests-net-tests compattestfile,atf ./usr/tests/net/sys/t_socketpair tests-obsolete obsolete ./usr/tests/net/tcp tests-net-tests compattestfile,atf -./usr/tests/net/tcp/Atffiletests-net-tests compattestfile,atf -./usr/tests/net/tcp/Kyuafiletests-net-tests compattestfile,atf,kyua -./usr/tests/net/tcp/t_tcp_nctests-net-tests compattestfile,atf +./usr/tests/net/tcp/Atffiletests-net-tests atf,rump +./usr/tests/net/tcp/Kyuafiletests-net-tests atf,rump,kyua +./usr/tests/net/tcp/t_tcp_nctests-net-tests atf,rump ./usr/tests/net/wireguardtests-obsolete obsolete ./usr/tests/net/wireguard/Atffile tests-obsolete obsolete ./usr/tests/net/wireguard/Kyuafile tests-obsolete obsolete
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: ozaki-r Date: Fri Nov 4 07:54:28 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi Log Message: sets: fix wrong keywords for tests/net/tcp To generate a diff of this commit: cvs rdiff -u -r1.1225 -r1.1226 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Wed Nov 2 09:37:56 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net: Makefile Added Files: src/tests/net/tcp: Makefile t_tcp_nc.sh Log Message: tests: add tests for TCP with nc To generate a diff of this commit: cvs rdiff -u -r1.1224 -r1.1225 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.193 -r1.194 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.39 -r1.40 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/tcp/Makefile \ src/tests/net/tcp/t_tcp_nc.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1224 src/distrib/sets/lists/tests/mi:1.1225 --- src/distrib/sets/lists/tests/mi:1.1224 Tue Oct 11 09:55:21 2022 +++ src/distrib/sets/lists/tests/mi Wed Nov 2 09:37:56 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1224 2022/10/11 09:55:21 knakahara Exp $ +# $NetBSD: mi,v 1.1225 2022/11/02 09:37:56 ozaki-r Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4283,6 +4283,10 @@ ./usr/tests/net/sys/t_listentests-obsolete obsolete ./usr/tests/net/sys/t_rfc6056tests-net-tests compattestfile,atf ./usr/tests/net/sys/t_socketpair tests-obsolete obsolete +./usr/tests/net/tcp tests-net-tests compattestfile,atf +./usr/tests/net/tcp/Atffiletests-net-tests compattestfile,atf +./usr/tests/net/tcp/Kyuafiletests-net-tests compattestfile,atf,kyua +./usr/tests/net/tcp/t_tcp_nctests-net-tests compattestfile,atf ./usr/tests/net/wireguardtests-obsolete obsolete ./usr/tests/net/wireguard/Atffile tests-obsolete obsolete ./usr/tests/net/wireguard/Kyuafile tests-obsolete obsolete Index: src/etc/mtree/NetBSD.dist.tests diff -u src/etc/mtree/NetBSD.dist.tests:1.193 src/etc/mtree/NetBSD.dist.tests:1.194 --- src/etc/mtree/NetBSD.dist.tests:1.193 Thu Jul 21 09:52:48 2022 +++ src/etc/mtree/NetBSD.dist.tests Wed Nov 2 09:37:56 2022 @@ -1,4 +1,4 @@ -# $NetBSD: NetBSD.dist.tests,v 1.193 2022/07/21 09:52:48 kre Exp $ +# $NetBSD: NetBSD.dist.tests,v 1.194 2022/11/02 09:37:56 ozaki-r Exp $ ./usr/libdata/debug/usr/tests ./usr/libdata/debug/usr/tests/atf @@ -382,6 +382,7 @@ ./usr/tests/net/npf ./usr/tests/net/route ./usr/tests/net/sys +./usr/tests/net/tcp ./usr/tests/rump ./usr/tests/rump/modautoload ./usr/tests/rump/rumpkern Index: src/tests/net/Makefile diff -u src/tests/net/Makefile:1.39 src/tests/net/Makefile:1.40 --- src/tests/net/Makefile:1.39 Wed Jul 14 03:22:33 2021 +++ src/tests/net/Makefile Wed Nov 2 09:37:56 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.39 2021/07/14 03:22:33 ozaki-r Exp $ +# $NetBSD: Makefile,v 1.40 2022/11/02 09:37:56 ozaki-r Exp $ .include @@ -9,7 +9,7 @@ TESTS_SUBDIRS= fdpass in_cksum net sys TESTS_SUBDIRS+= altq arp bpf bpfilter can carp icmp if if_bridge if_gif TESTS_SUBDIRS+= if_ipsec if_l2tp if_lagg if_loop if_pppoe if_tap TESTS_SUBDIRS+= if_tun if_vether if_vlan if_wg ipsec mcast mpls -TESTS_SUBDIRS+= ndp npf route +TESTS_SUBDIRS+= ndp npf route tcp .if (${MKSLJIT} != "no") TESTS_SUBDIRS+= bpfjit .endif Added files: Index: src/tests/net/tcp/Makefile diff -u /dev/null src/tests/net/tcp/Makefile:1.1 --- /dev/null Wed Nov 2 09:37:56 2022 +++ src/tests/net/tcp/Makefile Wed Nov 2 09:37:56 2022 @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.1 2022/11/02 09:37:56 ozaki-r Exp $ +# + +.include + +TESTSDIR= ${TESTSBASE}/net/tcp + +.for name in tcp_nc +TESTS_SH+= t_${name} +TESTS_SH_SRC_t_${name}= ../net_common.sh t_${name}.sh +.endfor + +.include Index: src/tests/net/tcp/t_tcp_nc.sh diff -u /dev/null src/tests/net/tcp/t_tcp_nc.sh:1.1 --- /dev/null Wed Nov 2 09:37:56 2022 +++ src/tests/net/tcp/t_tcp_nc.sh Wed Nov 2 09:37:56 2022 @@ -0,0 +1,161 @@ +# $NetBSD: t_tcp_nc.sh,v 1.1 2022/11/02 09:37:56 ozaki-r Exp $ +# +# Copyright (c) 2022 Internet Initiative Japan Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +#notice, this list of conditions and the following disclaimer in the +#documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +#
CVS commit: src
Module Name:src Committed By: ozaki-r Date: Wed Nov 2 09:37:56 UTC 2022 Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/net: Makefile Added Files: src/tests/net/tcp: Makefile t_tcp_nc.sh Log Message: tests: add tests for TCP with nc To generate a diff of this commit: cvs rdiff -u -r1.1224 -r1.1225 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.193 -r1.194 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.39 -r1.40 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/tcp/Makefile \ src/tests/net/tcp/t_tcp_nc.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 2 09:35:12 UTC 2022 Modified Files: src/tests/net: net_common.sh Log Message: tests: enable start_nc_server to have extra options for nc To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/net/net_common.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net
Module Name:src Committed By: ozaki-r Date: Wed Nov 2 09:35:12 UTC 2022 Modified Files: src/tests/net: net_common.sh Log Message: tests: enable start_nc_server to have extra options for nc To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/net/net_common.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/net_common.sh diff -u src/tests/net/net_common.sh:1.43 src/tests/net/net_common.sh:1.44 --- src/tests/net/net_common.sh:1.43 Thu Nov 25 14:17:22 2021 +++ src/tests/net/net_common.sh Wed Nov 2 09:35:12 2022 @@ -1,4 +1,4 @@ -# $NetBSD: net_common.sh,v 1.43 2021/11/25 14:17:22 hannken Exp $ +# $NetBSD: net_common.sh,v 1.44 2022/11/02 09:35:12 ozaki-r Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -139,6 +139,7 @@ start_nc_server() local port=$2 local outfile=$3 local proto=${4:-ipv4} + local extra_opts="$5" local backup=$RUMP_SERVER local opts= @@ -149,6 +150,7 @@ start_nc_server() else opts="-l -6" fi + opts="$opts $extra_opts" env LD_PRELOAD=/usr/lib/librumphijack.so nc $opts $port > $outfile & echo $! > $NC_PID
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: ozaki-r Date: Wed Nov 2 09:01:42 UTC 2022 Modified Files: src/sys/rump/librump/rumpkern: lwproc.c Log Message: rump: don't touch p_nlwps without holding p_lock There was a race condition on p_nlwps. Heavy thread switching could cause a kernel panic like: panic: kernel diagnostic assertion "LIST_EMPTY(>p_lwps)" failed: file "(hidden)/src/lib/librump/../../sys/rump/librump/rumpkern/lwproc.c", line 177 To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/rump/librump/rumpkern/lwproc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: ozaki-r Date: Wed Nov 2 09:01:42 UTC 2022 Modified Files: src/sys/rump/librump/rumpkern: lwproc.c Log Message: rump: don't touch p_nlwps without holding p_lock There was a race condition on p_nlwps. Heavy thread switching could cause a kernel panic like: panic: kernel diagnostic assertion "LIST_EMPTY(>p_lwps)" failed: file "(hidden)/src/lib/librump/../../sys/rump/librump/rumpkern/lwproc.c", line 177 To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/rump/librump/rumpkern/lwproc.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/rump/librump/rumpkern/lwproc.c diff -u src/sys/rump/librump/rumpkern/lwproc.c:1.51 src/sys/rump/librump/rumpkern/lwproc.c:1.52 --- src/sys/rump/librump/rumpkern/lwproc.c:1.51 Sat May 30 19:16:53 2020 +++ src/sys/rump/librump/rumpkern/lwproc.c Wed Nov 2 09:01:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: lwproc.c,v 1.51 2020/05/30 19:16:53 ad Exp $ */ +/* $NetBSD: lwproc.c,v 1.52 2022/11/02 09:01:42 ozaki-r Exp $ */ /* * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ #define RUMP__CURLWP_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.51 2020/05/30 19:16:53 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.52 2022/11/02 09:01:42 ozaki-r Exp $"); #include #include @@ -348,6 +348,14 @@ lwproc_makelwp(struct proc *p, bool dosw { struct lwp *l = kmem_zalloc(sizeof(*l), KM_SLEEP); + l->l_refcnt = 1; + l->l_proc = p; + l->l_stat = LSIDL; + l->l_mutex = _lock; + + proc_alloc_lwpid(p, l); + + mutex_enter(p->p_lock); /* * Account the new lwp to the owner of the process. * For some reason, NetBSD doesn't count the first lwp @@ -357,14 +365,6 @@ lwproc_makelwp(struct proc *p, bool dosw chglwpcnt(kauth_cred_getuid(p->p_cred), 1); } - l->l_refcnt = 1; - l->l_proc = p; - l->l_stat = LSIDL; - l->l_mutex = _lock; - - proc_alloc_lwpid(p, l); - - mutex_enter(p->p_lock); KASSERT((p->p_sflag & PS_RUMP_LWPEXIT) == 0); LIST_INSERT_HEAD(>p_lwps, l, l_sibling);
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Mon Oct 31 00:56:33 UTC 2022 Modified Files: src/sys/netinet: tcp_subr.c Log Message: tcp: fix wrong logic in tcp_drop Pointed out by mlelstv@ To generate a diff of this commit: cvs rdiff -u -r1.293 -r1.294 src/sys/netinet/tcp_subr.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/tcp_subr.c diff -u src/sys/netinet/tcp_subr.c:1.293 src/sys/netinet/tcp_subr.c:1.294 --- src/sys/netinet/tcp_subr.c:1.293 Fri Oct 28 05:25:36 2022 +++ src/sys/netinet/tcp_subr.c Mon Oct 31 00:56:33 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_subr.c,v 1.293 2022/10/28 05:25:36 ozaki-r Exp $ */ +/* $NetBSD: tcp_subr.c,v 1.294 2022/10/31 00:56:33 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.293 2022/10/28 05:25:36 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.294 2022/10/31 00:56:33 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1022,7 +1022,7 @@ tcp_drop(struct tcpcb *tp, int errno) KASSERT(tp->t_inpcb != NULL); so = tp->t_inpcb->inp_socket; - if (so != NULL) + if (so == NULL) return NULL; if (TCPS_HAVERCVDSYN(tp->t_state)) {
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Mon Oct 31 00:56:33 UTC 2022 Modified Files: src/sys/netinet: tcp_subr.c Log Message: tcp: fix wrong logic in tcp_drop Pointed out by mlelstv@ To generate a diff of this commit: cvs rdiff -u -r1.293 -r1.294 src/sys/netinet/tcp_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Sun Oct 30 08:45:46 UTC 2022 Modified Files: src/sys/netinet: tcp_usrreq.c Log Message: tcp: restore NULL check for inp in tcp_ctloutput To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/netinet/tcp_usrreq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Sun Oct 30 08:45:46 UTC 2022 Modified Files: src/sys/netinet: tcp_usrreq.c Log Message: tcp: restore NULL check for inp in tcp_ctloutput To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/netinet/tcp_usrreq.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/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.235 src/sys/netinet/tcp_usrreq.c:1.236 --- src/sys/netinet/tcp_usrreq.c:1.235 Sat Oct 29 15:35:16 2022 +++ src/sys/netinet/tcp_usrreq.c Sun Oct 30 08:45:46 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.235 2022/10/29 15:35:16 ozaki-r Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.236 2022/10/30 08:45:46 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.235 2022/10/29 15:35:16 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.236 2022/10/30 08:45:46 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -272,6 +272,10 @@ tcp_ctloutput(int op, struct socket *so, s = splsoftnet(); inp = sotoinpcb(so); + if (inp == NULL) { + splx(s); + return ECONNRESET; + } if (level != IPPROTO_TCP) { switch (family) { case PF_INET:
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Sat Oct 29 15:35:17 UTC 2022 Modified Files: src/sys/netinet: tcp_usrreq.c Log Message: tcp: restore NULL checks for inp To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/netinet/tcp_usrreq.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/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.234 src/sys/netinet/tcp_usrreq.c:1.235 --- src/sys/netinet/tcp_usrreq.c:1.234 Fri Oct 28 05:25:36 2022 +++ src/sys/netinet/tcp_usrreq.c Sat Oct 29 15:35:16 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.234 2022/10/28 05:25:36 ozaki-r Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.235 2022/10/29 15:35:16 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.234 2022/10/28 05:25:36 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.235 2022/10/29 15:35:16 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -502,6 +502,8 @@ tcp_detach(struct socket *so) int s; inp = sotoinpcb(so); + if (inp == NULL) + return; tp = intotcpcb(inp); s = splsoftnet(); @@ -518,6 +520,8 @@ tcp_accept(struct socket *so, struct soc int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_ACCEPT); @@ -556,6 +560,8 @@ tcp_bind(struct socket *so, struct socka int ostate = 0; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_BIND); @@ -597,6 +603,8 @@ tcp_listen(struct socket *so, struct lwp int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_LISTEN); @@ -636,6 +644,8 @@ tcp_connect(struct socket *so, struct so int ostate = 0; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_CONNECT); @@ -719,6 +729,8 @@ tcp_connect2(struct socket *so, struct s KASSERT(solocked(so)); inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_CONNECT2); @@ -738,6 +750,8 @@ tcp_disconnect(struct socket *so) int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_DISCONNECT); @@ -771,6 +785,8 @@ tcp_shutdown(struct socket *so) int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_SHUTDOWN); @@ -798,6 +814,8 @@ tcp_abort(struct socket *so) int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_ABORT); @@ -846,6 +864,8 @@ tcp_peeraddr(struct socket *so, struct s int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_PEERADDR); @@ -874,6 +894,8 @@ tcp_sockaddr(struct socket *so, struct s int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_SOCKADDR); @@ -902,6 +924,8 @@ tcp_rcvd(struct socket *so, int flags, s int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_RCVD); @@ -934,6 +958,8 @@ tcp_recvoob(struct socket *so, struct mb int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_RCVOOB); @@ -976,6 +1002,8 @@ tcp_send(struct socket *so, struct mbuf int s; inp = sotoinpcb(so); + if (inp == NULL) + return EINVAL; tp = intotcpcb(inp); ostate = tcp_debug_capture(tp, PRU_SEND); @@ -1011,6 +1039,11 @@ tcp_sendoob(struct socket *so, struct mb int s; inp = sotoinpcb(so); + if (inp == NULL) { + m_freem(m); + m_freem(control); + return EINVAL; + } tp = intotcpcb(inp); if (tp->t_template == NULL) { /*
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Sat Oct 29 15:35:17 UTC 2022 Modified Files: src/sys/netinet: tcp_usrreq.c Log Message: tcp: restore NULL checks for inp To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/netinet/tcp_usrreq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Sat Oct 29 02:56:29 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: fix for kernels without INET6 To generate a diff of this commit: cvs rdiff -u -r1.193 -r1.194 src/sys/netinet/in_pcb.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/in_pcb.c diff -u src/sys/netinet/in_pcb.c:1.193 src/sys/netinet/in_pcb.c:1.194 --- src/sys/netinet/in_pcb.c:1.193 Fri Oct 28 05:25:36 2022 +++ src/sys/netinet/in_pcb.c Sat Oct 29 02:56:29 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: in_pcb.c,v 1.193 2022/10/28 05:25:36 ozaki-r Exp $ */ +/* $NetBSD: in_pcb.c,v 1.194 2022/10/29 02:56:29 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -93,7 +93,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.193 2022/10/28 05:25:36 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.194 2022/10/29 02:56:29 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -157,7 +157,9 @@ int lowportmin = IPPORT_RESERVEDMIN; int lowportmax = IPPORT_RESERVEDMAX; static struct pool in4pcb_pool; +#ifdef INET6 static struct pool in6pcb_pool; +#endif static int inpcb_poolinit(void) @@ -165,8 +167,10 @@ inpcb_poolinit(void) pool_init(_pool, sizeof(struct in4pcb), 0, 0, 0, "in4pcbpl", NULL, IPL_NET); +#ifdef INET6 pool_init(_pool, sizeof(struct in6pcb), 0, 0, 0, "in6pcbpl", NULL, IPL_NET); +#endif return 0; } @@ -195,12 +199,17 @@ in_pcballoc(struct socket *so, void *v) struct inpcb *inp; int s; +#ifdef INET6 KASSERT(soaf(so) == AF_INET || soaf(so) == AF_INET6); if (soaf(so) == AF_INET) inp = pool_get(_pool, PR_NOWAIT|PR_ZERO); else inp = pool_get(_pool, PR_NOWAIT|PR_ZERO); +#else + KASSERT(soaf(so) == AF_INET); + inp = pool_get(_pool, PR_NOWAIT|PR_ZERO); +#endif if (inp == NULL) return (ENOBUFS); inp->inp_af = soaf(so); @@ -226,10 +235,15 @@ in_pcballoc(struct socket *so, void *v) if (ipsec_enabled) { int error = ipsec_init_pcbpolicy(so, >inp_sp); if (error != 0) { +#ifdef INET6 if (inp->inp_af == AF_INET) pool_put(_pool, inp); else pool_put(_pool, inp); +#else + KASSERT(inp->inp_af == AF_INET); + pool_put(_pool, inp); +#endif return error; } inp->inp_sp->sp_inp = inp; @@ -665,6 +679,7 @@ in_pcbdetach(void *v) } rtcache_free(>inp_route); ip_freemoptions(inp->inp_moptions); +#ifdef INET6 if (inp->inp_af == AF_INET6) { if (in6p_outputopts(inp) != NULL) { ip6_clearpktopts(in6p_outputopts(inp), -1); @@ -672,12 +687,18 @@ in_pcbdetach(void *v) } ip6_freemoptions(in6p_moptions(inp)); } +#endif sofree(so); /* drops the socket's lock */ +#ifdef INET6 if (inp->inp_af == AF_INET) pool_put(_pool, inp); else pool_put(_pool, inp); +#else + KASSERT(inp->inp_af == AF_INET); + pool_put(_pool, inp); +#endif mutex_enter(softnet_lock); /* reacquire the softnet_lock */ } @@ -1096,10 +1117,15 @@ void in_pcbstate(struct inpcb *inp, int state) { +#ifdef INET6 if (inp->inp_af == AF_INET6) { in6_pcbstate(inp, state); return; } +#else + if (inp->inp_af != AF_INET) + return; +#endif if (inp->inp_state > INP_ATTACHED) LIST_REMOVE(inp, inp_hash); @@ -1130,8 +1156,10 @@ in_pcbrtentry(struct inpcb *inp) struct sockaddr_in dst4; } u; +#ifdef INET6 if (inp->inp_af == AF_INET6) return in6_pcbrtentry(inp); +#endif if (inp->inp_af != AF_INET) return (NULL);
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Sat Oct 29 02:56:29 UTC 2022 Modified Files: src/sys/netinet: in_pcb.c Log Message: inpcb: fix for kernels without INET6 To generate a diff of this commit: cvs rdiff -u -r1.193 -r1.194 src/sys/netinet/in_pcb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.