Module Name:    src
Committed By:   yamaguchi
Date:           Fri Apr 23 01:13:26 UTC 2021

Modified Files:
        src/sys/net: if_sppp.h if_spppsubr.c

Log Message:
Introduct a new flag to accept different authentication protocol
in myauthproto and hisauthproto

When the flag is enabled, a authentication protocol notified
at LCP negotiation is used as my authentication protocol.
When the flags is NOT enabled, my authentication protoco is
not changed at LCP negotiation.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_sppp.h
cvs rdiff -u -r1.217 -r1.218 src/sys/net/if_spppsubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_sppp.h
diff -u src/sys/net/if_sppp.h:1.30 src/sys/net/if_sppp.h:1.31
--- src/sys/net/if_sppp.h:1.30	Wed Dec  2 14:20:20 2020
+++ src/sys/net/if_sppp.h	Fri Apr 23 01:13:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sppp.h,v 1.30 2020/12/02 14:20:20 wiz Exp $	*/
+/*	$NetBSD: if_sppp.h,v 1.31 2021/04/23 01:13:25 yamaguchi Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -44,6 +44,7 @@
 #define SPPP_AUTHFLAG_NOCALLOUT		1	/* do not require authentication on */
 						/* callouts */
 #define SPPP_AUTHFLAG_NORECHALLENGE	2	/* do not re-challenge CHAP */
+#define SPPP_AUTHFLAG_PASSIVEAUTHPROTO	4	/* use authproto proposed by peer */
 
 struct spppauthcfg {
 	char	ifname[IFNAMSIZ];	/* pppoe interface name */

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.217 src/sys/net/if_spppsubr.c:1.218
--- src/sys/net/if_spppsubr.c:1.217	Fri Apr 16 02:12:00 2021
+++ src/sys/net/if_spppsubr.c	Fri Apr 23 01:13:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.218 2021/04/23 01:13:25 yamaguchi Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.217 2021/04/16 02:12:00 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.218 2021/04/23 01:13:25 yamaguchi Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2701,6 +2701,10 @@ sppp_lcp_confreq(struct sppp *sp, struct
 					addlog(" [invalid chap len]");
 				break;
 			}
+			if (ISSET(sp->myauth.flags, SPPP_AUTHFLAG_PASSIVEAUTHPROTO)) {
+				if (authproto == PPP_PAP || authproto == PPP_CHAP)
+					sp->myauth.proto = authproto;
+			}
 			if (sp->myauth.proto == 0) {
 				/* we are not configured to do auth */
 				if (debug)
@@ -2831,6 +2835,10 @@ sppp_lcp_confreq(struct sppp *sp, struct
 
 		case LCP_OPT_AUTH_PROTO:
 			authproto = (p[2] << 8) + p[3];
+			if (ISSET(sp->myauth.flags, SPPP_AUTHFLAG_PASSIVEAUTHPROTO)) {
+				if (authproto == PPP_PAP || authproto == PPP_CHAP)
+					sp->myauth.proto = authproto;
+			}
 			if (sp->myauth.proto != authproto) {
 				/* not agreed, nak */
 				if (debug)

Reply via email to