summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-02-23 16:34:22 +0000
committerjulian <julian@FreeBSD.org>2001-02-23 16:34:22 +0000
commit575ee59b1c3162f7917e5e0b3fdacb39c4b96039 (patch)
treed20bb9bdc213856eb1223ca1ac24826ae7676b4b
parentcaa8a14382c376f9c55e5e5b70bd6bb997d4bd38 (diff)
downloadFreeBSD-src-575ee59b1c3162f7917e5e0b3fdacb39c4b96039.zip
FreeBSD-src-575ee59b1c3162f7917e5e0b3fdacb39c4b96039.tar.gz
Shuffle sysctls a bit (thankyou whoever made them dynamic for modules)
and add a sysctl to pppoe to activate non standard ethertypes so that idiot ISPs (apparently in France) who use equipment from idiot suppliers (rumour says 3com) who use nonstandard ethertypes can still connect. "yep, sure we do pppoe, we use a different identifier to that dictated in the standard, but sure it's pppoe!" sysctl -w net.graph.stupid_isp=1 enables the changeover.
-rw-r--r--share/man/man4/ng_pppoe.415
-rw-r--r--sys/netgraph/netgraph.h6
-rw-r--r--sys/netgraph/ng_base.c4
-rw-r--r--sys/netgraph/ng_pppoe.c51
-rw-r--r--sys/netgraph/ng_pppoe.h4
-rw-r--r--sys/netgraph/ng_socket.c1
6 files changed, 74 insertions, 7 deletions
diff --git a/share/man/man4/ng_pppoe.4 b/share/man/man4/ng_pppoe.4
index 8af8017..c9cce64 100644
--- a/share/man/man4/ng_pppoe.4
+++ b/share/man/man4/ng_pppoe.4
@@ -164,6 +164,21 @@ This node shuts down upon receipt of a
control message, when all session have been disconnected or when the
.Dv ethernet
hook is disconnected.
+.Sh SYSCTLs
+If you are one of the unfortunate people who have an ISP that
+uses some "pppoe" equipment from (I believe) 3com, and who have to
+use a different ethertype on pppoe packets
+(hey why not change it from the standard for
+no reason?) then after you have kldloaded or compiled in your pppoe node,
+you may have to do the following sysctl:
+.Bd -literal
+(kldload netgraph)
+(kldload ng_pppoe)
+sysctl -w net.graph.stupid_isp=1
+.Ed
+.Pp
+to enable the alternate ethertypes. Then phone your ISP and ask them
+why you need to set option "stupid_isp" for you to be able to connect.
.Sh EXAMPLES
The following code uses
.Dv libnetgraph
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h
index 21db90b..faef2e5 100644
--- a/sys/netgraph/netgraph.h
+++ b/sys/netgraph/netgraph.h
@@ -1124,7 +1124,11 @@ MALLOC_DECLARE(M_NETGRAPH);
MALLOC_DECLARE(M_NETGRAPH_MSG);
MALLOC_DECLARE(M_NETGRAPH_META);
-
+/* declare the base of the netgraph sysclt hierarchy */
+/* but only if this file cares about sysctls */
+#ifdef SYSCTL_DECL
+SYSCTL_DECL(_net_graph);
+#endif
/*
* Methods that the nodes can use.
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 177aead..f512b98 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -55,6 +55,7 @@
#include <sys/queue.h>
#include <sys/mbuf.h>
#include <sys/ctype.h>
+#include <sys/sysctl.h>
#include <machine/limits.h>
#include <net/netisr.h>
@@ -2948,6 +2949,9 @@ static moduledata_t netgraph_mod = {
(NULL)
};
DECLARE_MODULE(netgraph, netgraph_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
+SYSCTL_NODE(_net, OID_AUTO, graph, CTLFLAG_RW, 0, "netgraph Family");
+SYSCTL_INT(_net_graph, OID_AUTO, abi_version, CTLFLAG_RD, 0, NG_ABI_VERSION,"");
+SYSCTL_INT(_net_graph, OID_AUTO, msg_version, CTLFLAG_RD, 0, NG_VERSION, "");
/************************************************************************
Queue element get/free routines
diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c
index 2fc8dc5..faa323c 100644
--- a/sys/netgraph/ng_pppoe.c
+++ b/sys/netgraph/ng_pppoe.c
@@ -53,6 +53,7 @@
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/errno.h>
+#include <sys/sysctl.h>
#include <net/ethernet.h>
#include <netgraph/ng_message.h>
@@ -71,7 +72,7 @@ MALLOC_DEFINE(M_NETGRAPH_PPPOE, "netgraph_pppoe", "netgraph pppoe node");
/*
* This section contains the netgraph method declarations for the
- * sample node. These methods define the netgraph 'type'.
+ * pppoe node. These methods define the netgraph pppoe 'type'.
*/
static ng_constructor_t ng_pppoe_constructor;
@@ -238,11 +239,35 @@ struct PPPOE {
};
typedef struct PPPOE *priv_p;
-const struct ether_header eh_prototype =
+struct ether_header eh_prototype =
{{0xff,0xff,0xff,0xff,0xff,0xff},
{0x00,0x00,0x00,0x00,0x00,0x00},
ETHERTYPE_PPPOE_DISC};
+int stupid_isp;
+static int
+ngpppoe_set_ethertype(SYSCTL_HANDLER_ARGS)
+{
+ int error;
+ int val;
+
+ val = stupid_isp;
+ error = sysctl_handle_int(oidp, &val, sizeof(int), req);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+ if (val == 1) {
+ stupid_isp = 1;
+ eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
+ } else {
+ stupid_isp = 0;
+ eh_prototype.ether_type = ETHERTYPE_PPPOE_DISC;
+ }
+ return (0);
+}
+
+SYSCTL_PROC(_net_graph, OID_AUTO, stupid_isp, CTLTYPE_INT | CTLFLAG_RW,
+ 0, sizeof(int), ngpppoe_set_ethertype, "I", "select normal or stupid ISP");
+
union uniq {
char bytes[sizeof(void *)];
void * pointer;
@@ -902,6 +927,10 @@ AAA
wh = mtod(m, struct pppoe_full_hdr *);
length = ntohs(wh->ph.length);
switch(wh->eh.ether_type) {
+ case ETHERTYPE_PPPOE_STUPID_DISC:
+ stupid_isp = 1;
+ eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
+ /* fall through */
case ETHERTYPE_PPPOE_DISC:
/*
* We need to try to make sure that the tag area
@@ -1099,7 +1128,11 @@ AAA
* from NEWCONNECTED to CONNECTED
*/
sp->pkt_hdr = neg->pkt->pkt_header;
- sp->pkt_hdr.eh.ether_type
+ if (stupid_isp)
+ sp->pkt_hdr.eh.ether_type
+ = ETHERTYPE_PPPOE_STUPID_SESS;
+ else
+ sp->pkt_hdr.eh.ether_type
= ETHERTYPE_PPPOE_SESS;
sp->pkt_hdr.ph.code = 0;
pppoe_send_event(sp, NGM_PPPOE_SUCCESS);
@@ -1146,7 +1179,11 @@ AAA
* Keep a copy of the header we will be using.
*/
sp->pkt_hdr = neg->pkt->pkt_header;
- sp->pkt_hdr.eh.ether_type
+ if (stupid_isp)
+ sp->pkt_hdr.eh.ether_type
+ = ETHERTYPE_PPPOE_STUPID_SESS;
+ else
+ sp->pkt_hdr.eh.ether_type
= ETHERTYPE_PPPOE_SESS;
sp->pkt_hdr.ph.code = 0;
m_freem(neg->m);
@@ -1176,6 +1213,7 @@ AAA
LEAVE(EPFNOSUPPORT);
}
break;
+ case ETHERTYPE_PPPOE_STUPID_SESS:
case ETHERTYPE_PPPOE_SESS:
/*
* find matching peer/session combination.
@@ -1423,7 +1461,10 @@ AAA
/* revert the stored header to DISC/PADT mode */
wh = &sp->pkt_hdr;
wh->ph.code = PADT_CODE;
- wh->eh.ether_type = ETHERTYPE_PPPOE_DISC;
+ if (stupid_isp)
+ wh->eh.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
+ else
+ wh->eh.ether_type = ETHERTYPE_PPPOE_DISC;
/* generate a packet of that type */
MGETHDR(m, M_DONTWAIT, MT_DATA);
diff --git a/sys/netgraph/ng_pppoe.h b/sys/netgraph/ng_pppoe.h
index 6c5d72a..b841d85 100644
--- a/sys/netgraph/ng_pppoe.h
+++ b/sys/netgraph/ng_pppoe.h
@@ -177,6 +177,8 @@ struct ngpppoe_sts {
#define ETHERTYPE_PPPOE_DISC 0x8863 /* pppoe discovery packets */
#define ETHERTYPE_PPPOE_SESS 0x8864 /* pppoe session packets */
+#define ETHERTYPE_PPPOE_STUPID_DISC 0x3c12 /* pppoe discovery packets 3com? */
+#define ETHERTYPE_PPPOE_STUPID_SESS 0x3c13 /* pppoe session packets 3com? */
#else
#define PTT_EOL (0x0000)
#define PTT_SRV_NAME (0x0101)
@@ -191,6 +193,8 @@ struct ngpppoe_sts {
#define ETHERTYPE_PPPOE_DISC 0x6388 /* pppoe discovery packets */
#define ETHERTYPE_PPPOE_SESS 0x6488 /* pppoe session packets */
+#define ETHERTYPE_PPPOE_STUPID_DISC 0x123c /* pppoe discovery packets 3com? */
+#define ETHERTYPE_PPPOE_STUPID_SESS 0x133c /* pppoe session packets 3com? */
#endif
struct pppoe_tag {
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index 9375c4a..09b8ab7 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -1084,7 +1084,6 @@ ngs_mod_event(module_t mod, int event, void *data)
return (error);
}
-SYSCTL_NODE(_net, AF_NETGRAPH, graph, CTLFLAG_RW, 0, "netgraph Family");
SYSCTL_INT(_net_graph, OID_AUTO, family, CTLFLAG_RD, 0, AF_NETGRAPH, "");
SYSCTL_NODE(_net_graph, OID_AUTO, data, CTLFLAG_RW, 0, "DATA");
SYSCTL_INT(_net_graph_data, OID_AUTO, proto, CTLFLAG_RD, 0, NG_DATA, "");
OpenPOWER on IntegriCloud