CVS commit: src/sbin/tunefs
Module Name:src Committed By: dholland Date: Thu Nov 26 02:06:01 UTC 2020 Modified Files: src/sbin/tunefs: tunefs.c Log Message: Add missing newlines to ACL prints in tunefs; from Jan Schaumann in PR 55824. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sbin/tunefs/tunefs.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/tunefs/tunefs.c diff -u src/sbin/tunefs/tunefs.c:1.53 src/sbin/tunefs/tunefs.c:1.54 --- src/sbin/tunefs/tunefs.c:1.53 Sat Aug 8 11:44:55 2020 +++ src/sbin/tunefs/tunefs.c Thu Nov 26 02:06:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tunefs.c,v 1.53 2020/08/08 11:44:55 christos Exp $ */ +/* $NetBSD: tunefs.c,v 1.54 2020/11/26 02:06:01 dholland Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)tunefs.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: tunefs.c,v 1.53 2020/08/08 11:44:55 christos Exp $"); +__RCSID("$NetBSD: tunefs.c,v 1.54 2020/11/26 02:06:01 dholland Exp $"); #endif #endif /* not lint */ @@ -391,7 +391,7 @@ main(int argc, char *argv[]) "exclusive", name); } else { sblock.fs_flags |= FS_POSIX1EACLS; -printf("%s set", name); +printf("%s set\n", name); } } else if (strcmp(pvalue, "disable") == 0) { if ((~sblock.fs_flags & FS_POSIX1EACLS) == @@ -400,7 +400,7 @@ main(int argc, char *argv[]) name); } else { sblock.fs_flags &= ~FS_POSIX1EACLS; -printf("%s cleared", name); +printf("%s cleared\n", name); } } }
CVS commit: src/etc
Module Name:src Committed By: riastradh Date: Wed Nov 25 21:40:22 UTC 2020 Modified Files: src/etc: motd.beta motd.current motd.rc Log Message: Simplify default motd text and include donation link. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/etc/motd.beta src/etc/motd.rc cvs rdiff -u -r1.7 -r1.8 src/etc/motd.current Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/motd.beta diff -u src/etc/motd.beta:1.5 src/etc/motd.beta:1.6 --- src/etc/motd.beta:1.5 Tue May 28 18:25:23 2019 +++ src/etc/motd.beta Wed Nov 25 21:40:22 2020 @@ -2,15 +2,7 @@ NetBSD ?.? (UNKNOWN) Welcome to NetBSD! -This system is running a beta release of the NetBSD operating system, aimed -at stabilizing the next formal release. It is close to formal release quality, -but may still contain bugs, even serious ones. Please bear this in mind and -use the system with care. - -You are encouraged to test this version as thoroughly as possible. Should you -encounter any problem, please report it back to the development team using the -send-pr(1) utility (requires a working MTA). If yours is not properly set up, -use the web interface at: https://www.NetBSD.org/support/send-pr.html - -Thank you for helping us test and improve this beta NetBSD release. +This is a beta release of NetBSD for testing. +Bug reports: https://www.NetBSD.org/support/send-pr.html +Donations to the NetBSD Foundation: https://www.NetBSD.org/donations/ Index: src/etc/motd.rc diff -u src/etc/motd.rc:1.5 src/etc/motd.rc:1.6 --- src/etc/motd.rc:1.5 Tue May 28 18:25:23 2019 +++ src/etc/motd.rc Wed Nov 25 21:40:22 2020 @@ -2,15 +2,7 @@ NetBSD ?.? (UNKNOWN) Welcome to NetBSD! -This system is running a release candidate of the NetBSD operating system, -aimed at shaking out the most serious bugs that may affect the next formal -release. It should be considered close to release quality, but may still -contain unresolved issues. - -You are encouraged to test this version as thoroughly as possible. Should you -encounter any problem, please report it back to the development team using the -send-pr(1) utility (requires a working MTA). If yours is not properly set up, -use the web interface at: https://www.NetBSD.org/support/send-pr.html - -Thank you for helping us test and improve this NetBSD release candidate. +This is a release candidate for NetBSD. +Bug reports: https://www.NetBSD.org/support/send-pr.html +Donations to the NetBSD Foundation: https://www.NetBSD.org/donations/ Index: src/etc/motd.current diff -u src/etc/motd.current:1.7 src/etc/motd.current:1.8 --- src/etc/motd.current:1.7 Tue May 28 18:25:23 2019 +++ src/etc/motd.current Wed Nov 25 21:40:22 2020 @@ -2,15 +2,7 @@ NetBSD ?.? (UNKNOWN) Welcome to NetBSD! -This system is running a development snapshot of the NetBSD operating system, -also known as NetBSD-current. It is very possible that it has serious bugs, -regressions, broken features or other problems. Please bear this in mind -and use the system with care. - -You are encouraged to test this version as thoroughly as possible. Should you -encounter any problem, please report it back to the development team using the -send-pr(1) utility (requires a working MTA). If yours is not properly set up, -use the web interface at: https://www.NetBSD.org/support/send-pr.html - -Thank you for helping us test and improve NetBSD. +This is a development snapshot of NetBSD for testing -- user beware! +Bug reports: https://www.NetBSD.org/support/send-pr.html +Donations to the NetBSD Foundation: https://www.NetBSD.org/donations/
CVS commit: src/sys/kern
Module Name:src Committed By: wiz Date: Wed Nov 25 21:08:59 UTC 2020 Modified Files: src/sys/kern: kern_exec.c Log Message: Define LMSG outside the MAXTSIZ check so it also exists in non-MAXTSIZ kernels. To generate a diff of this commit: cvs rdiff -u -r1.502 -r1.503 src/sys/kern/kern_exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.502 src/sys/kern/kern_exec.c:1.503 --- src/sys/kern/kern_exec.c:1.502 Tue Oct 6 13:38:00 2020 +++ src/sys/kern/kern_exec.c Wed Nov 25 21:08:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.502 2020/10/06 13:38:00 christos Exp $ */ +/* $NetBSD: kern_exec.c,v 1.503 2020/11/25 21:08:59 wiz Exp $ */ /*- * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.502 2020/10/06 13:38:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.503 2020/11/25 21:08:59 wiz Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -498,10 +498,12 @@ check_exec(struct lwp *l, struct exec_pa } /* check limits */ +#ifdef DIAGNOSTIC +#define LMSG "%s: rejecting due to %s limit (%ju > %ju)\n" +#endif #ifdef MAXTSIZ if (epp->ep_tsize > MAXTSIZ) { #ifdef DIAGNOSTIC -#define LMSG "%s: rejecting due to %s limit (%ju > %ju)\n" printf(LMSG, __func__, "text", (uintmax_t)epp->ep_tsize, (uintmax_t)MAXTSIZ);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Nov 25 21:02:35 UTC 2020 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Add support for message-based interrupts. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/gicv3_fdt.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/arch/arm/fdt/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.9 src/sys/arch/arm/fdt/gicv3_fdt.c:1.10 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.9 Tue Nov 24 23:31:55 2020 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Wed Nov 25 21:02:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.9 2020/11/24 23:31:55 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.10 2020/11/25 21:02:35 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -31,7 +31,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.9 2020/11/24 23:31:55 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.10 2020/11/25 21:02:35 jmcneill Exp $"); #include #include @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c, #include #include #include +#include #define GICV3_MAXIRQ 1020 @@ -62,6 +63,7 @@ static void gicv3_fdt_attach(device_t, d static int gicv3_fdt_map_registers(struct gicv3_fdt_softc *); #if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX) +static void gicv3_fdt_attach_mbi(struct gicv3_fdt_softc *); static void gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int); #endif @@ -176,12 +178,18 @@ gicv3_fdt_attach(device_t parent, device } #if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX) - for (int child = OF_child(phandle); child; child = OF_peer(child)) { - if (!fdtbus_status_okay(child)) - continue; - const char * const its_compat[] = { "arm,gic-v3-its", NULL }; - if (of_match_compatible(child, its_compat)) - gicv3_fdt_attach_its(sc, faa->faa_bst, child); + if (of_hasprop(phandle, "msi-controller")) { + /* Message Based Interrupts */ + gicv3_fdt_attach_mbi(sc); + } else { + /* Interrupt Translation Services */ + for (int child = OF_child(phandle); child; child = OF_peer(child)) { + if (!fdtbus_status_okay(child)) +continue; + const char * const its_compat[] = { "arm,gic-v3-its", NULL }; + if (of_match_compatible(child, its_compat)) +gicv3_fdt_attach_its(sc, faa->faa_bst, child); + } } #endif @@ -257,6 +265,52 @@ gicv3_fdt_map_registers(struct gicv3_fdt #if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX) static void +gicv3_fdt_attach_mbi(struct gicv3_fdt_softc *sc) +{ + struct gic_v2m_frame *frame; + const u_int *ranges; + bus_addr_t addr; + int len, frame_count; + + if (of_hasprop(sc->sc_phandle, "mbi-alias")) { + aprint_error_dev(sc->sc_gic.sc_dev, "'mbi-alias' property not supported\n"); + return; + } + + if (fdtbus_get_reg(sc->sc_phandle, 0, , NULL) != 0) + return; + + ranges = fdtbus_get_prop(sc->sc_phandle, "mbi-ranges", ); + if (ranges == NULL) { + aprint_error_dev(sc->sc_gic.sc_dev, "missing 'mbi-ranges' property\n"); + return; + } + + frame_count = 0; + while (len >= 8) { + const u_int base_spi = be32dec([0]); + const u_int num_spis = be32dec([1]); + + frame = kmem_zalloc(sizeof(*frame), KM_SLEEP); + frame->frame_reg = addr; + frame->frame_pic = pic_list[0]; + frame->frame_base = base_spi; + frame->frame_count = num_spis; + + if (gic_v2m_init(frame, sc->sc_gic.sc_dev, frame_count++) != 0) { + aprint_error_dev(sc->sc_gic.sc_dev, "failed to initialize MBI frame\n"); + } else { + aprint_normal_dev(sc->sc_gic.sc_dev, "MBI frame @ %#" PRIx64 + ", SPIs %u-%u\n", frame->frame_reg, + frame->frame_base, frame->frame_base + frame->frame_count - 1); + } + + ranges += 2; + len -= 8; + } +} + +static void gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle) { bus_space_handle_t bsh;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Nov 25 20:59:20 UTC 2020 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Fix off-by-one when printing the range of SPIs in a GICv2m frame To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/fdt/gic_fdt.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/arch/arm/fdt/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.18 src/sys/arch/arm/fdt/gic_fdt.c:1.19 --- src/sys/arch/arm/fdt/gic_fdt.c:1.18 Sun Nov 24 11:10:12 2019 +++ src/sys/arch/arm/fdt/gic_fdt.c Wed Nov 25 20:59:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.19 2020/11/25 20:59:20 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -29,7 +29,7 @@ #include "pci.h" #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.19 2020/11/25 20:59:20 jmcneill Exp $"); #include #include @@ -227,8 +227,8 @@ gic_fdt_attach_v2m(struct gic_fdt_softc aprint_error_dev(sc->sc_gicdev, "failed to initialize GICv2m\n"); } else { aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64 - ", SPIs %u-%u\n", frame->frame_reg, - frame->frame_base, frame->frame_base + frame->frame_count); + ", SPIs %u-%u\n", frame->frame_reg, frame->frame_base, + frame->frame_base + frame->frame_count - 1); } } #endif
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Wed Nov 25 19:50:06 UTC 2020 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Fix comment. Spotted by jmcneill@ To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/fdt/cpu_fdt.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/arch/arm/fdt/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.36 src/sys/arch/arm/fdt/cpu_fdt.c:1.37 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.36 Wed Jun 10 19:29:48 2020 +++ src/sys/arch/arm/fdt/cpu_fdt.c Wed Nov 25 19:50:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.36 2020/06/10 19:29:48 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.37 2020/11/25 19:50:06 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.36 2020/06/10 19:29:48 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.37 2020/11/25 19:50:06 skrll Exp $"); #include #include @@ -167,7 +167,7 @@ arm_fdt_cpu_bootstrap(void) /* MPIDR affinity levels of boot processor. */ bp_mpidr = cpu_mpidr_aff_read(); - /* Boot APs */ + /* Add APs to cpu_mpidr array */ cpuindex = 1; for (child = OF_child(cpus); child; child = OF_peer(child)) { if (!arm_fdt_cpu_okay(child))
CVS commit: src/crypto/dist/ipsec-tools/src/racoon
Module Name:src Committed By: bouyer Date: Wed Nov 25 18:11:00 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/racoon: cfparse.y cftoken.l isakmp_xauth.c isakmp_xauth.h racoon.conf.5 Log Message: Add ldap parameters debug and timeout. Fix bug when using URI (use correct len for malloc) document ldap parameters uri, debug and timeout. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/crypto/dist/ipsec-tools/src/racoon/cfparse.y cvs rdiff -u -r1.28 -r1.29 src/crypto/dist/ipsec-tools/src/racoon/cftoken.l cvs rdiff -u -r1.32 -r1.33 \ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c cvs rdiff -u -r1.9 -r1.10 \ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.h cvs rdiff -u -r1.68 -r1.69 \ src/crypto/dist/ipsec-tools/src/racoon/racoon.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/racoon/cfparse.y diff -u src/crypto/dist/ipsec-tools/src/racoon/cfparse.y:1.52 src/crypto/dist/ipsec-tools/src/racoon/cfparse.y:1.53 --- src/crypto/dist/ipsec-tools/src/racoon/cfparse.y:1.52 Wed Nov 25 16:42:53 2020 +++ src/crypto/dist/ipsec-tools/src/racoon/cfparse.y Wed Nov 25 18:11:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cfparse.y,v 1.52 2020/11/25 16:42:53 bouyer Exp $ */ +/* $NetBSD: cfparse.y,v 1.53 2020/11/25 18:11:00 bouyer Exp $ */ /* Id: cfparse.y,v 1.66 2006/08/22 18:17:17 manubsd Exp */ @@ -296,7 +296,7 @@ static const char error_message_dpd_not_ /* listen */ %token LISTEN X_ISAKMP X_ISAKMP_NATT X_ADMIN STRICT_ADDRESS ADMINSOCK DISABLED /* ldap config */ -%token LDAPCFG LDAP_URI LDAP_HOST LDAP_PORT LDAP_TLS LDAP_PVER LDAP_BASE LDAP_BIND_DN LDAP_BIND_PW LDAP_SUBTREE +%token LDAPCFG LDAP_URI LDAP_HOST LDAP_PORT LDAP_TLS LDAP_PVER LDAP_DEBUG LDAP_TIMEOUT LDAP_BASE LDAP_BIND_DN LDAP_BIND_PW LDAP_SUBTREE %token LDAP_ATTR_USER LDAP_ATTR_ADDR LDAP_ATTR_MASK LDAP_ATTR_GROUP LDAP_ATTR_MEMBER /* radius config */ %token RADCFG RAD_AUTH RAD_ACCT RAD_TIMEOUT RAD_RETRIES @@ -773,6 +773,24 @@ ldapcfg_stmt #endif } EOS + | LDAP_DEBUG NUMBER + { +#ifdef ENABLE_HYBRID +#ifdef HAVE_LIBLDAP + xauth_ldap_config.debug = $2; +#endif +#endif + } + EOS + | LDAP_TIMEOUT NUMBER + { +#ifdef ENABLE_HYBRID +#ifdef HAVE_LIBLDAP + xauth_ldap_config.timeout = $2; +#endif +#endif + } + EOS | LDAP_URI QUOTEDSTRING { #ifdef ENABLE_HYBRID Index: src/crypto/dist/ipsec-tools/src/racoon/cftoken.l diff -u src/crypto/dist/ipsec-tools/src/racoon/cftoken.l:1.28 src/crypto/dist/ipsec-tools/src/racoon/cftoken.l:1.29 --- src/crypto/dist/ipsec-tools/src/racoon/cftoken.l:1.28 Wed Nov 25 16:42:53 2020 +++ src/crypto/dist/ipsec-tools/src/racoon/cftoken.l Wed Nov 25 18:11:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cftoken.l,v 1.28 2020/11/25 16:42:53 bouyer Exp $ */ +/* $NetBSD: cftoken.l,v 1.29 2020/11/25 18:11:00 bouyer Exp $ */ /* Id: cftoken.l,v 1.53 2006/08/22 18:17:17 manubsd Exp */ @@ -224,6 +224,8 @@ hexstring 0x{hexdigit}+ ldapcfg { BEGIN S_LDAP; YYDB; return(LDAPCFG); } {bcl} { return(BOC); } version { YYD; return(LDAP_PVER); } +debug { YYD; return(LDAP_DEBUG); } +timeout { YYD; return(LDAP_TIMEOUT); } uri { YYD; return(LDAP_URI); } host { YYD; return(LDAP_HOST); } port { YYD; return(LDAP_PORT); } Index: src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c diff -u src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.32 src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.33 --- src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.32 Wed Nov 25 16:42:53 2020 +++ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c Wed Nov 25 18:11:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: isakmp_xauth.c,v 1.32 2020/11/25 16:42:53 bouyer Exp $ */ +/* $NetBSD: isakmp_xauth.c,v 1.33 2020/11/25 18:11:00 bouyer Exp $ */ /* Id: isakmp_xauth.c,v 1.38 2006/08/22 18:17:17 manubsd Exp */ @@ -803,6 +803,8 @@ xauth_ldap_init_conf(void) int error = -1; xauth_ldap_config.pver = 3; + xauth_ldap_config.debug = 0; + xauth_ldap_config.timeout = -1; xauth_ldap_config.uri = NULL; xauth_ldap_config.host = NULL; xauth_ldap_config.port = LDAP_PORT; @@ -896,7 +898,7 @@ xauth_login_ldap(iph1, usr, pwd) atlist[2] = NULL; if (xauth_ldap_config.uri != NULL) { - tmplen = strlen(xauth_ldap_config.host->v); + tmplen = strlen(xauth_ldap_config.uri->v); init = racoon_malloc(tmplen); if (init == NULL) { plog(LLV_ERROR, LOCATION, NULL, @@ -918,6 +920,9 @@ xauth_login_ldap(iph1, usr, pwd) xauth_ldap_config.host->v, xauth_ldap_config.port ); } + /* initialize the debug level */ + ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, _ldap_config.debug); + ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, _ldap_config.debug); plog(LLV_DEBUG, LOCATION, NULL, "ldap URI: %s\n", init); /* initialize the ldap handle */ @@ -933,12 +938,26 @@ xauth_login_ldap(iph1, usr, pwd) if ((res = ldap_set_option(ld,
CVS commit: src/crypto/dist/ipsec-tools/src/racoon
Module Name:src Committed By: bouyer Date: Wed Nov 25 16:42:53 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/racoon: cfparse.y cftoken.l isakmp_xauth.c isakmp_xauth.h Log Message: Add an option to pass a ldap uri, instead of just server and port. uri takes precedence. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/crypto/dist/ipsec-tools/src/racoon/cfparse.y cvs rdiff -u -r1.27 -r1.28 src/crypto/dist/ipsec-tools/src/racoon/cftoken.l cvs rdiff -u -r1.31 -r1.32 \ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c cvs rdiff -u -r1.8 -r1.9 \ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/racoon/cfparse.y diff -u src/crypto/dist/ipsec-tools/src/racoon/cfparse.y:1.51 src/crypto/dist/ipsec-tools/src/racoon/cfparse.y:1.52 --- src/crypto/dist/ipsec-tools/src/racoon/cfparse.y:1.51 Sat May 19 20:14:56 2018 +++ src/crypto/dist/ipsec-tools/src/racoon/cfparse.y Wed Nov 25 16:42:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cfparse.y,v 1.51 2018/05/19 20:14:56 maxv Exp $ */ +/* $NetBSD: cfparse.y,v 1.52 2020/11/25 16:42:53 bouyer Exp $ */ /* Id: cfparse.y,v 1.66 2006/08/22 18:17:17 manubsd Exp */ @@ -296,7 +296,7 @@ static const char error_message_dpd_not_ /* listen */ %token LISTEN X_ISAKMP X_ISAKMP_NATT X_ADMIN STRICT_ADDRESS ADMINSOCK DISABLED /* ldap config */ -%token LDAPCFG LDAP_HOST LDAP_PORT LDAP_TLS LDAP_PVER LDAP_BASE LDAP_BIND_DN LDAP_BIND_PW LDAP_SUBTREE +%token LDAPCFG LDAP_URI LDAP_HOST LDAP_PORT LDAP_TLS LDAP_PVER LDAP_BASE LDAP_BIND_DN LDAP_BIND_PW LDAP_SUBTREE %token LDAP_ATTR_USER LDAP_ATTR_ADDR LDAP_ATTR_MASK LDAP_ATTR_GROUP LDAP_ATTR_MEMBER /* radius config */ %token RADCFG RAD_AUTH RAD_ACCT RAD_TIMEOUT RAD_RETRIES @@ -773,6 +773,19 @@ ldapcfg_stmt #endif } EOS + | LDAP_URI QUOTEDSTRING + { +#ifdef ENABLE_HYBRID +#ifdef HAVE_LIBLDAP + if (xauth_ldap_config.uri != NULL) +vfree(xauth_ldap_config.uri); + + xauth_ldap_config.uri = vdup($2); +#endif +#endif + vfree($2); + } + EOS | LDAP_HOST QUOTEDSTRING { #ifdef ENABLE_HYBRID Index: src/crypto/dist/ipsec-tools/src/racoon/cftoken.l diff -u src/crypto/dist/ipsec-tools/src/racoon/cftoken.l:1.27 src/crypto/dist/ipsec-tools/src/racoon/cftoken.l:1.28 --- src/crypto/dist/ipsec-tools/src/racoon/cftoken.l:1.27 Thu Nov 29 15:31:24 2012 +++ src/crypto/dist/ipsec-tools/src/racoon/cftoken.l Wed Nov 25 16:42:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cftoken.l,v 1.27 2012/11/29 15:31:24 vanhu Exp $ */ +/* $NetBSD: cftoken.l,v 1.28 2020/11/25 16:42:53 bouyer Exp $ */ /* Id: cftoken.l,v 1.53 2006/08/22 18:17:17 manubsd Exp */ @@ -224,6 +224,7 @@ hexstring 0x{hexdigit}+ ldapcfg { BEGIN S_LDAP; YYDB; return(LDAPCFG); } {bcl} { return(BOC); } version { YYD; return(LDAP_PVER); } +uri { YYD; return(LDAP_URI); } host { YYD; return(LDAP_HOST); } port { YYD; return(LDAP_PORT); } tls { YYD; return(LDAP_TLS); } Index: src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c diff -u src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.31 src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.32 --- src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.31 Wed Nov 25 16:41:39 2020 +++ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c Wed Nov 25 16:42:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: isakmp_xauth.c,v 1.31 2020/11/25 16:41:39 bouyer Exp $ */ +/* $NetBSD: isakmp_xauth.c,v 1.32 2020/11/25 16:42:53 bouyer Exp $ */ /* Id: isakmp_xauth.c,v 1.38 2006/08/22 18:17:17 manubsd Exp */ @@ -803,6 +803,7 @@ xauth_ldap_init_conf(void) int error = -1; xauth_ldap_config.pver = 3; + xauth_ldap_config.uri = NULL; xauth_ldap_config.host = NULL; xauth_ldap_config.port = LDAP_PORT; xauth_ldap_config.tls = 0; @@ -894,19 +895,31 @@ xauth_login_ldap(iph1, usr, pwd) atlist[1] = NULL; atlist[2] = NULL; - /* build our initialization url */ - tmplen = strlen("ldap://:;) + 17; - tmplen += strlen(xauth_ldap_config.host->v); - init = racoon_malloc(tmplen); - if (init == NULL) { - plog(LLV_ERROR, LOCATION, NULL, - "unable to alloc ldap init url\n"); - goto ldap_end; + if (xauth_ldap_config.uri != NULL) { + tmplen = strlen(xauth_ldap_config.host->v); + init = racoon_malloc(tmplen); + if (init == NULL) { + plog(LLV_ERROR, LOCATION, NULL, +"unable to alloc ldap init url\n"); + goto ldap_end; + } + sprintf(init,"%s", xauth_ldap_config.uri->v); + } else { + /* build our initialization url */ + tmplen = strlen("ldap://:;) + 17; + tmplen += strlen(xauth_ldap_config.host->v); + init = racoon_malloc(tmplen); + if (init == NULL) { + plog(LLV_ERROR, LOCATION, NULL, +"unable to alloc ldap init url\n"); + goto ldap_end; + } + sprintf(init,"ldap://%s:%d;, + xauth_ldap_config.host->v, + xauth_ldap_config.port ); } - sprintf(init,"ldap://%s:%d;, -
CVS commit: src/crypto/dist/ipsec-tools/src/racoon
Module Name:src Committed By: bouyer Date: Wed Nov 25 16:41:39 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/racoon: isakmp_xauth.c Log Message: Fix ldap: ldap_sasl_bind_s() doens't like a NULL struct berval *, pass a pointer to a zero'd struct instead. While there use LDAP_SASL_SIMPLE instead of NULL for mechanism, and check return of ldap_set_option(). To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 \ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c diff -u src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.30 src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.31 --- src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c:1.30 Sat May 19 20:14:56 2018 +++ src/crypto/dist/ipsec-tools/src/racoon/isakmp_xauth.c Wed Nov 25 16:41:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: isakmp_xauth.c,v 1.30 2018/05/19 20:14:56 maxv Exp $ */ +/* $NetBSD: isakmp_xauth.c,v 1.31 2020/11/25 16:41:39 bouyer Exp $ */ /* Id: isakmp_xauth.c,v 1.38 2006/08/22 18:17:17 manubsd Exp */ @@ -917,9 +917,15 @@ xauth_login_ldap(iph1, usr, pwd) } /* initialize the protocol version */ - ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, - _ldap_config.pver); - + if ((res = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, + _ldap_config.pver)) != LDAP_OPT_SUCCESS) { + plog(LLV_ERROR, LOCATION, NULL, + "LDAP_OPT_PROTOCOL_VERSION %s failed: %s\n", + xauth_ldap_config.pver, + ldap_err2string(res)); + goto ldap_end; + } + /* Enable TLS */ if (xauth_ldap_config.tls) { res = ldap_start_tls_s(ld, NULL, NULL); @@ -943,13 +949,15 @@ xauth_login_ldap(iph1, usr, pwd) cred.bv_val = xauth_ldap_config.bind_pw->v; cred.bv_len = strlen( cred.bv_val ); res = ldap_sasl_bind_s(ld, - xauth_ldap_config.bind_dn->v, NULL, , + xauth_ldap_config.bind_dn->v, LDAP_SASL_SIMPLE, , NULL, NULL, NULL); } else { + cred.bv_val = NULL; + cred.bv_len = 0; res = ldap_sasl_bind_s(ld, - NULL, NULL, NULL, + NULL, LDAP_SASL_SIMPLE, , NULL, NULL, NULL); }
CVS commit: src/sys/arch/dreamcast/conf
Module Name:src Committed By: tsutsui Date: Wed Nov 25 15:31:15 UTC 2020 Modified Files: src/sys/arch/dreamcast/conf: majors.dreamcast Log Message: Reserve device-major for ld(4) on possible sdmmc(4) at scimci. https://mail-index.netbsd.org/port-dreamcast/2014/10/25/msg000263.html https://mail-index.netbsd.org/port-dreamcast/2014/10/30/msg000265.html To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/dreamcast/conf/majors.dreamcast Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/dreamcast/conf/majors.dreamcast diff -u src/sys/arch/dreamcast/conf/majors.dreamcast:1.25 src/sys/arch/dreamcast/conf/majors.dreamcast:1.26 --- src/sys/arch/dreamcast/conf/majors.dreamcast:1.25 Sat Apr 4 16:06:12 2020 +++ src/sys/arch/dreamcast/conf/majors.dreamcast Wed Nov 25 15:31:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: majors.dreamcast,v 1.25 2020/04/04 16:06:12 jdolecek Exp $ +# $NetBSD: majors.dreamcast,v 1.26 2020/11/25 15:31:15 tsutsui Exp $ # # Device majors for dreamcast # @@ -58,6 +58,7 @@ device-major mlcd char 63 mlcd device-major ksyms char 64 ksyms device-major wsfont char 65 wsfont #device-major obsolete char 66 obsolete (opencrypto) +device-major ld char 67 block 22 ld #device-major obsolete char 98 obsolete (nsmb)
CVS commit: src/etc/etc.dreamcast
Module Name:src Committed By: tsutsui Date: Wed Nov 25 15:14:04 UTC 2020 Modified Files: src/etc/etc.dreamcast: MAKEDEV.conf Log Message: Create wd0 and wd1 device node for G1IDE kernel. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/etc/etc.dreamcast/MAKEDEV.conf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/etc.dreamcast/MAKEDEV.conf diff -u src/etc/etc.dreamcast/MAKEDEV.conf:1.6 src/etc/etc.dreamcast/MAKEDEV.conf:1.7 --- src/etc/etc.dreamcast/MAKEDEV.conf:1.6 Thu Dec 8 11:31:13 2016 +++ src/etc/etc.dreamcast/MAKEDEV.conf Wed Nov 25 15:14:03 2020 @@ -1,16 +1,18 @@ -# $NetBSD: MAKEDEV.conf,v 1.6 2016/12/08 11:31:13 nat Exp $ +# $NetBSD: MAKEDEV.conf,v 1.7 2020/11/25 15:14:03 tsutsui Exp $ all_md) makedev wscons gdrom0 maple makedev scif0 sci0 makedev audio speaker makedev cfs + makedev wd0 wd1 ;; ramdisk) makedev std bpf md0 gdrom0 makedev scif0 sci0 opty makedev ttyE0 ttyEcfg wsmouse0 wskbd0 tun0 tun1 ipl + makedev wd0 wd1 ;; maple)
CVS commit: src/crypto/dist/ipsec-tools/src/racoon
Module Name:src Committed By: christos Date: Wed Nov 25 14:15:41 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/racoon: grabmyaddr.c Log Message: Reduce previous To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 \ src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c diff -u src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.38 src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.39 --- src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.38 Wed Nov 25 05:57:11 2020 +++ src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c Wed Nov 25 09:15:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: grabmyaddr.c,v 1.38 2020/11/25 10:57:11 kardel Exp $ */ +/* $NetBSD: grabmyaddr.c,v 1.39 2020/11/25 14:15:41 christos Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 2008 Timo Teras . @@ -683,13 +683,11 @@ kernel_sync() #elif defined(USE_ROUTE) -#ifdef RT_ROUNDUP -#define SAROUNDUP(X) RT_ROUNDUP(((struct sockaddr *)(X))->sa_len) -#else -#define ROUNDUP(a) \ +#ifndef RT_ROUNDUP +#define RT_ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) -#define SAROUNDUP(X) ROUNDUP(((struct sockaddr *)(X))->sa_len) #endif +#define SAROUNDUP(X) RT_ROUNDUP(((struct sockaddr *)(X))->sa_len) static size_t
CVS commit: src/crypto/dist/ipsec-tools/src/racoon
Module Name:src Committed By: kardel Date: Wed Nov 25 10:57:11 UTC 2020 Modified Files: src/crypto/dist/ipsec-tools/src/racoon: grabmyaddr.c Log Message: Fix address advancing for i386 and other 32-bit platforms. Makes racoon grok IPv6 addresses again on these platforms. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 \ src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c diff -u src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.37 src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.38 --- src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c:1.37 Sat May 19 20:14:56 2018 +++ src/crypto/dist/ipsec-tools/src/racoon/grabmyaddr.c Wed Nov 25 10:57:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: grabmyaddr.c,v 1.37 2018/05/19 20:14:56 maxv Exp $ */ +/* $NetBSD: grabmyaddr.c,v 1.38 2020/11/25 10:57:11 kardel Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 2008 Timo Teras . @@ -683,10 +683,14 @@ kernel_sync() #elif defined(USE_ROUTE) +#ifdef RT_ROUNDUP +#define SAROUNDUP(X) RT_ROUNDUP(((struct sockaddr *)(X))->sa_len) +#else #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) - #define SAROUNDUP(X) ROUNDUP(((struct sockaddr *)(X))->sa_len) +#endif + static size_t parse_address(caddr_t start, caddr_t end, struct sockaddr_storage *dest)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:44:53 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: add KASSERT(!cpu_softintr_p()); pointed out by knakahara@n.o., thanks. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 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.213 src/sys/net/if_spppsubr.c:1.214 --- src/sys/net/if_spppsubr.c:1.213 Wed Nov 25 10:30:51 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:44:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.213 2020/11/25 10:30:51 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.214 2020/11/25 10:44:53 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.213 2020/11/25 10:30:51 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.214 2020/11/25 10:44:53 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1869,6 +1869,7 @@ sppp_up_event(struct sppp *sp, void *xcp STDDCL; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); if ((cp->flags & CP_AUTH) != 0 && sppp_auth_role(cp, sp) == SPPP_AUTH_NOROLE) @@ -1902,6 +1903,7 @@ sppp_down_event(struct sppp *sp, void *x STDDCL; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); if ((cp->flags & CP_AUTH) != 0 && sppp_auth_role(cp, sp) == SPPP_AUTH_NOROLE) @@ -1944,6 +1946,7 @@ sppp_open_event(struct sppp *sp, void *x STDDCL; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); if ((cp->flags & CP_AUTH) != 0 && sppp_auth_role(cp, sp) == SPPP_AUTH_NOROLE) @@ -1986,6 +1989,7 @@ sppp_close_event(struct sppp *sp, void * STDDCL; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); if ((cp->flags & CP_AUTH) != 0 && sppp_auth_role(cp, sp) == SPPP_AUTH_NOROLE) @@ -2035,6 +2039,7 @@ sppp_to_event(struct sppp *sp, void *xcp STDDCL; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); s = splnet(); @@ -2097,6 +2102,8 @@ sppp_rcr_event(struct sppp *sp, void *xc size_t blen; STDDCL; + KASSERT(!cpu_softintr_p()); + type = sp->scp[cp->protoidx].rcr_type; buf = sp->scp[cp->protoidx].rcr_buf; blen = sp->scp[cp->protoidx].rcr_blen; @@ -2202,6 +2209,8 @@ sppp_rca_event(struct sppp *sp, void *xc const struct cp *cp = xcp; STDDCL; + KASSERT(!cpu_softintr_p()); + switch (sp->scp[cp->protoidx].state) { case STATE_CLOSED: case STATE_STOPPED: @@ -2246,6 +2255,8 @@ sppp_rcn_event(struct sppp *sp, void *xc const struct cp *cp = xcp; struct ifnet *ifp = >pp_if; + KASSERT(!cpu_softintr_p()); + switch (sp->scp[cp->protoidx].state) { case STATE_CLOSED: case STATE_STOPPED: @@ -2283,6 +2294,8 @@ sppp_rtr_event(struct sppp *sp, void *xc const struct cp *cp = xcp; STDDCL; + KASSERT(!cpu_softintr_p()); + switch (sp->scp[cp->protoidx].state) { case STATE_ACK_RCVD: case STATE_ACK_SENT: @@ -2323,6 +2336,8 @@ sppp_rta_event(struct sppp *sp, void *xc const struct cp *cp = xcp; struct ifnet *ifp = >pp_if; + KASSERT(!cpu_softintr_p()); + switch (sp->scp[cp->protoidx].state) { case STATE_CLOSED: case STATE_STOPPED: @@ -2359,6 +2374,8 @@ sppp_rxj_event(struct sppp *sp, void *xc const struct cp *cp = xcp; struct ifnet *ifp = >pp_if; + KASSERT(!cpu_softintr_p()); + /* XXX catastrophic rejects (RXJ-) aren't handled yet. */ switch (sp->scp[cp->protoidx].state) { case STATE_CLOSED: @@ -2485,6 +2502,7 @@ sppp_lcp_down(struct sppp *sp, void *xcp STDDCL; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); pidx = cp->protoidx; sppp_down_event(sp, xcp); @@ -2536,6 +2554,7 @@ sppp_lcp_open(struct sppp *sp, void *xcp { KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); sp->lcp.reestablish = false; @@ -3300,6 +3319,7 @@ sppp_ipcp_open(struct sppp *sp, void *xc uint32_t myaddr, hisaddr; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); sp->ipcp.flags &= ~(IPCP_HISADDR_SEEN|IPCP_MYADDR_SEEN|IPCP_MYADDR_DYN|IPCP_HISADDR_DYN); sp->ipcp.req_myaddr = 0; @@ -3360,6 +3380,7 @@ sppp_ipcp_close(struct sppp *sp, void *x { KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); sppp_close_event(sp, xcp); @@ -3850,6 +3871,7 @@ sppp_ipv6cp_open(struct sppp *sp, void * struct in6_addr myaddr, hisaddr; KASSERT(SPPP_WLOCKED(sp)); + KASSERT(!cpu_softintr_p()); #ifdef IPV6CP_MYIFID_DYN sp->ipv6cp.flags &= ~(IPV6CP_MYIFID_SEEN|IPV6CP_MYIFID_DYN); @@ -4795,6 +4817,8 @@ sppp_chap_rcv_challenge_event(struct spp { const struct cp *cp = xcp; + KASSERT(!cpu_softintr_p()); + sp->chap.rechallenging = false; switch (sp->scp[IDX_CHAP].state) { @@ -5193,6 +5217,7 @@ sppp_auth_to_event(struct sppp *sp, void STDDCL; KASSERT(SPPP_WLOCKED(sp)); +
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:42:35 UTC 2020 Modified Files: src/sys/net: if_pppoe.c Log Message: Fix to reconnect after PADT received To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 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.157 src/sys/net/if_pppoe.c:1.158 --- src/sys/net/if_pppoe.c:1.157 Wed Nov 25 10:39:47 2020 +++ src/sys/net/if_pppoe.c Wed Nov 25 10:42:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.157 2020/11/25 10:39:47 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.158 2020/11/25 10:42: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.157 2020/11/25 10:39:47 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.158 2020/11/25 10:42:35 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1006,6 +1006,8 @@ 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); PPPOE_UNLOCK(sc); break;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:39:47 UTC 2020 Modified Files: src/sys/net: if_pppoe.c Log Message: add a logging function used at debugging pppoe(4) To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 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.156 src/sys/net/if_pppoe.c:1.157 --- src/sys/net/if_pppoe.c:1.156 Wed Nov 25 10:38:10 2020 +++ src/sys/net/if_pppoe.c Wed Nov 25 10:39:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.156 2020/11/25 10:38:10 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.157 2020/11/25 10:39:47 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.156 2020/11/25 10:38:10 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.157 2020/11/25 10:39:47 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -155,6 +155,12 @@ struct pppoetag { } while (0) #endif +#ifdef PPPOE_DEBUG +#define DPRINTF(_sc, _fmt, _arg...) pppoe_printf((_sc), (_fmt), ##_arg) +#else +#define DPRINTF(_sc, _fmt, _arg...) __nothing +#endif + struct pppoe_softc { struct sppp sc_sppp; /* contains a struct ifnet as first element */ LIST_ENTRY(pppoe_softc) sc_list; @@ -212,6 +218,7 @@ static void pppoe_start(struct ifnet *); static int pppoe_transmit(struct ifnet *, struct mbuf *); #endif static void pppoe_clear_softc(struct pppoe_softc *, const char *); +static void pppoe_printf(struct pppoe_softc *, const char *, ...); /* internal timeout handling */ static void pppoe_timeout_co(void *); @@ -445,6 +452,35 @@ pppoe_clone_destroy(struct ifnet *ifp) return 0; } +static void +pppoe_printf(struct pppoe_softc *sc, const char *fmt, ...) +{ + va_list ap; + bool pppoe_debug; + +#ifdef PPPOE_DEBUG + pppoe_debug = true; +#else + pppoe_debug = false; +#endif + + if (sc == NULL) { + if (!pppoe_debug) + return; + + printf("pppoe: "); + } else { + if (!ISSET(sc->sc_sppp.pp_if.if_flags, IFF_DEBUG)) + return; + + printf("%s: ", sc->sc_sppp.pp_if.if_xname); + } + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} + /* * Find the interface handling the specified session. * Note: O(number of sessions open), this is a client-side only, mean @@ -504,22 +540,21 @@ pppoe_find_softc_by_hunique(uint8_t *tok rw_exit(_softc_list_lock); if (sc == NULL) { -#ifdef PPPOE_DEBUG - printf("pppoe: alien host unique tag, no session found\n"); -#endif + pppoe_printf(NULL, "alien host unique tag" + ", no session found\n"); return NULL; } /* should be safe to access *sc now */ if (sc->sc_state < PPPOE_STATE_PADI_SENT || sc->sc_state >= PPPOE_STATE_SESSION) { - printf("%s: host unique tag found, but it belongs to a connection in state %d\n", - sc->sc_sppp.pp_if.if_xname, sc->sc_state); + pppoe_printf(sc, "host unique tag found" + ", but it belongs to a connection in state %d\n", + sc->sc_state); PPPOE_UNLOCK(sc); return NULL; } if (sc->sc_eth_if != rcvif) { - printf("%s: wrong interface, not accepting host unique\n", - sc->sc_sppp.pp_if.if_xname); + pppoe_printf(sc, "wrong interface, not accepting host unique\n"); PPPOE_UNLOCK(sc); return NULL; } @@ -577,7 +612,6 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, uint16_t session, plen; struct pppoe_softc *sc; const char *err_msg; - char devname[IF_NAMESIZE]; char *error; size_t dlen; uint8_t *ac_cookie; @@ -669,7 +703,7 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, strnvisx(error, dlen, mtod(n, char*) + noff, len, VIS_SAFE | VIS_OCTAL); -printf("pppoe: connected to %s\n", error); +pppoe_printf(NULL, "connected to %s\n", error); free(error, M_TEMP); } break; /* ignored */ @@ -743,10 +777,10 @@ pppoe_dispatch_disc_pkt(struct mbuf *m, } } if (error) { -printf("pppoe: %s: %s\n", err_msg, error); +pppoe_printf(NULL, "%s: %s\n", err_msg, error); free(error, M_TEMP); } else -printf("pppoe: %s\n", err_msg); +pppoe_printf(NULL, "%s\n", err_msg); if (errortag || m == NULL) goto done; } @@ -827,7 +861,7 @@ breakbreak:; /* be quiet if there is not a single pppoe instance */ rw_enter(_softc_list_lock, RW_READER); if (!LIST_EMPTY(_softc_list)) { -printf("pppoe: received PADR" +pppoe_printf(NULL, "received PADR" " but could not find request for it\n"); } rw_exit(_softc_list_lock); @@ -835,8 +869,7 @@ breakbreak:; } if (sc->sc_state != PPPOE_STATE_PADO_SENT) { - printf("%s: received unexpected PADR\n", - sc->sc_sppp.pp_if.if_xname); + pppoe_printf(sc, "received unexpected PADR\n"); PPPOE_UNLOCK(sc); goto done; } @@ -880,7 +913,7 @@ breakbreak:; /* be quiet if there is not a single pppoe
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:38:10 UTC 2020 Modified Files: src/sys/net: if_pppoe.c Log Message: fix to remove trailing garbage To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 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.155 src/sys/net/if_pppoe.c:1.156 --- src/sys/net/if_pppoe.c:1.155 Wed Nov 25 10:37:04 2020 +++ src/sys/net/if_pppoe.c Wed Nov 25 10:38:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.155 2020/11/25 10:37:04 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.156 2020/11/25 10:38: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.155 2020/11/25 10:37:04 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.156 2020/11/25 10:38:10 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1144,6 +1144,8 @@ pppoe_data_input(struct mbuf *m) if (m->m_pkthdr.len < plen) goto drop; + /* ignore trailing garbage */ + m_adj(m, plen - m->m_pkthdr.len); /* * Fix incoming interface pointer (not the raw ethernet interface * anymore)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:37:04 UTC 2020 Modified Files: src/sys/net: if_pppoe.c Log Message: stop callout even when the state is in PPPOE_STATE_INITIAL To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 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.154 src/sys/net/if_pppoe.c:1.155 --- src/sys/net/if_pppoe.c:1.154 Wed Nov 25 10:18:49 2020 +++ src/sys/net/if_pppoe.c Wed Nov 25 10:37:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.154 2020/11/25 10:18:49 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.155 2020/11/25 10:37: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.154 2020/11/25 10:18:49 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.155 2020/11/25 10:37:04 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1317,7 +1317,6 @@ pppoe_ioctl(struct ifnet *ifp, unsigned PPPOE_LOCK(sc, RW_WRITER); if ((ifr->ifr_flags & IFF_UP) == 0 - && sc->sc_state >= PPPOE_STATE_PADI_SENT && sc->sc_state < PPPOE_STATE_SESSION) { callout_stop(>sc_timeout); sc->sc_state = PPPOE_STATE_INITIAL;
CVS commit: src/tests/net/if_pppoe
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:35:07 UTC 2020 Modified Files: src/tests/net/if_pppoe: t_pppoe.sh Log Message: Use a state of IPCP and IPv6CP to wait for connection established To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 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.23 src/tests/net/if_pppoe/t_pppoe.sh:1.24 --- src/tests/net/if_pppoe/t_pppoe.sh:1.23 Fri Sep 25 06:15:30 2020 +++ src/tests/net/if_pppoe/t_pppoe.sh Wed Nov 25 10:35:07 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_pppoe.sh,v 1.23 2020/09/25 06:15:30 yamaguchi Exp $ +# $NetBSD: t_pppoe.sh,v 1.24 2020/11/25 10:35:07 yamaguchi Exp $ # # Copyright (c) 2016 Internet Initiative Japan Inc. # All rights reserved. @@ -113,14 +113,18 @@ setup() unset RUMP_SERVER } -wait_for_session_established() +wait_for_opened() { - local dontfail=$1 + local cp=$1 + local dontfail=$2 local n=$WAITTIME for i in $(seq $n); do - $HIJACKING pppoectl -d pppoe0 |grep -q "state = session" - [ $? = 0 ] && return + $HIJACKING pppoectl -dd pppoe0 | grep -q "$cp state: opened" + if [ $? = 0 ]; then + rump.ifconfig -w 10 + return + fi sleep 1 done @@ -135,12 +139,10 @@ wait_for_disconnected() local n=$WAITTIME for i in $(seq $n); do - $HIJACKING pppoectl -d pppoe0 | grep -q "state = initial" - [ $? = 0 ] && return - # If PPPoE client is disconnected by PPPoE server and then - # the client kicks callout of pppoe_timeout(), the client - # state is changed to PPPOE_STATE_PADI_SENT while padi retrying. - $HIJACKING pppoectl -d pppoe0 | grep -q "state = PADI sent" + # If PPPoE client is disconnected by PPPoE server, then + # the LCP state will of the client is in a starting to send PADI. + $HIJACKING pppoectl -dd pppoe0 | grep -q \ + -e "LCP state: initial" -e "LCP state: starting" [ $? = 0 ] && return sleep 1 @@ -154,6 +156,7 @@ wait_for_disconnected() run_test() { local auth=$1 + local cp="IPCP" setup # As pppoe client doesn't support rechallenge yet. @@ -180,7 +183,7 @@ run_test() atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" atf_check -s exit:0 rump.ifconfig pppoe0 up $DEBUG && rump.ifconfig - wait_for_session_established + wait_for_opened $cp atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP unset RUMP_SERVER @@ -198,7 +201,7 @@ run_test() # test for reconnecting atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 up" export RUMP_SERVER=$CLIENT - wait_for_session_established + wait_for_opened $cp atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $SERVER_IP unset RUMP_SERVER @@ -217,7 +220,7 @@ run_test() # test for reconnecting export RUMP_SERVER=$CLIENT atf_check -s exit:0 -x rump.ifconfig pppoe0 up - wait_for_session_established + wait_for_opened $cp $DEBUG && rump.ifconfig pppoe0 $DEBUG && $HIJACKING pppoectl -d pppoe0 unset RUMP_SERVER @@ -240,7 +243,7 @@ run_test() 'max-auth-failure=1'" atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" atf_check -s exit:0 rump.ifconfig pppoe0 up - wait_for_session_established dontfail + wait_for_opened $cp dontfail 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:'DETACHED' rump.ifconfig pppoe0 @@ -290,6 +293,7 @@ pppoe_chap_cleanup() run_test6() { local auth=$1 + local cp="IPv6CP" setup "inet=false" # As pppoe client doesn't support rechallenge yet. @@ -318,7 +322,7 @@ run_test6() atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $CLIENT_IP6/64 down atf_check -s exit:0 rump.ifconfig pppoe0 up $DEBUG && rump.ifconfig - wait_for_session_established + wait_for_opened $cp atf_check -s exit:0 -o ignore rump.ifconfig -w 10 export RUMP_SERVER=$SERVER atf_check -s exit:0 -o ignore rump.ifconfig -w 10 @@ -341,7 +345,7 @@ run_test6() # test for reconnecting export RUMP_SERVER=$SERVER atf_check -s exit:0 rump.ifconfig pppoe0 up - wait_for_session_established + wait_for_opened $cp atf_check -s exit:0 rump.ifconfig -w 10 $DEBUG && $HIJACKING pppoectl -d pppoe0 $DEBUG && rump.ifconfig pppoe0 @@ -366,7 +370,7 @@ run_test6() # test for reconnecting export RUMP_SERVER=$CLIENT atf_check -s exit:0 rump.ifconfig pppoe0 up - wait_for_session_established + wait_for_opened $cp atf_check -s exit:0 rump.ifconfig -w 10 $DEBUG && rump.ifconfig pppoe0 @@ -391,7 +395,7 @@ run_test6() 'max-auth-failure=1'" atf_check -s exit:0 -x "$HIJACKING $setup_clientparam" atf_check -s exit:0 rump.ifconfig pppoe0 up - wait_for_session_established dontfail + wait_for_opened $cp dontfail atf_check -s not-exit:0 -o ignore -e ignore \ rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6 atf_check -s exit:0 -o match:'DETACHED'
CVS commit: src/sbin/pppoectl
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:32:54 UTC 2020 Modified Files: src/sbin/pppoectl: pppoectl.c Log Message: add -dd option for reference of the parameter about control protocols reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 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.25 src/sbin/pppoectl/pppoectl.c:1.26 --- src/sbin/pppoectl/pppoectl.c:1.25 Sat Jan 23 15:41:47 2016 +++ src/sbin/pppoectl/pppoectl.c Wed Nov 25 10:32:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pppoectl.c,v 1.25 2016/01/23 15:41:47 christos Exp $ */ +/* $NetBSD: pppoectl.c,v 1.26 2020/11/25 10:32:54 yamaguchi Exp $ */ /* * Copyright (c) 1997 Joerg Wunsch @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: pppoectl.c,v 1.25 2016/01/23 15:41:47 christos Exp $"); +__RCSID("$NetBSD: pppoectl.c,v 1.26 2020/11/25 10:32:54 yamaguchi Exp $"); #endif @@ -44,6 +44,7 @@ __RCSID("$NetBSD: pppoectl.c,v 1.25 2016 #include #include #include +#include #include #include #include @@ -56,11 +57,26 @@ __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); +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); static const char *proto_name(int proto); static const char *authflags(int flags); +static const char *pppoe_state_name(int state); +static const char *ppp_state_name(int state); static void pppoectl_argument(char *arg); +#define ISSET(x, a) ((x) & (a)) +#define PPPOECTL_IOCTL(_ifname, _s, _cmd, _st) do { \ + int __e; \ + memset((_st), 0, sizeof(*(_st))); \ + strncpy((_st)->ifname, (_ifname), \ + sizeof((_st)->ifname)); \ + __e = ioctl((_s), (_cmd), (_st)); \ + if (__e != 0) \ + print_error((_ifname), __e, #_cmd); \ +} while (0) + static int hz = 0; static int set_auth, set_lcp, set_idle_to, set_auth_failure, set_dns, @@ -174,60 +190,14 @@ main(int argc, char **argv) } if (dns1 || dns2) { - /* print DNS addresses */ - int e; - struct spppdnsaddrs addrs; - memset(, 0, sizeof addrs); - strncpy(addrs.ifname, ifname, sizeof addrs.ifname); - e = ioctl(s, SPPPGETDNSADDRS, ); - if (e) - print_error(ifname, e, "SPPPGETDNSADDRS"); - if (dns1) - printf("%d.%d.%d.%d\n", -(addrs.dns[0] >> 24) & 0xff, -(addrs.dns[0] >> 16) & 0xff, -(addrs.dns[0] >> 8) & 0xff, -addrs.dns[0] & 0xff); - if (dns2) - printf("%d.%d.%d.%d\n", -(addrs.dns[1] >> 24) & 0xff, -(addrs.dns[1] >> 16) & 0xff, -(addrs.dns[1] >> 8) & 0xff, -addrs.dns[1] & 0xff); + print_dns(ifname, dns1, dns2, s, 0); } if (dump) { - /* dump PPPoE session state */ - struct pppoeconnectionstate state; - int e; - - memset(, 0, sizeof state); - strncpy(state.ifname, ifname, sizeof state.ifname); - e = ioctl(s, PPPOEGETSESSION, ); - if (e) - print_error(ifname, e, "PPPOEGETSESSION"); - - printf("%s:\tstate = ", ifname); - switch(state.state) { - case PPPOE_STATE_INITIAL: - printf("initial\n"); break; - case PPPOE_STATE_PADI_SENT: - printf("PADI sent\n"); break; - case PPPOE_STATE_PADR_SENT: - printf("PADR sent\n"); break; - case PPPOE_STATE_SESSION: - printf("session\n"); break; - case PPPOE_STATE_CLOSING: - printf("closing\n"); break; - } - printf("\tSession ID: 0x%x\n", state.session_id); - printf("\tPADI retries: %d\n", state.padi_retry_no); - printf("\tPADR retries: %d\n", state.padr_retry_no); - + print_stats(ifname, s, dump); return 0; } - memset(, 0, sizeof spr); strncpy(spr.ifname, ifname, sizeof spr.ifname); memset(, 0, sizeof lcp); @@ -570,6 +540,110 @@ print_vals(const char *ifname, int phase #endif } +static void +print_dns(const char *ifname, int dns1, int dns2, int s, int tabs) +{ + int i; + struct spppdnsaddrs addrs; + + if (!dns1 && !dns2) + return; + + PPPOECTL_IOCTL(ifname, s, SPPPGETDNSADDRS, ); + if (dns1) { + for (i = 0; i < tabs; i++) + printf("\t"); + if (tabs > 0) + printf("primary dns address "); + printf("%d.%d.%d.%d\n", + (addrs.dns[0] >> 24) & 0xff, + (addrs.dns[0] >> 16) & 0xff, + (addrs.dns[0] >> 8) & 0xff, + addrs.dns[0] & 0xff); + } + if (dns2) { + for (i = 0; i < tabs; i++) + printf("\t"); + if (tabs > 0) + printf("secondary dns address "); + printf("%d.%d.%d.%d\n", + (addrs.dns[1] >> 24) & 0xff, + (addrs.dns[1] >> 16) & 0xff, + (addrs.dns[1] >> 8) & 0xff, + addrs.dns[1] & 0xff); + } +} + +static void +print_stats(const char *ifname, int s, int dump) +{
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:30:51 UTC 2020 Modified Files: src/sys/net: if_sppp.h if_spppsubr.c if_spppvar.h Log Message: Add commands to refer params of control protocols in if_spppsubr.c reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/net/if_sppp.h cvs rdiff -u -r1.212 -r1.213 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.31 -r1.32 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.28 src/sys/net/if_sppp.h:1.29 --- src/sys/net/if_sppp.h:1.28 Sun Sep 6 06:01:01 2015 +++ src/sys/net/if_sppp.h Wed Nov 25 10:30:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sppp.h,v 1.28 2015/09/06 06:01:01 dholland Exp $ */ +/* $NetBSD: if_sppp.h,v 1.29 2020/11/25 10:30:51 yamaguchi Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -165,5 +165,72 @@ struct spppkeepalivesettings50 { /* 134 already used! */ +/* states are named and numbered according to RFC 1661 */ +#define SPPP_STATE_INITIAL 0 +#define SPPP_STATE_STARTING 1 +#define SPPP_STATE_CLOSED 2 +#define SPPP_STATE_STOPPED 3 +#define SPPP_STATE_CLOSING 4 +#define SPPP_STATE_STOPPING 5 +#define SPPP_STATE_REQ_SENT 6 +#define SPPP_STATE_ACK_RCVD 7 +#define SPPP_STATE_ACK_SENT 8 +#define SPPP_STATE_OPENED 9 + +#define SPPP_LCP_OPT_MRU __BIT(1) +#define SPPP_LCP_OPT_ASYNC_MAP __BIT(2) +#define SPPP_LCP_OPT_AUTH_PROTO __BIT(3) +#define SPPP_LCP_OPT_QUAL_PROTO __BIT(4) +#define SPPP_LCP_OPT_MAGIC __BIT(5) +#define SPPP_LCP_OPT_RESERVED __BIT(6) +#define SPPP_LCP_OPT_PROTO_COMP __BIT(7) +#define SPPP_LCP_OPT_ADDR_COMP __BIT(8) +#define SPPP_LCP_OPT_FCS_ALTS __BIT(9) +#define SPPP_LCP_OPT_SELF_DESC_PAD __BIT(10) +#define SPPP_LCP_OPT_CALL_BACK __BIT(13) +#define SPPP_LCP_OPT_COMPOUND_FRMS __BIT(15) +#define SPPP_LCP_OPT_MP_MRRU __BIT(17) +#define SPPP_LCP_OPT_MP_SSNHF __BIT(18) +#define SPPP_LCP_OPT_MP_EID __BIT(19) + +/* #define SPPP_OPT_ADDRESSES __BIT(0) */ +#define SPPP_IPCP_OPT_COMPRESSION __BIT(1) +#define SPPP_IPCP_OPT_ADDRESS __BIT(2) +#define SPPP_IPCP_OPT_PRIMDNS __BIT(3) +#define SPPP_IPCP_OPT_SECDNS __BIT(4) + +#define SPPP_IPV6CP_OPT_IFID __BIT(1) +#define SPPP_IPV6CP_OPT_COMPRESSION __BIT(2) + +struct sppplcpstatus { + char ifname[IFNAMSIZ]; + int state; + int timeout; + u_long opts; + u_long magic; + u_long mru; +}; + +#define SPPPGETLCPSTATUS _IOWR('i', 135, struct sppplcpstatus) + +struct spppipcpstatus { + char ifname[IFNAMSIZ]; + int state; + u_long opts; + u_int32_t myaddr; +}; + +#define SPPPGETIPCPSTATUS _IOWR('i', 136, struct spppipcpstatus) + +struct spppipv6cpstatus { + char ifname[IFNAMSIZ]; + int state; + u_long opts; + u_int8_t my_ifid[8]; + u_int8_t his_ifid[8]; +}; + +#define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus) + #endif /* !_NET_IF_SPPP_H_ */ Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.212 src/sys/net/if_spppsubr.c:1.213 --- src/sys/net/if_spppsubr.c:1.212 Wed Nov 25 10:27:18 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:30:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.212 2020/11/25 10:27:18 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.213 2020/11/25 10:30:51 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.212 2020/11/25 10:27:18 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.213 2020/11/25 10:30:51 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -185,17 +185,18 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define CISCO_ADDR_REPLY 1 /* Cisco address reply */ #define CISCO_KEEPALIVE_REQ 2 /* Cisco keepalive request */ -/* states are named and numbered according to RFC 1661 */ -#define STATE_INITIAL 0 -#define STATE_STARTING 1 -#define STATE_CLOSED 2 -#define STATE_STOPPED 3 -#define STATE_CLOSING 4 -#define STATE_STOPPING 5 -#define STATE_REQ_SENT 6 -#define STATE_ACK_RCVD 7 -#define STATE_ACK_SENT 8 -#define STATE_OPENED 9 +enum { + STATE_INITIAL = SPPP_STATE_INITIAL, + STATE_STARTING = SPPP_STATE_STARTING, + STATE_CLOSED = SPPP_STATE_CLOSED, + STATE_STOPPED = SPPP_STATE_STOPPED, + STATE_CLOSING = SPPP_STATE_CLOSING, + STATE_STOPPING = SPPP_STATE_STOPPING, + STATE_REQ_SENT = SPPP_STATE_REQ_SENT, + STATE_ACK_RCVD = SPPP_STATE_ACK_RCVD, + STATE_ACK_SENT = SPPP_STATE_ACK_SENT, + STATE_OPENED = SPPP_STATE_OPENED, +}; enum cp_rcr_type { CP_RCR_NONE = 0, /* initial value */ @@ -1268,6 +1269,9 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd case __SPPPGETIDLETO50: case __SPPPGETKEEPALIVE50: #endif /* COMPAT_50 || MODULAR */ + case SPPPGETLCPSTATUS: + case SPPPGETIPCPSTATUS: + case SPPPGETIPV6CPSTATUS: error = sppp_params(sp, cmd, data); break; @@ -2420,7 +2424,7 @@ sppp_lcp_init(struct sppp *sp)
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:27:18 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Reconnect when a down event caused by tlf caught To generate a diff of this commit: cvs rdiff -u -r1.211 -r1.212 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.30 -r1.31 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.211 src/sys/net/if_spppsubr.c:1.212 --- src/sys/net/if_spppsubr.c:1.211 Wed Nov 25 10:25:22 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:27:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.211 2020/11/25 10:25:22 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.212 2020/11/25 10:27:18 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.211 2020/11/25 10:25:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.212 2020/11/25 10:27:18 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2426,6 +2426,7 @@ sppp_lcp_init(struct sppp *sp) sp->lcp.max_terminate = 2; sp->lcp.max_configure = 10; sp->lcp.max_failure = 10; + sp->lcp.tlf_sent = false; /* * Initialize counters and timeout values. Note that we don't @@ -2485,6 +2486,16 @@ sppp_lcp_down(struct sppp *sp, void *xcp sppp_down_event(sp, xcp); /* + * We need to do tls to restart when a down event is caused + * by the last tlf. + */ + if (sp->scp[pidx].state == STATE_STARTING && + sp->lcp.tlf_sent) { + cp->tls(cp, sp); + 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 @@ -3149,6 +3160,7 @@ sppp_lcp_tls(const struct cp *cp __unuse /* Notify lower layer if desired. */ sppp_notify_tls_wlocked(sp); + sp->lcp.tlf_sent = false; } static void @@ -3161,6 +3173,17 @@ sppp_lcp_tlf(const struct cp *cp __unuse /* Notify lower layer if desired. */ sppp_notify_tlf_wlocked(sp); + + switch (sp->scp[IDX_LCP].state) { + case STATE_CLOSED: + case STATE_STOPPED: + sp->lcp.tlf_sent = true; + break; + case STATE_INITIAL: + default: + /* just in case */ + sp->lcp.tlf_sent = false; + } } static void Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.30 src/sys/net/if_spppvar.h:1.31 --- src/sys/net/if_spppvar.h:1.30 Wed Nov 25 10:12:03 2020 +++ src/sys/net/if_spppvar.h Wed Nov 25 10:27:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.30 2020/11/25 10:12:03 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.31 2020/11/25 10:27:18 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -58,6 +58,7 @@ struct slcp { u_long mrru; /* our max received reconstructed unit */ u_long their_mrru; /* their max receive dreconstructed unit */ bool reestablish; /* reestablish after the next down event */ + bool tlf_sent; /* call lower layer's tlf before a down event */ }; #define IDX_IPCP 1 /* idx into state table */
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:25:22 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Move code related to module to bottom To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 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.210 src/sys/net/if_spppsubr.c:1.211 --- src/sys/net/if_spppsubr.c:1.210 Wed Nov 25 10:23:33 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:25:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.210 2020/11/25 10:23:33 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.211 2020/11/25 10:25:22 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.210 2020/11/25 10:23:33 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.211 2020/11/25 10:25:22 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -6271,33 +6271,6 @@ sppp_ifdown(struct sppp *sp, void *xcp _ SPPP_LOCK(sp, RW_WRITER); } -/* - * This file is large. Tell emacs to highlight it nevertheless. - * - * Local Variables: - * hilit-auto-highlight-maxout: 12 - * End: - */ - -/* - * Module glue - */ -MODULE(MODULE_CLASS_MISC, sppp_subr, NULL); - -static int -sppp_subr_modcmd(modcmd_t cmd, void *arg) -{ -switch (cmd) { -case MODULE_CMD_INIT: -case MODULE_CMD_FINI: -return 0; -case MODULE_CMD_STAT: -case MODULE_CMD_AUTOUNLOAD: -default: -return ENOTTY; -} -} - static void sppp_notify_up(struct sppp *sp) { @@ -6445,3 +6418,31 @@ sppp_wq_wait(struct workqueue *wq, struc atomic_swap_uint(>state, SPPP_WK_UNAVAIL); workqueue_wait(wq, >work); } + +/* + * This file is large. Tell emacs to highlight it nevertheless. + * + * Local Variables: + * hilit-auto-highlight-maxout: 12 + * End: + */ + +/* + * Module glue + */ +MODULE(MODULE_CLASS_MISC, sppp_subr, NULL); + +static int +sppp_subr_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + case MODULE_CMD_FINI: + return 0; + case MODULE_CMD_STAT: + case MODULE_CMD_AUTOUNLOAD: + default: + return ENOTTY; + } +}
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:23:33 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Reconnect lcp after authentication or network phase finish To generate a diff of this commit: cvs rdiff -u -r1.209 -r1.210 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.209 src/sys/net/if_spppsubr.c:1.210 --- src/sys/net/if_spppsubr.c:1.209 Wed Nov 25 10:18:49 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:23:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.209 2020/11/25 10:18:49 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.210 2020/11/25 10:23:33 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.209 2020/11/25 10:18:49 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.210 2020/11/25 10:23:33 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3243,6 +3243,7 @@ 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); } /*
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:18:50 UTC 2020 Modified Files: src/sys/net: if_pppoe.c if_spppsubr.c Log Message: Close lcp when the lower layer down if the interface is passive or on-demand reivewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.153 -r1.154 src/sys/net/if_pppoe.c cvs rdiff -u -r1.208 -r1.209 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.153 src/sys/net/if_pppoe.c:1.154 --- src/sys/net/if_pppoe.c:1.153 Fri Sep 25 06:22:33 2020 +++ src/sys/net/if_pppoe.c Wed Nov 25 10:18:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.153 2020/09/25 06:22:33 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.154 2020/11/25 10:18:49 yamaguchi Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.153 2020/09/25 06:22:33 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.154 2020/11/25 10:18:49 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -1886,9 +1886,16 @@ pppoe_tlf(struct sppp *sp) PPPOE_LOCK(sc, RW_WRITER); if (sc->sc_state < PPPOE_STATE_SESSION) { + callout_stop(>sc_timeout); + sc->sc_state = PPPOE_STATE_INITIAL; + sc->sc_padi_retried = 0; + sc->sc_padr_retried = 0; + memcpy(>sc_dest, etherbroadcastaddr, + sizeof(sc->sc_dest)); PPPOE_UNLOCK(sc); return; } + /* * Do not call pppoe_disconnect here, the upper layer state * machine gets confused by this. We must return from this Index: src/sys/net/if_spppsubr.c diff -u src/sys/net/if_spppsubr.c:1.208 src/sys/net/if_spppsubr.c:1.209 --- src/sys/net/if_spppsubr.c:1.208 Wed Nov 25 10:12:03 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:18:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.208 2020/11/25 10:12:03 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.209 2020/11/25 10:18:49 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.208 2020/11/25 10:12:03 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.209 2020/11/25 10:18:49 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #include #include #include +#include #include #include @@ -2466,10 +2467,6 @@ sppp_lcp_up(struct sppp *sp, void *xcp) sppp_wq_add(sp->wq_cp, >scp[pidx].work_open); } else if (debug) addlog("\n"); - } else if ((ifp->if_flags & (IFF_AUTO | IFF_PASSIVE)) == 0 && - (sp->scp[IDX_LCP].state == STATE_INITIAL)) { - ifp->if_flags |= IFF_RUNNING; - sppp_wq_add(sp->wq_cp, >scp[pidx].work_open); } sppp_up_event(sp, xcp); @@ -2510,12 +2507,13 @@ sppp_lcp_down(struct sppp *sp, void *xcp log(LOG_DEBUG, "%s: Down event (carrier loss)\n", ifp->if_xname); + + sp->pp_flags &= ~PP_CALLIN; + if (sp->scp[pidx].state != STATE_INITIAL) + sppp_wq_add(sp->wq_cp, >scp[pidx].work_close); + ifp->if_flags &= ~IFF_RUNNING; } sp->scp[pidx].fail_counter = 0; - sp->pp_flags &= ~PP_CALLIN; - if (sp->scp[pidx].state != STATE_INITIAL) - sppp_wq_add(sp->wq_cp, >scp[IDX_LCP].work_close); - ifp->if_flags &= ~IFF_RUNNING; } static void
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:12:04 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Update ip addresses in the workqueue for control protocols reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.207 -r1.208 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.29 -r1.30 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.207 src/sys/net/if_spppsubr.c:1.208 --- src/sys/net/if_spppsubr.c:1.207 Wed Nov 25 10:08:22 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:12:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.207 2020/11/25 10:08:22 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.208 2020/11/25 10:12:03 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.207 2020/11/25 10:08:22 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.208 2020/11/25 10:12:03 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -430,11 +430,8 @@ static const char *sppp_state_name(int); static int sppp_params(struct sppp *, u_long, void *); #ifdef INET static void sppp_get_ip_addrs(struct sppp *, uint32_t *, uint32_t *, uint32_t *); -static void sppp_set_ip_addrs_work(struct work *, struct sppp *); static void sppp_set_ip_addrs(struct sppp *); -static void sppp_clear_ip_addrs_work(struct work *, struct sppp *); static void sppp_clear_ip_addrs(struct sppp *); -static void sppp_update_ip_addrs_work(struct work *, void *); #endif static void sppp_keepalive(void *); static void sppp_phase_network(struct sppp *); @@ -1077,12 +1074,6 @@ sppp_detach(struct ifnet *ifp) SPPP_LOCK(sp, RW_WRITER); - /* to avoid workqueue enqueued */ - atomic_swap_uint(>ipcp.update_addrs_enqueued, 1); - workqueue_wait(sp->ipcp.update_addrs_wq, >ipcp.update_addrs_wk); - workqueue_destroy(sp->ipcp.update_addrs_wq); - pcq_destroy(sp->ipcp.update_addrs_q); - sppp_cp_fini(, sp); sppp_cp_fini(, sp); sppp_cp_fini(, sp); @@ -3267,7 +3258,6 @@ sppp_lcp_check_and_close(struct sppp *sp static void sppp_ipcp_init(struct sppp *sp) { - int error; KASSERT(SPPP_WLOCKED(sp)); @@ -3275,15 +3265,6 @@ sppp_ipcp_init(struct sppp *sp) sp->ipcp.opts = 0; sp->ipcp.flags = 0; - - error = workqueue_create(>ipcp.update_addrs_wq, "ipcp_addr", - sppp_update_ip_addrs_work, sp, PRI_SOFTNET, IPL_NET, 0); - if (error) - panic("%s: update_addrs workqueue_create failed (%d)\n", - __func__, error); - sp->ipcp.update_addrs_q = pcq_create(IPCP_UPDATE_LIMIT, KM_SLEEP); - - sp->ipcp.update_addrs_enqueued = 0; } static void @@ -5382,7 +5363,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3 * If an address is 0, leave it the way it is. */ static void -sppp_set_ip_addrs_work(struct work *wk, struct sppp *sp) +sppp_set_ip_addrs(struct sppp *sp) { STDDCL; struct ifaddr *ifa; @@ -5460,28 +5441,11 @@ sppp_set_ip_addrs_work(struct work *wk, sppp_notify_con(sp); } -static void -sppp_set_ip_addrs(struct sppp *sp) -{ - struct ifnet *ifp = >pp_if; - - if (!pcq_put(sp->ipcp.update_addrs_q, (void *)IPCP_SET_ADDRS)) { - log(LOG_WARNING, "%s: cannot enqueued, ignore sppp_clear_ip_addrs\n", - ifp->if_xname); - return; - } - - if (atomic_swap_uint(>ipcp.update_addrs_enqueued, 1) == 1) - return; - - workqueue_enqueue(sp->ipcp.update_addrs_wq, >ipcp.update_addrs_wk, NULL); -} - /* * Clear IP addresses. Must be called at splnet. */ static void -sppp_clear_ip_addrs_work(struct work *wk, struct sppp *sp) +sppp_clear_ip_addrs(struct sppp *sp) { STDDCL; struct ifaddr *ifa; @@ -5542,41 +5506,6 @@ sppp_clear_ip_addrs_work(struct work *wk IFNET_UNLOCK(ifp); } - -static void -sppp_clear_ip_addrs(struct sppp *sp) -{ - struct ifnet *ifp = >pp_if; - - if (!pcq_put(sp->ipcp.update_addrs_q, (void *)IPCP_CLEAR_ADDRS)) { - log(LOG_WARNING, "%s: cannot enqueued, ignore sppp_clear_ip_addrs\n", - ifp->if_xname); - return; - } - - if (atomic_swap_uint(>ipcp.update_addrs_enqueued, 1) == 1) - return; - - workqueue_enqueue(sp->ipcp.update_addrs_wq, >ipcp.update_addrs_wk, NULL); -} - -static void -sppp_update_ip_addrs_work(struct work *wk, void *arg) -{ - struct sppp *sp = arg; - void *work; - - atomic_swap_uint(>ipcp.update_addrs_enqueued, 0); - - while ((work = pcq_get(sp->ipcp.update_addrs_q)) != NULL) { - int update = (intptr_t)work; - - if (update == IPCP_SET_ADDRS) - sppp_set_ip_addrs_work(wk, sp); - else if (update == IPCP_CLEAR_ADDRS) - sppp_clear_ip_addrs_work(wk, sp); - } -} #endif #ifdef INET6 Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.29 src/sys/net/if_spppvar.h:1.30 --- src/sys/net/if_spppvar.h:1.29 Wed Nov 25 09:46:05 2020 +++ src/sys/net/if_spppvar.h Wed Nov 25 10:12:03 2020 @@
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:08:22 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Add the id check for TERM_ACK To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 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.206 src/sys/net/if_spppsubr.c:1.207 --- src/sys/net/if_spppsubr.c:1.206 Wed Nov 25 10:05:40 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:08:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.206 2020/11/25 10:05:40 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.207 2020/11/25 10:08:22 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.206 2020/11/25 10:05:40 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.207 2020/11/25 10:08:22 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1717,6 +1717,18 @@ sppp_cp_input(const struct cp *cp, struc sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rtr); break; case TERM_ACK: + if (h->ident != sp->scp[cp->protoidx].confid && + h->ident != sp->scp[cp->protoidx].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); + if_statinc(ifp, if_ierrors); + break; + } + sppp_wq_add(sp->wq_cp, >scp[cp->protoidx].work_rta); break; case CODE_REJ:
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:05:40 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: remove double newlines To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 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.205 src/sys/net/if_spppsubr.c:1.206 --- src/sys/net/if_spppsubr.c:1.205 Wed Nov 25 10:03:38 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:05:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.205 2020/11/25 10:03:38 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.206 2020/11/25 10:05:40 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.205 2020/11/25 10:03:38 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.206 2020/11/25 10:05:40 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -50,7 +50,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #include "opt_net_mpsafe.h" #endif - #include #include #include @@ -462,7 +461,6 @@ static void sppp_notify_con(struct sppp static void sppp_notify_chg_wlocked(struct sppp *); - /* our control protocol descriptors */ static const struct cp lcp = { PPP_LCP, IDX_LCP, CP_LCP, "lcp", @@ -1289,7 +1287,6 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd return (error); } - /* * Cisco framing implementation. */ @@ -1502,7 +1499,6 @@ sppp_cp_send(struct sppp *sp, u_short pr if_statadd(ifp, if_obytes, m->m_pkthdr.len + sp->pp_framebytes); IF_ENQUEUE(>pp_cpq, m); - if (! (ifp->if_flags & IFF_OACTIVE)) { SPPP_UNLOCK(sp); if_start_lock(ifp); @@ -1550,7 +1546,6 @@ sppp_cp_to_chap(void *xsp) sppp_wq_add(sp->wq_cp, >scp[IDX_CHAP].work_to); } - static void sppp_cp_init(const struct cp *cp, struct sppp *sp) { @@ -1855,7 +1850,6 @@ sppp_cp_input(const struct cp *cp, struc SPPP_UNLOCK(sp); } - /* * The generic part of all Up/Down/Open/Close/TO event handlers. * Basically, the state transition handling in the automaton. @@ -1935,7 +1929,6 @@ sppp_down_event(struct sppp *sp, void *x } } - static void sppp_open_event(struct sppp *sp, void *xcp) { @@ -1978,7 +1971,6 @@ sppp_open_event(struct sppp *sp, void *x } } - static void sppp_close_event(struct sppp *sp, void *xcp) { @@ -3790,7 +3782,6 @@ sppp_ipcp_scr(struct sppp *sp) sppp_cp_send(sp, PPP_IPCP, CONF_REQ, sp->scp[IDX_IPCP].confid, i, ); } - /* *--* * * @@ -4325,7 +4316,6 @@ sppp_ipv6cp_scr(struct sppp *sp) } #endif /*INET6*/ - /* *--* * * @@ -5272,7 +5262,6 @@ sppp_keepalive(void *dummy) continue; } - /* No keepalive in PPP mode if LCP not opened yet. */ if (! (sp->pp_flags & PP_CISCO) && sp->pp_phase < SPPP_PHASE_AUTHENTICATE) { @@ -5760,7 +5749,6 @@ sppp_params(struct sppp *sp, u_long cmd, } else { len = sp->myauth.name_len + 1; - if (cfg->myname_length < len) { SPPP_UNLOCK(sp); return (ENAMETOOLONG);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 10:03:39 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: change function name(RCR => parse_confreq) reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.204 -r1.205 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.204 src/sys/net/if_spppsubr.c:1.205 --- src/sys/net/if_spppsubr.c:1.204 Wed Nov 25 09:59:52 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 10:03:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.204 2020/11/25 09:59:52 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.205 2020/11/25 10:03:38 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.204 2020/11/25 09:59:52 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.205 2020/11/25 10:03:38 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -197,6 +197,15 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define STATE_ACK_SENT 8 #define STATE_OPENED 9 +enum cp_rcr_type { + CP_RCR_NONE = 0, /* initial value */ + CP_RCR_ACK, /* RCR+ */ + CP_RCR_NAK, /* RCR- */ + CP_RCR_REJ, /* RCR- */ + CP_RCR_DROP, /* DROP message */ + CP_RCR_ERR, /* internal error */ +}; + struct ppp_header { uint8_t address; uint8_t control; @@ -242,9 +251,6 @@ struct cp { void (*Open)(struct sppp *, void *); void (*Close)(struct sppp *, void *); void (*TO)(struct sppp *, void *); - int (*RCR)(struct sppp *, struct lcp_header *, int); - void (*RCN_rej)(struct sppp *, struct lcp_header *, int); - void (*RCN_nak)(struct sppp *, struct lcp_header *, int); /* actions */ void (*tlu)(struct sppp *); void (*tld)(struct sppp *); @@ -252,6 +258,13 @@ struct cp { void (*tlf)(const struct cp *, struct sppp *); void (*scr)(struct sppp *); void (*scan)(const struct cp *, struct sppp *); + + /* message parser */ + enum cp_rcr_type + (*parse_confreq)(struct sppp *, struct lcp_header *, int, + uint8_t **, size_t *, size_t *); + void (*parse_confrej)(struct sppp *, struct lcp_header *, int); + void (*parse_confnak)(struct sppp *, struct lcp_header *, int); }; enum auth_role { @@ -357,9 +370,11 @@ static void sppp_lcp_init(struct sppp *) static void sppp_lcp_up(struct sppp *, void *); static void sppp_lcp_down(struct sppp *, void *); static void sppp_lcp_open(struct sppp *, void *); -static int sppp_lcp_RCR(struct sppp *, struct lcp_header *, int); -static void sppp_lcp_RCN_rej(struct sppp *, struct lcp_header *, int); -static void sppp_lcp_RCN_nak(struct sppp *, struct lcp_header *, int); +static enum cp_rcr_type + sppp_lcp_confreq(struct sppp *, struct lcp_header *, int, + uint8_t **, size_t *, size_t *); +static void sppp_lcp_confrej(struct sppp *, struct lcp_header *, int); +static void sppp_lcp_confnak(struct sppp *, struct lcp_header *, int); static void sppp_lcp_tlu(struct sppp *); static void sppp_lcp_tld(struct sppp *); static void sppp_lcp_tls(const struct cp *, struct sppp *); @@ -371,17 +386,21 @@ static int sppp_cp_check(struct sppp *, static void sppp_ipcp_init(struct sppp *); static void sppp_ipcp_open(struct sppp *, void *); static void sppp_ipcp_close(struct sppp *, void *); -static int sppp_ipcp_RCR(struct sppp *, struct lcp_header *, int); -static void sppp_ipcp_RCN_rej(struct sppp *, struct lcp_header *, int); -static void sppp_ipcp_RCN_nak(struct sppp *, struct lcp_header *, int); +static enum cp_rcr_type + sppp_ipcp_confreq(struct sppp *, struct lcp_header *, int, + uint8_t **, size_t *, size_t *); +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_scr(struct sppp *); static void sppp_ipv6cp_init(struct sppp *); static void sppp_ipv6cp_open(struct sppp *, void *); -static int sppp_ipv6cp_RCR(struct sppp *, struct lcp_header *, int); -static void sppp_ipv6cp_RCN_rej(struct sppp *, struct lcp_header *, int); -static void sppp_ipv6cp_RCN_nak(struct sppp *, struct lcp_header *, int); +static enum cp_rcr_type + sppp_ipv6cp_confreq(struct sppp *, struct lcp_header *, int, + uint8_t **, size_t *, size_t *); +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_scr(struct sppp *); @@ -447,10 +466,11 @@ static void sppp_notify_chg_wlocked(stru /* our control protocol descriptors */ static const struct cp lcp = { PPP_LCP, IDX_LCP, CP_LCP, "lcp", - sppp_lcp_up, sppp_lcp_down, sppp_lcp_open, sppp_close_event, - sppp_to_event, sppp_lcp_RCR,
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:59:52 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Add a function to initialize parameters To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 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.203 src/sys/net/if_spppsubr.c:1.204 --- src/sys/net/if_spppsubr.c:1.203 Wed Nov 25 09:57:26 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:59:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.203 2020/11/25 09:57:26 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.204 2020/11/25 09:59:52 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.203 2020/11/25 09:57:26 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.204 2020/11/25 09:59:52 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1541,6 +1541,10 @@ sppp_cp_init(const struct cp *cp, struct }; scp = >scp[cp->protoidx]; + scp->state = STATE_INITIAL; + scp->fail_counter = 0; + scp->seq = 0; + scp->rseq = 0; SPPP_WQ_SET(>work_up, cp->Up, cp); SPPP_WQ_SET(>work_down, cp->Down, cp); @@ -2375,13 +2379,14 @@ sppp_lcp_init(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + sppp_cp_init(, sp); + sp->lcp.opts = (1 << LCP_OPT_MAGIC); sp->lcp.magic = 0; - sp->scp[IDX_LCP].state = STATE_INITIAL; - sp->scp[IDX_LCP].fail_counter = 0; - sp->scp[IDX_LCP].seq = 0; - sp->scp[IDX_LCP].rseq = 0; sp->lcp.protos = 0; + sp->lcp.max_terminate = 2; + sp->lcp.max_configure = 10; + sp->lcp.max_failure = 10; /* * Initialize counters and timeout values. Note that we don't @@ -2391,10 +2396,6 @@ sppp_lcp_init(struct sppp *sp) * relevant for all control protocols, not just LCP only. */ sp->lcp.timeout = 1 * hz; - sp->lcp.max_terminate = 2; - sp->lcp.max_configure = 10; - sp->lcp.max_failure = 10; - sppp_cp_init(, sp); } static void @@ -3230,13 +3231,10 @@ sppp_ipcp_init(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + sppp_cp_init(, sp); + sp->ipcp.opts = 0; sp->ipcp.flags = 0; - sp->scp[IDX_IPCP].state = STATE_INITIAL; - sp->scp[IDX_IPCP].fail_counter = 0; - sp->scp[IDX_IPCP].seq = 0; - sp->scp[IDX_IPCP].rseq = 0; - sppp_cp_init(, sp); error = workqueue_create(>ipcp.update_addrs_wq, "ipcp_addr", sppp_update_ip_addrs_work, sp, PRI_SOFTNET, IPL_NET, 0); @@ -3778,13 +3776,10 @@ sppp_ipv6cp_init(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); + sppp_cp_init(, sp); + sp->ipv6cp.opts = 0; sp->ipv6cp.flags = 0; - sp->scp[IDX_IPV6CP].state = STATE_INITIAL; - sp->scp[IDX_IPV6CP].fail_counter = 0; - sp->scp[IDX_IPV6CP].seq = 0; - sp->scp[IDX_IPV6CP].rseq = 0; - sppp_cp_init(, sp); } static void @@ -4628,13 +4623,10 @@ sppp_chap_init(struct sppp *sp) KASSERT(SPPP_WLOCKED(sp)); - sp->scp[IDX_CHAP].state = STATE_INITIAL; - sp->scp[IDX_CHAP].fail_counter = 0; - sp->scp[IDX_CHAP].seq = 0; - sp->scp[IDX_CHAP].rseq = 0; + sppp_cp_init(, sp); + SPPP_WQ_SET(>chap.work_challenge_rcvd, sppp_chap_rcv_challenge_event, ); - sppp_cp_init(, sp); } static void @@ -4958,11 +4950,6 @@ sppp_pap_init(struct sppp *sp) { KASSERT(SPPP_WLOCKED(sp)); - - sp->scp[IDX_PAP].state = STATE_INITIAL; - sp->scp[IDX_PAP].fail_counter = 0; - sp->scp[IDX_PAP].seq = 0; - sp->scp[IDX_PAP].rseq = 0; sppp_cp_init(, sp); }
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:57:26 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Remove unused and unimplemented code related to CP_QUAL To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 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.202 src/sys/net/if_spppsubr.c:1.203 --- src/sys/net/if_spppsubr.c:1.202 Wed Nov 25 09:55:01 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:57:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.202 2020/11/25 09:55:01 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.203 2020/11/25 09:57:26 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.202 2020/11/25 09:55:01 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.203 2020/11/25 09:57:26 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3036,11 +3036,6 @@ sppp_lcp_tlu(struct sppp *sp) SPPP_LOCK(sp, RW_WRITER); } - for (i = 0; i < IDX_COUNT; i++) - if ((cps[i])->flags & CP_QUAL) { - (cps[i])->Open(sp, __UNCONST([i])); - } - if ((sp->lcp.opts & (1 << LCP_OPT_AUTH_PROTO)) != 0 || (sp->pp_flags & PP_NEEDAUTH) != 0) sppp_change_phase(sp, SPPP_PHASE_AUTHENTICATE);
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:55:02 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Simplify commonly used functions reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 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.201 src/sys/net/if_spppsubr.c:1.202 --- src/sys/net/if_spppsubr.c:1.201 Wed Nov 25 09:46:05 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:55:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.201 2020/11/25 09:46:05 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.202 2020/11/25 09:55:01 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.201 2020/11/25 09:46:05 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.202 2020/11/25 09:55:01 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -102,9 +102,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define DEFAULT_NORECV_TIME 15 /* before we get worried */ #define DEFAULT_MAX_AUTH_FAILURES 5 /* max. auth. failures */ -#define FAILMSG "Failed..." -#define SUCCMSG "Welcome!" - /* * Interface flags that can be set in an ifconfig command. * @@ -249,11 +246,11 @@ struct cp { void (*RCN_rej)(struct sppp *, struct lcp_header *, int); void (*RCN_nak)(struct sppp *, struct lcp_header *, int); /* actions */ - void (*tlu)(struct sppp *sp); - void (*tld)(struct sppp *sp); - void (*tls)(struct sppp *sp); - void (*tlf)(struct sppp *sp); - void (*scr)(struct sppp *sp); + void (*tlu)(struct sppp *); + void (*tld)(struct sppp *); + 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 *); }; @@ -335,7 +332,8 @@ static void sppp_cp_to_ipv6cp(void *); static void sppp_auth_send(const struct cp *, struct sppp *, unsigned int, unsigned int, ...); static int sppp_auth_role(const struct cp *, struct sppp *); -static void sppp_auth_to_event(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_up_event(struct sppp *, void *); static void sppp_down_event(struct sppp *, void *); @@ -350,6 +348,8 @@ static void sppp_rta_event(struct sppp * static void sppp_rxj_event(struct sppp *, void *); 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_ifdown(struct sppp *, void *); @@ -357,76 +357,45 @@ static void sppp_lcp_init(struct sppp *) static void sppp_lcp_up(struct sppp *, void *); static void sppp_lcp_down(struct sppp *, void *); static void sppp_lcp_open(struct sppp *, void *); -static void sppp_lcp_close(struct sppp *, void *); -static void sppp_lcp_TO(struct sppp *, void *); static int sppp_lcp_RCR(struct sppp *, struct lcp_header *, int); static void sppp_lcp_RCN_rej(struct sppp *, struct lcp_header *, int); static void sppp_lcp_RCN_nak(struct sppp *, struct lcp_header *, int); static void sppp_lcp_tlu(struct sppp *); static void sppp_lcp_tld(struct sppp *); -static void sppp_lcp_tls(struct sppp *); -static void sppp_lcp_tlf(struct sppp *); +static void sppp_lcp_tls(const struct cp *, struct sppp *); +static void sppp_lcp_tlf(const struct cp *, struct sppp *); static void sppp_lcp_scr(struct sppp *); static void sppp_lcp_check_and_close(struct sppp *); -static int sppp_ncp_check(struct sppp *); -static int sppp_auth_check(struct sppp *); +static int sppp_cp_check(struct sppp *, u_char); static void sppp_ipcp_init(struct sppp *); -static void sppp_ipcp_up(struct sppp *, void *); -static void sppp_ipcp_down(struct sppp *, void *); static void sppp_ipcp_open(struct sppp *, void *); static void sppp_ipcp_close(struct sppp *, void *); -static void sppp_ipcp_TO(struct sppp *, void *); static int sppp_ipcp_RCR(struct sppp *, struct lcp_header *, int); static void sppp_ipcp_RCN_rej(struct sppp *, struct lcp_header *, int); static void sppp_ipcp_RCN_nak(struct sppp *, struct lcp_header *, int); static void sppp_ipcp_tlu(struct sppp *); -static void sppp_ipcp_tld(struct sppp *); -static void sppp_ipcp_tls(struct sppp *); -static void sppp_ipcp_tlf(struct sppp *); static void sppp_ipcp_scr(struct sppp *); static void sppp_ipv6cp_init(struct sppp *); -static void sppp_ipv6cp_up(struct sppp *, void *); -static void sppp_ipv6cp_down(struct sppp *, void *); static void sppp_ipv6cp_open(struct sppp *, void *); -static void sppp_ipv6cp_close(struct sppp *, void *); -static void
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:46:05 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: implement auth protocols on the state-machine of control protocols reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.28 -r1.29 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.200 src/sys/net/if_spppsubr.c:1.201 --- src/sys/net/if_spppsubr.c:1.200 Wed Nov 25 09:41:20 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:46:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.200 2020/11/25 09:41:20 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.201 2020/11/25 09:46:05 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.200 2020/11/25 09:41:20 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.201 2020/11/25 09:46:05 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -102,6 +102,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_spppsubr. #define DEFAULT_NORECV_TIME 15 /* before we get worried */ #define DEFAULT_MAX_AUTH_FAILURES 5 /* max. auth. failures */ +#define FAILMSG "Failed..." +#define SUCCMSG "Welcome!" + /* * Interface flags that can be set in an ifconfig command. * @@ -254,6 +257,12 @@ struct cp { void (*scan)(const struct cp *, struct sppp *); }; +enum auth_role { + SPPP_AUTH_NOROLE = 0, + SPPP_AUTH_SERV = __BIT(0), + SPPP_AUTH_PEER = __BIT(1), +}; + static struct sppp *spppq; static kmutex_t *spppq_lock = NULL; static callout_t keepalive_ch; @@ -325,6 +334,8 @@ static void sppp_cp_to_ipcp(void *); static void sppp_cp_to_ipv6cp(void *); static void sppp_auth_send(const struct cp *, struct sppp *, unsigned int, unsigned int, ...); +static int sppp_auth_role(const struct cp *, struct sppp *); +static void sppp_auth_to_event(const struct cp *, struct sppp *); static void sppp_up_event(struct sppp *, void *); static void sppp_down_event(struct sppp *, void *); @@ -337,7 +348,6 @@ static void sppp_rcn_event(struct sppp * static void sppp_rtr_event(struct sppp *, void *); static void sppp_rta_event(struct sppp *, void *); static void sppp_rxj_event(struct sppp *, void *); -static void sppp_null_event(struct sppp *, void *); static void sppp_null(struct sppp *); static void sppp_sca_scn(const struct cp *, struct sppp *); @@ -359,6 +369,7 @@ static void sppp_lcp_tlf(struct sppp *); static void sppp_lcp_scr(struct sppp *); static void sppp_lcp_check_and_close(struct sppp *); static int sppp_ncp_check(struct sppp *); +static int sppp_auth_check(struct sppp *); static void sppp_ipcp_init(struct sppp *); static void sppp_ipcp_up(struct sppp *, void *); @@ -392,22 +403,31 @@ static void sppp_ipv6cp_scr(struct sppp static void sppp_pap_input(struct sppp *, struct mbuf *); static void sppp_pap_init(struct sppp *); +static void sppp_pap_up(struct sppp *, void *); +static void sppp_pap_down(struct sppp *, void *); static void sppp_pap_open(struct sppp *, void *); static void sppp_pap_close(struct sppp *, void *); -static void sppp_pap_TO(void *); -static void sppp_pap_my_TO(void *); +static void sppp_pap_TO(struct sppp *, void *); +static void sppp_pap_tls(struct sppp *); +static void sppp_pap_tlf(struct sppp *); static void sppp_pap_tlu(struct sppp *); -static void sppp_pap_tld(struct sppp *); static void sppp_pap_scr(struct sppp *); +static void sppp_pap_scr(struct sppp *); +static void sppp_pap_scan(const struct cp *, struct sppp *); static void sppp_chap_input(struct sppp *, struct mbuf *); static void sppp_chap_init(struct sppp *); +static void sppp_chap_up(struct sppp *, void *); +static void sppp_chap_down(struct sppp *, void *); static void sppp_chap_open(struct sppp *, void *); static void sppp_chap_close(struct sppp *, void *); -static void sppp_chap_TO(void *); +static void sppp_chap_TO(struct sppp *, void *); static void sppp_chap_tlu(struct sppp *); -static void sppp_chap_tld(struct sppp *); +static void sppp_chap_tls(struct sppp *); +static void sppp_chap_tlf(struct sppp *); static void sppp_chap_scr(struct sppp *); +static void sppp_chap_scan(const struct cp *, 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); @@ -494,18 +514,18 @@ static const struct cp ipv6cp = { static const struct cp pap = { PPP_PAP, IDX_PAP, CP_AUTH, "pap", - sppp_null_event, sppp_null_event, sppp_pap_open, sppp_pap_close, - sppp_null_event, 0, 0, 0, - sppp_pap_tlu, sppp_pap_tld, sppp_null, sppp_null, - sppp_pap_scr, 0 + sppp_pap_up, sppp_pap_down, sppp_pap_open,
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:41:20 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Insert an entry after initialization To generate a diff of this commit: cvs rdiff -u -r1.199 -r1.200 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.199 src/sys/net/if_spppsubr.c:1.200 --- src/sys/net/if_spppsubr.c:1.199 Wed Nov 25 09:38:39 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:41:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.199 2020/11/25 09:38:39 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.200 2020/11/25 09:41:20 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.199 2020/11/25 09:38:39 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.200 2020/11/25 09:41:20 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -998,10 +998,6 @@ sppp_attach(struct ifnet *ifp) if (! spppq_lock) spppq_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET); - /* Insert new entry into the keepalive list. */ - sp->pp_next = spppq; - spppq = sp; - sp->pp_if.if_type = IFT_PPP; sp->pp_if.if_output = sppp_output; sp->pp_fastq.ifq_maxlen = 32; @@ -1039,6 +1035,12 @@ sppp_attach(struct ifnet *ifp) sppp_pap_init(sp); sppp_chap_init(sp); SPPP_UNLOCK(sp); + + SPPPQ_LOCK(); + /* Insert new entry into the keepalive list. */ + sp->pp_next = spppq; + spppq = sp; + SPPPQ_UNLOCK(); } void
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:38:39 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: call if_down() in workqueue instead of callout(9) To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.27 -r1.28 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.198 src/sys/net/if_spppsubr.c:1.199 --- src/sys/net/if_spppsubr.c:1.198 Wed Nov 25 09:35:23 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:38:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.198 2020/11/25 09:35:23 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.199 2020/11/25 09:38:39 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.198 2020/11/25 09:35:23 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.199 2020/11/25 09:38:39 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -341,6 +341,7 @@ static void sppp_null_event(struct sppp static void sppp_null(struct sppp *); static void sppp_sca_scn(const struct cp *, struct sppp *); +static void sppp_ifdown(struct sppp *, void *); static void sppp_lcp_init(struct sppp *); static void sppp_lcp_up(struct sppp *, void *); @@ -1016,6 +1017,7 @@ sppp_attach(struct ifnet *ifp) sp->pp_phase = SPPP_PHASE_DEAD; sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; + sppp_wq_set(>work_ifdown, sppp_ifdown, NULL); memset(sp->scp, 0, sizeof(sp->scp)); rw_init(>pp_lock); @@ -5486,11 +5488,7 @@ sppp_keepalive(void *dummy) if (sp->pp_alivecnt >= sp->pp_maxalive) { /* No keepalive packets got. Stop the interface. */ - SPPP_UNLOCK(sp); - if_down (ifp); - SPPP_LOCK(sp, RW_WRITER); - - IF_PURGE(>pp_cpq); + 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", @@ -6498,6 +6496,17 @@ sppp_sca_scn(const struct cp *cp, struct kmem_free(buf, blen); } } + +static void +sppp_ifdown(struct sppp *sp, void *xcp __unused) +{ + + SPPP_UNLOCK(sp); + if_down(>pp_if); + IF_PURGE(>pp_cpq); + SPPP_LOCK(sp, RW_WRITER); +} + /* * This file is large. Tell emacs to highlight it nevertheless. * Index: src/sys/net/if_spppvar.h diff -u src/sys/net/if_spppvar.h:1.27 src/sys/net/if_spppvar.h:1.28 --- src/sys/net/if_spppvar.h:1.27 Wed Nov 25 09:35:23 2020 +++ src/sys/net/if_spppvar.h Wed Nov 25 09:38:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppvar.h,v 1.27 2020/11/25 09:35:23 yamaguchi Exp $ */ +/* $NetBSD: if_spppvar.h,v 1.28 2020/11/25 09:38:39 yamaguchi Exp $ */ #ifndef _NET_IF_SPPPVAR_H_ #define _NET_IF_SPPPVAR_H_ @@ -160,6 +160,7 @@ struct sppp { struct callout_handle pap_my_to_ch; /* PAP needs one more... */ #endif struct workqueue *wq_cp; + struct sppp_work work_ifdown; struct sppp_cp scp[IDX_COUNT]; struct slcp lcp; /* LCP params */ struct sipcp ipcp; /* IPCP params */
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:35:24 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Change a state of control protocol in thread context reviewed by knakahara@n.o. To generate a diff of this commit: cvs rdiff -u -r1.197 -r1.198 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.26 -r1.27 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.197 src/sys/net/if_spppsubr.c:1.198 --- src/sys/net/if_spppsubr.c:1.197 Wed Nov 25 09:30:49 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:35:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.197 2020/11/25 09:30:49 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.198 2020/11/25 09:35:23 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.197 2020/11/25 09:30:49 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.198 2020/11/25 09:35:23 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -237,11 +237,11 @@ struct cp { #define CP_QUAL 0x08 /* this is a quality reporting protocol */ const char *name; /* name of this control protocol */ /* event handlers */ - void (*Up)(struct sppp *); - void (*Down)(struct sppp *); - void (*Open)(struct sppp *); - void (*Close)(struct sppp *); - void (*TO)(void *); + void (*Up)(struct sppp *, void *); + void (*Down)(struct sppp *, void *); + void (*Open)(struct sppp *, void *); + void (*Close)(struct sppp *, void *); + void (*TO)(struct sppp *, void *); int (*RCR)(struct sppp *, struct lcp_header *, int); void (*RCN_rej)(struct sppp *, struct lcp_header *, int); void (*RCN_nak)(struct sppp *, struct lcp_header *, int); @@ -271,6 +271,8 @@ static callout_t keepalive_ch; SPPP_LOCK(_sp, RW_WRITER); \ }while (0) #define SPPP_DOWNGRADE(_sp) rw_downgrade(&(_sp)->pp_lock) +#define SPPP_WQ_SET(_wk, _func, _arg) \ + sppp_wq_set((_wk), (_func), __UNCONST((_arg))) #ifdef INET #ifndef SPPPSUBR_MPSAFE @@ -301,36 +303,51 @@ static int sppp_output(struct ifnet *, s 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 *, + struct mbuf *); static void sppp_cp_input(const struct cp *, struct sppp *, struct mbuf *); static void sppp_cp_send(struct sppp *, u_short, u_char, u_char, u_short, void *); /* static void sppp_cp_timeout(void *arg); */ static void sppp_cp_change_state(const struct cp *, struct sppp *, int); +static struct workqueue * +sppp_wq_create(struct sppp *, const char *, pri_t, int, int); +static void sppp_wq_destroy(struct sppp *, struct workqueue *); +static void sppp_wq_set(struct sppp_work *, +void (*)(struct sppp *, void *), void *); +static void sppp_wq_add(struct workqueue *, struct sppp_work *); +static void sppp_wq_wait(struct workqueue *, struct sppp_work *); +static void sppp_cp_to_lcp(void *); +static void sppp_cp_to_ipcp(void *); +static void sppp_cp_to_ipv6cp(void *); static void sppp_auth_send(const struct cp *, struct sppp *, unsigned int, unsigned int, ...); -static void sppp_up_event(const struct cp *, struct sppp *); -static void sppp_down_event(const struct cp *, struct sppp *); -static void sppp_open_event(const struct cp *, struct sppp *); -static void sppp_close_event(const struct cp *, struct sppp *); -static void sppp_to_event(const struct cp *, struct sppp *); -static void sppp_rcr_event(const struct cp *, struct sppp *); -static void sppp_rca_event(const struct cp *, struct sppp *); -static void sppp_rcn_event(const struct cp *, struct sppp *); -static void sppp_rtr_event(const struct cp *, struct sppp *); -static void sppp_rta_event(const struct cp *, struct sppp *); -static void sppp_rxj_event(const struct cp *, struct sppp *); +static void sppp_up_event(struct sppp *, void *); +static void sppp_down_event(struct sppp *, void *); +static void sppp_open_event(struct sppp *, void *); +static void sppp_close_event(struct sppp *, void *); +static void sppp_to_event(struct sppp *, void *); +static void sppp_rcr_event(struct sppp *, void *); +static void sppp_rca_event(struct sppp *, void *); +static void sppp_rcn_event(struct sppp *, void *); +static void sppp_rtr_event(struct sppp *, void *); +static void sppp_rta_event(struct sppp *, void *); +static void sppp_rxj_event(struct sppp *, void *); +static void sppp_null_event(struct sppp *, void *); static void sppp_null(struct sppp *); static void sppp_sca_scn(const struct cp *, struct sppp *); static void sppp_lcp_init(struct sppp *); -static void
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:30:49 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Add a function for RXJ event To generate a diff of this commit: cvs rdiff -u -r1.196 -r1.197 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.196 src/sys/net/if_spppsubr.c:1.197 --- src/sys/net/if_spppsubr.c:1.196 Wed Nov 25 09:26:34 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:30:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.196 2020/11/25 09:26:34 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.197 2020/11/25 09:30:49 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.196 2020/11/25 09:26:34 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.197 2020/11/25 09:30:49 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -320,6 +320,7 @@ static void sppp_rca_event(const struct static void sppp_rcn_event(const struct cp *, struct sppp *); static void sppp_rtr_event(const struct cp *, struct sppp *); static void sppp_rta_event(const struct cp *, struct sppp *); +static void sppp_rxj_event(const struct cp *, struct sppp *); static void sppp_null(struct sppp *); static void sppp_sca_scn(const struct cp *, struct sppp *); @@ -1580,25 +1581,7 @@ sppp_cp_input(const struct cp *cp, struc "danger will robinson\n", ifp->if_xname, cp->name, sppp_cp_type_name(h->type)); - switch (sp->scp[cp->protoidx].state) { - case STATE_CLOSED: - case STATE_STOPPED: - case STATE_REQ_SENT: - case STATE_ACK_SENT: - case STATE_CLOSING: - case STATE_STOPPING: - case STATE_OPENED: - break; - case STATE_ACK_RCVD: - sppp_cp_change_state(cp, sp, STATE_REQ_SENT); - break; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp, if_ierrors); - } + sppp_rxj_event(cp, sp); break; case PROTO_REJ: { @@ -1637,27 +1620,7 @@ sppp_cp_input(const struct cp *cp, struc break; } } - - /* XXX catastrophic rejects (RXJ-) aren't handled yet. */ - switch (sp->scp[cp->protoidx].state) { - case STATE_CLOSED: - case STATE_STOPPED: - case STATE_REQ_SENT: - case STATE_ACK_SENT: - case STATE_CLOSING: - case STATE_STOPPING: - case STATE_OPENED: - break; - case STATE_ACK_RCVD: - sppp_cp_change_state(cp, sp, STATE_REQ_SENT); - break; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp, if_ierrors); - } + sppp_rxj_event(cp, sp); break; } case DISC_REQ: @@ -2206,6 +2169,32 @@ sppp_rta_event(const struct cp *cp, stru } } +static void +sppp_rxj_event(const struct cp *cp, struct sppp *sp) +{ + struct ifnet *ifp = >pp_if; + + /* XXX catastrophic rejects (RXJ-) aren't handled yet. */ + switch (sp->scp[cp->protoidx].state) { + case STATE_CLOSED: + case STATE_STOPPED: + case STATE_REQ_SENT: + case STATE_ACK_SENT: + case STATE_CLOSING: + case STATE_STOPPING: + case STATE_OPENED: + break; + case STATE_ACK_RCVD: + sppp_cp_change_state(cp, sp, STATE_REQ_SENT); + break; + default: + printf("%s: %s illegal RXJ- in state %s\n", + ifp->if_xname, cp->name, + sppp_state_name(sp->scp[cp->protoidx].state)); + if_statinc(ifp, if_ierrors); + } +} + /* * Change the state of a control protocol in the state automaton. * Takes care of starting/stopping the restart timer.
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:26:34 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Add a function for RTR and RTA event To generate a diff of this commit: cvs rdiff -u -r1.195 -r1.196 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.195 src/sys/net/if_spppsubr.c:1.196 --- src/sys/net/if_spppsubr.c:1.195 Wed Nov 25 09:21:53 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:26:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.195 2020/11/25 09:21:53 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.196 2020/11/25 09:26:34 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.195 2020/11/25 09:21:53 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.196 2020/11/25 09:26:34 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -318,6 +318,8 @@ static void sppp_to_event(const struct c static void sppp_rcr_event(const struct cp *, struct sppp *); static void sppp_rca_event(const struct cp *, struct sppp *); static void sppp_rcn_event(const struct cp *, struct sppp *); +static void sppp_rtr_event(const struct cp *, struct sppp *); +static void sppp_rta_event(const struct cp *, struct sppp *); static void sppp_null(struct sppp *); static void sppp_sca_scn(const struct cp *, struct sppp *); @@ -1565,68 +1567,11 @@ sppp_cp_input(const struct cp *cp, struc break; case TERM_REQ: - switch (sp->scp[cp->protoidx].state) { - case STATE_ACK_RCVD: - case STATE_ACK_SENT: - sppp_cp_change_state(cp, sp, STATE_REQ_SENT); - /* fall through */ - case STATE_CLOSED: - case STATE_STOPPED: - case STATE_CLOSING: - case STATE_STOPPING: - case STATE_REQ_SENT: - sta: - /* Send Terminate-Ack packet. */ - if (debug) -log(LOG_DEBUG, "%s: %s send terminate-ack\n", -ifp->if_xname, cp->name); - sppp_cp_send(sp, cp->proto, TERM_ACK, h->ident, 0, 0); - break; - case STATE_OPENED: - (cp->tld)(sp); - sp->scp[cp->protoidx].rst_counter = 0; - sppp_cp_change_state(cp, sp, STATE_STOPPING); - goto sta; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp, if_ierrors); - } + sp->scp[cp->protoidx].rseq = h->ident; + sppp_rtr_event(cp, sp); break; case TERM_ACK: - switch (sp->scp[cp->protoidx].state) { - case STATE_CLOSED: - case STATE_STOPPED: - case STATE_REQ_SENT: - case STATE_ACK_SENT: - break; - case STATE_CLOSING: - (cp->tlf)(sp); - sppp_cp_change_state(cp, sp, STATE_CLOSED); - sppp_lcp_check_and_close(sp); - break; - case STATE_STOPPING: - (cp->tlf)(sp); - sppp_cp_change_state(cp, sp, STATE_STOPPED); - sppp_lcp_check_and_close(sp); - break; - case STATE_ACK_RCVD: - sppp_cp_change_state(cp, sp, STATE_REQ_SENT); - break; - case STATE_OPENED: - (cp->tld)(sp); - (cp->scr)(sp); - sppp_cp_change_state(cp, sp, STATE_ACK_RCVD); - break; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp, if_ierrors); - } + sppp_rta_event(cp, sp); break; case CODE_REJ: /* XXX catastrophic rejects (RXJ-) aren't handled yet. */ @@ -2187,6 +2132,80 @@ sppp_rcn_event(const struct cp *cp, stru } } +static void +sppp_rtr_event(const struct cp *cp, struct sppp *sp) +{ + STDDCL; + + switch (sp->scp[cp->protoidx].state) { + case STATE_ACK_RCVD: + case STATE_ACK_SENT: + sppp_cp_change_state(cp, sp, STATE_REQ_SENT); + break; + case STATE_CLOSED: + case STATE_STOPPED: + case STATE_CLOSING: + case STATE_STOPPING: + case STATE_REQ_SENT: + break; + case STATE_OPENED: + (cp->tld)(sp); + sp->scp[cp->protoidx].rst_counter = 0; + sppp_cp_change_state(cp, sp, STATE_STOPPING); + break; + default: + printf("%s: %s illegal RTR in state %s\n", + ifp->if_xname, cp->name, + sppp_state_name(sp->scp[cp->protoidx].state)); + if_statinc(ifp, if_ierrors); + return; + } + + /* Send Terminate-Ack packet. */ + if (debug) + log(LOG_DEBUG, "%s: %s send terminate-ack\n", + ifp->if_xname, cp->name); + sppp_cp_send(sp, cp->proto, TERM_ACK, + sp->scp[cp->protoidx].rseq, 0, 0); +} + +static void +sppp_rta_event(const struct cp *cp, struct sppp *sp) +{ + struct ifnet *ifp = >pp_if; + + switch (sp->scp[cp->protoidx].state) { + case STATE_CLOSED: + case STATE_STOPPED: + case STATE_REQ_SENT: + case STATE_ACK_SENT: + break; + case STATE_CLOSING: + (cp->tlf)(sp); + sppp_cp_change_state(cp, sp, STATE_CLOSED); + sppp_lcp_check_and_close(sp); + break; + case
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:21:53 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Add a function for RCA and RCN event To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 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.194 src/sys/net/if_spppsubr.c:1.195 --- src/sys/net/if_spppsubr.c:1.194 Wed Nov 25 09:18:45 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:21:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.194 2020/11/25 09:18:45 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.195 2020/11/25 09:21:53 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.194 2020/11/25 09:18:45 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.195 2020/11/25 09:21:53 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -316,6 +316,8 @@ static void sppp_open_event(const struct static void sppp_close_event(const struct cp *, struct sppp *); static void sppp_to_event(const struct cp *, struct sppp *); static void sppp_rcr_event(const struct cp *, struct sppp *); +static void sppp_rca_event(const struct cp *, struct sppp *); +static void sppp_rcn_event(const struct cp *, struct sppp *); static void sppp_null(struct sppp *); static void sppp_sca_scn(const struct cp *, struct sppp *); @@ -1542,40 +1544,7 @@ sppp_cp_input(const struct cp *cp, struc if_statinc(ifp, if_ierrors); break; } - switch (sp->scp[cp->protoidx].state) { - case STATE_CLOSED: - case STATE_STOPPED: - sppp_cp_send(sp, cp->proto, TERM_ACK, h->ident, 0, 0); - break; - case STATE_CLOSING: - case STATE_STOPPING: - break; - case STATE_REQ_SENT: - sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; - sppp_cp_change_state(cp, sp, STATE_ACK_RCVD); - break; - case STATE_OPENED: - (cp->tld)(sp); - /* fall through */ - case STATE_ACK_RCVD: - (cp->scr)(sp); - sppp_cp_change_state(cp, sp, STATE_REQ_SENT); - break; - case STATE_ACK_SENT: - sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; - sppp_cp_change_state(cp, sp, STATE_OPENED); - if (debug) -log(LOG_DEBUG, "%s: %s tlu\n", - ifp->if_xname, cp->name); - (cp->tlu)(sp); - break; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp, if_ierrors); - } + sppp_rca_event(cp, sp); break; case CONF_NAK: case CONF_REJ: @@ -1592,33 +1561,7 @@ sppp_cp_input(const struct cp *cp, struc else /* CONF_REJ */ (cp->RCN_rej)(sp, h, len); - switch (sp->scp[cp->protoidx].state) { - case STATE_CLOSED: - case STATE_STOPPED: - sppp_cp_send(sp, cp->proto, TERM_ACK, h->ident, 0, 0); - break; - case STATE_REQ_SENT: - case STATE_ACK_SENT: - sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; - (cp->scr)(sp); - break; - case STATE_OPENED: - (cp->tld)(sp); - /* fall through */ - case STATE_ACK_RCVD: - sppp_cp_change_state(cp, sp, STATE_ACK_SENT); - (cp->scr)(sp); - break; - case STATE_CLOSING: - case STATE_STOPPING: - break; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp, if_ierrors); - } + sppp_rcn_event(cp, sp); break; case TERM_REQ: @@ -2169,6 +2112,81 @@ sppp_rcr_event(const struct cp *cp, stru } } +static void +sppp_rca_event(const struct cp *cp, struct sppp *sp) +{ + STDDCL; + + switch (sp->scp[cp->protoidx].state) { + case STATE_CLOSED: + case STATE_STOPPED: + sppp_cp_send(sp, cp->proto, TERM_ACK, + sp->scp[cp->protoidx].rconfid, 0, 0); + break; + case STATE_CLOSING: + case STATE_STOPPING: + break; + case STATE_REQ_SENT: + sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; + sppp_cp_change_state(cp, sp, STATE_ACK_RCVD); + break; + case STATE_OPENED: + (cp->tld)(sp); + /* fall through */ + case STATE_ACK_RCVD: + (cp->scr)(sp); + sppp_cp_change_state(cp, sp, STATE_REQ_SENT); + break; + case STATE_ACK_SENT: + sppp_cp_change_state(cp, sp, STATE_OPENED); + sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; + if (debug) + log(LOG_DEBUG, "%s: %s tlu\n", + ifp->if_xname, cp->name); + (cp->tlu)(sp); + break; + default: + printf("%s: %s illegal RCA in state %s\n", + ifp->if_xname, cp->name, + sppp_state_name(sp->scp[cp->protoidx].state)); + if_statinc(ifp, if_ierrors); + } +} + +static void +sppp_rcn_event(const struct cp *cp, struct sppp *sp) +{ + struct ifnet *ifp = >pp_if; + + switch
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:18:45 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Add a function for RCR event To generate a diff of this commit: cvs rdiff -u -r1.193 -r1.194 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.25 -r1.26 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.193 src/sys/net/if_spppsubr.c:1.194 --- src/sys/net/if_spppsubr.c:1.193 Wed Nov 25 09:16:20 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:18:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.193 2020/11/25 09:16:20 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.194 2020/11/25 09:18:45 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.193 2020/11/25 09:16:20 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.194 2020/11/25 09:18:45 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -251,6 +251,7 @@ struct cp { void (*tls)(struct sppp *sp); void (*tlf)(struct sppp *sp); void (*scr)(struct sppp *sp); + void (*scan)(const struct cp *, struct sppp *); }; static struct sppp *spppq; @@ -314,8 +315,10 @@ static void sppp_down_event(const struct static void sppp_open_event(const struct cp *, struct sppp *); static void sppp_close_event(const struct cp *, struct sppp *); static void sppp_to_event(const struct cp *, struct sppp *); +static void sppp_rcr_event(const struct cp *, struct sppp *); static void sppp_null(struct sppp *); +static void sppp_sca_scn(const struct cp *, struct sppp *); static void sppp_lcp_init(struct sppp *); static void sppp_lcp_up(struct sppp *); @@ -435,7 +438,7 @@ static const struct cp lcp = { sppp_lcp_up, sppp_lcp_down, sppp_lcp_open, sppp_lcp_close, sppp_lcp_TO, sppp_lcp_RCR, sppp_lcp_RCN_rej, sppp_lcp_RCN_nak, sppp_lcp_tlu, sppp_lcp_tld, sppp_lcp_tls, sppp_lcp_tlf, - sppp_lcp_scr + sppp_lcp_scr, sppp_sca_scn }; static const struct cp ipcp = { @@ -449,7 +452,7 @@ static const struct cp ipcp = { sppp_ipcp_up, sppp_ipcp_down, sppp_ipcp_open, sppp_ipcp_close, sppp_ipcp_TO, sppp_ipcp_RCR, sppp_ipcp_RCN_rej, sppp_ipcp_RCN_nak, sppp_ipcp_tlu, sppp_ipcp_tld, sppp_ipcp_tls, sppp_ipcp_tlf, - sppp_ipcp_scr + sppp_ipcp_scr, sppp_sca_scn }; static const struct cp ipv6cp = { @@ -463,7 +466,7 @@ static const struct cp ipv6cp = { sppp_ipv6cp_up, sppp_ipv6cp_down, sppp_ipv6cp_open, sppp_ipv6cp_close, sppp_ipv6cp_TO, sppp_ipv6cp_RCR, sppp_ipv6cp_RCN_rej, sppp_ipv6cp_RCN_nak, sppp_ipv6cp_tlu, sppp_ipv6cp_tld, sppp_ipv6cp_tls, sppp_ipv6cp_tlf, - sppp_ipv6cp_scr + sppp_ipv6cp_scr, sppp_sca_scn }; static const struct cp pap = { @@ -471,7 +474,7 @@ static const struct cp pap = { sppp_null, sppp_null, sppp_pap_open, sppp_pap_close, sppp_pap_TO, 0, 0, 0, sppp_pap_tlu, sppp_pap_tld, sppp_null, sppp_null, - sppp_pap_scr + sppp_pap_scr, 0 }; static const struct cp chap = { @@ -479,7 +482,7 @@ static const struct cp chap = { sppp_null, sppp_null, sppp_chap_open, sppp_chap_close, sppp_chap_TO, 0, 0, 0, sppp_chap_tlu, sppp_chap_tld, sppp_null, sppp_null, - sppp_chap_scr + sppp_chap_scr, 0 }; static const struct cp *cps[IDX_COUNT] = { @@ -1519,18 +1522,6 @@ sppp_cp_input(const struct cp *cp, struc if_statinc(ifp, if_ierrors); break; } - /* handle states where RCR doesn't get a SCA/SCN */ - switch (sp->scp[cp->protoidx].state) { - case STATE_CLOSING: - case STATE_STOPPING: - SPPP_UNLOCK(sp); - return; - case STATE_CLOSED: - sppp_cp_send(sp, cp->proto, TERM_ACK, h->ident, - 0, 0); - SPPP_UNLOCK(sp); - return; - } rv = (cp->RCR)(sp, h, len); if (rv < 0) { /* fatal error, shut down */ @@ -1539,40 +1530,8 @@ sppp_cp_input(const struct cp *cp, struc SPPP_UNLOCK(sp); return; } - switch (sp->scp[cp->protoidx].state) { - case STATE_OPENED: - (cp->tld)(sp); - (cp->scr)(sp); - /* fall through... */ - case STATE_ACK_SENT: - case STATE_REQ_SENT: - sppp_cp_change_state(cp, sp, rv? - STATE_ACK_SENT: STATE_REQ_SENT); - break; - case STATE_STOPPED: - sp->scp[cp->protoidx].rst_counter = sp->lcp.max_configure; - (cp->scr)(sp); - sppp_cp_change_state(cp, sp, rv? - STATE_ACK_SENT: STATE_REQ_SENT); - break; - case STATE_ACK_RCVD: - if (rv) { -sppp_cp_change_state(cp, sp, STATE_OPENED); -if (debug) - log(LOG_DEBUG, "%s: %s tlu\n", - ifp->if_xname, - cp->name); -(cp->tlu)(sp); - } else -sppp_cp_change_state(cp, sp, STATE_ACK_RCVD); - break; - default: - printf("%s: %s illegal %s in state %s\n", - ifp->if_xname, cp->name, - sppp_cp_type_name(h->type), - sppp_state_name(sp->scp[cp->protoidx].state)); - if_statinc(ifp,
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:16:20 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: Refactoring functions for RCR and RCN To generate a diff of this commit: cvs rdiff -u -r1.192 -r1.193 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.192 src/sys/net/if_spppsubr.c:1.193 --- src/sys/net/if_spppsubr.c:1.192 Wed Nov 25 09:12:50 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:16:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.192 2020/11/25 09:12:50 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.193 2020/11/25 09:16:20 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.192 2020/11/25 09:12:50 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.193 2020/11/25 09:16:20 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -2294,21 +2294,30 @@ sppp_lcp_TO(void *cookie) * transition decision in the state automaton.) */ static int -sppp_lcp_RCR(struct sppp *sp, struct lcp_header *h, int len) +sppp_lcp_RCR(struct sppp *sp, struct lcp_header *h, int origlen) { STDDCL; - u_char *buf, *r, *p, l, blen; - int origlen, rlen; + u_char *buf, *r, *p, l, blen, type; + int len, rlen; uint32_t nmagic; u_short authproto; KASSERT(SPPP_WLOCKED(sp)); - len -= 4; - origlen = len; - buf = r = malloc (blen = len, M_TEMP, M_NOWAIT); - if (! buf) - return (0); + if (origlen < sizeof(*h)) + return 0; + + origlen -= sizeof(*h); + type = 0; + + if (origlen <= 0) + return 0; + else + blen = origlen; + + buf = kmem_intr_alloc(blen, KM_NOSLEEP); + if (buf == NULL) + return 0; if (debug) log(LOG_DEBUG, "%s: lcp parse opts:", @@ -2316,7 +2325,13 @@ sppp_lcp_RCR(struct sppp *sp, struct lcp /* pass 1: check for things that need to be rejected */ p = (void *)(h + 1); - for (rlen = 0; len > 1 && (l = p[1]) != 0; len -= l, p += l) { + r = buf; + rlen = 0; + for (len = origlen; len > 1; len-= l, p += l) { + l = p[1]; + if (l == 0) + break; + /* Sanity check option length */ if (l > len) { /* @@ -2326,11 +2341,12 @@ sppp_lcp_RCR(struct sppp *sp, struct lcp addlog("%s: received malicious LCP option 0x%02x, " "length 0x%02x, (len: 0x%02x) dropping.\n", ifp->if_xname, p[0], l, len); - goto drop; + rlen = -1; + goto end; } if (debug) addlog(" %s", sppp_lcp_opt_name(*p)); - switch (*p) { + switch (p[0]) { case LCP_OPT_MAGIC: /* Magic number. */ /* fall through, both are same length */ @@ -2418,12 +2434,13 @@ sppp_lcp_RCR(struct sppp *sp, struct lcp r += l; rlen += l; } - if (rlen) { - if (debug) - addlog(" send conf-rej\n"); - sppp_cp_send(sp, PPP_LCP, CONF_REJ, h->ident, rlen, buf); + + if (rlen > 0) { + type = CONF_REJ; goto end; - } else if (debug) + } + + if (debug) addlog("\n"); /* @@ -2435,11 +2452,16 @@ sppp_lcp_RCR(struct sppp *sp, struct lcp ifp->if_xname); p = (void *)(h + 1); - len = origlen; - for (rlen = 0; len > 1 && (l = p[1]) != 0; len -= l, p += l) { + r = buf; + rlen = 0; + for (len = origlen; len > 0; len -= l, p += l) { + l = p[1]; + if (l == 0) + break; + if (debug) addlog(" %s", sppp_lcp_opt_name(*p)); - switch (*p) { + switch (p[0]) { case LCP_OPT_MAGIC: /* Magic number -- extract. */ nmagic = (uint32_t)p[2] << 24 | @@ -2560,34 +2582,41 @@ sppp_lcp_RCR(struct sppp *sp, struct lcp r += l; rlen += l; } - if (rlen) { + + if (rlen > 0) { if (++sp->scp[IDX_LCP].fail_counter >= sp->lcp.max_failure) { if (debug) -addlog(" max_failure (%d) exceeded, " - "send conf-rej\n", - sp->lcp.max_failure); - sppp_cp_send(sp, PPP_LCP, CONF_REJ, h->ident, rlen, buf); +addlog(" max_failure (%d) exceeded, ", +sp->lcp.max_failure); + type = CONF_REJ; } else { - if (debug) -addlog(" send conf-nak\n"); - sppp_cp_send(sp, PPP_LCP, CONF_NAK, h->ident, rlen, buf); + type = CONF_NAK; } - goto end; } else { - if (debug) - addlog(" send conf-ack\n"); + type = CONF_ACK; + rlen = origlen; + memcpy(r, h + 1, rlen); sp->scp[IDX_LCP].fail_counter = 0; sp->pp_loopcnt = 0; - sppp_cp_send(sp, PPP_LCP, CONF_ACK, h->ident, origlen, h + 1); } - end: - free(buf, M_TEMP); - return (rlen == 0); +end: + if (rlen > 0) { + if (debug) + addlog("send %s", sppp_cp_type_name(type)); + sppp_cp_send(sp, PPP_LCP, type, h->ident, rlen, buf); + } + + if (debug) + addlog("\n"); + + kmem_free(buf, blen); - drop: - free(buf, M_TEMP); - return -1; + if (rlen > 0) + return -1; + if (type != CONF_ACK) + return 0; + return 1; } /* @@ -2598,15 +2627,15 @@ static void sppp_lcp_RCN_rej(struct sppp *sp, struct lcp_header *h, int len) { STDDCL;
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:12:50 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c if_spppvar.h Log Message: Add a structure for params related to control protocols To generate a diff of this commit: cvs rdiff -u -r1.191 -r1.192 src/sys/net/if_spppsubr.c cvs rdiff -u -r1.24 -r1.25 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.191 src/sys/net/if_spppsubr.c:1.192 --- src/sys/net/if_spppsubr.c:1.191 Wed Nov 25 09:09:24 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:12:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.191 2020/11/25 09:09:24 yamaguchi Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.192 2020/11/25 09:12:50 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.191 2020/11/25 09:09:24 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.192 2020/11/25 09:12:50 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -626,12 +626,12 @@ sppp_input(struct ifnet *ifp, struct mbu switch (protocol) { default: - if (sp->state[IDX_LCP] == STATE_OPENED) { + if (sp->scp[IDX_LCP].state == STATE_OPENED) { uint16_t prot = htons(protocol); SPPP_UPGRADE(sp); sppp_cp_send(sp, PPP_LCP, PROTO_REJ, - ++sp->pp_seq[IDX_LCP], m->m_pkthdr.len + 2, + ++sp->scp[IDX_LCP].seq, m->m_pkthdr.len + 2, ); SPPP_DOWNGRADE(sp); } @@ -669,7 +669,7 @@ sppp_input(struct ifnet *ifp, struct mbu m_freem(m); return; case PPP_IP: - if (sp->state[IDX_IPCP] == STATE_OPENED) { + if (sp->scp[IDX_IPCP].state == STATE_OPENED) { sp->pp_last_activity = time_uptime; pktq = ip_pktq; } @@ -685,7 +685,7 @@ sppp_input(struct ifnet *ifp, struct mbu return; case PPP_IPV6: - if (sp->state[IDX_IPV6CP] == STATE_OPENED) { + if (sp->scp[IDX_IPV6CP].state == STATE_OPENED) { sp->pp_last_activity = time_uptime; pktq = ip6_pktq; } @@ -888,7 +888,7 @@ sppp_output(struct ifnet *ifp, struct mb * ENETDOWN, as opposed to ENOBUFS. */ protocol = htons(PPP_IP); - if (sp->state[IDX_IPCP] != STATE_OPENED) + if (sp->scp[IDX_IPCP].state != STATE_OPENED) error = ENETDOWN; } break; @@ -908,7 +908,7 @@ sppp_output(struct ifnet *ifp, struct mb * ENETDOWN, as opposed to ENOBUFS. */ protocol = htons(PPP_IPV6); - if (sp->state[IDX_IPV6CP] != STATE_OPENED) + if (sp->scp[IDX_IPV6CP].state != STATE_OPENED) error = ENETDOWN; } break; @@ -995,13 +995,11 @@ sppp_attach(struct ifnet *ifp) sp->pp_maxalive = DEFAULT_MAXALIVECNT; sp->pp_max_noreceive = DEFAULT_NORECV_TIME; sp->pp_idle_timeout = 0; - memset(>pp_seq[0], 0, sizeof(sp->pp_seq)); - memset(>pp_rseq[0], 0, sizeof(sp->pp_rseq)); - sp->pp_auth_failures = 0; sp->pp_max_auth_fail = DEFAULT_MAX_AUTH_FAILURES; sp->pp_phase = SPPP_PHASE_DEAD; sp->pp_up = sppp_notify_up; sp->pp_down = sppp_notify_down; + memset(sp->scp, 0, sizeof(sp->scp)); rw_init(>pp_lock); if_alloc_sadl(ifp); @@ -1049,12 +1047,12 @@ sppp_detach(struct ifnet *ifp) workqueue_destroy(sp->ipcp.update_addrs_wq); pcq_destroy(sp->ipcp.update_addrs_q); - callout_stop(>ch[IDX_LCP]); - callout_stop(>ch[IDX_IPCP]); - callout_stop(>ch[IDX_PAP]); - callout_stop(>ch[IDX_CHAP]); + callout_stop(>scp[IDX_LCP].ch); + callout_stop(>scp[IDX_IPCP].ch); + callout_stop(>scp[IDX_PAP].ch); + callout_stop(>scp[IDX_CHAP].ch); #ifdef INET6 - callout_stop(>ch[IDX_IPV6CP]); + callout_stop(>scp[IDX_IPV6CP].ch); #endif callout_stop(>pap_my_to_ch); @@ -1296,8 +1294,8 @@ sppp_cisco_input(struct sppp *sp, struct break; case CISCO_KEEPALIVE_REQ: sp->pp_alivecnt = 0; - sp->pp_rseq[IDX_LCP] = ntohl(h->par1); - if (sp->pp_seq[IDX_LCP] == sp->pp_rseq[IDX_LCP]) { + sp->scp[IDX_LCP].rseq = ntohl(h->par1); + if (sp->scp[IDX_LCP].seq == sp->scp[IDX_LCP].rseq) { /* Local and remote sequence numbers are equal. * Probably, the line is in loopback mode. */ if (sp->pp_loopcnt >= LOOPALIVECNT) { @@ -1315,7 +1313,7 @@ sppp_cisco_input(struct sppp *sp, struct ++sp->pp_loopcnt; /* Generate new local sequence number */ - sp->pp_seq[IDX_LCP] = cprng_fast32(); + sp->scp[IDX_LCP].seq = cprng_fast32(); break; } sp->pp_loopcnt = 0; @@ -1500,7 +1498,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->state[cp->protoidx]), + sppp_state_name(sp->scp[cp->protoidx].state), sppp_cp_type_name(h->type), h->ident, printlen); if (len < printlen) printlen = len; @@ -1522,7 +1520,7 @@ sppp_cp_input(const struct cp *cp, struc break; } /* handle states where RCR doesn't get a SCA/SCN */ - switch
CVS commit: src/sys/net
Module Name:src Committed By: yamaguchi Date: Wed Nov 25 09:09:24 UTC 2020 Modified Files: src/sys/net: if_spppsubr.c Log Message: remove variable names in function declaration To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 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.190 src/sys/net/if_spppsubr.c:1.191 --- src/sys/net/if_spppsubr.c:1.190 Mon Oct 5 16:11:25 2020 +++ src/sys/net/if_spppsubr.c Wed Nov 25 09:09:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.190 2020/10/05 16:11:25 roy Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.191 2020/11/25 09:09:24 yamaguchi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.190 2020/10/05 16:11:25 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.191 2020/11/25 09:09:24 yamaguchi Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -237,14 +237,14 @@ struct cp { #define CP_QUAL 0x08 /* this is a quality reporting protocol */ const char *name; /* name of this control protocol */ /* event handlers */ - void (*Up)(struct sppp *sp); - void (*Down)(struct sppp *sp); - void (*Open)(struct sppp *sp); - void (*Close)(struct sppp *sp); - void (*TO)(void *sp); - int (*RCR)(struct sppp *sp, struct lcp_header *h, int len); - void (*RCN_rej)(struct sppp *sp, struct lcp_header *h, int len); - void (*RCN_nak)(struct sppp *sp, struct lcp_header *h, int len); + void (*Up)(struct sppp *); + void (*Down)(struct sppp *); + void (*Open)(struct sppp *); + void (*Close)(struct sppp *); + void (*TO)(void *); + int (*RCR)(struct sppp *, struct lcp_header *, int); + void (*RCN_rej)(struct sppp *, struct lcp_header *, int); + void (*RCN_nak)(struct sppp *, struct lcp_header *, int); /* actions */ void (*tlu)(struct sppp *sp); void (*tld)(struct sppp *sp); @@ -294,130 +294,127 @@ static u_short interactive_ports[8] = { struct ifnet *ifp = >pp_if;\ int debug = ifp->if_flags & IFF_DEBUG -static int sppp_output(struct ifnet *ifp, struct mbuf *m, - const struct sockaddr *dst, const struct rtentry *rt); +static int sppp_output(struct ifnet *, struct mbuf *, + const struct sockaddr *, const struct rtentry *); -static void sppp_cisco_send(struct sppp *sp, int type, int32_t par1, int32_t par2); -static void sppp_cisco_input(struct sppp *sp, struct mbuf *m); +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_input(const struct cp *cp, struct sppp *sp, - struct mbuf *m); -static void sppp_cp_send(struct sppp *sp, u_short proto, u_char type, - u_char ident, u_short len, void *data); +static void sppp_cp_input(const struct cp *, struct sppp *, + struct mbuf *); +static void sppp_cp_send(struct sppp *, u_short, u_char, + u_char, u_short, void *); /* static void sppp_cp_timeout(void *arg); */ -static void sppp_cp_change_state(const struct cp *cp, struct sppp *sp, - int newstate); -static void sppp_auth_send(const struct cp *cp, - struct sppp *sp, unsigned int type, unsigned int id, - ...); - -static void sppp_up_event(const struct cp *cp, struct sppp *sp); -static void sppp_down_event(const struct cp *cp, struct sppp *sp); -static void sppp_open_event(const struct cp *cp, struct sppp *sp); -static void sppp_close_event(const struct cp *cp, struct sppp *sp); -static void sppp_to_event(const struct cp *cp, struct sppp *sp); - -static void sppp_null(struct sppp *sp); - -static void sppp_lcp_init(struct sppp *sp); -static void sppp_lcp_up(struct sppp *sp); -static void sppp_lcp_down(struct sppp *sp); -static void sppp_lcp_open(struct sppp *sp); -static void sppp_lcp_close(struct sppp *sp); -static void sppp_lcp_TO(void *sp); -static int sppp_lcp_RCR(struct sppp *sp, struct lcp_header *h, int len); -static void sppp_lcp_RCN_rej(struct sppp *sp, struct lcp_header *h, int len); -static void sppp_lcp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len); -static void sppp_lcp_tlu(struct sppp *sp); -static void sppp_lcp_tld(struct sppp *sp); -static void sppp_lcp_tls(struct sppp *sp); -static void sppp_lcp_tlf(struct sppp *sp); -static void sppp_lcp_scr(struct sppp *sp); -static void sppp_lcp_check_and_close(struct sppp *sp); -static int sppp_ncp_check(struct sppp *sp); - -static void sppp_ipcp_init(struct sppp *sp); -static void sppp_ipcp_up(struct sppp *sp); -static void sppp_ipcp_down(struct sppp *sp); -static void sppp_ipcp_open(struct sppp *sp); -static void sppp_ipcp_close(struct sppp *sp); -static void sppp_ipcp_TO(void *sp); -static int sppp_ipcp_RCR(struct sppp *sp, struct lcp_header *h, int len); -static void sppp_ipcp_RCN_rej(struct sppp *sp, struct lcp_header *h, int len); -static void