CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu Jul 15 04:05:47 UTC 2021 Modified Files: src/sys/net: if_vlan.c Log Message: vlan: drop tagged outgoing packets vlan(4) doesn't support Q-in-Q yet. To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.160 src/sys/net/if_vlan.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_vlan.c diff -u src/sys/net/if_vlan.c:1.159 src/sys/net/if_vlan.c:1.160 --- src/sys/net/if_vlan.c:1.159 Wed Jul 14 06:50:22 2021 +++ src/sys/net/if_vlan.c Thu Jul 15 04:05:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $ */ +/* $NetBSD: if_vlan.c,v 1.160 2021/07/15 04:05:47 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.160 2021/07/15 04:05:47 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1321,6 +1321,7 @@ vlan_start(struct ifnet *ifp) struct mbuf *m; struct ifvlan_linkmib *mib; struct psref psref; + struct ether_header *eh; int error; mib = vlan_getref_linkmib(ifv, ); @@ -1342,6 +1343,21 @@ vlan_start(struct ifnet *ifp) if (m == NULL) break; + if (m->m_len < sizeof(*eh)) { + m = m_pullup(m, sizeof(*eh)); + if (m == NULL) { +if_statinc(ifp, if_oerrors); +continue; + } + } + + eh = mtod(m, struct ether_header *); + if (ntohs(eh->ether_type) == ETHERTYPE_VLAN) { + m_freem(m); + if_statinc(ifp, if_noproto); + continue; + } + #ifdef ALTQ /* * KERNEL_LOCK is required for ALTQ even if NET_MPSAFE is @@ -1465,10 +1481,26 @@ vlan_transmit(struct ifnet *ifp, struct struct ethercom *ec; struct ifvlan_linkmib *mib; struct psref psref; + struct ether_header *eh; int error; size_t pktlen = m->m_pkthdr.len; bool mcast = (m->m_flags & M_MCAST) != 0; + if (m->m_len < sizeof(*eh)) { + m = m_pullup(m, sizeof(*eh)); + if (m == NULL) { + if_statinc(ifp, if_oerrors); + return ENOBUFS; + } + } + + eh = mtod(m, struct ether_header *); + if (ntohs(eh->ether_type) == ETHERTYPE_VLAN) { + m_freem(m); + if_statinc(ifp, if_noproto); + return EPROTONOSUPPORT; + } + mib = vlan_getref_linkmib(ifv, ); if (mib == NULL) { m_freem(m);
CVS commit: src/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Wed Jul 14 08:51:51 UTC 2021 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: vlan: Added missing $HIJACKING before brconfig To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/tests/net/if_vlan/t_vlan.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/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.22 src/tests/net/if_vlan/t_vlan.sh:1.23 --- src/tests/net/if_vlan/t_vlan.sh:1.22 Wed Jul 14 08:50:24 2021 +++ src/tests/net/if_vlan/t_vlan.sh Wed Jul 14 08:51:51 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_vlan.sh,v 1.22 2021/07/14 08:50:24 yamaguchi Exp $ +# $NetBSD: t_vlan.sh,v 1.23 2021/07/14 08:51:51 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -723,7 +723,7 @@ vlan_bridge_body_common() atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 $atf_brconfig bridge0 add vlan0 - $DEBUG && brconfig bridge0 + $DEBUG && $HIJACKING /sbin/brconfig bridge0 atf_check -s exit:0 -o match:'mtu 1495' rump.ifconfig vlan0 $atf_brconfig bridge0 delete vlan0 @@ -734,13 +734,13 @@ vlan_bridge_body_common() $atf_ifconfig vlan0 mtu 1495 $atf_brconfig bridge0 add vlan0 - $DEBUG && brconfig bridge0 + $DEBUG && $HIJACKING /sbin/brconfig bridge0 atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 $atf_brconfig bridge0 delete vlan0 $atf_ifconfig bridge0 mtu 1497 atf_check -s not-exit:0 -o ignore -e ignore \ - /sbin/brconfig bridge0 add vlan0 + $HIJACKING /sbin/brconfig bridge0 add vlan0 # # Destroy a vlan interface that is bridge member
CVS commit: src/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Wed Jul 14 08:50:24 UTC 2021 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: Added tests for adding vlan(4) to a bridge and deleting from it - add vlan(4) that has no parent interface to a bridge member - the vlan(4) cannot be added to a bridge member - detach the parent interface of vlan(4) that is in a bridge member - vlan(4) is deleted from a bridge member at the detaching To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/tests/net/if_vlan/t_vlan.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/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.21 src/tests/net/if_vlan/t_vlan.sh:1.22 --- src/tests/net/if_vlan/t_vlan.sh:1.21 Wed Jul 14 06:35:59 2021 +++ src/tests/net/if_vlan/t_vlan.sh Wed Jul 14 08:50:24 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_vlan.sh,v 1.21 2021/07/14 06:35:59 yamaguchi Exp $ +# $NetBSD: t_vlan.sh,v 1.22 2021/07/14 08:50:24 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -681,8 +681,6 @@ vlan_bridge_body_common() $atf_ifconfig shmif0 up $atf_ifconfig vlan0 create - $atf_ifconfig vlan0 vlan 10 vlanif shmif0 - $atf_ifconfig vlan0 up $DEBUG && rump.ifconfig vlan0 $atf_ifconfig bridge0 create @@ -692,16 +690,36 @@ vlan_bridge_body_common() # Add vlan to bridge member # $atf_ifconfig bridge0 mtu 1496 + + # vlan0 can not add to bridge member + # because it is not an ethernet device + atf_check -s not-exit:0 -e match:'Invalid argument' \ + $HIJACKING /sbin/brconfig bridge0 add vlan0 + + $atf_ifconfig vlan0 vlan 10 vlanif shmif0 + $atf_ifconfig vlan0 up atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 + # vlan0 becomes an ethernet device + # after attaching the parent interface $atf_brconfig bridge0 add vlan0 - $DEBUG && brconfig bridge0 + $DEBUG && $HIJACKING /sbin/brconfig bridge0 + $atf_brconfig bridge0 delete vlan0 + $atf_brconfig bridge0 add vlan0 + $atf_ifconfig vlan0 -vlanif + atf_check -s exit:0 -o not-match:'vlan0' \ + $HIJACKING /sbin/brconfig bridge0 + atf_check -s not-exit:0 -e match:'No such' \ + $HIJACKING /sbin/brconfig bridge0 delete vlan0 + # # decrease MTU on adding to bridge member # $atf_ifconfig bridge0 mtu 1495 + $atf_ifconfig vlan0 vlan 10 vlanif shmif0 + $atf_ifconfig vlan0 up atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 $atf_brconfig bridge0 add vlan0
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Jul 14 06:50:22 UTC 2021 Modified Files: src/sys/net: bpf.c if_vlan.c Log Message: unset IFF_PROMISC at bpf_detach() Doing "d->bd_promisc = 0" is that bpf_detach() does not call ifpromisc(ifp, 0). Currently, there is no reason for this behavior so that it is removed. In addition to the change, the workaround for it in vlan(4) is also removed. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/sys/net/bpf.c cvs rdiff -u -r1.158 -r1.159 src/sys/net/if_vlan.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.240 src/sys/net/bpf.c:1.241 --- src/sys/net/bpf.c:1.240 Wed Jun 9 15:44:15 2021 +++ src/sys/net/bpf.c Wed Jul 14 06:50:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.240 2021/06/09 15:44:15 martin Exp $ */ +/* $NetBSD: bpf.c,v 1.241 2021/07/14 06:50:22 yamaguchi Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.240 2021/06/09 15:44:15 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.241 2021/07/14 06:50:22 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_bpf.h" @@ -2194,7 +2194,6 @@ _bpfdetach(struct ifnet *ifp) * Detach the descriptor from an interface now. * It will be free'ed later by close routine. */ - d->bd_promisc = 0; /* we can't touch device. */ bpf_detachd(d); mutex_exit(d->bd_mtx); goto again_d; Index: src/sys/net/if_vlan.c diff -u src/sys/net/if_vlan.c:1.158 src/sys/net/if_vlan.c:1.159 --- src/sys/net/if_vlan.c:1.158 Wed Jul 14 06:23:06 2021 +++ src/sys/net/if_vlan.c Wed Jul 14 06:50:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.158 2021/07/14 06:23:06 yamaguchi Exp $ */ +/* $NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.158 2021/07/14 06:23:06 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -701,8 +701,6 @@ vlan_unconfig_locked(struct ifvlan *ifv, KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); #endif - if ((ifp->if_flags & IFF_PROMISC) != 0) - vlan_safe_ifpromisc_locked(ifp, 0); if_down_locked(ifp); ifp->if_capabilities = 0; mutex_enter(>ifv_lock);
CVS commit: src/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Wed Jul 14 06:36:00 UTC 2021 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: Added a test about clearing IFF_PROMISC at vlan_unconfig This test is related to PR/49196 To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/net/if_vlan/t_vlan.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/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.20 src/tests/net/if_vlan/t_vlan.sh:1.21 --- src/tests/net/if_vlan/t_vlan.sh:1.20 Fri Jul 9 05:54:11 2021 +++ src/tests/net/if_vlan/t_vlan.sh Wed Jul 14 06:35:59 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_vlan.sh,v 1.20 2021/07/09 05:54:11 yamaguchi Exp $ +# $NetBSD: t_vlan.sh,v 1.21 2021/07/14 06:35:59 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -986,6 +986,27 @@ vlan_promisc_body() atf_check -s exit:0 -o not-match:'PROMISC' rump.ifconfig vlan0 atf_check -s exit:0 -o not-match:'PROMISC' rump.ifconfig shmif0 + $atf_ifconfig vlan0 -vlanif + + # + # clear IFF_PROMISC after bpf_detach called from ether_ifdetach + # + $atf_ifconfig vlan0 vlan 1 vlanif shmif0 + $atf_ifconfig vlan0 up + + $bpfopen -r vlan0 & + pid=$! + + atf_check -s exit:0 -o match:'PROMISC' rump.ifconfig vlan0 + atf_check -s exit:0 -o match:'PROMISC' rump.ifconfig shmif0 + + $atf_ifconfig vlan0 -vlanif + + atf_check -s exit:0 -o not-match:'PROMISC' rump.ifconfig vlan0 + atf_check -s exit:0 -o not-match:'PROMISC' rump.ifconfig shmif0 + + kill -TERM $pid + atf_check -s exit:0 -o not-match:'PROMISC' rump.ifconfig vlan0 } vlan_promisc_cleanup()
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Jul 14 06:23:06 UTC 2021 Modified Files: src/sys/net: if_vlan.c Log Message: Make an mbuf writable before un-tagging To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 src/sys/net/if_vlan.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_vlan.c diff -u src/sys/net/if_vlan.c:1.157 src/sys/net/if_vlan.c:1.158 --- src/sys/net/if_vlan.c:1.157 Tue Jul 6 02:39:46 2021 +++ src/sys/net/if_vlan.c Wed Jul 14 06:23:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.157 2021/07/06 02:39:46 yamaguchi Exp $ */ +/* $NetBSD: if_vlan.c,v 1.158 2021/07/14 06:23:06 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.157 2021/07/06 02:39:46 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.158 2021/07/14 06:23:06 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1622,6 +1622,14 @@ vlan_input(struct ifnet *ifp, struct mbu "dropping packet.\n", ifp->if_xname); return; } + + if (m_makewritable(, 0, + sizeof(struct ether_vlan_header), M_DONTWAIT)) { + m_freem(m); + if_statinc(ifp, if_ierrors); + return; + } + evl = mtod(m, struct ether_vlan_header *); KASSERT(ntohs(evl->evl_encap_proto) == ETHERTYPE_VLAN);
CVS commit: src
Module Name:src Committed By: yamaguchi Date: Fri Jul 9 05:54:11 UTC 2021 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/tests/net: net_common.sh src/tests/net/if_vlan: Makefile t_vlan.sh Added Files: src/tests/net/if_vlan: bpfopen.c Log Message: added tests for IFF_PROMISC of vlan(4) To generate a diff of this commit: cvs rdiff -u -r1.354 -r1.355 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.1079 -r1.1080 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.41 -r1.42 src/tests/net/net_common.sh cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_vlan/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/if_vlan/bpfopen.c cvs rdiff -u -r1.19 -r1.20 src/tests/net/if_vlan/t_vlan.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/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.354 src/distrib/sets/lists/debug/mi:1.355 --- src/distrib/sets/lists/debug/mi:1.354 Thu Jul 8 09:16:24 2021 +++ src/distrib/sets/lists/debug/mi Fri Jul 9 05:54:11 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.354 2021/07/08 09:16:24 christos Exp $ +# $NetBSD: mi,v 1.355 2021/07/09 05:54:11 yamaguchi 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 @@ -2396,6 +2396,7 @@ ./usr/libdata/debug/usr/tests/net/if/t_compat.debug tests-net-debug debug,atf,rump ./usr/libdata/debug/usr/tests/net/if_loop/t_pr.debug tests-net-debug debug,atf,rump ./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/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 Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1079 src/distrib/sets/lists/tests/mi:1.1080 --- src/distrib/sets/lists/tests/mi:1.1079 Thu Jul 8 09:16:24 2021 +++ src/distrib/sets/lists/tests/mi Fri Jul 9 05:54:11 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1079 2021/07/08 09:16:24 christos Exp $ +# $NetBSD: mi,v 1.1080 2021/07/09 05:54:11 yamaguchi Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4142,6 +4142,7 @@ ./usr/tests/net/if_vlan tests-net-tests compattestfile,atf ./usr/tests/net/if_vlan/Atffiletests-net-tests atf,rump ./usr/tests/net/if_vlan/Kyuafile tests-net-tests atf,rump,kyua +./usr/tests/net/if_vlan/bpfopentests-net-tests atf,rump ./usr/tests/net/if_vlan/siocXmulti tests-net-tests atf,rump ./usr/tests/net/if_vlan/t_vlantests-net-tests atf,rump ./usr/tests/net/if_wg tests-net-tests compattestfile,atf Index: src/tests/net/net_common.sh diff -u src/tests/net/net_common.sh:1.41 src/tests/net/net_common.sh:1.42 --- src/tests/net/net_common.sh:1.41 Wed Apr 1 00:49:04 2020 +++ src/tests/net/net_common.sh Fri Jul 9 05:54:11 2021 @@ -1,4 +1,4 @@ -# $NetBSD: net_common.sh,v 1.41 2020/04/01 00:49:04 christos Exp $ +# $NetBSD: net_common.sh,v 1.42 2021/07/09 05:54:11 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -180,6 +180,7 @@ CRYPTO_LIBS="$BASIC_LIBS -lrumpdev -lrum -lrumpkern_z -lrumpkern_crypto" NPF_LIBS="$BASIC_LIBS -lrumpdev -lrumpvfs -lrumpdev_bpf -lrumpnet_npf" CRYPTO_NPF_LIBS="$CRYPTO_LIBS -lrumpvfs -lrumpdev_bpf -lrumpnet_npf" +BPF_LIBS="$BASIC_LIBS -lrumpdev -lrumpvfs -lrumpdev_bpf" # We cannot keep variables between test phases, so need to store in files _rump_server_socks=./.__socks @@ -315,6 +316,24 @@ rump_server_crypto_npf_start() return 0 } +rump_server_bpf_start() +{ + local sock=$1 + local lib= + local libs="$BPF_LIBS" + + shift 1 + + for lib + do + libs="$libs -lrumpnet_$lib" + done + + _rump_server_start_common $sock $libs + + return 0 +} + rump_server_add_iface() { local sock=$1 Index: src/tests/net/if_vlan/Makefile diff -u src/tests/net/if_vlan/Makefile:1.2 src/tests/net/if_vlan/Makefile:1.3 --- src/tests/net/if_vlan/Makefile:1.2 Thu Jun 14 08:22:52 2018 +++ src/tests/net/if_vlan/Makefile Fri Jul 9 05:54:11 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2018/06/14 08:22:52 yamaguchi Exp $ +# $NetBSD: Makefile,v 1.3 2021/07/09 05:54:11 yamaguchi Exp $ # .include @@ -14,4 +14,8 @@ PROGS= siocXmulti MAN.siocXmulti= #empty BINDIR.siocXmulti= ${TESTSDIR} +PROGS+= bpfopen +MAN.bpfopen= #empty +BINDIR.bpfopen= ${TESTSDIR} + .include Index: src/tests/net/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.19 src/tests/net/if_vlan/t_vlan.sh:1.20 --- src/tests/net/if_vlan/t_vlan.sh:1.19 Tue Jul 6
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jul 6 02:39:46 UTC 2021 Modified Files: src/sys/net: if_vlan.c Log Message: Drop unicast packets that are not for us when vlan(4) is not in promisc To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/net/if_vlan.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_vlan.c diff -u src/sys/net/if_vlan.c:1.156 src/sys/net/if_vlan.c:1.157 --- src/sys/net/if_vlan.c:1.156 Tue Jul 6 02:34:12 2021 +++ src/sys/net/if_vlan.c Tue Jul 6 02:39:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.156 2021/07/06 02:34:12 yamaguchi Exp $ */ +/* $NetBSD: if_vlan.c,v 1.157 2021/07/06 02:39:46 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.156 2021/07/06 02:34:12 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.157 2021/07/06 02:39:46 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1661,6 +1661,24 @@ vlan_input(struct ifnet *ifp, struct mbu m_adj(m, mib->ifvm_encaplen); } + /* + * Drop promiscuously received packets if we are not in + * promiscuous mode + */ + if ((m->m_flags & (M_BCAST | M_MCAST)) == 0 && + (ifp->if_flags & IFF_PROMISC) && + (ifv->ifv_if.if_flags & IFF_PROMISC) == 0) { + struct ether_header *eh; + + eh = mtod(m, struct ether_header *); + if (memcmp(CLLADDR(ifv->ifv_if.if_sadl), + eh->ether_dhost, ETHER_ADDR_LEN) != 0) { + m_freem(m); + if_statinc(>ifv_if, if_ierrors); + goto out; + } + } + m_set_rcvif(m, >ifv_if); if (pfil_run_hooks(ifp->if_pfil, , ifp, PFIL_IN) != 0)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jul 6 02:34:12 UTC 2021 Modified Files: src/sys/net: if_vlan.c Log Message: vlan: added NULL check for the parent interface The pointer may set to NULL by vlan_unconfig while packet processing To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 src/sys/net/if_vlan.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_vlan.c diff -u src/sys/net/if_vlan.c:1.155 src/sys/net/if_vlan.c:1.156 --- src/sys/net/if_vlan.c:1.155 Tue Jul 6 01:16:01 2021 +++ src/sys/net/if_vlan.c Tue Jul 6 02:34:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.155 2021/07/06 01:16:01 yamaguchi Exp $ */ +/* $NetBSD: if_vlan.c,v 1.156 2021/07/06 02:34:12 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.155 2021/07/06 01:16:01 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.156 2021/07/06 02:34:12 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1328,6 +1328,12 @@ vlan_start(struct ifnet *ifp) mib = vlan_getref_linkmib(ifv, ); if (mib == NULL) return; + + if (__predict_false(mib->ifvm_p == NULL)) { + vlan_putref_linkmib(mib, ); + return; + } + p = mib->ifvm_p; ec = (void *)mib->ifvm_p; @@ -1471,6 +1477,12 @@ vlan_transmit(struct ifnet *ifp, struct return ENETDOWN; } + if (__predict_false(mib->ifvm_p == NULL)) { + vlan_putref_linkmib(mib, ); + m_freem(m); + return ENETDOWN; + } + p = mib->ifvm_p; ec = (void *)mib->ifvm_p;
CVS commit: src/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Tue Jul 6 01:18:22 UTC 2021 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: vlan: added checks of linkstate To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/net/if_vlan/t_vlan.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/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.18 src/tests/net/if_vlan/t_vlan.sh:1.19 --- src/tests/net/if_vlan/t_vlan.sh:1.18 Fri Jul 2 04:38:10 2021 +++ src/tests/net/if_vlan/t_vlan.sh Tue Jul 6 01:18:22 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_vlan.sh,v 1.18 2021/07/02 04:38:10 yamaguchi Exp $ +# $NetBSD: t_vlan.sh,v 1.19 2021/07/06 01:18:22 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -589,8 +589,12 @@ vlan_configs_body_common() $atf_ifconfig shmif1 link b0:a0:75:00:01:01 active $atf_ifconfig vlan0 create + atf_check -s exit:0 -o match:'status: +down' \ + rump.ifconfig vlan0 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 $atf_ifconfig vlan0 -vlanif + atf_check -s exit:0 -o match:'status: +down' \ + rump.ifconfig vlan0 $atf_ifconfig vlan0 vlan 10 vlanif shmif0 $atf_ifconfig vlan0 -vlanif shmif0
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jul 6 01:16:01 UTC 2021 Modified Files: src/sys/net: if_vlan.c Log Message: vlan: set the link state to DOWN when its parent detaches To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/sys/net/if_vlan.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_vlan.c diff -u src/sys/net/if_vlan.c:1.154 src/sys/net/if_vlan.c:1.155 --- src/sys/net/if_vlan.c:1.154 Wed Jun 16 00:21:19 2021 +++ src/sys/net/if_vlan.c Tue Jul 6 01:16:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.154 2021/06/16 00:21:19 riastradh Exp $ */ +/* $NetBSD: if_vlan.c,v 1.155 2021/07/06 01:16:01 yamaguchi Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.154 2021/06/16 00:21:19 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.155 2021/07/06 01:16:01 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -366,6 +366,7 @@ vlan_clone_create(struct if_clone *ifc, * Set the link state to down. * When the parent interface attaches we will use that link state. * When the parent interface link state changes, so will ours. + * When the parent interface detaches, set the link state to down. */ ifp->if_link_state = LINK_STATE_DOWN; @@ -685,6 +686,7 @@ vlan_unconfig_locked(struct ifvlan *ifv, PSLIST_ENTRY_DESTROY(ifv, ifv_hash); vlan_linkmib_update(ifv, nmib); + if_link_state_change(ifp, LINK_STATE_DOWN); mutex_exit(>ifv_lock);
CVS commit: src/tests/net/if_vlan
Module Name:src Committed By: yamaguchi Date: Fri Jul 2 04:38:11 UTC 2021 Modified Files: src/tests/net/if_vlan: t_vlan.sh Log Message: Added tests for changing a MTU when the vlan(4) is added to bridge(4) The tests is for PR kern/56292 To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/tests/net/if_vlan/t_vlan.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/if_vlan/t_vlan.sh diff -u src/tests/net/if_vlan/t_vlan.sh:1.17 src/tests/net/if_vlan/t_vlan.sh:1.18 --- src/tests/net/if_vlan/t_vlan.sh:1.17 Sun Mar 8 09:05:33 2020 +++ src/tests/net/if_vlan/t_vlan.sh Fri Jul 2 04:38:10 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_vlan.sh,v 1.17 2020/03/08 09:05:33 nisimura Exp $ +# $NetBSD: t_vlan.sh,v 1.18 2021/07/02 04:38:10 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -669,6 +669,7 @@ vlan_configs6_cleanup() vlan_bridge_body_common() { local atf_ifconfig="atf_check -s exit:0 rump.ifconfig" + local atf_brconfig="atf_check -s exit:0 $HIJACKING /sbin/brconfig" rump_server_add_iface $SOCK_LOCAL shmif0 $BUS @@ -681,17 +682,49 @@ vlan_bridge_body_common() $DEBUG && rump.ifconfig vlan0 $atf_ifconfig bridge0 create - # Adjust to the MTU of a vlan on a shmif - $atf_ifconfig bridge0 mtu 1496 $atf_ifconfig bridge0 up - # Test brconfig add - atf_check -s exit:0 $HIJACKING brconfig bridge0 add vlan0 + + # + # Add vlan to bridge member + # + $atf_ifconfig bridge0 mtu 1496 + atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 + + $atf_brconfig bridge0 add vlan0 + $DEBUG && brconfig bridge0 + $atf_brconfig bridge0 delete vlan0 + + # + # decrease MTU on adding to bridge member + # + $atf_ifconfig bridge0 mtu 1495 + atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 + + $atf_brconfig bridge0 add vlan0 + $DEBUG && brconfig bridge0 + atf_check -s exit:0 -o match:'mtu 1495' rump.ifconfig vlan0 + $atf_brconfig bridge0 delete vlan0 + + # + # increase MTU on adding to bridge member + # + $atf_ifconfig bridge0 mtu 1496 + $atf_ifconfig vlan0 mtu 1495 + $atf_brconfig bridge0 add vlan0 + $DEBUG && brconfig bridge0 - # Test brconfig delete - atf_check -s exit:0 $HIJACKING brconfig bridge0 delete vlan0 + atf_check -s exit:0 -o match:'mtu 1496' rump.ifconfig vlan0 + $atf_brconfig bridge0 delete vlan0 - atf_check -s exit:0 $HIJACKING brconfig bridge0 add vlan0 - # Test vlan destruction with bridge + $atf_ifconfig bridge0 mtu 1497 + atf_check -s not-exit:0 -o ignore -e ignore \ + /sbin/brconfig bridge0 add vlan0 + + # + # Destroy a vlan interface that is bridge member + # + $atf_ifconfig bridge0 mtu 1496 + $atf_brconfig bridge0 add vlan0 $atf_ifconfig vlan0 destroy rump_server_destroy_ifaces
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Jul 2 03:30:46 UTC 2021 Modified Files: src/sys/net: if_bridge.c Log Message: Use if_ioctl() for changing MTU, not ether_ioctl to prevent panic Fix PR kern/56292 To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/sys/net/if_bridge.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_bridge.c diff -u src/sys/net/if_bridge.c:1.180 src/sys/net/if_bridge.c:1.181 --- src/sys/net/if_bridge.c:1.180 Wed Jun 16 00:21:19 2021 +++ src/sys/net/if_bridge.c Fri Jul 2 03:30:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bridge.c,v 1.180 2021/06/16 00:21:19 riastradh Exp $ */ +/* $NetBSD: if_bridge.c,v 1.181 2021/07/02 03:30:46 yamaguchi Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.180 2021/06/16 00:21:19 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.181 2021/07/02 03:30:46 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -861,7 +861,7 @@ bridge_ioctl_add(struct bridge_softc *sc memset(, 0, sizeof(ifr)); ifr.ifr_mtu = sc->sc_if.if_mtu; IFNET_LOCK(ifs); - error = ether_ioctl(ifs, SIOCSIFMTU, ); + error = ifs->if_ioctl(ifs, SIOCSIFMTU, ); IFNET_UNLOCK(ifs); if (error != 0) goto out;
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Wed Jun 30 06:39:47 UTC 2021 Modified Files: src/sys/net/lagg: if_lagg_lacp.c Log Message: lagg: fix an uninitialize variable pointed out by tnn@n.o., thanks. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/net/lagg/if_lagg_lacp.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/lagg/if_lagg_lacp.c diff -u src/sys/net/lagg/if_lagg_lacp.c:1.2 src/sys/net/lagg/if_lagg_lacp.c:1.3 --- src/sys/net/lagg/if_lagg_lacp.c:1.2 Tue May 18 11:02:58 2021 +++ src/sys/net/lagg/if_lagg_lacp.c Wed Jun 30 06:39:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg_lacp.c,v 1.2 2021/05/18 11:02:58 hannken Exp $ */ +/* $NetBSD: if_lagg_lacp.c,v 1.3 2021/06/30 06:39:47 yamaguchi Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-NetBSD @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.2 2021/05/18 11:02:58 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.3 2021/06/30 06:39:47 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_lagg.h" @@ -2368,13 +2368,17 @@ lacp_unselect(struct lacp_softc *lsc, st lacpp->lp_aggregator = NULL; if (LIST_EMPTY(>la_ports)) { + remove_actaggr = false; + if (la == lsc->lsc_aggregator) { LACP_DPRINTF((lsc, NULL, "remove active aggregator\n")); lsc->lsc_aggregator = NULL; remove_actaggr = true; } + TAILQ_REMOVE(>lsc_aggregators, la, la_q); kmem_free(la, sizeof(*la)); + if (remove_actaggr) { lacp_select_active_aggregator(lsc); }
CVS commit: src/share/man/man4
Module Name:src Committed By: yamaguchi Date: Mon Jun 21 06:36:28 UTC 2021 Modified Files: src/share/man/man4: lagg.4 Log Message: lagg: fix typo To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/share/man/man4/lagg.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/lagg.4 diff -u src/share/man/man4/lagg.4:1.1 src/share/man/man4/lagg.4:1.2 --- src/share/man/man4/lagg.4:1.1 Mon May 17 04:07:42 2021 +++ src/share/man/man4/lagg.4 Mon Jun 21 06:36:28 2021 @@ -1,5 +1,5 @@ -.\" $NetBSD: lagg.4,v 1.1 2021/05/17 04:07:42 yamaguchi Exp $ +.\" $NetBSD: lagg.4,v 1.2 2021/06/21 06:36:28 yamaguchi Exp $ .\" .\" Copyright (c) 2005, 2006 Reyk Floeter .\" @@ -136,7 +136,7 @@ The maximum number of active ports in a .Ic lagglacp Nm maxports Ar N option. .It Ic none -THis protocol is intended to do nothing: it disables any traffic without +This protocol is intended to do nothing: it disables any traffic without disabling the .Nm interface itself.
CVS commit: src/sys/sys
Module Name:src Committed By: yamaguchi Date: Wed Jun 2 01:48:08 UTC 2021 Modified Files: src/sys/sys: param.h Log Message: NetBSD 9.99.83 - struct ifnet adds 'if_lagg' field To generate a diff of this commit: cvs rdiff -u -r1.692 -r1.693 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.692 src/sys/sys/param.h:1.693 --- src/sys/sys/param.h:1.692 Sat Apr 24 23:40:16 2021 +++ src/sys/sys/param.h Wed Jun 2 01:48:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.692 2021/04/24 23:40:16 thorpej Exp $ */ +/* $NetBSD: param.h,v 1.693 2021/06/02 01:48:08 yamaguchi Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 999008200 /* NetBSD 9.99.82 */ +#define __NetBSD_Version__ 999008300 /* NetBSD 9.99.83 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Jun 2 00:47:59 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added missing definition of sppp_ipv6cp_tld Fixed build without INET6 To generate a diff of this commit: cvs rdiff -u -r1.257 -r1.258 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.257 src/sys/net/if_spppsubr.c:1.258 --- src/sys/net/if_spppsubr.c:1.257 Tue Jun 1 05:22:57 2021 +++ src/sys/net/if_spppsubr.c Wed Jun 2 00:47:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.257 2021/06/01 05:22:57 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.258 2021/06/02 00:47:59 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.257 2021/06/01 05:22:57 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.258 2021/06/02 00:47:59 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -4575,6 +4575,13 @@ sppp_ipv6cp_tlu(struct sppp *sp) } static void +sppp_ipv6cp_tld(struct sppp *sp) +{ + + KASSERT(SPPP_WLOCKED(sp)); +} + +static void sppp_ipv6cp_scr(struct sppp *sp) {
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 05:22:57 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Fix the wrong timeout event handler for PAP sppp_auth_to_event() is a implementation of TO+/TO- event for authentication protocol and it drops TO+ event in Ack-rcvd state. To generate a diff of this commit: cvs rdiff -u -r1.256 -r1.257 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.256 src/sys/net/if_spppsubr.c:1.257 --- src/sys/net/if_spppsubr.c:1.256 Tue Jun 1 05:16:46 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 05:22:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.256 2021/06/01 05:16:46 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.257 2021/06/01 05:22:57 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.256 2021/06/01 05:16:46 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.257 2021/06/01 05:22:57 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -538,7 +538,7 @@ static const struct cp ipv6cp = { static const struct cp pap = { PPP_PAP, IDX_PAP, CP_AUTH, "pap", sppp_up_event, sppp_down_event, sppp_open_event, - sppp_close_event, sppp_to_event, + sppp_close_event, sppp_auth_to_event, sppp_pap_tlu, sppp_null, sppp_tls, sppp_tlf, sppp_pap_scr, sppp_auth_screply, NULL, NULL, NULL
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 05:18:33 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Update test case. The state of IPCP and IPv6CP is Closed when those are disabled. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.32 src/tests/net/if_pppoe/t_pppoe.sh:1.33 --- src/tests/net/if_pppoe/t_pppoe.sh:1.32 Thu May 13 03:37:58 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Tue Jun 1 05:18:33 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.32 2021/05/13 03:37:58 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.33 2021/06/01 05:18:33 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -743,7 +743,7 @@ pppoe_params_body() atf_pppoectl pppoe0 noipv6cp atf_ifconfig pppoe0 up wait_for_opened "IPCP" - atf_check -s exit:0 -o match:'IPv6CP state: initial' \ + atf_check -s exit:0 -o match:'IPv6CP state: closed' \ -x "$HIJACKING pppoectl -dd pppoe0" atf_ifconfig pppoe0 down @@ -755,7 +755,7 @@ pppoe_params_body() atf_pppoectl pppoe0 noipcp ipv6cp atf_ifconfig pppoe0 up wait_for_opened "IPv6CP" - atf_check -s exit:0 -o match:'IPCP state: initial' \ + atf_check -s exit:0 -o match:'IPCP state: closed' \ -x "$HIJACKING pppoectl -dd pppoe0" }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 05:16:46 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Send Up event in tlu action of LCP When LCP is stopping, the layer send Down event and Close event (Down -> Close). To align the sequence, Up event is moved before Open event. To generate a diff of this commit: cvs rdiff -u -r1.255 -r1.256 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.255 src/sys/net/if_spppsubr.c:1.256 --- src/sys/net/if_spppsubr.c:1.255 Tue Jun 1 05:11:22 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 05:16:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.255 2021/06/01 05:11:22 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.256 2021/06/01 05:16:46 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.255 2021/06/01 05:11:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.256 2021/06/01 05:16:46 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1898,6 +1898,7 @@ sppp_open_event(struct sppp *sp, void *x break; case STATE_CLOSED: sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; + sp->lcp.protos |= (1 << cp->protoidx); (cp->scr)(sp); sppp_cp_change_state(cp, sp, STATE_REQ_SENT); break; @@ -3114,6 +3115,7 @@ static void sppp_lcp_tlu(struct sppp *sp) { struct ifnet *ifp; + struct sppp_cp *scp; int i; bool going_up; @@ -3160,26 +3162,28 @@ sppp_lcp_tlu(struct sppp *sp) else sppp_change_phase(sp, SPPP_PHASE_NETWORK); - /* - * Open all authentication protocols. This is even required - * if we already proceeded to network phase, since it might be - * that remote wants us to authenticate, so we might have to - * send a PAP request. Undesired authentication protocols - * don't do anything when they get an Open event. - */ - for (i = 0; i < IDX_COUNT; i++) - if ((cps[i])->flags & CP_AUTH) { - sppp_wq_add(sp->wq_cp, - >scp[(cps[i])->protoidx].work_open); - } - if (sp->pp_phase == SPPP_PHASE_NETWORK) { - /* Notify all NCPs. */ - for (i = 0; i < IDX_COUNT; i++) - if ((cps[i])->flags & CP_NCP) { - sppp_wq_add(sp->wq_cp, - >scp[(cps[i])->protoidx].work_open); - } + for (i = 0; i < IDX_COUNT; i++) { + scp = >scp[(cps[i])->protoidx]; + + if (((cps[i])->flags & CP_LCP) == 0) + sppp_wq_add(sp->wq_cp, >work_up); + + /* + * Open all authentication protocols. This is even required + * if we already proceeded to network phase, since it might be + * that remote wants us to authenticate, so we might have to + * send a PAP request. Undesired authentication protocols + * don't do anything when they get an Open event. + */ + if ((cps[i])->flags & CP_AUTH) + sppp_wq_add(sp->wq_cp, >work_open); + + /* Open all NCPs. */ + if (sp->pp_phase == SPPP_PHASE_NETWORK && + ((cps[i])->flags & CP_NCP) != 0) { + sppp_wq_add(sp->wq_cp, >work_open); + } } /* notify low-level driver of state change */ @@ -3190,7 +3194,8 @@ static void sppp_lcp_tld(struct sppp *sp) { struct ifnet *ifp; - int i, pi, phase; + struct sppp_cp *scp; + int i, phase; KASSERT(SPPP_WLOCKED(sp)); @@ -3221,15 +3226,19 @@ sppp_lcp_tld(struct sppp *sp) * describes it. */ for (i = 0; i < IDX_COUNT; i++) { - pi = (cps[i])->protoidx; - if (((cps[i])->flags & CP_LCP) == 0) { - /* skip if ncp was not started */ - if (phase != SPPP_PHASE_NETWORK && - ((cps[i])->flags & CP_NCP) != 0) -continue; + scp = >scp[(cps[i])->protoidx]; - sppp_wq_add(sp->wq_cp, >scp[pi].work_down); - sppp_wq_add(sp->wq_cp, >scp[pi].work_close); + if (((cps[i])->flags & CP_LCP) == 0) + sppp_wq_add(sp->wq_cp, >work_down); + + if ((cps[i])->flags & CP_AUTH) { + sppp_wq_add(sp->wq_cp, >work_close); + } + + /* Close all NCPs. */ + if (phase == SPPP_PHASE_NETWORK && + ((cps[i])->flags & CP_NCP) != 0) { + sppp_wq_add(sp->wq_cp, >work_close); } } } @@ -6510,11 +6519,10 @@ static void sppp_tls(const struct cp *cp, struct sppp *sp) { + SPPP_DLOG(sp, "%s tls\n", cp->name); + /* notify lcp that is lower layer */ sp->lcp.protos |= (1 << cp->protoidx); - - if (sp->scp[IDX_LCP].state == STATE_OPENED) - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_up); } static void
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 05:11:22 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added logs when IPCP and IPv6CP are up or down To generate a diff of this commit: cvs rdiff -u -r1.254 -r1.255 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.254 src/sys/net/if_spppsubr.c:1.255 --- src/sys/net/if_spppsubr.c:1.254 Tue Jun 1 05:08:46 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 05:11:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.254 2021/06/01 05:08:46 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.255 2021/06/01 05:11:22 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.254 2021/06/01 05:08:46 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.255 2021/06/01 05:11:22 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3897,6 +3897,7 @@ sppp_ipcp_tlu(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + SPPP_LOG(sp, LOG_INFO, "IPCP layer up\n"); ifp = >pp_if; if ((sp->ipcp.flags & IPCP_MYADDR_DYN) && ((sp->ipcp.flags & IPCP_MYADDR_SEEN) == 0)) { @@ -3920,6 +3921,7 @@ sppp_ipcp_tld(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + SPPP_LOG(sp, LOG_INFO, "IPCP layer down\n"); ifp = >pp_if; rt_ifmsg(ifp); #endif @@ -4464,6 +4466,7 @@ sppp_ipv6cp_tlu(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + SPPP_LOG(sp, LOG_INFO, "IPv6CP layer up\n"); ifp = >pp_if; /* we are up - notify isdn daemon */ sppp_notify_con_wlocked(sp); @@ -4477,6 +4480,7 @@ sppp_ipv6cp_tld(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + SPPP_LOG(sp, LOG_INFO, "IPv6CP layer down\n"); ifp = >pp_if; rt_ifmsg(ifp); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 05:08:46 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added SPPP_LOG() for refactoring around log To generate a diff of this commit: cvs rdiff -u -r1.253 -r1.254 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.253 src/sys/net/if_spppsubr.c:1.254 --- src/sys/net/if_spppsubr.c:1.253 Tue Jun 1 05:04:06 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 05:08:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.253 2021/06/01 05:04:06 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.254 2021/06/01 05:08:46 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.253 2021/06/01 05:04:06 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.254 2021/06/01 05:08:46 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -319,6 +319,17 @@ static unsigned int sppp_keepalive_cnt = #define SPPP_DOWNGRADE(_sp) rw_downgrade(&(_sp)->pp_lock) #define SPPP_WQ_SET(_wk, _func, _arg) \ sppp_wq_set((_wk), (_func), __UNCONST((_arg))) +#define SPPP_LOG(_sp, _lvl, _fmt, _args...) do { \ + if (__predict_true((_sp) != NULL)) { \ + log((_lvl), "%s: ", (_sp)->pp_if.if_xname); \ + } \ + addlog((_fmt), ##_args);\ +} while (0) +#define SPPP_DLOG(_sp, _fmt, _args...) do { \ + if (!sppp_debug_enabled(_sp)) \ + break; \ + SPPP_LOG(_sp, LOG_DEBUG, _fmt, ##_args); \ +} while (0) #ifdef INET #ifndef SPPPSUBR_MPSAFE @@ -339,10 +350,8 @@ static u_short interactive_ports[8] = { #endif /* almost every function needs these */ -#define STDDCL \ - struct ifnet *ifp = >pp_if;\ - int debug = ifp->if_flags & IFF_DEBUG +static bool sppp_debug_enabled(struct sppp *sp); static int sppp_output(struct ifnet *, struct mbuf *, const struct sockaddr *, const struct rtentry *); @@ -580,13 +589,28 @@ sppp_authproto2proto(u_int authproto) return PPP_NOPROTO; } +static inline bool +sppp_debug_enabled(struct sppp *sp) +{ + + if (__predict_false(sp == NULL)) + return false; + + if ((sp->pp_if.if_flags & IFF_DEBUG) == 0) + return false; + + return true; +} + static void sppp_change_phase(struct sppp *sp, int phase) { - STDDCL; + struct ifnet *ifp; KASSERT(SPPP_WLOCKED(sp)); + ifp = >pp_if; + if (sp->pp_phase == phase) return; @@ -597,11 +621,8 @@ sppp_change_phase(struct sppp *sp, int p else if_link_state_change(ifp, LINK_STATE_DOWN); - if (debug) - { - log(LOG_INFO, "%s: phase %s\n", ifp->if_xname, - sppp_phase_name(sp->pp_phase)); - } + SPPP_DLOG(sp, "phase %s\n", + sppp_phase_name(sp->pp_phase)); } /* @@ -619,7 +640,6 @@ sppp_input(struct ifnet *ifp, struct mbu struct ifqueue *inq = NULL; uint16_t protocol; struct sppp *sp = (struct sppp *)ifp; - int debug = ifp->if_flags & IFF_DEBUG; int isr = 0; SPPP_LOCK(sp, RW_READER); @@ -633,10 +653,8 @@ sppp_input(struct ifnet *ifp, struct mbu if (m->m_pkthdr.len <= PPP_HEADER_LEN) { /* Too small packet, drop it. */ - if (debug) - log(LOG_DEBUG, - "%s: input packet is too small, %d bytes\n", - ifp->if_xname, m->m_pkthdr.len); + SPPP_DLOG(sp, "input packet is too small, " + "%d bytes\n", m->m_pkthdr.len); goto drop; } @@ -658,21 +676,15 @@ sppp_input(struct ifnet *ifp, struct mbu case CISCO_MULTICAST: case CISCO_UNICAST: /* Don't check the control field here (RFC 1547). */ - if (debug) -log(LOG_DEBUG, -"%s: Cisco packet in PPP mode " -"\n", -ifp->if_xname, -h->address, h->control, ntohs(h->protocol)); + SPPP_DLOG(sp, "Cisco packet in PPP mode " + "\n", + h->address, h->control, ntohs(h->protocol)); goto drop; default:/* Invalid PPP packet. */ invalid: - if (debug) -log(LOG_DEBUG, -"%s: invalid input packet " -"\n", -ifp->if_xname, -h->address, h->control, ntohs(h->protocol)); + SPPP_DLOG(sp, "invalid input packet " + "\n", + h->address, h->control, ntohs(h->protocol)); goto drop; } protocol = ntohs(h->protocol); @@ -692,11 +704,8 @@ sppp_input(struct ifnet *ifp, struct mbu if_statinc(ifp, if_noproto); goto drop; default: - if (debug) { - log(LOG_DEBUG, - "%s: invalid input protocol " - "\n", ifp->if_xname, protocol); - } + SPPP_DLOG(sp, "invalid input protocol " + "\n", protocol); goto reject_protocol; case PPP_LCP: SPPP_UNLOCK(sp); @@ -720,9 +729,8 @@ sppp_input(struct ifnet *ifp, struct mbu #ifdef INET case PPP_IPCP: if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) { - log(LOG_INFO, "%s: reject IPCP packet " - "because IPCP is disabled\n", - ifp->if_xname); + SPPP_LOG(sp,
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 05:04:06 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Send RTM_IFINFO when a network configuration protocol is up or down To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.252 src/sys/net/if_spppsubr.c:1.253 --- src/sys/net/if_spppsubr.c:1.252 Tue Jun 1 04:59:50 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 05:04:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.252 2021/06/01 04:59:50 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.253 2021/06/01 05:04:06 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.252 2021/06/01 04:59:50 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.253 2021/06/01 05:04:06 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -417,6 +417,7 @@ static enum cp_rcr_type static void sppp_ipcp_confrej(struct sppp *, struct lcp_header *, int); static void sppp_ipcp_confnak(struct sppp *, struct lcp_header *, int); static void sppp_ipcp_tlu(struct sppp *); +static void sppp_ipcp_tld(struct sppp *); static void sppp_ipcp_scr(struct sppp *); static void sppp_ipv6cp_init(struct sppp *); @@ -427,6 +428,7 @@ static enum cp_rcr_type static void sppp_ipv6cp_confrej(struct sppp *, struct lcp_header *, int); static void sppp_ipv6cp_confnak(struct sppp *, struct lcp_header *, int); static void sppp_ipv6cp_tlu(struct sppp *); +static void sppp_ipv6cp_tld(struct sppp *); static void sppp_ipv6cp_scr(struct sppp *); static void sppp_pap_input(struct sppp *, struct mbuf *); @@ -504,7 +506,7 @@ static const struct cp ipcp = { "ipcp", sppp_up_event, sppp_down_event, sppp_ipcp_open, sppp_ipcp_close, sppp_to_event, - sppp_ipcp_tlu, sppp_null, sppp_tls, + sppp_ipcp_tlu, sppp_ipcp_tld, sppp_tls, sppp_tlf, sppp_ipcp_scr, sppp_screply, sppp_ipcp_confreq, sppp_ipcp_confrej, sppp_ipcp_confnak, }; @@ -519,7 +521,7 @@ static const struct cp ipv6cp = { "ipv6cp", sppp_up_event, sppp_down_event, sppp_ipv6cp_open, sppp_close_event, sppp_to_event, - sppp_ipv6cp_tlu, sppp_null, sppp_tls, + sppp_ipv6cp_tlu, sppp_ipv6cp_tld, sppp_tls, sppp_tlf, sppp_ipv6cp_scr, sppp_screply, sppp_ipv6cp_confreq, sppp_ipv6cp_confrej, sppp_ipv6cp_confnak, }; @@ -3936,8 +3938,9 @@ sppp_ipcp_tlu(struct sppp *sp) #ifdef INET struct ifnet *ifp; - ifp = >pp_if; KASSERT(SPPP_WLOCKED(sp)); + + ifp = >pp_if; if ((sp->ipcp.flags & IPCP_MYADDR_DYN) && ((sp->ipcp.flags & IPCP_MYADDR_SEEN) == 0)) { log(LOG_WARNING, "%s: no IP address, closing IPCP\n", @@ -3947,11 +3950,25 @@ sppp_ipcp_tlu(struct sppp *sp) } else { /* we are up. Set addresses and notify anyone interested */ sppp_set_ip_addrs(sp); + rt_ifmsg(ifp); } #endif } static void +sppp_ipcp_tld(struct sppp *sp) +{ +#ifdef INET + struct ifnet *ifp; + + KASSERT(SPPP_WLOCKED(sp)); + + ifp = >pp_if; + rt_ifmsg(ifp); +#endif +} + +static void sppp_ipcp_scr(struct sppp *sp) { uint8_t opt[6 /* compression */ + 6 /* address */ + 12 /* dns addresses */]; @@ -4483,10 +4500,25 @@ end: static void sppp_ipv6cp_tlu(struct sppp *sp) { + struct ifnet *ifp; KASSERT(SPPP_WLOCKED(sp)); + + ifp = >pp_if; /* we are up - notify isdn daemon */ sppp_notify_con_wlocked(sp); + rt_ifmsg(ifp); +} + +static void +sppp_ipv6cp_tld(struct sppp *sp) +{ + struct ifnet *ifp; + + KASSERT(SPPP_WLOCKED(sp)); + + ifp = >pp_if; + rt_ifmsg(ifp); } static void
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 04:59:50 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Drop the Open event of LCP to stop the interface even a reconnection is scheduled The queue for events in if_spppsubr.c is not possible to enqueue the same event. So, The close event caused while a close event and open event are enqueued for reconnection is not possible to stop interface. To solve this issue, The open event after "ifconfig pppoe? down" is dropped. To generate a diff of this commit: cvs rdiff -u -r1.251 -r1.252 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.41 -r1.42 src/sys/net/if_spppvar.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/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.251 src/sys/net/if_spppsubr.c:1.252 --- src/sys/net/if_spppsubr.c:1.251 Tue Jun 1 04:55:55 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 04:59:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.251 2021/06/01 04:55:55 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.252 2021/06/01 04:59:50 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.251 2021/06/01 04:55:55 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.252 2021/06/01 04:59:50 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1256,6 +1256,12 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd ifp->if_flags &= ~IFF_AUTO; } + if (ifp->if_flags & IFF_UP) { + sp->pp_flags |= PP_ADMIN_UP; + } else { + sp->pp_flags &= ~PP_ADMIN_UP; + } + if (going_up || going_down) { sp->lcp.reestablish = false; sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_close); @@ -2571,6 +2577,10 @@ sppp_lcp_open(struct sppp *sp, void *xcp sp->lcp.reestablish = false; sp->scp[IDX_LCP].fail_counter = 0; + /* the interface was down while waiting for reconnection */ + if ((sp->pp_flags & PP_ADMIN_UP) == 0) + return; + if (sp->pp_if.if_mtu < PP_MTU) { sp->lcp.mru = sp->pp_if.if_mtu; SET(sp->lcp.opts, SPPP_LCP_OPT_MRU); Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.41 src/sys/net/if_spppvar.h:1.42 --- src/sys/net/if_spppvar.h:1.41 Tue Jun 1 04:55:55 2021 +++ src/sys/net/if_spppvar.h Tue Jun 1 04:59:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.41 2021/06/01 04:55:55 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.42 2021/06/01 04:59:50 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -214,6 +214,7 @@ struct sppp { #define PP_LOOPBACK 0x40 /* in line loopback mode */ #define PP_LOOPBACK_IFDOWN 0x80 /* if_down() when loopback detected */ #define PP_KEEPALIVE_IFDOWN 0x100 /* if_down() when no ECHO_REPLY received */ +#define PP_ADMIN_UP 0x200 /* the interface is up */ #define PP_MTU 1500/* default/minimal MRU */
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 04:55:56 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: remove PP_CISCO that was used in obsoleted drivers e.g. lmc(4) To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.40 -r1.41 src/sys/net/if_spppvar.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/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.250 src/sys/net/if_spppsubr.c:1.251 --- src/sys/net/if_spppsubr.c:1.250 Tue Jun 1 04:45:22 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 04:55:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.250 2021/06/01 04:45:22 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.251 2021/06/01 04:55:55 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.250 2021/06/01 04:45:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.251 2021/06/01 04:55:55 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -346,9 +346,6 @@ static u_short interactive_ports[8] = { static int sppp_output(struct ifnet *, struct mbuf *, const struct sockaddr *, const struct rtentry *); -static void sppp_cisco_send(struct sppp *, int, int32_t, int32_t); -static void sppp_cisco_input(struct sppp *, struct mbuf *); - static void sppp_cp_init(const struct cp *, struct sppp *); static void sppp_cp_fini(const struct cp *, struct sppp *); static void sppp_cp_input(const struct cp *, struct sppp *, @@ -655,49 +652,17 @@ sppp_input(struct ifnet *ifp, struct mbu case PPP_ALLSTATIONS: if (h->control != PPP_UI) goto invalid; - if (sp->pp_flags & PP_CISCO) { -if (debug) - log(LOG_DEBUG, - "%s: PPP packet in Cisco mode " - "\n", - ifp->if_xname, - h->address, h->control, ntohs(h->protocol)); -goto drop; - } break; case CISCO_MULTICAST: case CISCO_UNICAST: /* Don't check the control field here (RFC 1547). */ - if (! (sp->pp_flags & PP_CISCO)) { -if (debug) - log(LOG_DEBUG, - "%s: Cisco packet in PPP mode " - "\n", - ifp->if_xname, - h->address, h->control, ntohs(h->protocol)); -goto drop; - } - switch (ntohs(h->protocol)) { - default: -if_statinc(ifp, if_noproto); -goto invalid; - case CISCO_KEEPALIVE: -SPPP_UNLOCK(sp); -sppp_cisco_input((struct sppp *) ifp, m); -m_freem(m); -return; -#ifdef INET - case ETHERTYPE_IP: -pktq = ip_pktq; -break; -#endif -#ifdef INET6 - case ETHERTYPE_IPV6: -pktq = ip6_pktq; -break; -#endif - } - goto queue_pkt; + if (debug) +log(LOG_DEBUG, +"%s: Cisco packet in PPP mode " +"\n", +ifp->if_xname, +h->address, h->control, ntohs(h->protocol)); + goto drop; default:/* Invalid PPP packet. */ invalid: if (debug) @@ -799,7 +764,6 @@ sppp_input(struct ifnet *ifp, struct mbu #endif } -queue_pkt: if ((ifp->if_flags & IFF_UP) == 0 || (!inq && !pktq)) { goto drop; } @@ -979,74 +943,61 @@ sppp_output(struct ifnet *ifp, struct mb * (albeit due to the implementation it's always enough) */ h = mtod(m, struct ppp_header *); - if (sp->pp_flags & PP_CISCO) { - h->address = CISCO_UNICAST;/* unicast address */ - h->control = 0; - } else { - h->address = PPP_ALLSTATIONS;/* broadcast address */ - h->control = PPP_UI; /* Unnumbered Info */ - } + h->address = PPP_ALLSTATIONS;/* broadcast address */ + h->control = PPP_UI; /* Unnumbered Info */ } switch (dst->sa_family) { #ifdef INET case AF_INET: /* Internet Protocol */ - if (sp->pp_flags & PP_CISCO) - protocol = htons(ETHERTYPE_IP); - else { - /* - * Don't choke with an ENETDOWN early. It's - * possible that we just started dialing out, - * so don't drop the packet immediately. If - * we notice that we run out of buffer space - * below, we will however remember that we are - * not ready to carry IP packets, and return - * ENETDOWN, as opposed to ENOBUFS. - */ - protocol = htons(PPP_IP); - if (sp->scp[IDX_IPCP].state != STATE_OPENED) { -if (ifp->if_flags & IFF_AUTO) { - error = ENETDOWN; -} else { - IF_DROP(>if_snd); - SPPP_UNLOCK(sp); - splx(s); - - m_freem(m); - if_statinc(ifp, if_oerrors); - return (ENETDOWN); -} + /* + * Don't choke with an ENETDOWN early. It's + * possible that we just started dialing out, + * so don't drop the packet immediately. If + * we notice that we run out of buffer space + * below, we will however remember that we are + * not ready to carry IP packets, and return + * ENETDOWN, as opposed to ENOBUFS. + */ + protocol =
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 04:45:22 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Remove open event on tlf of PAP/CHAP when retry of them is over to prevent that LCP stops at Starting state. And also remove retry counter check on tls of LCP because of unnecessary. To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.249 src/sys/net/if_spppsubr.c:1.250 --- src/sys/net/if_spppsubr.c:1.249 Tue Jun 1 04:19:57 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 04:45:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.249 2021/06/01 04:19:57 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.250 2021/06/01 04:45:22 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.249 2021/06/01 04:19:57 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.250 2021/06/01 04:45:22 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3477,16 +3477,6 @@ sppp_lcp_tls(const struct cp *cp __unuse KASSERT(SPPP_WLOCKED(sp)); - if (sp->pp_max_auth_fail != 0 && sp->pp_auth_failures >= sp->pp_max_auth_fail) { - printf("%s: authentication failed %d times, not retrying again\n", - sp->pp_if.if_xname, sp->pp_auth_failures); - - SPPP_UNLOCK(sp); - if_down(>pp_if); - SPPP_LOCK(sp, RW_WRITER); - return; - } - sppp_change_phase(sp, SPPP_PHASE_ESTABLISH); /* Notify lower layer if desired. */ @@ -3597,7 +3587,18 @@ sppp_lcp_check_and_close(struct sppp *sp return; sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_close); - sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_open); + + if (sp->pp_max_auth_fail != 0 && + sp->pp_auth_failures >= sp->pp_max_auth_fail) { + printf("%s: authentication failed %d times, " + "not retrying again\n", + sp->pp_if.if_xname, sp->pp_auth_failures); + + sppp_wq_add(sp->wq_cp, >work_ifdown); + sp->pp_if.if_flags &= ~IFF_RUNNING; + } else { + sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_open); + } } /*
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 04:19:57 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Do not if_down() when a down event of the lower layer of LCP is happened since the layer try to reconnect. To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.248 src/sys/net/if_spppsubr.c:1.249 --- src/sys/net/if_spppsubr.c:1.248 Tue Jun 1 03:51:33 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 04:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.248 2021/06/01 03:51:33 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.249 2021/06/01 04:19:57 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.248 2021/06/01 03:51:33 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.249 2021/06/01 04:19:57 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2746,29 +2746,16 @@ sppp_lcp_down(struct sppp *sp, void *xcp sp->lcp.tlf_sent = false; } - /* - * If this is neither a dial-on-demand nor a passive - * interface, simulate an ``ifconfig down'' action, so the - * administrator can force a redial by another ``ifconfig - * up''. XXX For leased line operation, should we immediately - * try to reopen the connection here? - */ - if ((ifp->if_flags & (IFF_AUTO | IFF_PASSIVE)) == 0) { - if (debug) - log(LOG_INFO, - "%s: Down event (carrier loss), taking interface down.\n", - ifp->if_xname); - SPPP_UNLOCK(sp); - if_down(ifp); - SPPP_LOCK(sp, RW_WRITER); + if (debug) { + log(LOG_DEBUG, + "%s: Down event (carrier loss)\n", + ifp->if_xname); + } + if ((ifp->if_flags & (IFF_AUTO | IFF_PASSIVE)) == 0) { if (sp->lcp.reestablish) sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_open); } else { - if (debug) - log(LOG_DEBUG, - "%s: Down event (carrier loss)\n", - ifp->if_xname); sp->pp_flags &= ~PP_CALLIN; if (sp->scp[pidx].state != STATE_INITIAL)
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 03:51:33 UTC 2021 Modified Files: src/sys/conf: files src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Fix not to do if_down() before reconnect Almost network interface do not use if_down() even when there is no connectivity. So, pppoe(4) is also made be not used it. This behavior can be rollbacked by SPPP_IFDOWN_RECONNECT option. To generate a diff of this commit: cvs rdiff -u -r1.1285 -r1.1286 src/sys/conf/files cvs rdiff -u -r1.247 -r1.248 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.39 -r1.40 src/sys/net/if_spppvar.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/conf/files diff -u src/sys/conf/files:1.1285 src/sys/conf/files:1.1286 --- src/sys/conf/files:1.1285 Sat May 29 12:03:34 2021 +++ src/sys/conf/files Tue Jun 1 03:51:33 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1285 2021/05/29 12:03:34 simonb Exp $ +# $NetBSD: files,v 1.1286 2021/06/01 03:51:33 yamaguchi Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -292,6 +292,7 @@ defflag opt_ppp.h PPP_DEFLATE PPP_BSDCO defflag opt_pppoe.h PPPOE_SERVER PPPOE_DEBUG defparam opt_pppoe.h PPPOE_DEQUEUE_MAXLEN +defflag opt_sppp.h SPPP_IFDOWN_RECONNECT defparam opt_sppp.h SPPP_KEEPALIVE_INTERVAL SPPP_NORECV_TIME SPPP_ALIVE_INTERVAL Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.247 src/sys/net/if_spppsubr.c:1.248 --- src/sys/net/if_spppsubr.c:1.247 Tue Jun 1 03:27:23 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 03:51:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.247 2021/06/01 03:27:23 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.248 2021/06/01 03:51:33 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.247 2021/06/01 03:27:23 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.248 2021/06/01 03:51:33 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1136,6 +1136,9 @@ sppp_attach(struct ifnet *ifp) sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; sp->pp_ncpflags = SPPP_NCP_IPCP | SPPP_NCP_IPV6CP; +#ifdef SPPP_IFDOWN_RECONNECT + sp->pp_flags |= PP_LOOPBACK_IFDOWN | PP_KEEPALIVE_IFDOWN; +#endif sppp_wq_set(>work_ifdown, sppp_ifdown, NULL); memset(sp->scp, 0, sizeof(sp->scp)); rw_init(>pp_lock); @@ -1481,9 +1484,11 @@ sppp_cisco_input(struct sppp *sp, struct ifp->if_xname); sp->pp_loopcnt = 0; -sp->pp_flags |= PP_LOOPBACK; -sppp_wq_add(sp->wq_cp, ->work_ifdown); +if (sp->pp_flags & PP_LOOPBACK_IFDOWN) { + sp->pp_flags |= PP_LOOPBACK; + sppp_wq_add(sp->wq_cp, + >work_ifdown); +} sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_close); @@ -1951,9 +1956,11 @@ sppp_cp_input(const struct cp *cp, struc /* Line loopback mode detected. */ printf("%s: loopback\n", ifp->if_xname); - sp->pp_flags |= PP_LOOPBACK; - sppp_wq_add(sp->wq_cp, - >work_ifdown); + if (sp->pp_flags & PP_LOOPBACK_IFDOWN) { +sp->pp_flags |= PP_LOOPBACK; +sppp_wq_add(sp->wq_cp, +>work_ifdown); + } /* Shut down the PPP link. */ sppp_wq_add(sp->wq_cp, @@ -3001,9 +3008,11 @@ sppp_lcp_confreq(struct sppp *sp, struct ifp->if_xname); sp->pp_loopcnt = 0; -sp->pp_flags |= PP_LOOPBACK; -sppp_wq_add(sp->wq_cp, ->work_ifdown); +if (sp->pp_flags & PP_LOOPBACK_IFDOWN) { + sp->pp_flags |= PP_LOOPBACK; + sppp_wq_add(sp->wq_cp, + >work_ifdown); +} sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_close); @@ -5768,7 +5777,8 @@ sppp_keepalive(void *dummy) if (sp->pp_alivecnt >= sp->pp_maxalive) { /* No keepalive packets got. Stop the interface. */ - sppp_wq_add(sp->wq_cp, >work_ifdown); + if (sp->pp_flags & PP_KEEPALIVE_IFDOWN) +sppp_wq_add(sp->wq_cp, >work_ifdown); if (! (sp->pp_flags & PP_CISCO)) { printf("%s: LCP keepalive timed out, going to restart the connection\n", Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.39 src/sys/net/if_spppvar.h:1.40 --- src/sys/net/if_spppvar.h:1.39 Tue Jun 1 03:27:23 2021 +++ src/sys/net/if_spppvar.h Tue Jun 1 03:51:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.39 2021/06/01 03:27:23 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.40 2021/06/01 03:51:33 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -203,15 +203,17 @@ struct sppp { void (*pp_chg)(struct sppp *, int); }; -#define PP_KEEPALIVE 0x01 /* use keepalive protocol */ -#define PP_CISCO 0x02 /* use Cisco protocol instead of PPP */ -/* 0x04 was PP_TIMO */ -#define PP_CALLIN 0x08 /* we are being called */ -#define PP_NEEDAUTH 0x10 /* remote requested authentication */ -#define PP_NOFRAMING 0x20 /* do not add/expect
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Jun 1 03:27:23 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: restart LCP when loopback packets are detected In if_spppsubr.c down and up do not mean that LCP is stopping or running, but mean that the lower layer of LCP is up or down. And, restarting of LCP is had to use close event and open event. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.38 -r1.39 src/sys/net/if_spppvar.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/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.246 src/sys/net/if_spppsubr.c:1.247 --- src/sys/net/if_spppsubr.c:1.246 Wed May 19 02:14:19 2021 +++ src/sys/net/if_spppsubr.c Tue Jun 1 03:27:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.246 2021/05/19 02:14:19 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.247 2021/06/01 03:27:23 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.246 2021/05/19 02:14:19 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.247 2021/06/01 03:27:23 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1480,15 +1480,18 @@ sppp_cisco_input(struct sppp *sp, struct printf ("%s: loopback\n", ifp->if_xname); sp->pp_loopcnt = 0; -if (ifp->if_flags & IFF_UP) { - SPPP_UNLOCK(sp); - if_down(ifp); - SPPP_LOCK(sp, RW_WRITER); - IF_PURGE(>pp_cpq); -} +sp->pp_flags |= PP_LOOPBACK; +sppp_wq_add(sp->wq_cp, +>work_ifdown); + +sppp_wq_add(sp->wq_cp, +>scp[IDX_LCP].work_close); +sppp_wq_add(sp->wq_cp, +>scp[IDX_LCP].work_open); + } else { +++sp->pp_loopcnt; } - ++sp->pp_loopcnt; /* Generate new local sequence number */ sp->scp[IDX_LCP].seq = cprng_fast32(); @@ -1500,6 +1503,7 @@ sppp_cisco_input(struct sppp *sp, struct SPPP_UNLOCK(sp); if_up(ifp); SPPP_LOCK(sp, RW_WRITER); + sp->pp_flags &= ~PP_LOOPBACK; } break; case CISCO_ADDR_REQ: @@ -1946,20 +1950,16 @@ sppp_cp_input(const struct cp *cp, struc if (ntohl(u32) == sp->lcp.magic) { /* Line loopback mode detected. */ printf("%s: loopback\n", ifp->if_xname); - /* - * There is no change for items of sp->scp[cp->protoidx] - * while if_down() even without SPPP_LOCK - */ - SPPP_UNLOCK(sp); - if_down(ifp); - SPPP_LOCK(sp, RW_WRITER); - IF_PURGE(>pp_cpq); + sp->pp_flags |= PP_LOOPBACK; + sppp_wq_add(sp->wq_cp, + >work_ifdown); /* Shut down the PPP link. */ - /* XXX */ - sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_down); - sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_up); + sppp_wq_add(sp->wq_cp, + >scp[IDX_LCP].work_close); + sppp_wq_add(sp->wq_cp, + >scp[IDX_LCP].work_open); break; } u32 = htonl(sp->lcp.magic); @@ -3000,21 +3000,20 @@ sppp_lcp_confreq(struct sppp *sp, struct printf ("%s: loopback\n", ifp->if_xname); sp->pp_loopcnt = 0; -if (ifp->if_flags & IFF_UP) { - SPPP_UNLOCK(sp); - if_down(ifp); - SPPP_LOCK(sp, RW_WRITER); - IF_PURGE(>pp_cpq); - /* XXX ? */ - sppp_wq_add(sp->wq_cp, - >scp[IDX_LCP].work_down); - sppp_wq_add(sp->wq_cp, - >scp[IDX_LCP].work_up); -} - } else if (debug) -addlog(" [glitch]"); - ++sp->pp_loopcnt; +sp->pp_flags |= PP_LOOPBACK; +sppp_wq_add(sp->wq_cp, +>work_ifdown); + +sppp_wq_add(sp->wq_cp, +>scp[IDX_LCP].work_close); +sppp_wq_add(sp->wq_cp, +>scp[IDX_LCP].work_open); + } else { +if (debug) + addlog(" [glitch]"); +++sp->pp_loopcnt; + } /* * We negate our magic here, and NAK it. If * we see it later in an NAK packet, we @@ -3351,22 +3350,34 @@ sppp_lcp_tlu(struct sppp *sp) { STDDCL; int i; + bool going_up; KASSERT(SPPP_WLOCKED(sp)); /* unlock for IFNET_LOCK and if_up() */ SPPP_UNLOCK(sp); - /* XXX ? */ if (! (ifp->if_flags & IFF_UP) && (ifp->if_flags & IFF_RUNNING)) { /* Coming out of loopback mode. */ + going_up = true; if_up(ifp); + } else { + going_up = false; } IFNET_LOCK(ifp); SPPP_LOCK(sp, RW_WRITER); + if (going_up) { + if ((sp->pp_flags & PP_LOOPBACK) == 0) { + log(LOG_DEBUG, "%s: interface is going up, " + "but no loopback packet is deteted\n", + ifp->if_xname); + } + sp->pp_flags &= ~PP_LOOPBACK; + } + if (ifp->if_mtu > sp->lcp.their_mru) { sp->pp_saved_mtu = ifp->if_mtu; ifp->if_mtu = sp->lcp.their_mru; Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.38 src/sys/net/if_spppvar.h:1.39 --- src/sys/net/if_spppvar.h:1.38 Fri May 14 08:41:25 2021 +++ src/sys/net/if_spppvar.h Tue Jun 1 03:27:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v
CVS commit: src/tests/net/if_lagg
Module Name:src Committed By: yamaguchi Date: Tue May 25 00:38:30 UTC 2021 Modified Files: src/tests/net/if_lagg: t_lagg.sh Log Message: Added missing cleanup option Fixes PR/56206 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_lagg/t_lagg.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/if_lagg/t_lagg.sh diff -u src/tests/net/if_lagg/t_lagg.sh:1.1 src/tests/net/if_lagg/t_lagg.sh:1.2 --- src/tests/net/if_lagg/t_lagg.sh:1.1 Mon May 17 04:07:44 2021 +++ src/tests/net/if_lagg/t_lagg.sh Tue May 25 00:38:30 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_lagg.sh,v 1.1 2021/05/17 04:07:44 yamaguchi Exp $ +# $NetBSD: t_lagg.sh,v 1.2 2021/05/25 00:38:30 yamaguchi Exp $ # # Copyright (c) 2021 Internet Initiative Japan Inc. # All rights reserved. @@ -500,7 +500,7 @@ lagg_lacp_ipv4_cleanup() cleanup } -atf_test_case lagg_lacp_ipv6 +atf_test_case lagg_lacp_ipv6 cleanup lagg_lacp_ipv6_head() {
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Mon May 24 06:24:20 UTC 2021 Modified Files: src/sys/net/lagg: if_laggproto.h Log Message: Added missing copyright and license notice pointed out by thorpej@n.o., Thanks. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/net/lagg/if_laggproto.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/net/lagg/if_laggproto.h diff -u src/sys/net/lagg/if_laggproto.h:1.2 src/sys/net/lagg/if_laggproto.h:1.3 --- src/sys/net/lagg/if_laggproto.h:1.2 Wed May 19 06:13:08 2021 +++ src/sys/net/lagg/if_laggproto.h Mon May 24 06:24:20 2021 @@ -1,4 +1,30 @@ -/* $NetBSD: if_laggproto.h,v 1.2 2021/05/19 06:13:08 rillig Exp $ */ +/* $NetBSD: if_laggproto.h,v 1.3 2021/05/24 06:24:20 yamaguchi Exp $ */ + +/* + * Copyright (c) 2021 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. + */ #ifndef _NET_LAGG_IF_LAGGPROTO_H_ #define _NET_LAGG_IF_LAGGPROTO_H_
CVS commit: src/sys/net/lagg
Module Name:src Committed By: yamaguchi Date: Mon May 24 06:08:29 UTC 2021 Modified Files: src/sys/net/lagg: if_lagg.c if_lagg.h if_lagg_lacp.h if_laggvar.h Log Message: Added missing copyright and license notice pointed out by thorpej@n.o., Thanks. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.1 -r1.2 src/sys/net/lagg/if_lagg.h \ src/sys/net/lagg/if_lagg_lacp.h src/sys/net/lagg/if_laggvar.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/net/lagg/if_lagg.c diff -u src/sys/net/lagg/if_lagg.c:1.2 src/sys/net/lagg/if_lagg.c:1.3 --- src/sys/net/lagg/if_lagg.c:1.2 Wed May 19 10:20:50 2021 +++ src/sys/net/lagg/if_lagg.c Mon May 24 06:08:28 2021 @@ -1,7 +1,26 @@ -/* $NetBSD: if_lagg.c,v 1.2 2021/05/19 10:20:50 rillig Exp $ */ +/* $NetBSD: if_lagg.c,v 1.3 2021/05/24 06:08:28 yamaguchi Exp $ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.2 2021/05/19 10:20:50 rillig Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.3 2021/05/24 06:08:28 yamaguchi Exp $"); + +/* + * Copyright (c) 2005, 2006 Reyk Floeter + * Copyright (c) 2007 Andrew Thompson + * Copyright (c) 2014, 2016 Marcelo Araujo + * Copyright (c) 2021, Internet Initiative Japan Inc. + * + * 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. + */ #ifdef _KERNEL_OPT #include "opt_inet.h" Index: src/sys/net/lagg/if_lagg.h diff -u src/sys/net/lagg/if_lagg.h:1.1 src/sys/net/lagg/if_lagg.h:1.2 --- src/sys/net/lagg/if_lagg.h:1.1 Mon May 17 04:07:43 2021 +++ src/sys/net/lagg/if_lagg.h Mon May 24 06:08:28 2021 @@ -1,4 +1,48 @@ -/* $NetBSD: if_lagg.h,v 1.1 2021/05/17 04:07:43 yamaguchi Exp $ */ +/* $NetBSD: if_lagg.h,v 1.2 2021/05/24 06:08:28 yamaguchi Exp $ */ + +/* + * Copyright (c) 2005, 2006 Reyk Floeter + * + * 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. + * + * $FreeBSD$ + */ + +/* + * Copyright (c) 2021 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. + */ #ifndef _NET_LAGG_IF_LAGG_H_ #define _NET_LAGG_IF_LAGG_H_ Index: src/sys/net/lagg/if_lagg_lacp.h diff -u src/sys/net/lagg/if_lagg_lacp.h:1.1 src/sys/net/lagg/if_lagg_lacp.h:1.2 --- src/sys/net/lagg/if_lagg_lacp.h:1.1 Mon May 17 04:07:43 2021
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Wed May 19 03:44:46 UTC 2021 Modified Files: src/sys/conf: files src/sys/net: if_pppoe.c Log Message: Added a kernel option to change the number of processing packets at one pppoeintr() To generate a diff of this commit: cvs rdiff -u -r1.1283 -r1.1284 src/sys/conf/files cvs rdiff -u -r1.175 -r1.176 src/sys/net/if_pppoe.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/conf/files diff -u src/sys/conf/files:1.1283 src/sys/conf/files:1.1284 --- src/sys/conf/files:1.1283 Mon May 17 04:07:43 2021 +++ src/sys/conf/files Wed May 19 03:44:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1283 2021/05/17 04:07:43 yamaguchi Exp $ +# $NetBSD: files,v 1.1284 2021/05/19 03:44:46 yamaguchi Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -289,6 +289,7 @@ defflag opt_ppp.h PPP_DEFLATE PPP_BSDCO # compression, enable pppd # packet filtering support defflag opt_pppoe.h PPPOE_SERVER PPPOE_DEBUG +defparam opt_pppoe.h PPPOE_DEQUEUE_MAXLEN defparam opt_sppp.h SPPP_KEEPALIVE_INTERVAL SPPP_NORECV_TIME Index: src/sys/net/if_pppoe.c diff -u src/sys/net/if_pppoe.c:1.175 src/sys/net/if_pppoe.c:1.176 --- src/sys/net/if_pppoe.c:1.175 Wed May 19 03:35:27 2021 +++ src/sys/net/if_pppoe.c Wed May 19 03:44:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.175 2021/05/19 03:35:27 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.176 2021/05/19 03:44:46 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.175 2021/05/19 03:35:27 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.176 2021/05/19 03:44:46 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -76,6 +76,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v #define PPPOE_MPSAFE 1 #endif +#ifndef PPPOE_DEQUEUE_MAXLEN +#define PPPOE_DEQUEUE_MAXLEN IFQ_MAXLEN +#endif + struct pppoehdr { uint8_t vertype; uint8_t code; @@ -598,7 +602,7 @@ pppoeintr(void) SOFTNET_LOCK_UNLESS_NET_MPSAFE(); - for (i = 0; i < IFQ_MAXLEN; i++) { + for (i = 0; i < PPPOE_DEQUEUE_MAXLEN; i++) { IFQ_LOCK(); IF_DEQUEUE(, m); IFQ_UNLOCK(); @@ -607,7 +611,7 @@ pppoeintr(void) pppoe_disc_input(m); } - for (i = 0; i < IFQ_MAXLEN; i++) { + for (i = 0; i < PPPOE_DEQUEUE_MAXLEN; i++) { IFQ_LOCK(); IF_DEQUEUE(, m); IFQ_UNLOCK(); @@ -616,6 +620,11 @@ pppoeintr(void) pppoe_data_input(m); } +#if PPPOE_DEQUEUE_MAXLEN < IFQ_MAXLEN + if (!IF_IS_EMPTY() || !IF_IS_EMPTY()) + softint_schedule(pppoe_softintr); +#endif + SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed May 19 03:35:27 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Added a limitation of the number of processing packets because a enqueuing process can not add packets over IFQ_MAXLEN and removed reschedule at pppoeintr() because it also scheduled at enqueuing process. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.174 src/sys/net/if_pppoe.c:1.175 --- src/sys/net/if_pppoe.c:1.174 Tue May 18 01:46:29 2021 +++ src/sys/net/if_pppoe.c Wed May 19 03:35:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.174 2021/05/18 01:46:29 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.175 2021/05/19 03:35:27 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.174 2021/05/18 01:46:29 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.175 2021/05/19 03:35:27 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -594,36 +594,27 @@ static void pppoeintr(void) { struct mbuf *m; - int disc_done, data_done; + int i; SOFTNET_LOCK_UNLESS_NET_MPSAFE(); - do { - disc_done = 0; - data_done = 0; - for (;;) { - IFQ_LOCK(); - IF_DEQUEUE(, m); - IFQ_UNLOCK(); - if (m == NULL) -break; - disc_done = 1; - pppoe_disc_input(m); - } - - for (;;) { - IFQ_LOCK(); - IF_DEQUEUE(, m); - IFQ_UNLOCK(); - if (m == NULL) -break; - data_done = 1; - pppoe_data_input(m); - } - } while (disc_done || data_done); + for (i = 0; i < IFQ_MAXLEN; i++) { + IFQ_LOCK(); + IF_DEQUEUE(, m); + IFQ_UNLOCK(); + if (m == NULL) + break; + pppoe_disc_input(m); + } - if (!IF_IS_EMPTY() || !IF_IS_EMPTY()) - softint_schedule(pppoe_softintr); + for (i = 0; i < IFQ_MAXLEN; i++) { + IFQ_LOCK(); + IF_DEQUEUE(, m); + IFQ_UNLOCK(); + if (m == NULL) + break; + pppoe_data_input(m); + } SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed May 19 02:14:19 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Make functions that use for logging MP-safe There is no change in behavior. To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.245 src/sys/net/if_spppsubr.c:1.246 --- src/sys/net/if_spppsubr.c:1.245 Wed May 19 02:07:20 2021 +++ src/sys/net/if_spppsubr.c Wed May 19 02:14:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.245 2021/05/19 02:07:20 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.246 2021/05/19 02:14:19 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.245 2021/05/19 02:07:20 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.246 2021/05/19 02:14:19 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -116,6 +116,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define SPPP_ALIVE_INTERVAL DEFAULT_ALIVE_INTERVAL #endif +#define SPPP_CPTYPE_NAMELEN 5 /* buf size of cp type name */ +#define SPPP_AUTHTYPE_NAMELEN 32 /* buf size of auth type name */ +#define SPPP_LCPOPT_NAMELEN 5 /* buf size of lcp option name */ +#define SPPP_IPCPOPT_NAMELEN 5 /* buf size of ipcp option name */ +#define SPPP_IPV6CPOPT_NAMELEN 5 /* buf size of ipv6cp option name */ +#define SPPP_PROTO_NAMELEN 7 /* buf size of protocol name */ +#define SPPP_DOTQUAD_BUFLEN 16 /* length of "aa.bb.cc.dd" */ + /* * Interface flags that can be set in an ifconfig command. * @@ -437,16 +445,16 @@ static void sppp_chap_tlu(struct sppp *) static void sppp_chap_scr(struct sppp *); static void sppp_chap_rcv_challenge_event(struct sppp *, void *); -static const char *sppp_auth_type_name(u_short, u_char); -static const char *sppp_cp_type_name(u_char); -static const char *sppp_dotted_quad(uint32_t); -static const char *sppp_ipcp_opt_name(u_char); +static const char *sppp_auth_type_name(char *, size_t, u_short, u_char); +static const char *sppp_cp_type_name(char *, size_t, u_char); +static const char *sppp_dotted_quad(char *, size_t, uint32_t); +static const char *sppp_ipcp_opt_name(char *, size_t, u_char); #ifdef INET6 -static const char *sppp_ipv6cp_opt_name(u_char); +static const char *sppp_ipv6cp_opt_name(char *, size_t, u_char); #endif -static const char *sppp_lcp_opt_name(u_char); +static const char *sppp_lcp_opt_name(char *, size_t, u_char); static const char *sppp_phase_name(int); -static const char *sppp_proto_name(u_short); +static const char *sppp_proto_name(char *, size_t, u_short); static const char *sppp_state_name(int); static int sppp_params(struct sppp *, u_long, void *); #ifdef INET @@ -1612,10 +1620,15 @@ sppp_cp_send(struct sppp *sp, u_short pr memcpy(lh + 1, data, len); if (debug) { + char pbuf[SPPP_PROTO_NAMELEN]; + char tbuf[SPPP_CPTYPE_NAMELEN]; + const char *pname, *cpname; + + pname = sppp_proto_name(pbuf, sizeof(pbuf), proto); + cpname = sppp_cp_type_name(tbuf, sizeof(tbuf), lh->type); log(LOG_DEBUG, "%s: %s output <%s id=0x%x len=%d", - ifp->if_xname, - sppp_proto_name(proto), - sppp_cp_type_name(lh->type), lh->ident, ntohs(lh->len)); + ifp->if_xname, pname, cpname, + lh->ident, ntohs(lh->len)); if (len) sppp_print_bytes((u_char *)(lh + 1), len); addlog(">\n"); @@ -1756,6 +1769,8 @@ sppp_cp_input(const struct cp *cp, struc int printlen, len = m->m_pkthdr.len; u_char *p; uint32_t u32; + char tbuf[SPPP_CPTYPE_NAMELEN]; + const char *cpname; SPPP_LOCK(sp, RW_WRITER); @@ -1771,11 +1786,12 @@ sppp_cp_input(const struct cp *cp, struc h = mtod(m, struct lcp_header *); if (debug) { printlen = ntohs(h->len); + cpname = sppp_cp_type_name(tbuf, sizeof(tbuf), h->type); log(LOG_DEBUG, "%s: %s input(%s): <%s id=0x%x len=%d", ifp->if_xname, cp->name, sppp_state_name(scp->state), - sppp_cp_type_name(h->type), h->ident, printlen); + cpname, h->ident, printlen); if (len < printlen) printlen = len; if (printlen > 4) @@ -1855,11 +1871,11 @@ sppp_cp_input(const struct cp *cp, struc break; case CODE_REJ: /* XXX catastrophic rejects (RXJ-) aren't handled yet. */ + cpname = sppp_cp_type_name(tbuf, sizeof(tbuf), h->type); log(LOG_INFO, "%s: %s: ignoring RXJ (%s) for code ?, " "danger will robinson\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type)); + ifp->if_xname, cp->name, cpname); sppp_wq_add(sp->wq_cp, >work_rxj); break; case PROTO_REJ: @@ -1881,13 +1897,14 @@ sppp_cp_input(const struct cp *cp, struc if (upper == NULL) catastrophic++; - if (debug) + if (debug) { + cpname = sppp_cp_type_name(tbuf,
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed May 19 02:07:21 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added clear of dns addresses when IPCP is closed To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.244 src/sys/net/if_spppsubr.c:1.245 --- src/sys/net/if_spppsubr.c:1.244 Wed May 19 02:02:46 2021 +++ src/sys/net/if_spppsubr.c Wed May 19 02:07:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.244 2021/05/19 02:02:46 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.245 2021/05/19 02:07:20 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.244 2021/05/19 02:02:46 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.245 2021/05/19 02:07:20 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3662,12 +3662,14 @@ sppp_ipcp_close(struct sppp *sp, void *x sppp_close_event(sp, xcp); #ifdef INET - if (sp->ipcp.flags & (IPCP_MYADDR_DYN|IPCP_HISADDR_DYN)) + if (sp->ipcp.flags & (IPCP_MYADDR_DYN|IPCP_HISADDR_DYN)) { /* * Some address was dynamic, clear it again. */ sppp_clear_ip_addrs(sp); + } #endif + memset(>dns_addrs, 0, sizeof sp->dns_addrs); } /*
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed May 19 02:02:46 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added logs on dropping IPCP and IPv6CP packets To generate a diff of this commit: cvs rdiff -u -r1.243 -r1.244 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.243 src/sys/net/if_spppsubr.c:1.244 --- src/sys/net/if_spppsubr.c:1.243 Wed May 19 01:54:09 2021 +++ src/sys/net/if_spppsubr.c Wed May 19 02:02:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.243 2021/05/19 01:54:09 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.244 2021/05/19 02:02:46 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.243 2021/05/19 01:54:09 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.244 2021/05/19 02:02:46 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -714,13 +714,14 @@ sppp_input(struct ifnet *ifp, struct mbu ); SPPP_DOWNGRADE(sp); } - if (debug) - log(LOG_DEBUG, - "%s: invalid input protocol " - "\n", ifp->if_xname, protocol); if_statinc(ifp, if_noproto); goto drop; default: + if (debug) { + log(LOG_DEBUG, + "%s: invalid input protocol " + "\n", ifp->if_xname, protocol); + } goto reject_protocol; case PPP_LCP: SPPP_UNLOCK(sp); @@ -743,8 +744,12 @@ sppp_input(struct ifnet *ifp, struct mbu return; #ifdef INET case PPP_IPCP: - if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) { + log(LOG_INFO, "%s: reject IPCP packet " + "because IPCP is disabled\n", + ifp->if_xname); goto reject_protocol; + } SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -762,8 +767,12 @@ sppp_input(struct ifnet *ifp, struct mbu #endif #ifdef INET6 case PPP_IPV6CP: - if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) { + log(LOG_INFO, "%s: reject IPv6CP packet " + "because IPv6CP is disabled\n", + ifp->if_xname); goto reject_protocol; + } SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed May 19 01:54:09 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: remove a wrong ntohs(). The variable is already host-byte-order. To generate a diff of this commit: cvs rdiff -u -r1.242 -r1.243 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.242 src/sys/net/if_spppsubr.c:1.243 --- src/sys/net/if_spppsubr.c:1.242 Wed May 19 01:42:35 2021 +++ src/sys/net/if_spppsubr.c Wed May 19 01:54:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.242 2021/05/19 01:42:35 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.243 2021/05/19 01:54:09 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.242 2021/05/19 01:42:35 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.243 2021/05/19 01:54:09 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -717,7 +717,7 @@ sppp_input(struct ifnet *ifp, struct mbu if (debug) log(LOG_DEBUG, "%s: invalid input protocol " - "\n", ifp->if_xname, ntohs(protocol)); + "\n", ifp->if_xname, protocol); if_statinc(ifp, if_noproto); goto drop; default:
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed May 19 01:42:35 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added a log about rejection of IPCP address option To generate a diff of this commit: cvs rdiff -u -r1.241 -r1.242 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.241 src/sys/net/if_spppsubr.c:1.242 --- src/sys/net/if_spppsubr.c:1.241 Fri May 14 08:41:25 2021 +++ src/sys/net/if_spppsubr.c Wed May 19 01:42:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.241 2021/05/14 08:41:25 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.242 2021/05/19 01:42:35 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.241 2021/05/14 08:41:25 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.242 2021/05/19 01:42:35 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3929,6 +3929,11 @@ sppp_ipcp_confrej(struct sppp *sp, struc * Peer doesn't grok address option. This is * bad. XXX Should we better give up here? */ + if (!debug) { +log(LOG_ERR, "%s: " +"IPCP address option rejected\n", +ifp->if_xname); + } CLR(sp->ipcp.opts, SPPP_IPCP_OPT_ADDRESS); break; #ifdef notyet
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 18 01:46:29 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Added missing PPPOE_UNLOCK() on dropping PADS and PADT To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.173 src/sys/net/if_pppoe.c:1.174 --- src/sys/net/if_pppoe.c:1.173 Thu May 13 03:48:55 2021 +++ src/sys/net/if_pppoe.c Tue May 18 01:46:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.173 2021/05/13 03:48:55 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.174 2021/05/18 01:46:29 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.173 2021/05/13 03:48:55 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.174 2021/05/18 01:46:29 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1009,6 +1009,7 @@ breakbreak:; if (memcmp(>sc_dest, eh->ether_shost, sizeof sc->sc_dest) != 0) { + PPPOE_UNLOCK(sc); goto done; } @@ -1036,6 +1037,7 @@ breakbreak:; if (memcmp(>sc_dest, eh->ether_shost, sizeof sc->sc_dest) != 0) { + PPPOE_UNLOCK(sc); goto done; }
CVS commit: src/doc
Module Name:src Committed By: yamaguchi Date: Mon May 17 06:31:30 UTC 2021 Modified Files: src/doc: CHANGES Log Message: doc: added lagg(4) To generate a diff of this commit: cvs rdiff -u -r1.2806 -r1.2807 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2806 src/doc/CHANGES:1.2807 --- src/doc/CHANGES:1.2806 Sat May 15 10:22:46 2021 +++ src/doc/CHANGES Mon May 17 06:31:30 2021 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2806 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2807 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -374,3 +374,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0: audio API. wskbd(4): Added German Neo 2 layout. [nia 20210511] spiflash(4): Add support for Rockchip RK3328. [mrg 20210514] + lagg(4): Added a link-aggregation interface. [yamaguchi 20210517]
CVS commit: src/sbin/pppoectl
Module Name:src Committed By: yamaguchi Date: Fri May 14 09:08:59 UTC 2021 Modified Files: src/sbin/pppoectl: pppoectl.c Log Message: Added a keyword to change keepalive interval To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sbin/pppoectl/pppoectl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/pppoectl/pppoectl.c diff -u src/sbin/pppoectl/pppoectl.c:1.29 src/sbin/pppoectl/pppoectl.c:1.30 --- src/sbin/pppoectl/pppoectl.c:1.29 Tue May 11 06:58:03 2021 +++ src/sbin/pppoectl/pppoectl.c Fri May 14 09:08:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pppoectl.c,v 1.29 2021/05/11 06:58:03 yamaguchi Exp $ */ +/* $NetBSD: pppoectl.c,v 1.30 2021/05/14 09:08:59 yamaguchi Exp $ */ /* * Copyright (c) 1997 Joerg Wunsch @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pppoectl.c,v 1.29 2021/05/11 06:58:03 yamaguchi Exp $"); +__RCSID("$NetBSD: pppoectl.c,v 1.30 2021/05/14 09:08:59 yamaguchi Exp $"); #endif @@ -57,7 +57,7 @@ __dead static void print_error(const cha static void print_vals(const char *ifname, int phase, struct spppauthcfg *sp, int lcp_timeout, time_t idle_timeout, int authfailures, int max_auth_failures, u_int maxalive, time_t max_noreceive, - int ncp_flags); + u_int alive_interval, int ncp_flags); static void print_dns(const char *ifname, int dns1, int dns2, int s, int tabs); static void print_stats(const char *ifname, int s, int dump); static const char *phase_name(int phase); @@ -85,6 +85,7 @@ static int set_auth, set_lcp, set_idle_t static u_int set_ncpflags, clr_ncpflags; static int maxalive = -1; static int max_noreceive = -1; +static int alive_intval = -1; static struct spppauthcfg spr; static struct sppplcpcfg lcp; static struct spppncpcfg ncp; @@ -268,6 +269,7 @@ main(int argc, char **argv) authfailstats.max_failures, keepalivesettings.maxalive, keepalivesettings.max_noreceive, + keepalivesettings.alive_interval, ncp.ncp_flags); if (spr.hisname) free(spr.hisname); @@ -351,6 +353,8 @@ main(int argc, char **argv) keepalivesettings.max_noreceive = max_noreceive; if (maxalive >= 0) keepalivesettings.maxalive = maxalive; + if (alive_intval >= 0) + keepalivesettings.alive_interval = alive_intval; if (ioctl(s, SPPPSETKEEPALIVE, ) == -1) err(EX_OSERR, "SPPPSETKEEPALIVE"); } @@ -365,6 +369,7 @@ main(int argc, char **argv) authfailstats.max_failures, keepalivesettings.maxalive, keepalivesettings.max_noreceive, + keepalivesettings.alive_interval, ncp.ncp_flags); } @@ -446,6 +451,15 @@ pppoectl_argument(char *arg) } else { set_keepalive = 1; } + } else if (startswith(arg, "alive-interval=")) { + alive_intval = atoi(arg+off); + if (alive_intval < 0) { + fprintf(stderr, + "alive-interval value must be at least 0\n"); + alive_intval = -1; + } else { + set_keepalive = 1; + } } else if (strcmp(arg, "callin") == 0) spr.hisauthflags |= SPPP_AUTHFLAG_NOCALLOUT; else if (strcmp(arg, "always") == 0) @@ -528,7 +542,8 @@ usage(void) static void print_vals(const char *ifname, int phase, struct spppauthcfg *sp, int lcp_timeout, time_t idle_timeout, int authfailures, int max_auth_failures, - u_int maxalive_cnt, time_t max_noreceive_time, int ncp_flags) + u_int maxalive_cnt, time_t max_noreceive_time, u_int alive_interval, + int ncp_flags) { #ifndef __NetBSD__ time_t send, recv; @@ -568,6 +583,7 @@ print_vals(const char *ifname, int phase printf("\tmax-noreceive = %ld seconds\n", (long)max_noreceive_time); printf("\tmax-alive-missed = %u unanswered echo requests\n", maxalive_cnt); + printf("\talive-interval = %u\n", alive_interval); #ifndef __NetBSD__ printf("\tenable_vj: %s\n",
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Fri May 14 08:41:25 UTC 2021 Modified Files: src/sys/conf: files src/sys/net: if_sppp.h if_spppsubr.c if_spppvar.h Log Message: Add a parameter to change keepalive interval in each PPPoE I/F To generate a diff of this commit: cvs rdiff -u -r1.1281 -r1.1282 src/sys/conf/files cvs rdiff -u -r1.35 -r1.36 src/sys/net/if_sppp.h cvs rdiff -u -r1.240 -r1.241 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.37 -r1.38 src/sys/net/if_spppvar.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/conf/files diff -u src/sys/conf/files:1.1281 src/sys/conf/files:1.1282 --- src/sys/conf/files:1.1281 Fri May 14 08:31:14 2021 +++ src/sys/conf/files Fri May 14 08:41:25 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1281 2021/05/14 08:31:14 yamaguchi Exp $ +# $NetBSD: files,v 1.1282 2021/05/14 08:41:25 yamaguchi Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -292,6 +292,7 @@ defflag opt_pppoe.h PPPOE_SERVER PPPOE_ defparam opt_sppp.h SPPP_KEEPALIVE_INTERVAL SPPP_NORECV_TIME +SPPP_ALIVE_INTERVAL # networking options # Index: src/sys/net/if_sppp.h diff -u src/sys/net/if_sppp.h:1.35 src/sys/net/if_sppp.h:1.36 --- src/sys/net/if_sppp.h:1.35 Tue May 11 06:42:42 2021 +++ src/sys/net/if_sppp.h Fri May 14 08:41:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.35 2021/05/11 06:42:42 yamaguchi Exp $ */ +/* $NetBSD: if_sppp.h,v 1.36 2021/05/14 08:41:25 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -153,6 +153,7 @@ struct spppkeepalivesettings { u_int maxalive; /* number of LCP echo req. w/o reply */ time_t max_noreceive; /* (sec.) grace period before we start sending LCP echo requests. */ + u_int alive_interval; /* number of keepalive between echo req. */ }; struct spppkeepalivesettings50 { char ifname[IFNAMSIZ]; /* pppoe interface name */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.240 src/sys/net/if_spppsubr.c:1.241 --- src/sys/net/if_spppsubr.c:1.240 Fri May 14 08:31:14 2021 +++ src/sys/net/if_spppsubr.c Fri May 14 08:41:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.240 2021/05/14 08:31:14 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.241 2021/05/14 08:41:25 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.240 2021/05/14 08:31:14 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.241 2021/05/14 08:41:25 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #endif #define DEFAULT_KEEPALIVE_INTERVAL 10 /* seconds between checks */ +#define DEFAULT_ALIVE_INTERVAL 1 /* count of sppp_keepalive */ #define LOOPALIVECNT 3 /* loopback detection tries */ #define DEFAULT_MAXALIVECNT 3 /* max. missed alive packets */ #define DEFAULT_NORECV_TIME 15 /* before we get worried */ @@ -111,6 +112,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define SPPP_NORECV_TIME DEFAULT_NORECV_TIME #endif +#ifndef SPPP_ALIVE_INTERVAL +#define SPPP_ALIVE_INTERVAL DEFAULT_ALIVE_INTERVAL +#endif + /* * Interface flags that can be set in an ifconfig command. * @@ -289,6 +294,7 @@ enum auth_role { static struct sppp *spppq; static kmutex_t *spppq_lock = NULL; static callout_t keepalive_ch; +static unsigned int sppp_keepalive_cnt = 0; #define SPPPQ_LOCK() if (spppq_lock) \ mutex_enter(spppq_lock); @@ -1102,6 +1108,7 @@ sppp_attach(struct ifnet *ifp) sp->pp_cpq.ifq_maxlen = 20; sp->pp_loopcnt = 0; sp->pp_alivecnt = 0; + sp->pp_alive_interval = SPPP_ALIVE_INTERVAL; sp->pp_last_activity = 0; sp->pp_last_receive = 0; sp->pp_maxalive = DEFAULT_MAXALIVECNT; @@ -5637,6 +5644,18 @@ sppp_keepalive(void *dummy) continue; } + /* No echo request */ + if (sp->pp_alive_interval == 0) { + SPPP_UNLOCK(sp); + continue; + } + + /* send a ECHO_REQ once in sp->pp_alive_interval times */ + if ((sppp_keepalive_cnt % sp->pp_alive_interval) != 0) { + SPPP_UNLOCK(sp); + continue; + } + if (sp->pp_alivecnt >= sp->pp_maxalive) { /* No keepalive packets got. Stop the interface. */ sppp_wq_add(sp->wq_cp, >work_ifdown); @@ -5671,6 +5690,7 @@ sppp_keepalive(void *dummy) SPPP_UNLOCK(sp); } splx(s); + sppp_keepalive_cnt++; callout_reset(_ch, hz * SPPP_KEEPALIVE_INTERVAL, sppp_keepalive, NULL); SPPPQ_UNLOCK(); @@ -6318,6 +6338,7 @@ sppp_params(struct sppp *sp, u_long cmd, SPPP_LOCK(sp, RW_READER); settings->maxalive = sp->pp_maxalive; settings->max_noreceive = sp->pp_max_noreceive; + settings->alive_interval = sp->pp_alive_interval; SPPP_UNLOCK(sp); } break; @@ -6329,6 +6350,7 @@ sppp_params(struct sppp *sp, u_long cmd, SPPP_LOCK(sp, RW_WRITER); sp->pp_maxalive =
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Fri May 14 08:31:15 UTC 2021 Modified Files: src/sys/conf: files src/sys/net: if_spppsubr.c Log Message: Added SPPP_NORECV_TIME option to change pp_max_noreceive To generate a diff of this commit: cvs rdiff -u -r1.1280 -r1.1281 src/sys/conf/files cvs rdiff -u -r1.239 -r1.240 src/sys/net/if_spppsubr.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/conf/files diff -u src/sys/conf/files:1.1280 src/sys/conf/files:1.1281 --- src/sys/conf/files:1.1280 Fri May 14 08:06:32 2021 +++ src/sys/conf/files Fri May 14 08:31:14 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1280 2021/05/14 08:06:32 yamaguchi Exp $ +# $NetBSD: files,v 1.1281 2021/05/14 08:31:14 yamaguchi Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -291,6 +291,7 @@ defflag opt_ppp.h PPP_DEFLATE PPP_BSDCO defflag opt_pppoe.h PPPOE_SERVER PPPOE_DEBUG defparam opt_sppp.h SPPP_KEEPALIVE_INTERVAL +SPPP_NORECV_TIME # networking options # Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.239 src/sys/net/if_spppsubr.c:1.240 --- src/sys/net/if_spppsubr.c:1.239 Fri May 14 08:11:08 2021 +++ src/sys/net/if_spppsubr.c Fri May 14 08:31:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.239 2021/05/14 08:11:08 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.240 2021/05/14 08:31:14 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.239 2021/05/14 08:11:08 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.240 2021/05/14 08:31:14 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -107,6 +107,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define SPPP_KEEPALIVE_INTERVAL DEFAULT_KEEPALIVE_INTERVAL #endif +#ifndef SPPP_NORECV_TIME +#define SPPP_NORECV_TIME DEFAULT_NORECV_TIME +#endif + /* * Interface flags that can be set in an ifconfig command. * @@ -1101,7 +1105,7 @@ sppp_attach(struct ifnet *ifp) sp->pp_last_activity = 0; sp->pp_last_receive = 0; sp->pp_maxalive = DEFAULT_MAXALIVECNT; - sp->pp_max_noreceive = DEFAULT_NORECV_TIME; + sp->pp_max_noreceive = SPPP_NORECV_TIME; sp->pp_idle_timeout = 0; sp->pp_max_auth_fail = DEFAULT_MAX_AUTH_FAILURES; sp->pp_phase = SPPP_PHASE_DEAD;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri May 14 08:11:08 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Send echo request even while user data is received if pp_max_noreceive is 0 To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.238 src/sys/net/if_spppsubr.c:1.239 --- src/sys/net/if_spppsubr.c:1.238 Fri May 14 08:06:32 2021 +++ src/sys/net/if_spppsubr.c Fri May 14 08:11:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.238 2021/05/14 08:06:32 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.239 2021/05/14 08:11:08 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.238 2021/05/14 08:06:32 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.239 2021/05/14 08:11:08 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -5626,7 +5626,8 @@ sppp_keepalive(void *dummy) } /* No echo reply, but maybe user data passed through? */ - if ((now - sp->pp_last_receive) < sp->pp_max_noreceive) { + if (sp->pp_max_noreceive != 0 && + (now - sp->pp_last_receive) < sp->pp_max_noreceive) { sp->pp_alivecnt = 0; SPPP_UNLOCK(sp); continue;
CVS commit: src/sys
Module Name:src Committed By: yamaguchi Date: Fri May 14 08:06:32 UTC 2021 Modified Files: src/sys/conf: files src/sys/net: if_spppsubr.c Log Message: Introduce SPPP_KEEPALIVE_INTERVAL option to change the interval between LCP echo requests To generate a diff of this commit: cvs rdiff -u -r1.1279 -r1.1280 src/sys/conf/files cvs rdiff -u -r1.237 -r1.238 src/sys/net/if_spppsubr.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/conf/files diff -u src/sys/conf/files:1.1279 src/sys/conf/files:1.1280 --- src/sys/conf/files:1.1279 Sat Feb 6 16:03:31 2021 +++ src/sys/conf/files Fri May 14 08:06:32 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.1279 2021/02/06 16:03:31 dbj Exp $ +# $NetBSD: files,v 1.1280 2021/05/14 08:06:32 yamaguchi Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 version 20171118 @@ -290,6 +290,8 @@ defflag opt_ppp.h PPP_DEFLATE PPP_BSDCO # packet filtering support defflag opt_pppoe.h PPPOE_SERVER PPPOE_DEBUG +defparam opt_sppp.h SPPP_KEEPALIVE_INTERVAL + # networking options # defflagGATEWAY Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.237 src/sys/net/if_spppsubr.c:1.238 --- src/sys/net/if_spppsubr.c:1.237 Tue May 11 06:42:42 2021 +++ src/sys/net/if_spppsubr.c Fri May 14 08:06:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.237 2021/05/11 06:42:42 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.238 2021/05/14 08:06:32 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,13 +41,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.237 2021/05/11 06:42:42 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.238 2021/05/14 08:06:32 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" #include "opt_modular.h" #include "opt_compat_netbsd.h" #include "opt_net_mpsafe.h" +#include "opt_sppp.h" #endif #include @@ -96,12 +97,16 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define SPPPSUBR_MPSAFE 1 #endif -#define LCP_KEEPALIVE_INTERVAL 10 /* seconds between checks */ +#define DEFAULT_KEEPALIVE_INTERVAL 10 /* seconds between checks */ #define LOOPALIVECNT 3 /* loopback detection tries */ #define DEFAULT_MAXALIVECNT 3 /* max. missed alive packets */ #define DEFAULT_NORECV_TIME 15 /* before we get worried */ #define DEFAULT_MAX_AUTH_FAILURES 5 /* max. auth. failures */ +#ifndef SPPP_KEEPALIVE_INTERVAL +#define SPPP_KEEPALIVE_INTERVAL DEFAULT_KEEPALIVE_INTERVAL +#endif + /* * Interface flags that can be set in an ifconfig command. * @@ -1081,7 +1086,7 @@ sppp_attach(struct ifnet *ifp) /* Initialize keepalive handler. */ if (! spppq) { callout_init(_ch, CALLOUT_MPSAFE); - callout_reset(_ch, hz * LCP_KEEPALIVE_INTERVAL, sppp_keepalive, NULL); + callout_reset(_ch, hz * SPPP_KEEPALIVE_INTERVAL, sppp_keepalive, NULL); } if (! spppq_lock) @@ -5661,7 +5666,7 @@ sppp_keepalive(void *dummy) SPPP_UNLOCK(sp); } splx(s); - callout_reset(_ch, hz * LCP_KEEPALIVE_INTERVAL, sppp_keepalive, NULL); + callout_reset(_ch, hz * SPPP_KEEPALIVE_INTERVAL, sppp_keepalive, NULL); SPPPQ_UNLOCK(); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu May 13 03:48:55 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Drop PADS and PADT from unknown host for safety To generate a diff of this commit: cvs rdiff -u -r1.172 -r1.173 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.172 src/sys/net/if_pppoe.c:1.173 --- src/sys/net/if_pppoe.c:1.172 Thu May 13 03:28:36 2021 +++ src/sys/net/if_pppoe.c Thu May 13 03:48:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.172 2021/05/13 03:28:36 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.173 2021/05/13 03:48:55 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.172 2021/05/13 03:28:36 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.173 2021/05/13 03:48:55 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1007,6 +1007,11 @@ breakbreak:; if (sc == NULL) goto done; + if (memcmp(>sc_dest, eh->ether_shost, + sizeof sc->sc_dest) != 0) { + goto done; + } + sc->sc_session = session; callout_stop(>sc_timeout); pppoe_printf(sc, "session 0x%x connected\n", session); @@ -1029,6 +1034,11 @@ breakbreak:; if (sc == NULL) goto done; + if (memcmp(>sc_dest, eh->ether_shost, + sizeof sc->sc_dest) != 0) { + goto done; + } + pppoe_clear_softc(sc, "received PADT"); if (sc->sc_sppp.pp_if.if_flags & IFF_RUNNING) { pppoe_printf(sc, "wait for reconnect\n");
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Thu May 13 03:37:58 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Fix the wrong state check After disconnection from PPPoE server, the client waits for reconnection in initial state or reconnects in PADI state. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.31 src/tests/net/if_pppoe/t_pppoe.sh:1.32 --- src/tests/net/if_pppoe/t_pppoe.sh:1.31 Tue May 11 05:57:02 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Thu May 13 03:37:58 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.31 2021/05/11 05:57:02 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.32 2021/05/13 03:37:58 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -204,7 +204,8 @@ run_test() wait_for_disconnected atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping -c 1 -w $TIMEOUT $SERVER_IP - atf_check -s exit:0 -o match:'PADI sent' -x "$HIJACKING pppoectl -d pppoe0" + atf_check -s exit:0 -o match:'(PADI sent)|(initial)' \ + -x "$HIJACKING pppoectl -d pppoe0" unset RUMP_SERVER # test for reconnecting
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu May 13 03:28:36 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Change reconnect delay after PADT received (15 sec -> 5 sec) 5 sec is the same as minimum PADI resending interval To generate a diff of this commit: cvs rdiff -u -r1.171 -r1.172 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.171 src/sys/net/if_pppoe.c:1.172 --- src/sys/net/if_pppoe.c:1.171 Thu May 13 01:01:10 2021 +++ src/sys/net/if_pppoe.c Thu May 13 03:28:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.171 2021/05/13 01:01:10 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.172 2021/05/13 03:28:36 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.171 2021/05/13 01:01:10 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.172 2021/05/13 03:28:36 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -129,6 +129,7 @@ struct pppoetag { #define PPPOE_SLOW_RETRY (hz*60) /* persistent retry interval */ #define PPPOE_RECON_FAST (hz*15) /* first retry after auth failure */ #define PPPOE_RECON_IMMEDIATE (hz/10) /* "no delay" reconnect */ +#define PPPOE_RECON_PADTRCVD (hz*5) /* reconnect delay after PADT received */ #define PPPOE_DISC_MAXPADI 4 /* retry PADI four times (quickly) */ #define PPPOE_DISC_MAXPADR 2 /* retry PADR twice */ @@ -1029,8 +1030,11 @@ breakbreak:; goto done; pppoe_clear_softc(sc, "received PADT"); - if (sc->sc_sppp.pp_if.if_flags & IFF_RUNNING) - callout_schedule(>sc_timeout, PPPOE_RECON_FAST); + if (sc->sc_sppp.pp_if.if_flags & IFF_RUNNING) { + pppoe_printf(sc, "wait for reconnect\n"); + callout_schedule(>sc_timeout, + PPPOE_RECON_PADTRCVD); + } PPPOE_UNLOCK(sc); break;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu May 13 01:01:10 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Accept a frame like a PADT just containing PPPoE header To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.170 src/sys/net/if_pppoe.c:1.171 --- src/sys/net/if_pppoe.c:1.170 Thu Apr 22 10:26:24 2021 +++ src/sys/net/if_pppoe.c Thu May 13 01:01:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.170 2021/04/22 10:26:24 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.171 2021/05/13 01:01:10 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.170 2021/04/22 10:26:24 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.171 2021/05/13 01:01:10 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -659,7 +659,7 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, eh = mtod(m, struct ether_header *); off += sizeof(*eh); - if (m->m_pkthdr.len - off <= PPPOE_HEADERLEN) { + if (m->m_pkthdr.len - off < PPPOE_HEADERLEN) { goto done; }
CVS commit: src/sbin/pppoectl
Module Name:src Committed By: yamaguchi Date: Tue May 11 06:58:03 UTC 2021 Modified Files: src/sbin/pppoectl: pppoectl.c Log Message: Make authproto not change when "authproto" is not in command option To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sbin/pppoectl/pppoectl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/pppoectl/pppoectl.c diff -u src/sbin/pppoectl/pppoectl.c:1.28 src/sbin/pppoectl/pppoectl.c:1.29 --- src/sbin/pppoectl/pppoectl.c:1.28 Tue May 11 05:51:42 2021 +++ src/sbin/pppoectl/pppoectl.c Tue May 11 06:58:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pppoectl.c,v 1.28 2021/05/11 05:51:42 yamaguchi Exp $ */ +/* $NetBSD: pppoectl.c,v 1.29 2021/05/11 06:58:03 yamaguchi Exp $ */ /* * Copyright (c) 1997 Joerg Wunsch @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pppoectl.c,v 1.28 2021/05/11 05:51:42 yamaguchi Exp $"); +__RCSID("$NetBSD: pppoectl.c,v 1.29 2021/05/11 06:58:03 yamaguchi Exp $"); #endif @@ -203,6 +203,8 @@ main(int argc, char **argv) memset(, 0, sizeof spr); strncpy(spr.ifname, ifname, sizeof spr.ifname); + spr.myauth = SPPP_AUTHPROTO_NOCHG; + spr.hisauth = SPPP_AUTHPROTO_NOCHG; memset(, 0, sizeof lcp); strncpy(lcp.ifname, ifname, sizeof lcp.ifname); memset(, 0, sizeof ncp);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 06:42:42 UTC 2021 Modified Files: src/sys/net: if_sppp.h if_spppsubr.c Log Message: clear authentication protocol when SPPP_AUTHPROTO_NONE is specified To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/net/if_sppp.h cvs rdiff -u -r1.236 -r1.237 src/sys/net/if_spppsubr.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_sppp.h diff -u src/sys/net/if_sppp.h:1.34 src/sys/net/if_sppp.h:1.35 --- src/sys/net/if_sppp.h:1.34 Tue May 11 01:27:45 2021 +++ src/sys/net/if_sppp.h Tue May 11 06:42:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.34 2021/05/11 01:27:45 yamaguchi Exp $ */ +/* $NetBSD: if_sppp.h,v 1.35 2021/05/11 06:42:42 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -40,6 +40,7 @@ #define SPPP_AUTHPROTO_NONE 0 #define SPPP_AUTHPROTO_PAP 1 #define SPPP_AUTHPROTO_CHAP 2 +#define SPPP_AUTHPROTO_NOCHG 3 #define SPPP_AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ /* callouts */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.236 src/sys/net/if_spppsubr.c:1.237 --- src/sys/net/if_spppsubr.c:1.236 Tue May 11 06:33:17 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 06:42:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.236 2021/05/11 06:33:17 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.237 2021/05/11 06:42:42 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.236 2021/05/11 06:33:17 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.237 2021/05/11 06:42:42 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -185,6 +185,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define CISCO_ADDR_REPLY 1 /* Cisco address reply */ #define CISCO_KEEPALIVE_REQ 2 /* Cisco keepalive request */ +#define PPP_NOPROTO 0 /* no authentication protocol */ + enum { STATE_INITIAL = SPPP_STATE_INITIAL, STATE_STARTING = SPPP_STATE_STARTING, @@ -528,6 +530,34 @@ static const struct cp *cps[IDX_COUNT] = , /* IDX_CHAP */ }; +static inline u_int +sppp_proto2authproto(u_short proto) +{ + + switch (proto) { + case PPP_PAP: + return SPPP_AUTHPROTO_PAP; + case PPP_CHAP: + return SPPP_AUTHPROTO_CHAP; + } + + return SPPP_AUTHPROTO_NONE; +} + +static inline u_short +sppp_authproto2proto(u_int authproto) +{ + + switch (authproto) { + case SPPP_AUTHPROTO_PAP: + return PPP_PAP; + case SPPP_AUTHPROTO_CHAP: + return PPP_CHAP; + } + + return PPP_NOPROTO; +} + static void sppp_change_phase(struct sppp *sp, int phase) { @@ -2720,7 +2750,7 @@ sppp_lcp_open(struct sppp *sp, void *xcp /* * If we are authenticator, negotiate LCP_AUTH */ - if (sp->hisauth.proto != 0) + if (sp->hisauth.proto != PPP_NOPROTO) SET(sp->lcp.opts, SPPP_LCP_OPT_AUTH_PROTO); else CLR(sp->lcp.opts, SPPP_LCP_OPT_AUTH_PROTO); @@ -2854,7 +2884,7 @@ sppp_lcp_confreq(struct sppp *sp, struct if (authproto == PPP_PAP || authproto == PPP_CHAP) sp->myauth.proto = authproto; } - if (sp->myauth.proto == 0) { + if (sp->myauth.proto == PPP_NOPROTO) { /* we are not configured to do auth */ if (debug) addlog(" [not configured]"); @@ -5995,12 +6025,8 @@ sppp_params(struct sppp *sp, u_long cmd, cfg->myauthflags = sp->myauth.flags; cfg->hisauthflags = sp->hisauth.flags; strlcpy(cfg->ifname, sp->pp_if.if_xname, sizeof(cfg->ifname)); - cfg->hisauth = 0; - if (sp->hisauth.proto) - cfg->hisauth = (sp->hisauth.proto == PPP_PAP) ? SPPP_AUTHPROTO_PAP : SPPP_AUTHPROTO_CHAP; - cfg->myauth = 0; - if (sp->myauth.proto) - cfg->myauth = (sp->myauth.proto == PPP_PAP) ? SPPP_AUTHPROTO_PAP : SPPP_AUTHPROTO_CHAP; + cfg->hisauth = sppp_proto2authproto(sp->hisauth.proto); + cfg->myauth = sppp_proto2authproto(sp->myauth.proto); if (cfg->myname_length == 0) { if (sp->myauth.name != NULL) cfg->myname_length = sp->myauth.name_len + 1; @@ -6137,13 +6163,15 @@ sppp_params(struct sppp *sp, u_long cmd, sp->myauth.secret[sp->myauth.secret_len] = 0; } sp->myauth.flags = cfg->myauthflags; - if (cfg->myauth) - sp->myauth.proto = (cfg->myauth == SPPP_AUTHPROTO_PAP) ? PPP_PAP : PPP_CHAP; + if (cfg->myauth != SPPP_AUTHPROTO_NOCHG) { + sp->myauth.proto = sppp_authproto2proto(cfg->myauth); + } sp->hisauth.flags = cfg->hisauthflags; - if (cfg->hisauth) - sp->hisauth.proto = (cfg->hisauth == SPPP_AUTHPROTO_PAP) ? PPP_PAP : PPP_CHAP; + if (cfg->hisauth != SPPP_AUTHPROTO_NOCHG) { + sp->hisauth.proto = sppp_authproto2proto(cfg->hisauth); + } sp->pp_auth_failures = 0; - if (sp->hisauth.proto != 0) + if (sp->hisauth.proto != PPP_NOPROTO) SET(sp->lcp.opts, SPPP_LCP_OPT_AUTH_PROTO); else CLR(sp->lcp.opts, SPPP_LCP_OPT_AUTH_PROTO);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 06:33:17 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Drop packets that have no NCP not to start auto-dial To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.235 src/sys/net/if_spppsubr.c:1.236 --- src/sys/net/if_spppsubr.c:1.235 Tue May 11 06:27:18 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 06:33:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.235 2021/05/11 06:27:18 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.236 2021/05/11 06:33:17 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.235 2021/05/11 06:27:18 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.236 2021/05/11 06:33:17 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -809,6 +809,18 @@ sppp_output(struct ifnet *ifp, struct mb } if ((ifp->if_flags & (IFF_RUNNING | IFF_AUTO)) == IFF_AUTO) { + /* ignore packets that have no enabled NCP */ + if ((dst->sa_family == AF_INET && + !ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) || + (dst->sa_family == AF_INET6 && + !ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP))) { + SPPP_UNLOCK(sp); + splx(s); + + m_freem(m); + if_statinc(ifp, if_oerrors); + return (ENETDOWN); + } /* * Interface is not yet running, but auto-dial. Need * to start LCP for it.
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 06:27:19 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added missing if_oerror incrementing To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.234 src/sys/net/if_spppsubr.c:1.235 --- src/sys/net/if_spppsubr.c:1.234 Tue May 11 06:21:28 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 06:27:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.234 2021/05/11 06:21:28 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.235 2021/05/11 06:27:18 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.234 2021/05/11 06:21:28 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.235 2021/05/11 06:27:18 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -804,7 +804,7 @@ sppp_output(struct ifnet *ifp, struct mb splx(s); m_freem(m); - + if_statinc(ifp, if_oerrors); return (ENETDOWN); } @@ -930,8 +930,19 @@ sppp_output(struct ifnet *ifp, struct mb * ENETDOWN, as opposed to ENOBUFS. */ protocol = htons(PPP_IP); - if (sp->scp[IDX_IPCP].state != STATE_OPENED) -error = ENETDOWN; + if (sp->scp[IDX_IPCP].state != STATE_OPENED) { +if (ifp->if_flags & IFF_AUTO) { + error = ENETDOWN; +} else { + IF_DROP(>if_snd); + SPPP_UNLOCK(sp); + splx(s); + + m_freem(m); + if_statinc(ifp, if_oerrors); + return (ENETDOWN); +} + } } break; #endif @@ -950,8 +961,19 @@ sppp_output(struct ifnet *ifp, struct mb * ENETDOWN, as opposed to ENOBUFS. */ protocol = htons(PPP_IPV6); - if (sp->scp[IDX_IPV6CP].state != STATE_OPENED) -error = ENETDOWN; + if (sp->scp[IDX_IPV6CP].state != STATE_OPENED) { +if (ifp->if_flags & IFF_AUTO) { + error = ENETDOWN; +} else { + IF_DROP(>if_snd); + SPPP_UNLOCK(sp); + splx(s); + + m_freem(m); + if_statinc(ifp, if_oerrors); + return (ENETDOWN); +} + } } break; #endif
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 06:21:28 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Move RCA event after RCR event A authentication failed by TO+ event between RCA and RCR events 1. RCA event in REQ-SENT state - REQ-SENT => ACK-RCVD 2. TO+ event - ACK-RCVD => REQ-SENT 3. RCR+ event - REQ-SENT => ACK-SENT By moving RCA after RCR, the state is transisted to OPENED 1. RCR event - REQ-SENT => ACK-SENT 2. TO+ event - state is not changed 3. RCA event - ACK-SENT => OPENED To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.233 src/sys/net/if_spppsubr.c:1.234 --- src/sys/net/if_spppsubr.c:1.233 Tue May 11 01:27:45 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 06:21:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.233 2021/05/11 01:27:45 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.234 2021/05/11 06:21:28 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.233 2021/05/11 01:27:45 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.234 2021/05/11 06:21:28 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -4876,11 +4876,6 @@ sppp_chap_input(struct sppp *sp, struct if (memcmp(digest, value, value_len) == 0) { sp->scp[IDX_CHAP].rcr_type = CP_RCR_ACK; -if (!ISSET(sppp_auth_role(, sp), SPPP_AUTH_PEER) || -sp->chap.rechallenging) { - /* generate a dummy RCA event*/ - sppp_wq_add(sp->wq_cp, >scp[IDX_CHAP].work_rca); -} } else { sp->scp[IDX_CHAP].rcr_type = CP_RCR_NAK; } @@ -4896,6 +4891,13 @@ sppp_chap_input(struct sppp *sp, struct } sppp_wq_add(sp->wq_cp, >scp[IDX_CHAP].work_rcr); + + /* generate a dummy RCA event */ + if (sp->scp[IDX_CHAP].rcr_type == CP_RCR_ACK && + (!ISSET(sppp_auth_role(, sp), SPPP_AUTH_PEER) || + sp->chap.rechallenging)) { + sppp_wq_add(sp->wq_cp, >scp[IDX_CHAP].work_rca); + } break; default: @@ -5149,15 +5151,17 @@ sppp_pap_input(struct sppp *sp, struct m secret_len == sp->hisauth.secret_len && memcmp(secret, sp->hisauth.secret, secret_len) == 0) { sp->scp[IDX_PAP].rcr_type = CP_RCR_ACK; - if (!ISSET(sppp_auth_role(, sp), SPPP_AUTH_PEER)) { -/* generate a dummy RCA event*/ -sppp_wq_add(sp->wq_cp, >scp[IDX_PAP].work_rca); - } } else { sp->scp[IDX_PAP].rcr_type = CP_RCR_NAK; } sppp_wq_add(sp->wq_cp, >scp[IDX_PAP].work_rcr); + + /* generate a dummy RCA event */ + if (sp->scp[IDX_PAP].rcr_type == CP_RCR_ACK && + !ISSET(sppp_auth_role(, sp), SPPP_AUTH_PEER)) { + sppp_wq_add(sp->wq_cp, >scp[IDX_PAP].work_rca); + } break; /* ack and nak are his authproto */
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Tue May 11 05:57:02 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Add tests for "pppoectl {no}[ipcp|ipv6cp]" To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.30 src/tests/net/if_pppoe/t_pppoe.sh:1.31 --- src/tests/net/if_pppoe/t_pppoe.sh:1.30 Tue May 11 00:55:51 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Tue May 11 05:57:02 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.30 2021/05/11 00:55:51 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.31 2021/05/11 05:57:02 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -725,6 +725,37 @@ pppoe_params_body() -x "${dumpcmd} | grep PADR" atf_check -s exit:0 -o not-match:'\[AC-Name "ACNAME-TEST5\]"' -e ignore \ -x "${dumpcmd} | grep PADI" + + export RUMP_SERVER=$CLIENT + atf_ifconfig pppoe0 down + export RUMP_SERVER=$SERVER + wait_for_disconnected + + # ipcp & ipv6cp are enabled by default + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 -o match:'ipcp: enable' \ + -x "$HIJACKING pppoectl pppoe0" + atf_check -s exit:0 -o match:'ipv6cp: enable' \ + -x "$HIJACKING pppoectl pppoe0" + + # ipcp enable & ipv6cp disable + atf_pppoectl pppoe0 noipv6cp + atf_ifconfig pppoe0 up + wait_for_opened "IPCP" + atf_check -s exit:0 -o match:'IPv6CP state: initial' \ + -x "$HIJACKING pppoectl -dd pppoe0" + + atf_ifconfig pppoe0 down + export RUMP_SERVER=$SERVER + wait_for_disconnected + + # ipcp disable & ipv6cp enable + export RUMP_SERVER=$CLIENT + atf_pppoectl pppoe0 noipcp ipv6cp + atf_ifconfig pppoe0 up + wait_for_opened "IPv6CP" + atf_check -s exit:0 -o match:'IPCP state: initial' \ + -x "$HIJACKING pppoectl -dd pppoe0" } pppoe_params_cleanup()
CVS commit: src/sbin/pppoectl
Module Name:src Committed By: yamaguchi Date: Tue May 11 05:51:42 UTC 2021 Modified Files: src/sbin/pppoectl: pppoectl.c Log Message: Added keywords that are ipcp, noipcp, ipv6cp, noipv6cp for configuring NCP To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sbin/pppoectl/pppoectl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/pppoectl/pppoectl.c diff -u src/sbin/pppoectl/pppoectl.c:1.27 src/sbin/pppoectl/pppoectl.c:1.28 --- src/sbin/pppoectl/pppoectl.c:1.27 Fri Apr 23 02:28:40 2021 +++ src/sbin/pppoectl/pppoectl.c Tue May 11 05:51:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pppoectl.c,v 1.27 2021/04/23 02:28:40 yamaguchi Exp $ */ +/* $NetBSD: pppoectl.c,v 1.28 2021/05/11 05:51:42 yamaguchi Exp $ */ /* * Copyright (c) 1997 Joerg Wunsch @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pppoectl.c,v 1.27 2021/04/23 02:28:40 yamaguchi Exp $"); +__RCSID("$NetBSD: pppoectl.c,v 1.28 2021/05/11 05:51:42 yamaguchi Exp $"); #endif @@ -55,8 +55,9 @@ __RCSID("$NetBSD: pppoectl.c,v 1.27 2021 __dead static void usage(void); __dead static void print_error(const char *ifname, int error, const char * str); static void print_vals(const char *ifname, int phase, struct spppauthcfg *sp, - int lcp_timeout, time_t idle_timeout, int authfailures, - int max_auth_failures, u_int maxalive, time_t max_noreceive); + int lcp_timeout, time_t idle_timeout, int authfailures, + int max_auth_failures, u_int maxalive, time_t max_noreceive, + int ncp_flags); static void print_dns(const char *ifname, int dns1, int dns2, int s, int tabs); static void print_stats(const char *ifname, int s, int dump); static const char *phase_name(int phase); @@ -81,10 +82,12 @@ static int hz = 0; static int set_auth, set_lcp, set_idle_to, set_auth_failure, set_dns, clear_auth_failure_count, set_keepalive; +static u_int set_ncpflags, clr_ncpflags; static int maxalive = -1; static int max_noreceive = -1; static struct spppauthcfg spr; static struct sppplcpcfg lcp; +static struct spppncpcfg ncp; static struct spppstatus status; static struct spppidletimeout timeout; static struct spppauthfailurestats authfailstats; @@ -202,6 +205,8 @@ main(int argc, char **argv) strncpy(spr.ifname, ifname, sizeof spr.ifname); memset(, 0, sizeof lcp); strncpy(lcp.ifname, ifname, sizeof lcp.ifname); + memset(, 0, sizeof ncp); + strncpy(ncp.ifname, ifname, sizeof ncp.ifname); memset(, 0, sizeof status); strncpy(status.ifname, ifname, sizeof status.ifname); memset(, 0, sizeof timeout); @@ -245,6 +250,8 @@ main(int argc, char **argv) if (ioctl(s, SPPPGETLCPCFG, ) == -1) err(EX_OSERR, "SPPPGETLCPCFG"); + if (ioctl(s, SPPPGETNCPCFG, ) == -1) + err(EX_OSERR, "SPPPGETNCPCFG"); if (ioctl(s, SPPPGETSTATUS, ) == -1) err(EX_OSERR, "SPPPGETSTATUS"); if (ioctl(s, SPPPGETIDLETO, ) == -1) @@ -258,7 +265,8 @@ main(int argc, char **argv) timeout.idle_seconds, authfailstats.auth_failures, authfailstats.max_failures, keepalivesettings.maxalive, - keepalivesettings.max_noreceive); + keepalivesettings.max_noreceive, + ncp.ncp_flags); if (spr.hisname) free(spr.hisname); if (spr.myname) free(spr.myname); @@ -300,6 +308,16 @@ main(int argc, char **argv) if (ioctl(s, SPPPSETLCPCFG, ) == -1) err(EX_OSERR, "SPPPSETLCPCFG"); } + if (set_ncpflags != 0 || clr_ncpflags != 0) { + if (ioctl(s, SPPPGETNCPCFG, ) == -1) + err(EX_OSERR, "SPPPGETNCPCFG"); + + ncp.ncp_flags |= set_ncpflags; + ncp.ncp_flags &= ~clr_ncpflags; + + if (ioctl(s, SPPPSETNCPCFG, ) == -1) + err(EX_OSERR, "SPPPSETNCPCFG"); + } if (set_idle_to) { if (ioctl(s, SPPPSETIDLETO, ) == -1) err(EX_OSERR, "SPPPSETIDLETO"); @@ -344,7 +362,8 @@ main(int argc, char **argv) timeout.idle_seconds, authfailstats.auth_failures, authfailstats.max_failures, keepalivesettings.maxalive, - keepalivesettings.max_noreceive); + keepalivesettings.max_noreceive, + ncp.ncp_flags); } return 0; @@ -459,6 +478,18 @@ pppoectl_argument(char *arg) } else if (startswith(arg, "query-dns=")) { dnssettings.query_dns = atoi(arg+off); set_dns = 1; + } else if (strcmp(arg, "ipcp") == 0) { + set_ncpflags |= SPPP_NCP_IPCP; + clr_ncpflags &= ~SPPP_NCP_IPCP; + } else if (strcmp(arg, "noipcp") == 0) { + set_ncpflags &= ~SPPP_NCP_IPCP; + clr_ncpflags |= SPPP_NCP_IPCP; + } else if (strcmp(arg, "ipv6cp") == 0) { + set_ncpflags |= SPPP_NCP_IPV6CP; + clr_ncpflags &= ~SPPP_NCP_IPV6CP; + } else if (strcmp(arg, "noipv6cp") == 0) { + set_ncpflags &= ~SPPP_NCP_IPV6CP; + clr_ncpflags |= SPPP_NCP_IPV6CP; } else errx(EX_DATAERR, "bad parameter: \"%s\"", arg); } @@ -472,7 +503,7 @@ usage(void) " %s [-f config] ifname [...]\n" " %s [-v] ifname [{my|his}auth{proto|name|secret}=...] \\\n" " [callin]
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 01:27:45 UTC 2021 Modified Files: src/sys/net: if_sppp.h if_spppsubr.c if_spppvar.h Log Message: Added ioctl commands for configuring NCP of pppoe(4) To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/net/if_sppp.h cvs rdiff -u -r1.232 -r1.233 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.36 -r1.37 src/sys/net/if_spppvar.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/net/if_sppp.h diff -u src/sys/net/if_sppp.h:1.33 src/sys/net/if_sppp.h:1.34 --- src/sys/net/if_sppp.h:1.33 Tue May 11 01:15:11 2021 +++ src/sys/net/if_sppp.h Tue May 11 01:27:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.33 2021/05/11 01:15:11 yamaguchi Exp $ */ +/* $NetBSD: if_sppp.h,v 1.34 2021/05/11 01:27:45 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -233,5 +233,15 @@ struct spppipv6cpstatus { #define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus) +#define SPPP_NCP_IPCP __BIT(0) +#define SPPP_NCP_IPV6CP __BIT(1) +struct spppncpcfg { + char ifname[IFNAMSIZ]; + u_int ncp_flags; +}; + +#define SPPPGETNCPCFG _IOWR('i', 138, struct spppncpcfg) +#define SPPPSETNCPCFG _IOW('i', 139, struct spppncpcfg) + #endif /* !_NET_IF_SPPP_H_ */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.232 src/sys/net/if_spppsubr.c:1.233 --- src/sys/net/if_spppsubr.c:1.232 Tue May 11 01:15:11 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 01:27:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.232 2021/05/11 01:15:11 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.233 2021/05/11 01:27:45 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.232 2021/05/11 01:15:11 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.233 2021/05/11 01:27:45 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -585,11 +585,7 @@ sppp_input(struct ifnet *ifp, struct mbu log(LOG_DEBUG, "%s: input packet is too small, %d bytes\n", ifp->if_xname, m->m_pkthdr.len); - drop: - if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1); - m_freem(m); - SPPP_UNLOCK(sp); - return; + goto drop; } if (sp->pp_flags & PP_NOFRAMING) { @@ -663,7 +659,7 @@ sppp_input(struct ifnet *ifp, struct mbu } switch (protocol) { - default: + reject_protocol: if (sp->scp[IDX_LCP].state == STATE_OPENED) { uint16_t prot = htons(protocol); @@ -679,6 +675,8 @@ sppp_input(struct ifnet *ifp, struct mbu "\n", ifp->if_xname, ntohs(protocol)); if_statinc(ifp, if_noproto); goto drop; + default: + goto reject_protocol; case PPP_LCP: SPPP_UNLOCK(sp); sppp_cp_input(, sp, m); @@ -700,6 +698,8 @@ sppp_input(struct ifnet *ifp, struct mbu return; #ifdef INET case PPP_IPCP: + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) + goto reject_protocol; SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -717,6 +717,8 @@ sppp_input(struct ifnet *ifp, struct mbu #endif #ifdef INET6 case PPP_IPV6CP: + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) + goto reject_protocol; SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -766,6 +768,13 @@ queue_pkt: IF_ENQUEUE(inq, m); IFQ_UNLOCK(inq); schednetisr(isr); + return; + +drop: + if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1); + m_freem(m); + SPPP_UNLOCK(sp); + return; } /* @@ -1029,6 +1038,7 @@ sppp_attach(struct ifnet *ifp) sp->pp_phase = SPPP_PHASE_DEAD; sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; + sp->pp_ncpflags = SPPP_NCP_IPCP | SPPP_NCP_IPV6CP; sppp_wq_set(>work_ifdown, sppp_ifdown, NULL); memset(sp->scp, 0, sizeof(sp->scp)); rw_init(>pp_lock); @@ -1265,6 +1275,7 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SPPPSETAUTHCFG: case SPPPSETLCPCFG: + case SPPPSETNCPCFG: case SPPPSETIDLETO: case SPPPSETAUTHFAILURE: case SPPPSETDNSOPTS: @@ -1284,6 +1295,7 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SPPPGETAUTHCFG: case SPPPGETLCPCFG: + case SPPPGETNCPCFG: case SPPPGETAUTHFAILURES: error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, @@ -3491,6 +3503,9 @@ sppp_ipcp_open(struct sppp *sp, void *xc KASSERT(SPPP_WLOCKED(sp)); KASSERT(!cpu_softintr_p()); + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) + return; + sp->ipcp.flags &= ~(IPCP_HISADDR_SEEN|IPCP_MYADDR_SEEN|IPCP_MYADDR_DYN|IPCP_HISADDR_DYN); sp->ipcp.req_myaddr = 0; sp->ipcp.req_hisaddr = 0; @@ -4065,6 +4080,9 @@ sppp_ipv6cp_open(struct sppp *sp, void * KASSERT(SPPP_WLOCKED(sp)); KASSERT(!cpu_softintr_p()); + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) + return; + #ifdef IPV6CP_MYIFID_DYN sp->ipv6cp.flags &=
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 01:23:21 UTC 2021 Modified Files: src/sys/net: if_spppvar.h Log Message: back to r1.34 because of mistake of commit log To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/net/if_spppvar.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/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.35 src/sys/net/if_spppvar.h:1.36 --- src/sys/net/if_spppvar.h:1.35 Tue May 11 01:00:49 2021 +++ src/sys/net/if_spppvar.h Tue May 11 01:23:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.35 2021/05/11 01:00:49 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.36 2021/05/11 01:23:21 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -141,7 +141,6 @@ struct sppp { struct ifqueue pp_cpq; /* PPP control protocol queue */ struct sppp *pp_next; /* next interface in keepalive list */ u_int pp_flags; /* use Cisco protocol instead of PPP */ - u_int pp_ncpflags; /* enable or disable each NCP */ u_int pp_framebytes; /* number of bytes added by (hardware) framing */ u_int pp_alivecnt;/* keepalive packets counter */ u_int pp_loopcnt; /* loopback detection counter */
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 01:15:11 UTC 2021 Modified Files: src/sys/net: if_sppp.h if_spppsubr.c Log Message: Revert previous commit because of mistake of commit log back to r1.230(if_spppsubr.c) and r1.31(if_sppp.h) To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_sppp.h cvs rdiff -u -r1.231 -r1.232 src/sys/net/if_spppsubr.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_sppp.h diff -u src/sys/net/if_sppp.h:1.32 src/sys/net/if_sppp.h:1.33 --- src/sys/net/if_sppp.h:1.32 Tue May 11 01:00:49 2021 +++ src/sys/net/if_sppp.h Tue May 11 01:15:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.32 2021/05/11 01:00:49 yamaguchi Exp $ */ +/* $NetBSD: if_sppp.h,v 1.33 2021/05/11 01:15:11 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -233,15 +233,5 @@ struct spppipv6cpstatus { #define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus) -#define SPPP_NCP_IPCP __BIT(0) -#define SPPP_NCP_IPV6CP __BIT(1) -struct spppncpcfg { - char ifname[IFNAMSIZ]; - u_int ncp_flags; -}; - -#define SPPPGETNCPCFG _IOWR('i', 138, struct spppncpcfg) -#define SPPPSETNCPCFG _IOW('i', 139, struct spppncpcfg) - #endif /* !_NET_IF_SPPP_H_ */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.231 src/sys/net/if_spppsubr.c:1.232 --- src/sys/net/if_spppsubr.c:1.231 Tue May 11 01:00:49 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 01:15:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.231 2021/05/11 01:00:49 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.232 2021/05/11 01:15:11 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.231 2021/05/11 01:00:49 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.232 2021/05/11 01:15:11 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -585,7 +585,11 @@ sppp_input(struct ifnet *ifp, struct mbu log(LOG_DEBUG, "%s: input packet is too small, %d bytes\n", ifp->if_xname, m->m_pkthdr.len); - goto drop; + drop: + if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1); + m_freem(m); + SPPP_UNLOCK(sp); + return; } if (sp->pp_flags & PP_NOFRAMING) { @@ -659,7 +663,7 @@ sppp_input(struct ifnet *ifp, struct mbu } switch (protocol) { - reject_protocol: + default: if (sp->scp[IDX_LCP].state == STATE_OPENED) { uint16_t prot = htons(protocol); @@ -675,8 +679,6 @@ sppp_input(struct ifnet *ifp, struct mbu "\n", ifp->if_xname, ntohs(protocol)); if_statinc(ifp, if_noproto); goto drop; - default: - goto reject_protocol; case PPP_LCP: SPPP_UNLOCK(sp); sppp_cp_input(, sp, m); @@ -698,8 +700,6 @@ sppp_input(struct ifnet *ifp, struct mbu return; #ifdef INET case PPP_IPCP: - if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) - goto reject_protocol; SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -717,8 +717,6 @@ sppp_input(struct ifnet *ifp, struct mbu #endif #ifdef INET6 case PPP_IPV6CP: - if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) - goto reject_protocol; SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -768,13 +766,6 @@ queue_pkt: IF_ENQUEUE(inq, m); IFQ_UNLOCK(inq); schednetisr(isr); - return; - -drop: - if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1); - m_freem(m); - SPPP_UNLOCK(sp); - return; } /* @@ -1038,7 +1029,6 @@ sppp_attach(struct ifnet *ifp) sp->pp_phase = SPPP_PHASE_DEAD; sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; - sp->pp_ncpflags = SPPP_NCP_IPCP | SPPP_NCP_IPV6CP; sppp_wq_set(>work_ifdown, sppp_ifdown, NULL); memset(sp->scp, 0, sizeof(sp->scp)); rw_init(>pp_lock); @@ -1275,7 +1265,6 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SPPPSETAUTHCFG: case SPPPSETLCPCFG: - case SPPPSETNCPCFG: case SPPPSETIDLETO: case SPPPSETAUTHFAILURE: case SPPPSETDNSOPTS: @@ -1295,7 +1284,6 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SPPPGETAUTHCFG: case SPPPGETLCPCFG: - case SPPPGETNCPCFG: case SPPPGETAUTHFAILURES: error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, @@ -3503,9 +3491,6 @@ sppp_ipcp_open(struct sppp *sp, void *xc KASSERT(SPPP_WLOCKED(sp)); KASSERT(!cpu_softintr_p()); - if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) - return; - sp->ipcp.flags &= ~(IPCP_HISADDR_SEEN|IPCP_MYADDR_SEEN|IPCP_MYADDR_DYN|IPCP_HISADDR_DYN); sp->ipcp.req_myaddr = 0; sp->ipcp.req_hisaddr = 0; @@ -4080,9 +4065,6 @@ sppp_ipv6cp_open(struct sppp *sp, void * KASSERT(SPPP_WLOCKED(sp)); KASSERT(!cpu_softintr_p()); - if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) - return; - #ifdef IPV6CP_MYIFID_DYN sp->ipv6cp.flags &= ~(IPV6CP_MYIFID_SEEN|IPV6CP_MYIFID_DYN); #else
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue May 11 01:00:49 UTC 2021 Modified Files: src/sys/net: if_sppp.h if_spppsubr.c if_spppvar.h Log Message: Added keywords that are ipcp, noipcp, ipv6cp, noipv6cp for configuring NCP To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/net/if_sppp.h cvs rdiff -u -r1.230 -r1.231 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.34 -r1.35 src/sys/net/if_spppvar.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/net/if_sppp.h diff -u src/sys/net/if_sppp.h:1.31 src/sys/net/if_sppp.h:1.32 --- src/sys/net/if_sppp.h:1.31 Fri Apr 23 01:13:25 2021 +++ src/sys/net/if_sppp.h Tue May 11 01:00:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.31 2021/04/23 01:13:25 yamaguchi Exp $ */ +/* $NetBSD: if_sppp.h,v 1.32 2021/05/11 01:00:49 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -233,5 +233,15 @@ struct spppipv6cpstatus { #define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus) +#define SPPP_NCP_IPCP __BIT(0) +#define SPPP_NCP_IPV6CP __BIT(1) +struct spppncpcfg { + char ifname[IFNAMSIZ]; + u_int ncp_flags; +}; + +#define SPPPGETNCPCFG _IOWR('i', 138, struct spppncpcfg) +#define SPPPSETNCPCFG _IOW('i', 139, struct spppncpcfg) + #endif /* !_NET_IF_SPPP_H_ */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.230 src/sys/net/if_spppsubr.c:1.231 --- src/sys/net/if_spppsubr.c:1.230 Thu May 6 06:18:16 2021 +++ src/sys/net/if_spppsubr.c Tue May 11 01:00:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.230 2021/05/06 06:18:16 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.231 2021/05/11 01:00:49 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.230 2021/05/06 06:18:16 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.231 2021/05/11 01:00:49 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -585,11 +585,7 @@ sppp_input(struct ifnet *ifp, struct mbu log(LOG_DEBUG, "%s: input packet is too small, %d bytes\n", ifp->if_xname, m->m_pkthdr.len); - drop: - if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1); - m_freem(m); - SPPP_UNLOCK(sp); - return; + goto drop; } if (sp->pp_flags & PP_NOFRAMING) { @@ -663,7 +659,7 @@ sppp_input(struct ifnet *ifp, struct mbu } switch (protocol) { - default: + reject_protocol: if (sp->scp[IDX_LCP].state == STATE_OPENED) { uint16_t prot = htons(protocol); @@ -679,6 +675,8 @@ sppp_input(struct ifnet *ifp, struct mbu "\n", ifp->if_xname, ntohs(protocol)); if_statinc(ifp, if_noproto); goto drop; + default: + goto reject_protocol; case PPP_LCP: SPPP_UNLOCK(sp); sppp_cp_input(, sp, m); @@ -700,6 +698,8 @@ sppp_input(struct ifnet *ifp, struct mbu return; #ifdef INET case PPP_IPCP: + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) + goto reject_protocol; SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -717,6 +717,8 @@ sppp_input(struct ifnet *ifp, struct mbu #endif #ifdef INET6 case PPP_IPV6CP: + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) + goto reject_protocol; SPPP_UNLOCK(sp); if (sp->pp_phase == SPPP_PHASE_NETWORK) { sppp_cp_input(, sp, m); @@ -766,6 +768,13 @@ queue_pkt: IF_ENQUEUE(inq, m); IFQ_UNLOCK(inq); schednetisr(isr); + return; + +drop: + if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1); + m_freem(m); + SPPP_UNLOCK(sp); + return; } /* @@ -1029,6 +1038,7 @@ sppp_attach(struct ifnet *ifp) sp->pp_phase = SPPP_PHASE_DEAD; sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; + sp->pp_ncpflags = SPPP_NCP_IPCP | SPPP_NCP_IPV6CP; sppp_wq_set(>work_ifdown, sppp_ifdown, NULL); memset(sp->scp, 0, sizeof(sp->scp)); rw_init(>pp_lock); @@ -1265,6 +1275,7 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SPPPSETAUTHCFG: case SPPPSETLCPCFG: + case SPPPSETNCPCFG: case SPPPSETIDLETO: case SPPPSETAUTHFAILURE: case SPPPSETDNSOPTS: @@ -1284,6 +1295,7 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SPPPGETAUTHCFG: case SPPPGETLCPCFG: + case SPPPGETNCPCFG: case SPPPGETAUTHFAILURES: error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, @@ -3491,6 +3503,9 @@ sppp_ipcp_open(struct sppp *sp, void *xc KASSERT(SPPP_WLOCKED(sp)); KASSERT(!cpu_softintr_p()); + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP)) + return; + sp->ipcp.flags &= ~(IPCP_HISADDR_SEEN|IPCP_MYADDR_SEEN|IPCP_MYADDR_DYN|IPCP_HISADDR_DYN); sp->ipcp.req_myaddr = 0; sp->ipcp.req_hisaddr = 0; @@ -4065,6 +4080,9 @@ sppp_ipv6cp_open(struct sppp *sp, void * KASSERT(SPPP_WLOCKED(sp)); KASSERT(!cpu_softintr_p()); + if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP)) + return; + #ifdef IPV6CP_MYIFID_DYN sp->ipv6cp.flags &=
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Tue May 11 00:55:51 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Added missing '$' To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.29 src/tests/net/if_pppoe/t_pppoe.sh:1.30 --- src/tests/net/if_pppoe/t_pppoe.sh:1.29 Thu May 6 01:09:43 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Tue May 11 00:55:51 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.29 2021/05/06 01:09:43 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.30 2021/05/11 00:55:51 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -238,7 +238,7 @@ run_test() atf_ifconfig -w 10 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0" - $DEBUG && HIJACKING pppoectl -d pppoe0 + $DEBUG && $HIJACKING pppoectl -d pppoe0 unset RUMP_SERVER # test for invalid password
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu May 6 06:18:16 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: do not clear destination address if there is no saved address and add initialization of saved_hisaddr for safety 0.0.0.0 was sometimes configured to destination address when ipcp close was occurred before ipcp tlu. Following messages will be appeared when the issue is encountered and debug for pppoe(4) is enabled. tc-so:[ 1.890005] pppoe0: ipcp close(starting) (snip) tc-so:[ 1.890005] pppoe0: ipcp_open(): no IP interface To generate a diff of this commit: cvs rdiff -u -r1.229 -r1.230 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.229 src/sys/net/if_spppsubr.c:1.230 --- src/sys/net/if_spppsubr.c:1.229 Thu May 6 02:05:09 2021 +++ src/sys/net/if_spppsubr.c Thu May 6 06:18:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.229 2021/05/06 02:05:09 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.230 2021/05/06 06:18:16 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.229 2021/05/06 02:05:09 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.230 2021/05/06 06:18:16 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3531,6 +3531,7 @@ sppp_ipcp_open(struct sppp *sp, void *xc * remote has no valid address, we need to get one assigned. */ sp->ipcp.flags |= IPCP_HISADDR_DYN; + sp->ipcp.saved_hisaddr = htonl(hisaddr); } if (sp->query_dns & 1) { @@ -5744,7 +5745,8 @@ sppp_clear_ip_addrs(struct sppp *sp) if (sp->ipcp.flags & IPCP_MYADDR_DYN) new_sin.sin_addr.s_addr = 0; - if (sp->ipcp.flags & IPCP_HISADDR_DYN) + if (sp->ipcp.flags & IPCP_HISADDR_DYN && + ntohl(sp->ipcp.saved_hisaddr) != 0) new_dst.sin_addr.s_addr = sp->ipcp.saved_hisaddr; in_addrhash_remove(ifatoia(ifa));
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu May 6 02:05:09 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added m_freem for safety pointed out by knakahara@, thanks. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.228 src/sys/net/if_spppsubr.c:1.229 --- src/sys/net/if_spppsubr.c:1.228 Wed Apr 28 09:39:39 2021 +++ src/sys/net/if_spppsubr.c Thu May 6 02:05:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.228 2021/04/28 09:39:39 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.229 2021/05/06 02:05:09 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.228 2021/04/28 09:39:39 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.229 2021/05/06 02:05:09 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1632,6 +1632,15 @@ sppp_cp_fini(const struct cp *cp, struct callout_halt(>ch, NULL); callout_destroy(>ch); + + if (scp->mbuf_confreq != NULL) { + m_freem(scp->mbuf_confreq); + scp->mbuf_confreq = NULL; + } + if (scp->mbuf_confnak != NULL) { + m_freem(scp->mbuf_confnak); + scp->mbuf_confnak = NULL; + } } /*
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Thu May 6 01:09:43 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Added missing waiting for DAD completion To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.28 src/tests/net/if_pppoe/t_pppoe.sh:1.29 --- src/tests/net/if_pppoe/t_pppoe.sh:1.28 Fri Apr 23 03:41:55 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Thu May 6 01:09:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.28 2021/04/23 03:41:55 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.29 2021/05/06 01:09:43 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -760,6 +760,7 @@ pppoe_passiveauthproto() atf_ifconfig pppoe0 up $DEBUG && rump.ifconfig wait_for_opened $cp + atf_ifconfig -w 10 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Apr 28 09:39:39 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Introduce a pointer to refer sp->scp[cp->protoidx] There is no functional difference. To generate a diff of this commit: cvs rdiff -u -r1.227 -r1.228 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.227 src/sys/net/if_spppsubr.c:1.228 --- src/sys/net/if_spppsubr.c:1.227 Wed Apr 28 09:36:24 2021 +++ src/sys/net/if_spppsubr.c Wed Apr 28 09:39:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.227 2021/04/28 09:36:24 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.228 2021/04/28 09:39:39 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.227 2021/04/28 09:36:24 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.228 2021/04/28 09:39:39 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1642,12 +1642,15 @@ sppp_cp_input(const struct cp *cp, struc { STDDCL; struct lcp_header *h; + struct sppp_cp *scp; int printlen, len = m->m_pkthdr.len; u_char *p; uint32_t u32; SPPP_LOCK(sp, RW_WRITER); + scp = >scp[cp->protoidx]; + if (len < 4) { if (debug) log(LOG_DEBUG, @@ -1661,7 +1664,7 @@ sppp_cp_input(const struct cp *cp, struc log(LOG_DEBUG, "%s: %s input(%s): <%s id=0x%x len=%d", ifp->if_xname, cp->name, - sppp_state_name(sp->scp[cp->protoidx].state), + sppp_state_name(scp->state), sppp_cp_type_name(h->type), h->ident, printlen); if (len < printlen) printlen = len; @@ -1683,62 +1686,62 @@ sppp_cp_input(const struct cp *cp, struc break; } - sp->scp[cp->protoidx].rcr_type = CP_RCR_NONE; - sp->scp[cp->protoidx].rconfid = h->ident; - if (sp->scp[cp->protoidx].mbuf_confreq != NULL) { - m_freem(sp->scp[cp->protoidx].mbuf_confreq); + scp->rcr_type = CP_RCR_NONE; + scp->rconfid = h->ident; + if (scp->mbuf_confreq != NULL) { + m_freem(scp->mbuf_confreq); } - sp->scp[cp->protoidx].mbuf_confreq = m; + scp->mbuf_confreq = m; m = NULL; - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rcr); + sppp_wq_add(sp->wq_cp, >work_rcr); break; case CONF_ACK: - if (h->ident != sp->scp[cp->protoidx].confid) { + if (h->ident != scp->confid) { if (debug) addlog("%s: %s id mismatch 0x%x != 0x%x\n", ifp->if_xname, cp->name, - h->ident, sp->scp[cp->protoidx].confid); + h->ident, scp->confid); if_statinc(ifp, if_ierrors); break; } - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rca); + sppp_wq_add(sp->wq_cp, >work_rca); break; case CONF_NAK: case CONF_REJ: - if (h->ident != sp->scp[cp->protoidx].confid) { + if (h->ident != scp->confid) { if (debug) addlog("%s: %s id mismatch 0x%x != 0x%x\n", ifp->if_xname, cp->name, - h->ident, sp->scp[cp->protoidx].confid); + h->ident, scp->confid); if_statinc(ifp, if_ierrors); break; } - if (sp->scp[cp->protoidx].mbuf_confnak) { - m_freem(sp->scp[cp->protoidx].mbuf_confnak); + if (scp->mbuf_confnak) { + m_freem(scp->mbuf_confnak); } - sp->scp[cp->protoidx].mbuf_confnak = m; + scp->mbuf_confnak = m; m = NULL; - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rcn); + sppp_wq_add(sp->wq_cp, >work_rcn); break; case TERM_REQ: - sp->scp[cp->protoidx].rseq = h->ident; - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rtr); + scp->rseq = h->ident; + sppp_wq_add(sp->wq_cp, >work_rtr); break; case TERM_ACK: - if (h->ident != sp->scp[cp->protoidx].confid && - h->ident != sp->scp[cp->protoidx].seq) { + if (h->ident != scp->confid && + h->ident != scp->seq) { if (debug) addlog("%s: %s id mismatch " "0x%x != 0x%x and 0x%x != %0lx\n", ifp->if_xname, cp->name, -h->ident, sp->scp[cp->protoidx].confid, -h->ident, sp->scp[cp->protoidx].seq); +h->ident, scp->confid, +h->ident, scp->seq); if_statinc(ifp, if_ierrors); break; } - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rta); + sppp_wq_add(sp->wq_cp, >work_rta); break; case CODE_REJ: /* XXX catastrophic rejects (RXJ-) aren't handled yet. */ @@ -1747,7 +1750,7 @@ sppp_cp_input(const struct cp *cp, struc "danger will robinson\n", ifp->if_xname, cp->name, sppp_cp_type_name(h->type)); - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rxj); + sppp_wq_add(sp->wq_cp, >work_rxj); break; case PROTO_REJ: { @@ -1787,7 +1790,7 @@ sppp_cp_input(const struct cp *cp, struc break; } } - sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rxj); + sppp_wq_add(sp->wq_cp, >work_rxj); break; } case DISC_REQ: @@ -1798,7 +1801,7 @@
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Apr 28 09:36:24 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Move paese of conf-req, conf-nak and conf-rej into workqueue from softint context When the pases were processed in softint, the state machine in if_spppsubr.c had been broken by simultaneous events on rare occasions. Example: 1. Do ifconfig pppoe* up - lcp open event is enqueued to workqueue 2. Receive conf-ack, and parse the packet - save mru to sp->lcp.their_mru - lcp RCR+ event is enqueued to workqueue 3. Process lcp open event - initialize data including sp->lcp.their_mru 4. Process lcp RCR+ event - Use sp->lcp.their_mru - but it was initialized To generate a diff of this commit: cvs rdiff -u -r1.226 -r1.227 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.33 -r1.34 src/sys/net/if_spppvar.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/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.226 src/sys/net/if_spppsubr.c:1.227 --- src/sys/net/if_spppsubr.c:1.226 Mon Apr 26 08:45:57 2021 +++ src/sys/net/if_spppsubr.c Wed Apr 28 09:36:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.226 2021/04/26 08:45:57 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.227 2021/04/28 09:36:24 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.226 2021/04/26 08:45:57 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.227 2021/04/28 09:36:24 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -258,7 +258,8 @@ struct cp { void (*tls)(const struct cp *, struct sppp *); void (*tlf)(const struct cp *, struct sppp *); void (*scr)(struct sppp *); - void (*scan)(const struct cp *, struct sppp *); + void (*screply)(const struct cp *, struct sppp *, u_char, + uint8_t, size_t, void *); /* message parser */ enum cp_rcr_type @@ -347,8 +348,8 @@ static void sppp_auth_send(const struct unsigned int, unsigned int, ...); static int sppp_auth_role(const struct cp *, struct sppp *); static void sppp_auth_to_event(struct sppp *, void *); -static void sppp_auth_sca_scn(const struct cp *, struct sppp *); - +static void sppp_auth_screply(const struct cp *, struct sppp *, + u_char, uint8_t, size_t, void *); static void sppp_up_event(struct sppp *, void *); static void sppp_down_event(struct sppp *, void *); static void sppp_open_event(struct sppp *, void *); @@ -364,7 +365,8 @@ static void sppp_rxj_event(struct sppp * static void sppp_null(struct sppp *); static void sppp_tls(const struct cp *, struct sppp *); static void sppp_tlf(const struct cp *, struct sppp *); -static void sppp_sca_scn(const struct cp *, struct sppp *); +static void sppp_screply(const struct cp *, struct sppp *, + u_char, uint8_t, size_t, void *); static void sppp_ifdown(struct sppp *, void *); static void sppp_lcp_init(struct sppp *); @@ -466,7 +468,7 @@ static const struct cp lcp = { sppp_lcp_up, sppp_lcp_down, sppp_lcp_open, sppp_close_event, sppp_to_event, sppp_lcp_tlu, sppp_lcp_tld, sppp_lcp_tls, - sppp_lcp_tlf, sppp_lcp_scr, sppp_sca_scn, + sppp_lcp_tlf, sppp_lcp_scr, sppp_screply, sppp_lcp_confreq, sppp_lcp_confrej, sppp_lcp_confnak }; @@ -481,7 +483,7 @@ static const struct cp ipcp = { sppp_up_event, sppp_down_event, sppp_ipcp_open, sppp_ipcp_close, sppp_to_event, sppp_ipcp_tlu, sppp_null, sppp_tls, - sppp_tlf, sppp_ipcp_scr, sppp_sca_scn, + sppp_tlf, sppp_ipcp_scr, sppp_screply, sppp_ipcp_confreq, sppp_ipcp_confrej, sppp_ipcp_confnak, }; @@ -496,7 +498,7 @@ static const struct cp ipv6cp = { sppp_up_event, sppp_down_event, sppp_ipv6cp_open, sppp_close_event, sppp_to_event, sppp_ipv6cp_tlu, sppp_null, sppp_tls, - sppp_tlf, sppp_ipv6cp_scr, sppp_sca_scn, + sppp_tlf, sppp_ipv6cp_scr, sppp_screply, sppp_ipv6cp_confreq, sppp_ipv6cp_confrej, sppp_ipv6cp_confnak, }; @@ -505,7 +507,7 @@ static const struct cp pap = { sppp_up_event, sppp_down_event, sppp_open_event, sppp_close_event, sppp_to_event, sppp_pap_tlu, sppp_null, sppp_tls, sppp_tlf, - sppp_pap_scr, sppp_auth_sca_scn, + sppp_pap_scr, sppp_auth_screply, NULL, NULL, NULL }; @@ -514,7 +516,7 @@ static const struct cp chap = { sppp_up_event, sppp_down_event, sppp_chap_open, sppp_close_event, sppp_auth_to_event, sppp_chap_tlu, sppp_null, sppp_tls, sppp_tlf, - sppp_chap_scr, sppp_auth_sca_scn, + sppp_chap_scr, sppp_auth_screply, NULL, NULL, NULL }; @@ -680,7 +682,7 @@ sppp_input(struct ifnet *ifp, struct mbu case PPP_LCP: SPPP_UNLOCK(sp); sppp_cp_input(, sp, m); - m_freem(m); + /* already m_freem(m) */ return; case PPP_PAP: SPPP_UNLOCK(sp); @@ -701,8 +703,10 @@ sppp_input(struct ifnet *ifp, struct mbu SPPP_UNLOCK(sp); if (sp->pp_phase ==
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 26 08:45:57 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Fix the wrong CHAP option length in conf-nak RFC 1994 defines that the CHAP option length in conf-nak is 5. However, 4 was used when CHAP is cofigured and PPP is proposed by a peer. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.225 src/sys/net/if_spppsubr.c:1.226 --- src/sys/net/if_spppsubr.c:1.225 Mon Apr 26 08:42:19 2021 +++ src/sys/net/if_spppsubr.c Mon Apr 26 08:45:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.225 2021/04/26 08:42:19 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.226 2021/04/26 08:45:57 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.225 2021/04/26 08:42:19 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.226 2021/04/26 08:45:57 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2876,22 +2876,39 @@ sppp_lcp_confreq(struct sppp *sp, struct if (authproto == PPP_PAP || authproto == PPP_CHAP) sp->myauth.proto = authproto; } - if (sp->myauth.proto != authproto) { -/* not agreed, nak */ + if (sp->myauth.proto == authproto) { +if (authproto != PPP_CHAP || p[4] == CHAP_MD5) { + continue; +} +if (debug) + addlog(" [chap without MD5]"); + } else { if (debug) addlog(" [mine %s != his %s]", sppp_proto_name(sp->myauth.proto), sppp_proto_name(authproto)); -p[2] = sp->myauth.proto >> 8; -p[3] = sp->myauth.proto; -break; } - if (authproto == PPP_CHAP && p[4] != CHAP_MD5) { + /* not agreed, nak */ + if (sp->myauth.proto == PPP_CHAP) { +l = 5; + } else { +l = 4; + } + + if (rlen + l > blen) { if (debug) - addlog(" [chap not MD5]"); -p[4] = CHAP_MD5; -break; + addlog(" [overflow]"); +continue; } + + r[0] = LCP_OPT_AUTH_PROTO; + r[1] = l; + r[2] = sp->myauth.proto >> 8; + r[3] = sp->myauth.proto & 0xff; + if (sp->myauth.proto == PPP_CHAP) +r[4] = CHAP_MD5; + rlen += l; + r += l; continue; case LCP_OPT_MP_EID: /*
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 26 08:42:19 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Avoid updating of the state if the state is not changed not to reset the timer for state machine To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.224 src/sys/net/if_spppsubr.c:1.225 --- src/sys/net/if_spppsubr.c:1.224 Mon Apr 26 08:37:54 2021 +++ src/sys/net/if_spppsubr.c Mon Apr 26 08:42:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.224 2021/04/26 08:37:54 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.225 2021/04/26 08:42:19 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.224 2021/04/26 08:37:54 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.225 2021/04/26 08:42:19 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2153,9 +2153,10 @@ sppp_rcr_event(struct sppp *sp, void *xc cp->scr(sp); cp->scan(cp, sp); break; - case STATE_ACK_SENT: case STATE_REQ_SENT: sppp_cp_change_state(cp, sp, STATE_ACK_SENT); + /* fall through */ + case STATE_ACK_SENT: cp->scan(cp, sp); break; case STATE_STOPPED: @@ -2202,8 +2203,9 @@ sppp_rcr_event(struct sppp *sp, void *xc cp->scan(cp, sp); break; case STATE_ACK_SENT: - case STATE_REQ_SENT: sppp_cp_change_state(cp, sp, STATE_REQ_SENT); + /* fall through */ + case STATE_REQ_SENT: cp->scan(cp, sp); break; case STATE_STOPPED:
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 26 08:37:54 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Reset LCP fail counter when doing "ifconfig pppoe* up" To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.223 src/sys/net/if_spppsubr.c:1.224 --- src/sys/net/if_spppsubr.c:1.223 Mon Apr 26 08:34:22 2021 +++ src/sys/net/if_spppsubr.c Mon Apr 26 08:37:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.223 2021/04/26 08:34:22 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.224 2021/04/26 08:37:54 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.223 2021/04/26 08:34:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.224 2021/04/26 08:37:54 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2593,6 +2593,7 @@ sppp_lcp_open(struct sppp *sp, void *xcp KASSERT(!cpu_softintr_p()); sp->lcp.reestablish = false; + sp->scp[IDX_LCP].fail_counter = 0; if (sp->pp_if.if_mtu < PP_MTU) { sp->lcp.mru = sp->pp_if.if_mtu;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 26 08:34:22 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Added ipcp option name for logging To generate a diff of this commit: cvs rdiff -u -r1.222 -r1.223 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.222 src/sys/net/if_spppsubr.c:1.223 --- src/sys/net/if_spppsubr.c:1.222 Mon Apr 26 08:31:21 2021 +++ src/sys/net/if_spppsubr.c Mon Apr 26 08:34:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.222 2021/04/26 08:31:21 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.223 2021/04/26 08:34:22 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.222 2021/04/26 08:31:21 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.223 2021/04/26 08:34:22 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -6297,6 +6297,8 @@ sppp_ipcp_opt_name(u_char opt) case IPCP_OPT_ADDRESSES: return "addresses"; case IPCP_OPT_COMPRESSION: return "compression"; case IPCP_OPT_ADDRESS: return "address"; + case IPCP_OPT_PRIMDNS: return "primdns"; + case IPCP_OPT_SECDNS: return "secdns"; } snprintf(buf, sizeof(buf), "0x%x", opt); return buf;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 26 08:31:21 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Ignore 0.0.0.0 offered from PPPoE server To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.221 src/sys/net/if_spppsubr.c:1.222 --- src/sys/net/if_spppsubr.c:1.221 Mon Apr 26 02:36:45 2021 +++ src/sys/net/if_spppsubr.c Mon Apr 26 08:31:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.221 2021/04/26 02:36:45 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.222 2021/04/26 08:31:21 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.221 2021/04/26 02:36:45 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.222 2021/04/26 08:31:21 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3825,10 +3825,15 @@ sppp_ipcp_confnak(struct sppp *sp, struc * our already existing value. */ if (sp->ipcp.flags & IPCP_MYADDR_DYN) { - if (debug) - addlog(" [agree]"); - sp->ipcp.flags |= IPCP_MYADDR_SEEN; - sp->ipcp.req_myaddr = wantaddr; + if (ntohl(wantaddr) != INADDR_ANY) { + if (debug) + addlog(" [agree]"); + sp->ipcp.flags |= IPCP_MYADDR_SEEN; + sp->ipcp.req_myaddr = wantaddr; + } else { + if (debug) + addlog(" [not agreed]"); + } } } break; @@ -3865,9 +3870,20 @@ static void sppp_ipcp_tlu(struct sppp *sp) { #ifdef INET + struct ifnet *ifp; + + ifp = >pp_if; KASSERT(SPPP_WLOCKED(sp)); - /* we are up. Set addresses and notify anyone interested */ - sppp_set_ip_addrs(sp); + if ((sp->ipcp.flags & IPCP_MYADDR_DYN) && + ((sp->ipcp.flags & IPCP_MYADDR_SEEN) == 0)) { + log(LOG_WARNING, "%s: no IP address, closing IPCP\n", + ifp->if_xname); + sppp_wq_add(sp->wq_cp, + >scp[IDX_IPCP].work_close); + } else { + /* we are up. Set addresses and notify anyone interested */ + sppp_set_ip_addrs(sp); + } #endif }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 26 02:36:46 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Fix locking order since IFNET_LOCK must be held before acquiring SPPP_LOCK To generate a diff of this commit: cvs rdiff -u -r1.220 -r1.221 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.220 src/sys/net/if_spppsubr.c:1.221 --- src/sys/net/if_spppsubr.c:1.220 Fri Apr 23 03:36:13 2021 +++ src/sys/net/if_spppsubr.c Mon Apr 26 02:36:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.220 2021/04/23 03:36:13 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.221 2021/04/26 02:36:45 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.220 2021/04/23 03:36:13 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.221 2021/04/26 02:36:45 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -5542,7 +5542,10 @@ sppp_set_ip_addrs(struct sppp *sp) uint32_t myaddr = 0, hisaddr = 0; int s; + KASSERT(SPPP_WLOCKED(sp)); + SPPP_UNLOCK(sp); IFNET_LOCK(ifp); + SPPP_LOCK(sp, RW_WRITER); /* * Pick the first AF_INET address from the list, @@ -5614,7 +5617,10 @@ sppp_clear_ip_addrs(struct sppp *sp) struct sockaddr_in *si, *dest; int s; + KASSERT(SPPP_WLOCKED(sp)); + SPPP_UNLOCK(sp); IFNET_LOCK(ifp); + SPPP_LOCK(sp, RW_WRITER); /* * Pick the first AF_INET address from the list, @@ -5740,7 +5746,10 @@ sppp_set_ip6_addr(struct sppp *sp, const int s; struct psref psref; + KASSERT(SPPP_WLOCKED(sp)); + SPPP_UNLOCK(sp); IFNET_LOCK(ifp); + SPPP_LOCK(sp, RW_WRITER); /* * Pick the first link-local AF_INET6 address from the list,
CVS commit: src/sys/rump/net/lib/libpppoe
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:44:05 UTC 2021 Modified Files: src/sys/rump/net/lib/libpppoe: Makefile Log Message: enabled PPPOE_DEBUG for librumpnet_pppoe* when RUMP_DEBUG is defined To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libpppoe/Makefile 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/net/lib/libpppoe/Makefile diff -u src/sys/rump/net/lib/libpppoe/Makefile:1.2 src/sys/rump/net/lib/libpppoe/Makefile:1.3 --- src/sys/rump/net/lib/libpppoe/Makefile:1.2 Sun Jan 27 02:08:49 2019 +++ src/sys/rump/net/lib/libpppoe/Makefile Fri Apr 23 03:44:05 2021 @@ -9,5 +9,9 @@ SRCS= if_pppoe.c if_spppsubr.c SRCS+= pppoe_component.c +.ifdef RUMP_DEBUG +CPPFLAGS.if_pppoe.c+= -DPPPOE_DEBUG +.endif + .include .include
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:41:55 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Added a test case for MTU of pppoe(4) To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.27 src/tests/net/if_pppoe/t_pppoe.sh:1.28 --- src/tests/net/if_pppoe/t_pppoe.sh:1.27 Fri Apr 23 03:40:05 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Fri Apr 23 03:41:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.27 2021/04/23 03:40:05 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.28 2021/04/23 03:41:55 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -805,6 +805,74 @@ pppoe_passiveauthproto_chap_cleanup() cleanup } +atf_test_case pppoe_mtu cleanup +pppoe_mtu_head() +{ + + atf_set "descr" "Test for mtu" + atf_set "require.progs" "rump_server" +} + +pppoe_mtu_body() +{ + local auth=chap + local cp="IPCP" + setup + + export RUMP_SERVER=$SERVER + atf_pppoectl pppoe0 \ + "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \ + "hisauthproto=$auth" "myauthproto=none" \ + norechallenge + atf_ifconfig pppoe0 mtu 1400 + atf_ifconfig pppoe0 up + + export RUMP_SERVER=$CLIENT + atf_pppoectl pppoe0 \ + "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \ + "myauthproto=$auth" "hisauthproto=none" + atf_ifconfig pppoe0 mtu 1450 + atf_ifconfig pppoe0 up + + wait_for_opened $cp + atf_ifconfig -w 10 + + export RUMP_SERVER=$SERVER + atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0 + + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0 + + # mtu can set to 1460 but it is not applied. + atf_ifconfig pppoe0 mtu 1460 + atf_check -s exit:0 -o match:'mtu 1400' rump.ifconfig pppoe0 + + export RUMP_SERVER=$SERVER + atf_ifconfig pppoe0 mtu 1470 + atf_ifconfig pppoe0 down + atf_ifconfig pppoe0 up + wait_for_opened $cp + atf_ifconfig -w 10 + + # mtu 1460 is applied after LCP negotiation + atf_check -s exit:0 -o match:'mtu 1460' rump.ifconfig pppoe0 + + export RUMP_SERVER=$CLIENT + atf_check -s exit:0 -o match:'mtu 1460' rump.ifconfig pppoe0 + + rump.ifconfig pppoe0 mtu 1500 + atf_check -s exit:0 -o ignore \ + -e match:'SIOCSIFMTU: Invalid argument' \ + rump.ifconfig pppoe0 mtu 1501 +} + +pppoe_mtu_cleanup() +{ + + $DEBUG && dump + cleanup +} + atf_init_test_cases() { @@ -816,4 +884,5 @@ atf_init_test_cases() atf_add_test_case pppoe6_chap atf_add_test_case pppoe_passiveauthproto_pap atf_add_test_case pppoe_passiveauthproto_chap + atf_add_test_case pppoe_mtu }
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:40:05 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Make IFF_DEBUG enabled if $DEBUG is true To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.26 src/tests/net/if_pppoe/t_pppoe.sh:1.27 --- src/tests/net/if_pppoe/t_pppoe.sh:1.26 Fri Apr 23 03:38:19 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Fri Apr 23 03:40:05 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.26 2021/04/23 03:38:19 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.27 2021/04/23 03:40:05 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -88,6 +88,7 @@ setup_ifaces() inet $SERVER_IP $CLIENT_IP down atf_ifconfig pppoe0 link0 + $DEBUG && rump.ifconfig pppoe0 debug $DEBUG && rump.ifconfig $DEBUG && $HIJACKING pppoectl -d pppoe0 unset RUMP_SERVER @@ -98,6 +99,7 @@ setup_ifaces() $inet && atf_ifconfig pppoe0 \ inet 0.0.0.0 0.0.0.1 down + $DEBUG && rump.ifconfig pppoe0 debug $DEBUG && rump.ifconfig $DEBUG && $HIJACKING pppoectl -d pppoe0 unset RUMP_SERVER
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:38:19 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: functionalize rump.ifconfig and pppoectl for clearer test code To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.25 src/tests/net/if_pppoe/t_pppoe.sh:1.26 --- src/tests/net/if_pppoe/t_pppoe.sh:1.25 Fri Apr 23 03:07:19 2021 +++ src/tests/net/if_pppoe/t_pppoe.sh Fri Apr 23 03:38:19 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.25 2021/04/23 03:07:19 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.26 2021/04/23 03:38:19 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -39,6 +39,18 @@ TIMEOUT=3 WAITTIME=10 DEBUG=${DEBUG:-false} +atf_ifconfig() +{ + + atf_check -s exit:0 rump.ifconfig $* +} + +atf_pppoectl() +{ + + atf_check -s exit:0 -x "$HIJACKING pppoectl $*" +} + atf_test_case pppoe_create_destroy cleanup pppoe_create_destroy_head() { @@ -71,19 +83,19 @@ setup_ifaces() rump_server_add_iface $CLIENT pppoe0 export RUMP_SERVER=$SERVER - atf_check -s exit:0 rump.ifconfig shmif0 up - $inet && atf_check -s exit:0 rump.ifconfig pppoe0 \ + atf_ifconfig shmif0 up + $inet && atf_ifconfig pppoe0 \ inet $SERVER_IP $CLIENT_IP down - atf_check -s exit:0 rump.ifconfig pppoe0 link0 + atf_ifconfig pppoe0 link0 $DEBUG && rump.ifconfig $DEBUG && $HIJACKING pppoectl -d pppoe0 unset RUMP_SERVER export RUMP_SERVER=$CLIENT - atf_check -s exit:0 rump.ifconfig shmif0 up + atf_ifconfig shmif0 up - $inet && atf_check -s exit:0 rump.ifconfig pppoe0 \ + $inet && atf_ifconfig pppoe0 \ inet 0.0.0.0 0.0.0.1 down $DEBUG && rump.ifconfig @@ -105,11 +117,11 @@ setup() setup_ifaces export RUMP_SERVER=$SERVER - atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0" + atf_pppoectl -e shmif0 pppoe0 unset RUMP_SERVER export RUMP_SERVER=$CLIENT - atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0" + atf_pppoectl -e shmif0 pppoe0 unset RUMP_SERVER } @@ -166,22 +178,17 @@ run_test() fi export RUMP_SERVER=$SERVER - local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \ -'hisauthname=$AUTHNAME' \ -'hisauthsecret=$SECRET' \ -'myauthproto=none' \ -$server_optparam" - atf_check -s exit:0 -x "$HIJACKING $setup_serverparam" - atf_check -s exit:0 rump.ifconfig pppoe0 up + atf_pppoectl pppoe0 "hisauthproto=$auth" \ + "hisauthname=$AUTHNAME" "hisauthsecret=$SECRET" \ + "myauthproto=none" $server_optparam + atf_ifconfig pppoe0 up unset RUMP_SERVER export RUMP_SERVER=$CLIENT - local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \ -'myauthname=$AUTHNAME' \ -'myauthsecret=$SECRET' \ -'hisauthproto=none'" - atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" - atf_check -s exit:0 rump.ifconfig pppoe0 up + atf_pppoectl pppoe0 \ + "myauthname=$AUTHNAME" "myauthsecret=$SECRET" \ + "myauthproto=$auth" "hisauthproto=none" + atf_ifconfig pppoe0 up $DEBUG && rump.ifconfig wait_for_opened $cp atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP @@ -189,7 +196,7 @@ run_test() # test for disconnection from server export RUMP_SERVER=$SERVER - atf_check -s exit:0 rump.ifconfig pppoe0 down + atf_ifconfig pppoe0 down wait_for_disconnected export RUMP_SERVER=$CLIENT wait_for_disconnected @@ -207,7 +214,7 @@ run_test() # test for disconnection from client export RUMP_SERVER=$CLIENT - atf_check -s exit:0 -x rump.ifconfig pppoe0 down + atf_ifconfig pppoe0 down wait_for_disconnected export RUMP_SERVER=$SERVER wait_for_disconnected @@ -219,14 +226,14 @@ run_test() # test for reconnecting export RUMP_SERVER=$CLIENT - atf_check -s exit:0 -x rump.ifconfig pppoe0 up + atf_ifconfig pppoe0 up wait_for_opened $cp $DEBUG && rump.ifconfig pppoe0 $DEBUG && $HIJACKING pppoectl -d pppoe0 unset RUMP_SERVER export RUMP_SERVER=$SERVER - atf_check -s exit:0 rump.ifconfig -w 10 + atf_ifconfig -w 10 atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0" $DEBUG && HIJACKING pppoectl -d pppoe0 @@ -234,15 +241,14 @@ run_test() # test for invalid password export RUMP_SERVER=$CLIENT - atf_check -s exit:0 rump.ifconfig pppoe0 down + atf_ifconfig pppoe0 down wait_for_disconnected - local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \ -'myauthname=$AUTHNAME' \ -'myauthsecret=invalidsecret' \ -'hisauthproto=none' \ -'max-auth-failure=1'" - atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" - atf_check -s exit:0 rump.ifconfig pppoe0 up + atf_pppoectl pppoe0
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:36:13 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Adjust mtu at LCP instead at IPCP The adjustment must be done at LCP when a PPPoE connection does not use IPCP. To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.219 src/sys/net/if_spppsubr.c:1.220 --- src/sys/net/if_spppsubr.c:1.219 Fri Apr 23 03:31:33 2021 +++ src/sys/net/if_spppsubr.c Fri Apr 23 03:36:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.219 2021/04/23 03:31:33 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.220 2021/04/23 03:36:13 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.219 2021/04/23 03:31:33 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.220 2021/04/23 03:36:13 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1166,6 +1166,7 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd struct sppp *sp = (struct sppp *) ifp; int s, error=0, going_up, going_down; u_short newmode; + u_long lcp_mru; s = splnet(); switch (cmd) { @@ -1221,17 +1222,31 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd if (error == ENETRESET) error = 0; - if (sp->lcp.their_mru > 0 && + SPPP_LOCK(sp, RW_WRITER); + lcp_mru = sp->lcp.mru; + if (ifp->if_mtu < PP_MTU) { + sp->lcp.mru = ifp->if_mtu; + } else { + sp->lcp.mru = PP_MTU; + } + if (lcp_mru != sp->lcp.mru) + SET(sp->lcp.opts, SPPP_LCP_OPT_MRU); + + if (sp->scp[IDX_LCP].state == STATE_OPENED && ifp->if_mtu > sp->lcp.their_mru) { sp->pp_saved_mtu = ifp->if_mtu; ifp->if_mtu = sp->lcp.their_mru; + if (ifp->if_flags & IFF_DEBUG) { log(LOG_DEBUG, -"%s: setting MTU to " -"%"PRIu64" bytes\n", -ifp->if_xname, ifp->if_mtu); +"%s: setting MTU " +"from %"PRIu64" bytes " +"to %"PRIu64" bytes\n", +ifp->if_xname, sp->pp_saved_mtu, +ifp->if_mtu); } } + SPPP_UNLOCK(sp); break; case SIOCGIFMTU: @@ -2582,8 +2597,9 @@ sppp_lcp_open(struct sppp *sp, void *xcp if (sp->pp_if.if_mtu < PP_MTU) { sp->lcp.mru = sp->pp_if.if_mtu; SET(sp->lcp.opts, SPPP_LCP_OPT_MRU); - } else + } else { sp->lcp.mru = PP_MTU; + } sp->lcp.their_mru = PP_MTU; /* @@ -2597,6 +2613,7 @@ sppp_lcp_open(struct sppp *sp, void *xcp sppp_open_event(sp, xcp); } + /* * Analyze a configure request. Return true if it was agreeable, and * caused action sca, false if it has been rejected or nak'ed, and @@ -3115,20 +3132,38 @@ end: static void sppp_lcp_tlu(struct sppp *sp) { - struct ifnet *ifp = >pp_if; + STDDCL; int i; KASSERT(SPPP_WLOCKED(sp)); + /* unlock for IFNET_LOCK and if_up() */ + SPPP_UNLOCK(sp); + /* XXX ? */ if (! (ifp->if_flags & IFF_UP) && (ifp->if_flags & IFF_RUNNING)) { /* Coming out of loopback mode. */ - SPPP_UNLOCK(sp); if_up(ifp); - SPPP_LOCK(sp, RW_WRITER); } + IFNET_LOCK(ifp); + SPPP_LOCK(sp, RW_WRITER); + + if (ifp->if_mtu > sp->lcp.their_mru) { + sp->pp_saved_mtu = ifp->if_mtu; + ifp->if_mtu = sp->lcp.their_mru; + if (debug) { + log(LOG_DEBUG, + "%s: setting MTU " + "from %"PRIu64" bytes " + "to %"PRIu64" bytes\n", + ifp->if_xname, sp->pp_saved_mtu, + ifp->if_mtu); + } + } + IFNET_UNLOCK(ifp); + if (ISSET(sp->lcp.opts, SPPP_LCP_OPT_AUTH_PROTO) || (sp->pp_flags & PP_NEEDAUTH) != 0) sppp_change_phase(sp, SPPP_PHASE_AUTHENTICATE); @@ -3164,6 +3199,7 @@ sppp_lcp_tlu(struct sppp *sp) static void sppp_lcp_tld(struct sppp *sp) { + STDDCL; int i, pi, phase; KASSERT(SPPP_WLOCKED(sp)); @@ -3172,6 +3208,25 @@ sppp_lcp_tld(struct sppp *sp) sppp_change_phase(sp, SPPP_PHASE_TERMINATE); + if (sp->pp_saved_mtu > 0) { + SPPP_UNLOCK(sp); + IFNET_LOCK(ifp); + SPPP_LOCK(sp, RW_WRITER); + + if (debug) { + log(LOG_DEBUG, + "%s: setting MTU " + "from %"PRIu64" bytes " + "to %"PRIu64" bytes\n", + ifp->if_xname, ifp->if_mtu, + sp->pp_saved_mtu); + } + + ifp->if_mtu = sp->pp_saved_mtu; + sp->pp_saved_mtu = 0; + IFNET_UNLOCK(ifp); + } + /* * Take upper layers down. We send the Down event first and * the Close second to prevent the upper layers from sending @@ -5543,15 +5598,6 @@ sppp_set_ip_addrs(struct sppp *sp) } } - if (ifp->if_mtu > sp->lcp.their_mru) { - sp->pp_saved_mtu = ifp->if_mtu; - ifp->if_mtu = sp->lcp.their_mru; - if (debug) - log(LOG_DEBUG, - "%s: setting MTU to %" PRIu64 " bytes\n", - ifp->if_xname, ifp->if_mtu); - } - IFNET_UNLOCK(ifp); sppp_notify_con(sp); @@ -5611,15 +5657,6 @@ sppp_clear_ip_addrs(struct sppp *sp) } } - if
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:31:33 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Fix to set mtu even if it is bigger than mru notified at LCP To generate a diff of this commit: cvs rdiff -u -r1.218 -r1.219 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.218 src/sys/net/if_spppsubr.c:1.219 --- src/sys/net/if_spppsubr.c:1.218 Fri Apr 23 01:13:25 2021 +++ src/sys/net/if_spppsubr.c Fri Apr 23 03:31:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.218 2021/04/23 01:13:25 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.219 2021/04/23 03:31:33 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.218 2021/04/23 01:13:25 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.219 2021/04/23 03:31:33 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1212,11 +1212,28 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case SIOCSIFMTU: if (ifr->ifr_mtu < PPP_MINMRU || - ifr->ifr_mtu > sp->lcp.their_mru) { + ifr->ifr_mtu > PP_MTU) { error = EINVAL; break; } - /*FALLTHROUGH*/ + + error = ifioctl_common(ifp, cmd, data); + if (error == ENETRESET) + error = 0; + + if (sp->lcp.their_mru > 0 && + ifp->if_mtu > sp->lcp.their_mru) { + sp->pp_saved_mtu = ifp->if_mtu; + ifp->if_mtu = sp->lcp.their_mru; + if (ifp->if_flags & IFF_DEBUG) { +log(LOG_DEBUG, +"%s: setting MTU to " +"%"PRIu64" bytes\n", +ifp->if_xname, ifp->if_mtu); + } + } + break; + case SIOCGIFMTU: if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET) error = 0;
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 03:07:19 UTC 2021 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Added test cases for "pppoectl passiveauthproto" To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/net/if_pppoe/t_pppoe.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/if_pppoe/t_pppoe.sh diff -u src/tests/net/if_pppoe/t_pppoe.sh:1.24 src/tests/net/if_pppoe/t_pppoe.sh:1.25 --- src/tests/net/if_pppoe/t_pppoe.sh:1.24 Wed Nov 25 10:35:07 2020 +++ src/tests/net/if_pppoe/t_pppoe.sh Fri Apr 23 03:07:19 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.24 2020/11/25 10:35:07 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.25 2021/04/23 03:07:19 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -739,6 +739,82 @@ pppoe_params_cleanup() $DEBUG && dump cleanup } + +pppoe_passiveauthproto() +{ + local auth=$1 + local cp="IPCP" + setup + + local server_optparam="" + if [ $auth = "chap" ]; then + server_optparam="norechallenge" + fi + + export RUMP_SERVER=$SERVER + local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \ +'hisauthname=$AUTHNAME' \ +'hisauthsecret=$SECRET' \ +'myauthproto=none' \ +$server_optparam" + atf_check -s exit:0 -x "$HIJACKING $setup_serverparam" + atf_check -s exit:0 rump.ifconfig pppoe0 up + + export RUMP_SERVER=$CLIENT + local setup_clientparam="pppoectl pppoe0 myauthproto=none \ +'myauthname=$AUTHNAME' \ +'myauthsecret=$SECRET' \ +'hisauthproto=none' \ +'passiveauthproto'" + atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" + atf_check -s exit:0 rump.ifconfig pppoe0 up + $DEBUG && rump.ifconfig + wait_for_opened $cp + atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP +} + +atf_test_case pppoe_passiveauthproto_pap cleanup +pppoe_passiveauthproto_pap_head() +{ + + atf_set "descr" "Test for passiveauthproto option on PAP" + atf_set "require.progs" "rump_server" +} + +pppoe_passiveauthproto_pap_body() +{ + + pppoe_passiveauthproto "pap" +} + +pppoe_passiveauthproto_pap_cleanup() +{ + + $DEBUG && dump + cleanup +} + +atf_test_case pppoe_passiveauthproto_chap cleanup +pppoe_passiveauthproto_chap_head() +{ + + atf_set "descr" "Test for passiveauthproto option on chap" + atf_set "require.progs" "rump_server" +} + +pppoe_passiveauthproto_chap_body() +{ + + pppoe_passiveauthproto "chap" +} + +pppoe_passiveauthproto_chap_cleanup() +{ + + $DEBUG && dump + cleanup +} + atf_init_test_cases() { @@ -748,4 +824,6 @@ atf_init_test_cases() atf_add_test_case pppoe_chap atf_add_test_case pppoe6_pap atf_add_test_case pppoe6_chap + atf_add_test_case pppoe_passiveauthproto_pap + atf_add_test_case pppoe_passiveauthproto_chap }
CVS commit: src/sbin/pppoectl
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 02:28:40 UTC 2021 Modified Files: src/sbin/pppoectl: pppoectl.c Log Message: Add a new option to enable SPPP_AUTHFLAG_PASSIVEAUTHPROTO flag To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sbin/pppoectl/pppoectl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/pppoectl/pppoectl.c diff -u src/sbin/pppoectl/pppoectl.c:1.26 src/sbin/pppoectl/pppoectl.c:1.27 --- src/sbin/pppoectl/pppoectl.c:1.26 Wed Nov 25 10:32:54 2020 +++ src/sbin/pppoectl/pppoectl.c Fri Apr 23 02:28:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pppoectl.c,v 1.26 2020/11/25 10:32:54 yamaguchi Exp $ */ +/* $NetBSD: pppoectl.c,v 1.27 2021/04/23 02:28:40 yamaguchi Exp $ */ /* * Copyright (c) 1997 Joerg Wunsch @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pppoectl.c,v 1.26 2020/11/25 10:32:54 yamaguchi Exp $"); +__RCSID("$NetBSD: pppoectl.c,v 1.27 2021/04/23 02:28:40 yamaguchi Exp $"); #endif @@ -433,6 +433,8 @@ pppoectl_argument(char *arg) spr.hisauthflags |= SPPP_AUTHFLAG_NORECHALLENGE; else if (strcmp(arg, "rechallenge") == 0) spr.hisauthflags &= ~SPPP_AUTHFLAG_NORECHALLENGE; + else if (strcmp(arg, "passiveauthproto") == 0) + spr.myauthflags |= SPPP_AUTHFLAG_PASSIVEAUTHPROTO; #ifndef __NetBSD__ else if (strcmp(arg, "enable-vj") == 0) spr.defs.enable_vj = 1;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 23 01:13:26 UTC 2021 Modified Files: src/sys/net: if_sppp.h if_spppsubr.c Log Message: Introduct a new flag to accept different authentication protocol in myauthproto and hisauthproto When the flag is enabled, a authentication protocol notified at LCP negotiation is used as my authentication protocol. When the flags is NOT enabled, my authentication protoco is not changed at LCP negotiation. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_sppp.h cvs rdiff -u -r1.217 -r1.218 src/sys/net/if_spppsubr.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_sppp.h diff -u src/sys/net/if_sppp.h:1.30 src/sys/net/if_sppp.h:1.31 --- src/sys/net/if_sppp.h:1.30 Wed Dec 2 14:20:20 2020 +++ src/sys/net/if_sppp.h Fri Apr 23 01:13:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.30 2020/12/02 14:20:20 wiz Exp $ */ +/* $NetBSD: if_sppp.h,v 1.31 2021/04/23 01:13:25 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -44,6 +44,7 @@ #define SPPP_AUTHFLAG_NOCALLOUT 1 /* do not require authentication on */ /* callouts */ #define SPPP_AUTHFLAG_NORECHALLENGE 2 /* do not re-challenge CHAP */ +#define SPPP_AUTHFLAG_PASSIVEAUTHPROTO 4 /* use authproto proposed by peer */ struct spppauthcfg { char ifname[IFNAMSIZ]; /* pppoe interface name */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.217 src/sys/net/if_spppsubr.c:1.218 --- src/sys/net/if_spppsubr.c:1.217 Fri Apr 16 02:12:00 2021 +++ src/sys/net/if_spppsubr.c Fri Apr 23 01:13:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.218 2021/04/23 01:13:25 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.218 2021/04/23 01:13:25 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2701,6 +2701,10 @@ sppp_lcp_confreq(struct sppp *sp, struct addlog(" [invalid chap len]"); break; } + if (ISSET(sp->myauth.flags, SPPP_AUTHFLAG_PASSIVEAUTHPROTO)) { +if (authproto == PPP_PAP || authproto == PPP_CHAP) + sp->myauth.proto = authproto; + } if (sp->myauth.proto == 0) { /* we are not configured to do auth */ if (debug) @@ -2831,6 +2835,10 @@ sppp_lcp_confreq(struct sppp *sp, struct case LCP_OPT_AUTH_PROTO: authproto = (p[2] << 8) + p[3]; + if (ISSET(sp->myauth.flags, SPPP_AUTHFLAG_PASSIVEAUTHPROTO)) { +if (authproto == PPP_PAP || authproto == PPP_CHAP) + sp->myauth.proto = authproto; + } if (sp->myauth.proto != authproto) { /* not agreed, nak */ if (debug)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Thu Apr 22 10:26:24 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Added missing free of sc_hunique to prevent memory leak when using PPPoE server To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.169 src/sys/net/if_pppoe.c:1.170 --- src/sys/net/if_pppoe.c:1.169 Fri Apr 16 02:23:25 2021 +++ src/sys/net/if_pppoe.c Thu Apr 22 10:26:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.169 2021/04/16 02:23:25 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.170 2021/04/22 10:26:24 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.169 2021/04/16 02:23:25 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.170 2021/04/22 10:26:24 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -448,6 +448,13 @@ pppoe_clone_destroy(struct ifnet *ifp) callout_halt(>sc_timeout, NULL); callout_destroy(>sc_timeout); +#ifdef PPPOE_SERVER + if (sc->sc_hunique) { + free(sc->sc_hunique, M_DEVBUF); + sc->sc_hunique = NULL; + sc->sc_hunique_len = 0; + } +#endif if (sc->sc_concentrator_name) free(sc->sc_concentrator_name, M_DEVBUF); if (sc->sc_service_name)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 02:26:25 UTC 2021 Modified Files: src/sys/net: if_spppvar.h Log Message: Added missing locking order between sppp and IFNET_LOCK To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_spppvar.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/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.32 src/sys/net/if_spppvar.h:1.33 --- src/sys/net/if_spppvar.h:1.32 Wed Nov 25 10:30:51 2020 +++ src/sys/net/if_spppvar.h Fri Apr 16 02:26:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.32 2020/11/25 10:30:51 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.33 2021/04/16 02:26:25 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -240,7 +240,7 @@ void sppp_flush (struct ifnet *); * if_spppsubr.c. * * Locking order: - *- spppq_lock => struct sppp->pp_lock + *- IFNET_LOCK => spppq_lock => struct sppp->pp_lock * * NOTICE * - Lower layers must not acquire sppp->pp_lock
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 02:23:25 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Stop and destroy timeout after sppp_detach and if_detach for safety The functions may use resources of pppoe(4) while detaching, so the release should move after it. To generate a diff of this commit: cvs rdiff -u -r1.168 -r1.169 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.168 src/sys/net/if_pppoe.c:1.169 --- src/sys/net/if_pppoe.c:1.168 Fri Apr 16 02:12:00 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 02:23:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.168 2021/04/16 02:12:00 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.169 2021/04/16 02:23:25 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.168 2021/04/16 02:12:00 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.169 2021/04/16 02:23:25 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -436,13 +436,18 @@ pppoe_clone_destroy(struct ifnet *ifp) } rw_exit(_softc_list_lock); + bpf_detach(ifp); + sppp_detach(>sc_sppp.pp_if); + if_detach(ifp); + callout_setfunc(>sc_timeout, pppoe_timeout_co_halt, sc); + workqueue_wait(sc->sc_timeout_wq, >sc_timeout_wk); + workqueue_destroy(sc->sc_timeout_wq); + callout_halt(>sc_timeout, NULL); + callout_destroy(>sc_timeout); - bpf_detach(ifp); - sppp_detach(>sc_sppp.pp_if); - if_detach(ifp); if (sc->sc_concentrator_name) free(sc->sc_concentrator_name, M_DEVBUF); if (sc->sc_service_name) @@ -451,8 +456,6 @@ pppoe_clone_destroy(struct ifnet *ifp) free(sc->sc_ac_cookie, M_DEVBUF); if (sc->sc_relay_sid) free(sc->sc_relay_sid, M_DEVBUF); - callout_destroy(>sc_timeout); - workqueue_destroy(sc->sc_timeout_wq); rw_destroy(>sc_lock);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 02:12:00 UTC 2021 Modified Files: src/sys/net: if_pppoe.c if_spppsubr.c Log Message: Remove unnecessaly lock holdings to avoid dead lock The locks were held while callout_halt() and workqueue_wait() without reason. And the locks also were held at callout and workqueue handler so that the handler kicked by those function couldn't acquire the lock. The reasons why those are unneccesary are: - Items of callout_t are protected by callout_lock - Items of struct workqueue and struct work are protected by q_mutex in struct workqueue - Items of struct sppp_work protected by atomic_cas(3) - struct pppoe_softc does not free before workqueue_wait() and callout_halt() even if the locks are not held To generate a diff of this commit: cvs rdiff -u -r1.167 -r1.168 src/sys/net/if_pppoe.c cvs rdiff -u -r1.216 -r1.217 src/sys/net/if_spppsubr.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.167 src/sys/net/if_pppoe.c:1.168 --- src/sys/net/if_pppoe.c:1.167 Fri Apr 16 01:59:50 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 02:12:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.167 2021/04/16 01:59:50 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.168 2021/04/16 02:12:00 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.167 2021/04/16 01:59:50 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.168 2021/04/16 02:12:00 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -436,7 +436,6 @@ pppoe_clone_destroy(struct ifnet *ifp) } rw_exit(_softc_list_lock); - PPPOE_LOCK(sc, RW_WRITER); callout_setfunc(>sc_timeout, pppoe_timeout_co_halt, sc); workqueue_wait(sc->sc_timeout_wq, >sc_timeout_wk); callout_halt(>sc_timeout, NULL); @@ -455,7 +454,6 @@ pppoe_clone_destroy(struct ifnet *ifp) callout_destroy(>sc_timeout); workqueue_destroy(sc->sc_timeout_wq); - PPPOE_UNLOCK(sc); rw_destroy(>sc_lock); kmem_free(sc, sizeof(*sc)); Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.216 src/sys/net/if_spppsubr.c:1.217 --- src/sys/net/if_spppsubr.c:1.216 Fri Apr 16 02:05:37 2021 +++ src/sys/net/if_spppsubr.c Fri Apr 16 02:12:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.216 2021/04/16 02:05:37 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.216 2021/04/16 02:05:37 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1074,8 +1074,6 @@ sppp_detach(struct ifnet *ifp) spppq_lock = NULL; } - SPPP_LOCK(sp, RW_WRITER); - sppp_cp_fini(, sp); sppp_cp_fini(, sp); sppp_cp_fini(, sp); @@ -1090,7 +1088,6 @@ sppp_detach(struct ifnet *ifp) if (sp->myauth.secret) free(sp->myauth.secret, M_DEVBUF); if (sp->hisauth.name) free(sp->hisauth.name, M_DEVBUF); if (sp->hisauth.secret) free(sp->hisauth.secret, M_DEVBUF); - SPPP_UNLOCK(sp); rw_destroy(>pp_lock); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 02:05:37 UTC 2021 Modified Files: src/sys/net: if_spppsubr.c Log Message: Fix not to put the wrong error message To generate a diff of this commit: cvs rdiff -u -r1.215 -r1.216 src/sys/net/if_spppsubr.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_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.215 src/sys/net/if_spppsubr.c:1.216 --- src/sys/net/if_spppsubr.c:1.215 Fri Nov 27 03:37:11 2020 +++ src/sys/net/if_spppsubr.c Fri Apr 16 02:05:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.215 2020/11/27 03:37:11 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.216 2021/04/16 02:05:37 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.215 2020/11/27 03:37:11 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.216 2021/04/16 02:05:37 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1933,6 +1933,13 @@ sppp_down_event(struct sppp *sp, void *x sppp_cp_change_state(cp, sp, STATE_STARTING); break; default: + /* + * a down event may be caused regardless + * of state just in LCP case. + */ + if (cp->proto == PPP_LCP) + break; + printf("%s: %s illegal down in state %s\n", ifp->if_xname, cp->name, sppp_state_name(sp->scp[cp->protoidx].state));
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 01:59:50 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Stop ppp layer at first of destroying pppoe interface To generate a diff of this commit: cvs rdiff -u -r1.166 -r1.167 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.166 src/sys/net/if_pppoe.c:1.167 --- src/sys/net/if_pppoe.c:1.166 Fri Apr 16 01:44:35 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 01:59:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.166 2021/04/16 01:44:35 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.167 2021/04/16 01:59:50 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.166 2021/04/16 01:44:35 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.167 2021/04/16 01:59:50 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -188,6 +188,7 @@ struct pppoe_softc { int sc_padi_retried; /* number of PADI retries already done */ int sc_padr_retried; /* number of PADR retries already done */ krwlock_t sc_lock; /* lock of sc_state, sc_session, and sc_eth_if */ + bool sc_detaching; }; /* incoming traffic will be queued here */ @@ -417,13 +418,17 @@ pppoe_clone_destroy(struct ifnet *ifp) { struct pppoe_softc * sc = ifp->if_softc; - rw_enter(_softc_list_lock, RW_WRITER); - PPPOE_LOCK(sc, RW_WRITER); - callout_setfunc(>sc_timeout, pppoe_timeout_co_halt, sc); - workqueue_wait(sc->sc_timeout_wq, >sc_timeout_wk); - callout_halt(>sc_timeout, NULL); + /* stop ioctls */ + sc->sc_detaching = true; + if (ifp->if_flags & IFF_RUNNING) { + pppoe_clear_softc(sc, "destroy interface"); + sc->sc_eth_if = NULL; + } + PPPOE_UNLOCK(sc); + + rw_enter(_softc_list_lock, RW_WRITER); LIST_REMOVE(sc, sc_list); if (LIST_EMPTY(_softc_list)) { @@ -431,6 +436,11 @@ pppoe_clone_destroy(struct ifnet *ifp) } rw_exit(_softc_list_lock); + PPPOE_LOCK(sc, RW_WRITER); + callout_setfunc(>sc_timeout, pppoe_timeout_co_halt, sc); + workqueue_wait(sc->sc_timeout_wq, >sc_timeout_wk); + callout_halt(>sc_timeout, NULL); + bpf_detach(ifp); sppp_detach(>sc_sppp.pp_if); if_detach(ifp); @@ -1285,6 +1295,10 @@ pppoe_ioctl(struct ifnet *ifp, unsigned struct ifnet *eth_if; PPPOE_LOCK(sc, RW_WRITER); + if (sc->sc_detaching) { +PPPOE_UNLOCK(sc); +return ENXIO; + } eth_if = ifunit(parms->eth_ifname); if (eth_if == NULL || eth_if->if_dlt != DLT_EN10MB) { sc->sc_eth_if = NULL; @@ -1343,6 +1357,10 @@ pppoe_ioctl(struct ifnet *ifp, unsigned * administrators choice. */ PPPOE_LOCK(sc, RW_WRITER); + if (sc->sc_detaching) { + PPPOE_UNLOCK(sc); + return ENXIO; + } if ((ifr->ifr_flags & IFF_UP) == 0 && sc->sc_state < PPPOE_STATE_SESSION) { @@ -1506,7 +1524,8 @@ pppoe_timeout(struct pppoe_softc *sc) switch (sc->sc_state) { case PPPOE_STATE_INITIAL: /* delayed connect from pppoe_tls() */ - pppoe_connect(sc); + if (!sc->sc_detaching) + pppoe_connect(sc); break; case PPPOE_STATE_PADI_SENT: /*
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 01:44:35 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Sort initialization sequence in pppoe_clone_create() out for refactoring It has no functionality impact To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.165 src/sys/net/if_pppoe.c:1.166 --- src/sys/net/if_pppoe.c:1.165 Fri Apr 16 01:32:04 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 01:44:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.165 2021/04/16 01:32:04 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.166 2021/04/16 01:44:35 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.165 2021/04/16 01:32:04 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.166 2021/04/16 01:44:35 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -339,34 +339,43 @@ static int pppoe_clone_create(struct if_clone *ifc, int unit) { struct pppoe_softc *sc; + struct ifnet *ifp; int rv; sc = kmem_zalloc(sizeof(*sc), KM_SLEEP); + ifp = >sc_sppp.pp_if; rw_init(>sc_lock); pppoe_softc_genid(>sc_id); + /* changed to real address later */ + memcpy(>sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest)); - if_initname(>sc_sppp.pp_if, "pppoe", unit); - sc->sc_sppp.pp_if.if_softc = sc; - sc->sc_sppp.pp_if.if_mtu = PPPOE_MAXMTU; - sc->sc_sppp.pp_if.if_flags = IFF_SIMPLEX|IFF_POINTOPOINT|IFF_MULTICAST; + if_initname(ifp, "pppoe", unit); + ifp->if_softc = sc; + ifp->if_mtu = PPPOE_MAXMTU; + ifp->if_flags = IFF_SIMPLEX|IFF_POINTOPOINT|IFF_MULTICAST; +#ifdef PPPOE_MPSAFE + ifp->if_extflags = IFEF_MPSAFE; +#endif + ifp->if_type = IFT_PPP; + ifp->if_hdrlen = sizeof(struct ether_header) + PPPOE_HEADERLEN; + ifp->if_dlt = DLT_PPP_ETHER; + ifp->if_ioctl = pppoe_ioctl; + ifp->if_start = pppoe_start; #ifdef PPPOE_MPSAFE - sc->sc_sppp.pp_if.if_extflags = IFEF_MPSAFE; + ifp->if_transmit = pppoe_transmit; #endif - sc->sc_sppp.pp_if.if_type = IFT_PPP; - sc->sc_sppp.pp_if.if_hdrlen = sizeof(struct ether_header) + PPPOE_HEADERLEN; - sc->sc_sppp.pp_if.if_dlt = DLT_PPP_ETHER; + IFQ_SET_MAXLEN(>if_snd, IFQ_MAXLEN); + IFQ_SET_READY(>if_snd); + + sc->sc_sppp.pp_tls = pppoe_tls; + sc->sc_sppp.pp_tlf = pppoe_tlf; sc->sc_sppp.pp_flags |= PP_KEEPALIVE | /* use LCP keepalive */ PP_NOFRAMING; /* no serial encapsulation */ - sc->sc_sppp.pp_if.if_ioctl = pppoe_ioctl; - IFQ_SET_MAXLEN(>sc_sppp.pp_if.if_snd, IFQ_MAXLEN); - IFQ_SET_READY(>sc_sppp.pp_if.if_snd); - - /* changed to real address later */ - memcpy(>sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest)); + sc->sc_sppp.pp_framebytes = PPPOE_HEADERLEN; /* framing added to ppp packets */ rv = workqueue_create(>sc_timeout_wq, - sc->sc_sppp.pp_if.if_xname, pppoe_timeout_wk, sc, + ifp->if_xname, pppoe_timeout_wk, sc, PRI_SOFTNET, IPL_SOFTNET, 0); if (rv != 0) goto destroy_sclock; @@ -374,33 +383,23 @@ pppoe_clone_create(struct if_clone *ifc, callout_init(>sc_timeout, CALLOUT_MPSAFE); callout_setfunc(>sc_timeout, pppoe_timeout_co, sc); - sc->sc_sppp.pp_if.if_start = pppoe_start; -#ifdef PPPOE_MPSAFE - sc->sc_sppp.pp_if.if_transmit = pppoe_transmit; -#endif - sc->sc_sppp.pp_tls = pppoe_tls; - sc->sc_sppp.pp_tlf = pppoe_tlf; - sc->sc_sppp.pp_framebytes = PPPOE_HEADERLEN; /* framing added to ppp packets */ - - rv = if_initialize(>sc_sppp.pp_if); + rv = if_initialize(ifp); if (rv != 0) goto destroy_timeout; - sc->sc_sppp.pp_if.if_percpuq = if_percpuq_create(>sc_sppp.pp_if); - sppp_attach(>sc_sppp.pp_if); + ifp->if_percpuq = if_percpuq_create(ifp); - bpf_attach(>sc_sppp.pp_if, DLT_PPP_ETHER, 0); rw_enter(_softc_list_lock, RW_READER); if (LIST_EMPTY(_softc_list)) { pfil_add_ihook(pppoe_ifattach_hook, NULL, PFIL_IFNET, if_pfil); } + LIST_INSERT_HEAD(_softc_list, sc, sc_list); rw_exit(_softc_list_lock); - if_register(>sc_sppp.pp_if); + sppp_attach(ifp); + bpf_attach(ifp, DLT_PPP_ETHER, 0); + if_register(ifp); - rw_enter(_softc_list_lock, RW_WRITER); - LIST_INSERT_HEAD(_softc_list, sc, sc_list); - rw_exit(_softc_list_lock); return 0; destroy_timeout:
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 01:32:04 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Use kmem_zalloc to allocate pppoe_softc To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.164 src/sys/net/if_pppoe.c:1.165 --- src/sys/net/if_pppoe.c:1.164 Fri Apr 16 01:28:51 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 01:32:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.164 2021/04/16 01:28:51 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.165 2021/04/16 01:32:04 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.164 2021/04/16 01:28:51 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.165 2021/04/16 01:32:04 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -341,7 +341,7 @@ pppoe_clone_create(struct if_clone *ifc, struct pppoe_softc *sc; int rv; - sc = malloc(sizeof(struct pppoe_softc), M_DEVBUF, M_WAITOK|M_ZERO); + sc = kmem_zalloc(sizeof(*sc), KM_SLEEP); rw_init(>sc_lock); pppoe_softc_genid(>sc_id); @@ -408,7 +408,7 @@ destroy_timeout: workqueue_destroy(sc->sc_timeout_wq); destroy_sclock: rw_destroy(>sc_lock); - free(sc, M_DEVBUF); + kmem_free(sc, sizeof(*sc)); return rv; } @@ -449,7 +449,7 @@ pppoe_clone_destroy(struct ifnet *ifp) PPPOE_UNLOCK(sc); rw_destroy(>sc_lock); - free(sc, M_DEVBUF); + kmem_free(sc, sizeof(*sc)); return 0; }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 01:28:51 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Move initialization of sc_lock in pppoe_softc to first The lock may be held in callbacks for ppp layer or other components so that it should be initialized early. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.163 src/sys/net/if_pppoe.c:1.164 --- src/sys/net/if_pppoe.c:1.163 Fri Apr 16 01:24:35 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 01:28:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.163 2021/04/16 01:24:35 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.164 2021/04/16 01:28:51 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.163 2021/04/16 01:24:35 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.164 2021/04/16 01:28:51 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -343,6 +343,7 @@ pppoe_clone_create(struct if_clone *ifc, sc = malloc(sizeof(struct pppoe_softc), M_DEVBUF, M_WAITOK|M_ZERO); + rw_init(>sc_lock); pppoe_softc_genid(>sc_id); if_initname(>sc_sppp.pp_if, "pppoe", unit); @@ -368,7 +369,7 @@ pppoe_clone_create(struct if_clone *ifc, sc->sc_sppp.pp_if.if_xname, pppoe_timeout_wk, sc, PRI_SOFTNET, IPL_SOFTNET, 0); if (rv != 0) - goto free_sc; + goto destroy_sclock; callout_init(>sc_timeout, CALLOUT_MPSAFE); callout_setfunc(>sc_timeout, pppoe_timeout_co, sc); @@ -397,8 +398,6 @@ pppoe_clone_create(struct if_clone *ifc, if_register(>sc_sppp.pp_if); - rw_init(>sc_lock); - rw_enter(_softc_list_lock, RW_WRITER); LIST_INSERT_HEAD(_softc_list, sc, sc_list); rw_exit(_softc_list_lock); @@ -407,8 +406,10 @@ pppoe_clone_create(struct if_clone *ifc, destroy_timeout: callout_destroy(>sc_timeout); workqueue_destroy(sc->sc_timeout_wq); -free_sc: +destroy_sclock: + rw_destroy(>sc_lock); free(sc, M_DEVBUF); + return rv; }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Fri Apr 16 01:24:35 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: commonize error handling in pppoe_clone_create() To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.162 src/sys/net/if_pppoe.c:1.163 --- src/sys/net/if_pppoe.c:1.162 Tue Apr 13 05:04:54 2021 +++ src/sys/net/if_pppoe.c Fri Apr 16 01:24:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.162 2021/04/13 05:04:54 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.163 2021/04/16 01:24:35 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.162 2021/04/13 05:04:54 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.163 2021/04/16 01:24:35 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -367,10 +367,8 @@ pppoe_clone_create(struct if_clone *ifc, rv = workqueue_create(>sc_timeout_wq, sc->sc_sppp.pp_if.if_xname, pppoe_timeout_wk, sc, PRI_SOFTNET, IPL_SOFTNET, 0); - if (rv != 0) { - free(sc, M_DEVBUF); - return rv; - } + if (rv != 0) + goto free_sc; callout_init(>sc_timeout, CALLOUT_MPSAFE); callout_setfunc(>sc_timeout, pppoe_timeout_co, sc); @@ -384,13 +382,9 @@ pppoe_clone_create(struct if_clone *ifc, sc->sc_sppp.pp_framebytes = PPPOE_HEADERLEN; /* framing added to ppp packets */ rv = if_initialize(>sc_sppp.pp_if); - if (rv != 0) { - workqueue_destroy(sc->sc_timeout_wq); - callout_halt(>sc_timeout, NULL); - callout_destroy(>sc_timeout); - free(sc, M_DEVBUF); - return rv; - } + if (rv != 0) + goto destroy_timeout; + sc->sc_sppp.pp_if.if_percpuq = if_percpuq_create(>sc_sppp.pp_if); sppp_attach(>sc_sppp.pp_if); @@ -409,6 +403,13 @@ pppoe_clone_create(struct if_clone *ifc, LIST_INSERT_HEAD(_softc_list, sc, sc_list); rw_exit(_softc_list_lock); return 0; + +destroy_timeout: + callout_destroy(>sc_timeout); + workqueue_destroy(sc->sc_timeout_wq); +free_sc: + free(sc, M_DEVBUF); + return rv; } static int
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Apr 13 05:04:54 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Reschedule softint to process packets enqueued to ppoediscinq while doing pppoe_data_input And added a empty check for ppoeinq, for safety To generate a diff of this commit: cvs rdiff -u -r1.161 -r1.162 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.161 src/sys/net/if_pppoe.c:1.162 --- src/sys/net/if_pppoe.c:1.161 Tue Apr 13 05:00:06 2021 +++ src/sys/net/if_pppoe.c Tue Apr 13 05:04:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.161 2021/04/13 05:00:06 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.162 2021/04/13 05:04:54 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.161 2021/04/13 05:00:06 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.162 2021/04/13 05:04:54 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -602,6 +602,9 @@ pppoeintr(void) } } while (disc_done || data_done); + if (!IF_IS_EMPTY() || !IF_IS_EMPTY()) + softint_schedule(pppoe_softintr); + SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Apr 13 05:00:06 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Added missing counter clear when a pppoe state changes to PADI_SENT To generate a diff of this commit: cvs rdiff -u -r1.160 -r1.161 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.160 src/sys/net/if_pppoe.c:1.161 --- src/sys/net/if_pppoe.c:1.160 Tue Apr 13 04:57:15 2021 +++ src/sys/net/if_pppoe.c Tue Apr 13 05:00:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.160 2021/04/13 04:57:15 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.161 2021/04/13 05:00:06 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.160 2021/04/13 04:57:15 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.161 2021/04/13 05:00:06 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1547,6 +1547,7 @@ pppoe_timeout(struct pppoe_softc *sc) memcpy(>sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest)); sc->sc_state = PPPOE_STATE_PADI_SENT; + sc->sc_padi_retried = 0; sc->sc_padr_retried = 0; if ((err = pppoe_send_padi(sc)) != 0) { pppoe_printf(sc, @@ -1596,6 +1597,7 @@ pppoe_connect(struct pppoe_softc *sc) ACQUIRE_SPLNET(); /* save state, in case we fail to send PADI */ sc->sc_state = PPPOE_STATE_PADI_SENT; + sc->sc_padi_retried = 0; sc->sc_padr_retried = 0; err = pppoe_send_padi(sc); if (err != 0)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Apr 13 04:57:15 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Added a NULL check for parent interface of pppoe To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.160 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.159 src/sys/net/if_pppoe.c:1.160 --- src/sys/net/if_pppoe.c:1.159 Tue Apr 13 04:53:22 2021 +++ src/sys/net/if_pppoe.c Tue Apr 13 04:57:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.159 2021/04/13 04:53:22 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.160 2021/04/13 04:57:15 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.159 2021/04/13 04:53:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.160 2021/04/13 04:57:15 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -533,7 +533,7 @@ pppoe_find_softc_by_hunique(uint8_t *tok LIST_FOREACH(sc, _softc_list, sc_list) { PPPOE_LOCK(sc, lock); - if (sc->sc_id == t) { + if (sc->sc_id == t && sc->sc_eth_if != NULL) { break; } PPPOE_UNLOCK(sc);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Tue Apr 13 04:53:22 UTC 2021 Modified Files: src/sys/net: if_pppoe.c Log Message: Hold the lock for pppoe while referencing sc_id that is an item of struct pppoe_softc To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/sys/net/if_pppoe.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_pppoe.c diff -u src/sys/net/if_pppoe.c:1.158 src/sys/net/if_pppoe.c:1.159 --- src/sys/net/if_pppoe.c:1.158 Wed Nov 25 10:42:35 2020 +++ src/sys/net/if_pppoe.c Tue Apr 13 04:53:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.158 2020/11/25 10:42:35 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.159 2021/04/13 04:53:22 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.158 2020/11/25 10:42:35 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.159 2021/04/13 04:53:22 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -532,10 +532,11 @@ pppoe_find_softc_by_hunique(uint8_t *tok memcpy(, token, len); LIST_FOREACH(sc, _softc_list, sc_list) { + PPPOE_LOCK(sc, lock); if (sc->sc_id == t) { - PPPOE_LOCK(sc, lock); break; } + PPPOE_UNLOCK(sc); } rw_exit(_softc_list_lock);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 5 06:56:47 UTC 2021 Modified Files: src/sys/net: toeplitz.c Log Message: s/nitems/__arraycount/ To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/net/toeplitz.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/toeplitz.c diff -u src/sys/net/toeplitz.c:1.1 src/sys/net/toeplitz.c:1.2 --- src/sys/net/toeplitz.c:1.1 Sat Jan 30 21:23:08 2021 +++ src/sys/net/toeplitz.c Mon Apr 5 06:56:47 2021 @@ -165,7 +165,7 @@ stoeplitz_hash_ip6(const struct stoeplit uint32_t n32 = 0; size_t i; - for (i = 0; i < nitems(faddr6->s6_addr32); i++) + for (i = 0; i < __arraycount(faddr6->s6_addr32); i++) n32 ^= faddr6->s6_addr32[i] ^ laddr6->s6_addr32[i]; return (stoeplitz_hash_n32(scache, n32)); @@ -179,7 +179,7 @@ stoeplitz_hash_ip6port(const struct stoe uint32_t n32 = 0; size_t i; - for (i = 0; i < nitems(faddr6->s6_addr32); i++) + for (i = 0; i < __arraycount(faddr6->s6_addr32); i++) n32 ^= faddr6->s6_addr32[i] ^ laddr6->s6_addr32[i]; n32 ^= fport ^ lport;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Mon Apr 5 06:53:45 UTC 2021 Modified Files: src/sys/net: toeplitz.h Log Message: Include opt_inet.h for INET6 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/net/toeplitz.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/net/toeplitz.h diff -u src/sys/net/toeplitz.h:1.1 src/sys/net/toeplitz.h:1.2 --- src/sys/net/toeplitz.h:1.1 Sat Jan 30 21:23:08 2021 +++ src/sys/net/toeplitz.h Mon Apr 5 06:53:45 2021 @@ -19,6 +19,10 @@ #ifndef _SYS_NET_TOEPLITZ_H_ #define _SYS_NET_TOEPLITZ_H_ +#ifdef _KERNEL_OPT +#include "opt_inet.h" +#endif + #include /*
CVS commit: src/sys/dev/pci
Module Name:src Committed By: yamaguchi Date: Fri Mar 5 13:21:07 UTC 2021 Modified Files: src/sys/dev/pci: if_iavf.c Log Message: Fix missing IFM_FDX To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/if_iavf.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/dev/pci/if_iavf.c diff -u src/sys/dev/pci/if_iavf.c:1.12 src/sys/dev/pci/if_iavf.c:1.13 --- src/sys/dev/pci/if_iavf.c:1.12 Tue Feb 9 15:05:49 2021 +++ src/sys/dev/pci/if_iavf.c Fri Mar 5 13:21:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_iavf.c,v 1.12 2021/02/09 15:05:49 jakllsch Exp $ */ +/* $NetBSD: if_iavf.c,v 1.13 2021/03/05 13:21:07 yamaguchi Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.12 2021/02/09 15:05:49 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.13 2021/03/05 13:21:07 yamaguchi Exp $"); #include #include @@ -4435,6 +4435,7 @@ iavf_process_vc_event(struct iavf_softc if (event->link_status) { link = LINK_STATE_UP; sc->sc_media_status |= IFM_ACTIVE; + sc->sc_media_active |= IFM_FDX; ifp->if_baudrate = 0; speed = iavf_find_link_speed(sc, event->link_speed);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: yamaguchi Date: Thu Dec 10 04:03:00 UTC 2020 Modified Files: src/sys/dev/pci: if_iavf.c Log Message: Add a string literal for IAVF_VC_OP_CONFIG_RSS_LUT To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/if_iavf.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/dev/pci/if_iavf.c diff -u src/sys/dev/pci/if_iavf.c:1.10 src/sys/dev/pci/if_iavf.c:1.11 --- src/sys/dev/pci/if_iavf.c:1.10 Thu Dec 10 04:00:11 2020 +++ src/sys/dev/pci/if_iavf.c Thu Dec 10 04:03:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_iavf.c,v 1.10 2020/12/10 04:00:11 yamaguchi Exp $ */ +/* $NetBSD: if_iavf.c,v 1.11 2020/12/10 04:03:00 yamaguchi Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.10 2020/12/10 04:00:11 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.11 2020/12/10 04:03:00 yamaguchi Exp $"); #include #include @@ -3783,6 +3783,8 @@ iavf_aq_vc_opcode_str(const struct ixl_a return "EVENT"; case IAVF_VC_OP_CONFIG_RSS_KEY: return "CONFIG_RSS_KEY"; + case IAVF_VC_OP_CONFIG_RSS_LUT: + return "CONFIG_RSS_LUT"; case IAVF_VC_OP_GET_RSS_HENA_CAPS: return "GET_RS_HENA_CAPS"; case IAVF_VC_OP_SET_RSS_HENA: