kill unknown sessions ifdef, link set for sysctl.

This commit is contained in:
christos 2016-08-11 15:16:07 +00:00
parent f2d5a43da7
commit dc521af48a
1 changed files with 9 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_pppoe.c,v 1.116 2016/08/08 07:23:27 roy Exp $ */ /* $NetBSD: if_pppoe.c,v 1.117 2016/08/11 15:16:07 christos Exp $ */
/*- /*-
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.116 2016/08/08 07:23:27 roy Exp $"); __KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.117 2016/08/11 15:16:07 christos Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "pppoe.h" #include "pppoe.h"
@ -64,9 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.116 2016/08/08 07:23:27 roy Exp $");
#include "ioconf.h" #include "ioconf.h"
#undef PPPOE_DEBUG /* XXX - remove this or make it an option */
/* #define PPPOE_DEBUG 1 */
struct pppoehdr { struct pppoehdr {
uint8_t vertype; uint8_t vertype;
uint8_t code; uint8_t code;
@ -205,15 +202,10 @@ static LIST_HEAD(pppoe_softc_head, pppoe_softc) pppoe_softc_list;
static int pppoe_clone_create(struct if_clone *, int); static int pppoe_clone_create(struct if_clone *, int);
static int pppoe_clone_destroy(struct ifnet *); static int pppoe_clone_destroy(struct ifnet *);
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
static bool pppoe_term_unknown = false; static bool pppoe_term_unknown = false;
#endif
#ifdef _MODULE
static struct sysctllog *pppoe_sysctl_clog; static struct sysctllog *pppoe_sysctl_clog;
#endif static void sysctl_net_pppoe_setup(struct sysctllog **);
SYSCTL_SETUP_PROTO(sysctl_net_pppoe_setup);
static struct if_clone pppoe_cloner = static struct if_clone pppoe_cloner =
IF_CLONE_INITIALIZER("pppoe", pppoe_clone_create, pppoe_clone_destroy); IF_CLONE_INITIALIZER("pppoe", pppoe_clone_create, pppoe_clone_destroy);
@ -238,9 +230,7 @@ pppoeinit(void)
pppoe_softintr = softint_establish(SOFTINT_NET, pppoe_softintr_handler, pppoe_softintr = softint_establish(SOFTINT_NET, pppoe_softintr_handler,
NULL); NULL);
#ifdef _MODULE
sysctl_net_pppoe_setup(&pppoe_sysctl_clog); sysctl_net_pppoe_setup(&pppoe_sysctl_clog);
#endif
} }
static int static int
@ -255,9 +245,7 @@ pppoedetach(void)
if_clone_detach(&pppoe_cloner); if_clone_detach(&pppoe_cloner);
softint_disestablish(pppoe_softintr); softint_disestablish(pppoe_softintr);
/* Remove our sysctl sub-tree */ /* Remove our sysctl sub-tree */
#ifdef _MODULE
sysctl_teardown(&pppoe_sysctl_clog); sysctl_teardown(&pppoe_sysctl_clog);
#endif
} }
return error; return error;
@ -815,15 +803,13 @@ pppoe_data_input(struct mbuf *m)
struct pppoehdr *ph; struct pppoehdr *ph;
struct ifnet *rcvif; struct ifnet *rcvif;
struct psref psref; struct psref psref;
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
uint8_t shost[ETHER_ADDR_LEN]; uint8_t shost[ETHER_ADDR_LEN];
#endif
KASSERT(m->m_flags & M_PKTHDR); KASSERT(m->m_flags & M_PKTHDR);
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS if (pppoe_term_unknown)
memcpy(shost, mtod(m, struct ether_header*)->ether_shost, ETHER_ADDR_LEN); memcpy(shost, mtod(m, struct ether_header*)->ether_shost,
#endif ETHER_ADDR_LEN);
m_adj(m, sizeof(struct ether_header)); m_adj(m, sizeof(struct ether_header));
if (m->m_pkthdr.len <= PPPOE_HEADERLEN) { if (m->m_pkthdr.len <= PPPOE_HEADERLEN) {
printf("pppoe (data): dropping too short packet: %d bytes\n", printf("pppoe (data): dropping too short packet: %d bytes\n",
@ -854,13 +840,11 @@ pppoe_data_input(struct mbuf *m)
goto drop; goto drop;
sc = pppoe_find_softc_by_session(session, rcvif); sc = pppoe_find_softc_by_session(session, rcvif);
if (sc == NULL) { if (sc == NULL) {
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
if (pppoe_term_unknown) { if (pppoe_term_unknown) {
printf("pppoe: input for unknown session 0x%x, " printf("pppoe: input for unknown session %#x, "
"sending PADT\n", session); "sending PADT\n", session);
pppoe_send_padt(rcvif, session, shost); pppoe_send_padt(rcvif, session, shost);
} }
#endif
m_put_rcvif_psref(rcvif, &psref); m_put_rcvif_psref(rcvif, &psref);
goto drop; goto drop;
} }
@ -1671,7 +1655,8 @@ pppoedisc_input(struct ifnet *ifp, struct mbuf *m)
return; return;
} }
SYSCTL_SETUP(sysctl_net_pppoe_setup, "sysctl net.pppoe subtree setup") static void
sysctl_net_pppoe_setup(struct sysctllog **clog)
{ {
const struct sysctlnode *node = NULL; const struct sysctlnode *node = NULL;
@ -1685,14 +1670,12 @@ SYSCTL_SETUP(sysctl_net_pppoe_setup, "sysctl net.pppoe subtree setup")
if (node == NULL) if (node == NULL)
return; return;
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
sysctl_createv(clog, 0, &node, NULL, sysctl_createv(clog, 0, &node, NULL,
CTLFLAG_PERMANENT | CTLFLAG_READONLY, CTLFLAG_PERMANENT | CTLFLAG_READONLY,
CTLTYPE_BOOL, "term_unknown", CTLTYPE_BOOL, "term_unknown",
SYSCTL_DESCR("Terminate unknown sessions"), SYSCTL_DESCR("Terminate unknown sessions"),
NULL, 0, &pppoe_term_unknown, sizeof(pppoe_term_unknown), NULL, 0, &pppoe_term_unknown, sizeof(pppoe_term_unknown),
CTL_CREATE, CTL_EOL); CTL_CREATE, CTL_EOL);
#endif
} }
/* /*