Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Added ioctl commands for configuring NCP of pppoe(4)
details: https://anonhg.NetBSD.org/src/rev/531fd2bd34ee
branches: trunk
changeset: 1021127:531fd2bd34ee
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Tue May 11 01:27:45 2021 +0000
description:
Added ioctl commands for configuring NCP of pppoe(4)
diffstat:
sys/net/if_sppp.h | 12 ++++++++++-
sys/net/if_spppsubr.c | 52 +++++++++++++++++++++++++++++++++++++++++++-------
sys/net/if_spppvar.h | 3 +-
3 files changed, 57 insertions(+), 10 deletions(-)
diffs (192 lines):
diff -r 855b49cce1d3 -r 531fd2bd34ee sys/net/if_sppp.h
--- a/sys/net/if_sppp.h Tue May 11 01:23:21 2021 +0000
+++ b/sys/net/if_sppp.h Tue May 11 01:27:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_sppp.h,v 1.33 2021/05/11 01:15:11 yamaguchi Exp $ */
+/* $NetBSD: if_sppp.h,v 1.34 2021/05/11 01:27:45 yamaguchi Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -233,5 +233,15 @@
#define SPPPGETIPV6CPSTATUS _IOWR('i', 137, struct spppipv6cpstatus)
+#define SPPP_NCP_IPCP __BIT(0)
+#define SPPP_NCP_IPV6CP __BIT(1)
+struct spppncpcfg {
+ char ifname[IFNAMSIZ];
+ u_int ncp_flags;
+};
+
+#define SPPPGETNCPCFG _IOWR('i', 138, struct spppncpcfg)
+#define SPPPSETNCPCFG _IOW('i', 139, struct spppncpcfg)
+
#endif /* !_NET_IF_SPPP_H_ */
diff -r 855b49cce1d3 -r 531fd2bd34ee sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c Tue May 11 01:23:21 2021 +0000
+++ b/sys/net/if_spppsubr.c Tue May 11 01:27:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_spppsubr.c,v 1.232 2021/05/11 01:15:11 yamaguchi Exp $ */
+/* $NetBSD: if_spppsubr.c,v 1.233 2021/05/11 01:27:45 yamaguchi Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.232 2021/05/11 01:15:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.233 2021/05/11 01:27:45 yamaguchi Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -585,11 +585,7 @@
log(LOG_DEBUG,
"%s: input packet is too small, %d bytes\n",
ifp->if_xname, m->m_pkthdr.len);
- drop:
- if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1);
- m_freem(m);
- SPPP_UNLOCK(sp);
- return;
+ goto drop;
}
if (sp->pp_flags & PP_NOFRAMING) {
@@ -663,7 +659,7 @@
}
switch (protocol) {
- default:
+ reject_protocol:
if (sp->scp[IDX_LCP].state == STATE_OPENED) {
uint16_t prot = htons(protocol);
@@ -679,6 +675,8 @@
"<proto=0x%x>\n", ifp->if_xname, ntohs(protocol));
if_statinc(ifp, if_noproto);
goto drop;
+ default:
+ goto reject_protocol;
case PPP_LCP:
SPPP_UNLOCK(sp);
sppp_cp_input(&lcp, sp, m);
@@ -700,6 +698,8 @@
return;
#ifdef INET
case PPP_IPCP:
+ if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP))
+ goto reject_protocol;
SPPP_UNLOCK(sp);
if (sp->pp_phase == SPPP_PHASE_NETWORK) {
sppp_cp_input(&ipcp, sp, m);
@@ -717,6 +717,8 @@
#endif
#ifdef INET6
case PPP_IPV6CP:
+ if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP))
+ goto reject_protocol;
SPPP_UNLOCK(sp);
if (sp->pp_phase == SPPP_PHASE_NETWORK) {
sppp_cp_input(&ipv6cp, sp, m);
@@ -766,6 +768,13 @@
IF_ENQUEUE(inq, m);
IFQ_UNLOCK(inq);
schednetisr(isr);
+ return;
+
+drop:
+ if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1);
+ m_freem(m);
+ SPPP_UNLOCK(sp);
+ return;
}
/*
@@ -1029,6 +1038,7 @@
sp->pp_phase = SPPP_PHASE_DEAD;
sp->pp_up = sppp_notify_up;
sp->pp_down = sppp_notify_down;
+ sp->pp_ncpflags = SPPP_NCP_IPCP | SPPP_NCP_IPV6CP;
sppp_wq_set(&sp->work_ifdown, sppp_ifdown, NULL);
memset(sp->scp, 0, sizeof(sp->scp));
rw_init(&sp->pp_lock);
@@ -1265,6 +1275,7 @@
case SPPPSETAUTHCFG:
case SPPPSETLCPCFG:
+ case SPPPSETNCPCFG:
case SPPPSETIDLETO:
case SPPPSETAUTHFAILURE:
case SPPPSETDNSOPTS:
@@ -1284,6 +1295,7 @@
case SPPPGETAUTHCFG:
case SPPPGETLCPCFG:
+ case SPPPGETNCPCFG:
case SPPPGETAUTHFAILURES:
error = kauth_authorize_network(l->l_cred,
KAUTH_NETWORK_INTERFACE,
@@ -3491,6 +3503,9 @@
KASSERT(SPPP_WLOCKED(sp));
KASSERT(!cpu_softintr_p());
+ if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPCP))
+ return;
+
sp->ipcp.flags &= ~(IPCP_HISADDR_SEEN|IPCP_MYADDR_SEEN|IPCP_MYADDR_DYN|IPCP_HISADDR_DYN);
sp->ipcp.req_myaddr = 0;
sp->ipcp.req_hisaddr = 0;
@@ -4065,6 +4080,9 @@
KASSERT(SPPP_WLOCKED(sp));
KASSERT(!cpu_softintr_p());
+ if (!ISSET(sp->pp_ncpflags, SPPP_NCP_IPV6CP))
+ return;
+
#ifdef IPV6CP_MYIFID_DYN
sp->ipv6cp.flags &= ~(IPV6CP_MYIFID_SEEN|IPV6CP_MYIFID_DYN);
#else
@@ -6113,6 +6131,24 @@
SPPP_UNLOCK(sp);
}
break;
+ case SPPPGETNCPCFG:
+ {
+ struct spppncpcfg *ncpp = (struct spppncpcfg *) data;
+
+ SPPP_LOCK(sp, RW_READER);
+ ncpp->ncp_flags = sp->pp_ncpflags;
+ SPPP_UNLOCK(sp);
+ }
+ break;
+ case SPPPSETNCPCFG:
+ {
+ struct spppncpcfg *ncpp = (struct spppncpcfg *) data;
+
+ SPPP_LOCK(sp, RW_WRITER);
+ sp->pp_ncpflags = ncpp->ncp_flags;
+ SPPP_UNLOCK(sp);
+ }
+ break;
case SPPPGETSTATUS:
{
struct spppstatus *status = (struct spppstatus *)data;
diff -r 855b49cce1d3 -r 531fd2bd34ee sys/net/if_spppvar.h
--- a/sys/net/if_spppvar.h Tue May 11 01:23:21 2021 +0000
+++ b/sys/net/if_spppvar.h Tue May 11 01:27:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_spppvar.h,v 1.36 2021/05/11 01:23:21 yamaguchi Exp $ */
+/* $NetBSD: if_spppvar.h,v 1.37 2021/05/11 01:27:45 yamaguchi Exp $ */
#ifndef _NET_IF_SPPPVAR_H_
#define _NET_IF_SPPPVAR_H_
@@ -141,6 +141,7 @@
struct ifqueue pp_cpq; /* PPP control protocol queue */
struct sppp *pp_next; /* next interface in keepalive list */
u_int pp_flags; /* use Cisco protocol instead of PPP */
+ u_int pp_ncpflags; /* enable or disable each NCP */
u_int pp_framebytes; /* number of bytes added by (hardware) framing */
u_int pp_alivecnt; /* keepalive packets counter */
u_int pp_loopcnt; /* loopback detection counter */
Home |
Main Index |
Thread Index |
Old Index