Skip to content

Commit

Permalink
Introduct a new flag to accept different authentication protocol
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yamaguchi committed Apr 23, 2021
1 parent 4ad8bff commit cc377a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sys/net/if_sppp.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 */
Expand Down
12 changes: 10 additions & 2 deletions sys/net/if_spppsubr.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -2701,6 +2701,10 @@ sppp_lcp_confreq(struct sppp *sp, struct lcp_header *h, int origlen,
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)
Expand Down Expand Up @@ -2831,6 +2835,10 @@ sppp_lcp_confreq(struct sppp *sp, struct lcp_header *h, int origlen,

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)
Expand Down

0 comments on commit cc377a6

Please sign in to comment.