diff --git a/share/man/man4/ng_pppoe.4 b/share/man/man4/ng_pppoe.4 index d9853a74651..ff53d4ef3a9 100644 --- a/share/man/man4/ng_pppoe.4 +++ b/share/man/man4/ng_pppoe.4 @@ -322,7 +322,7 @@ control message, when all session have been disconnected or when the hook is disconnected. .Sh SYSCTL VARIABLES The node can mark transmitted LCP Ethernet packets (protocol 0xc021) -with 3-bit Priority code point (PCP) referring to IEEE 802.1p +with 3-bit Priority Code Point (PCP) referring to IEEE 802.1p class of service with following .Xr sysctl 8 variable. diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c index 8bc44e16004..5a327f95b93 100644 --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -49,8 +49,13 @@ #include #include #include +#include +#include #include #include +#include +#include +#include #include #include @@ -64,8 +69,19 @@ static MALLOC_DEFINE(M_NETGRAPH_PPPOE, "netgraph_pppoe", "netgraph pppoe node"); #define M_NETGRAPH_PPPOE M_NETGRAPH #endif +/* Some PPP protocol numbers we're interested in */ +#define PROT_LCP 0xc021 + #define SIGNOFF "session closed" +VNET_DEFINE_STATIC(u_int32_t, ng_pppoe_lcp_pcp) = 0; +#define V_ng_pppoe_lcp_pcp VNET(ng_pppoe_lcp_pcp) + +SYSCTL_NODE(_net_graph, OID_AUTO, pppoe, CTLFLAG_RW, 0, "PPPoE"); +SYSCTL_UINT(_net_graph_pppoe, OID_AUTO, lcp_pcp, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ng_pppoe_lcp_pcp), 0, + "Set PCP for LCP"); + /* * This section contains the netgraph method declarations for the * pppoe node. These methods define the netgraph pppoe 'type'. @@ -1438,6 +1454,12 @@ ng_pppoe_rcvdata(hook_p hook, item_p item) mtod(m, u_char *)[1] == 0x03) m_adj(m, 2); } + + if (V_ng_pppoe_lcp_pcp && m->m_pkthdr.len >= 2 && + m->m_len >= 2 && (m = m_pullup(m, 2)) && + mtod(m, uint16_t *)[0] == htons(PROT_LCP)) + EVL_APPLY_PRI(m, (uint8_t)(V_ng_pppoe_lcp_pcp & 0x7)); + /* * Bang in a pre-made header, and set the length up * to be correct. Then send it to the ethernet driver.