#include "bpfilter.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/timeout.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/syslog.h>
#include <sys/ioctl.h>
#include <sys/smr.h>
#include <sys/percpu.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_types.h>
#include <net/if_sppp.h>
#include <net/if_pppoe.h>
#include <net/netisr.h>
#include <netinet/if_ether.h>
#if NBPFILTER > 0
#include <net/bpf.h>
#endif
#undef PPPOE_DEBUG
#define PPPOEDEBUG(a) ((sc->sc_sppp.pp_if.if_flags & IFF_DEBUG) ? printf a : 0)
struct pppoehdr {
u_int8_t vertype;
u_int8_t code;
u_int16_t session;
u_int16_t plen;
} __packed;
struct pppoetag {
u_int16_t tag;
u_int16_t len;
} __packed;
#define PPPOE_HEADERLEN sizeof(struct pppoehdr)
#define PPPOE_OVERHEAD (PPPOE_HEADERLEN + 2)
#define PPPOE_VERTYPE 0x11
#define PPPOE_TAG_EOL 0x0000
#define PPPOE_TAG_SNAME 0x0101
#define PPPOE_TAG_ACNAME 0x0102
#define PPPOE_TAG_HUNIQUE 0x0103
#define PPPOE_TAG_ACCOOKIE 0x0104
#define PPPOE_TAG_VENDOR 0x0105
#define PPPOE_TAG_RELAYSID 0x0110
#define PPPOE_TAG_MAX_PAYLOAD 0x0120
#define PPPOE_TAG_SNAME_ERR 0x0201
#define PPPOE_TAG_ACSYS_ERR 0x0202
#define PPPOE_TAG_GENERIC_ERR 0x0203
#define PPPOE_CODE_PADI 0x09
#define PPPOE_CODE_PADO 0x07
#define PPPOE_CODE_PADR 0x19
#define PPPOE_CODE_PADS 0x65
#define PPPOE_CODE_PADT 0xA7
#define PPPOE_MTU (ETHERMTU - PPPOE_OVERHEAD)
#define PPPOE_MAXMTU PP_MAX_MRU
#define PPPOE_ADD_16(PTR, VAL) \
*(PTR)++ = (VAL) / 256; \
*(PTR)++ = (VAL) % 256
#define PPPOE_ADD_HEADER(PTR, CODE, SESS, LEN) \
*(PTR)++ = PPPOE_VERTYPE; \
*(PTR)++ = (CODE); \
PPPOE_ADD_16(PTR, SESS); \
PPPOE_ADD_16(PTR, LEN)
#define PPPOE_DISC_TIMEOUT 5
#define PPPOE_SLOW_RETRY 60
#define PPPOE_DISC_MAXPADI 4
#define PPPOE_DISC_MAXPADR 2
struct pppoe_softc {
struct sppp sc_sppp;
LIST_ENTRY(pppoe_softc) sc_list;
unsigned int sc_eth_ifidx;
caddr_t sc_bpf;
SMR_LIST_ENTRY(pppoe_softc) sc_session_entry;
int sc_state;
struct ether_addr sc_dest;
u_int16_t sc_session;
char *sc_service_name;
char *sc_concentrator_name;
u_int8_t *sc_ac_cookie;
size_t sc_ac_cookie_len;
u_int8_t *sc_relay_sid;
size_t sc_relay_sid_len;
u_int32_t sc_unique;
struct timeout sc_timeout;
int sc_padi_retried;
int sc_padr_retried;
struct timeval sc_session_time;
};
void pppoe_disc_input(struct mbuf *);
void pppoe_data_input(struct mbuf *);
static void pppoe_dispatch_disc_pkt(struct mbuf *);
void pppoeattach(int);
static int pppoe_connect(struct pppoe_softc *);
static int pppoe_disconnect(struct pppoe_softc *);
static void pppoe_abort_connect(struct pppoe_softc *);
static int pppoe_ioctl(struct ifnet *, unsigned long, caddr_t);
static void pppoe_tls(struct sppp *);
static void pppoe_tlf(struct sppp *);
static int pppoe_enqueue(struct ifnet *, struct mbuf *);
static void pppoe_start(struct ifnet *);
static void pppoe_timeout(void *);
static int pppoe_send_padi(struct pppoe_softc *);
static int pppoe_send_padr(struct pppoe_softc *);
static int pppoe_send_padt(unsigned int, u_int, const u_int8_t *, u_int8_t);
static int pppoe_output(struct pppoe_softc *, struct mbuf *);
static struct pppoe_softc *pppoe_find_softc_by_session(u_int, u_int);
static struct pppoe_softc *pppoe_find_softc_by_hunique(u_int8_t *, size_t, u_int);
static struct mbuf *pppoe_get_mbuf(size_t len);
LIST_HEAD(pppoe_softc_head, pppoe_softc) pppoe_softc_list;
SMR_LIST_HEAD(pppoe_softc_sessions, pppoe_softc) pppoe_sessions;
int pppoe_clone_create(struct if_clone *, int);
int pppoe_clone_destroy(struct ifnet *);
struct if_clone pppoe_cloner =
IF_CLONE_INITIALIZER("pppoe", pppoe_clone_create, pppoe_clone_destroy);
struct mbuf_queue pppoediscinq = MBUF_QUEUE_INITIALIZER(
IFQ_MAXLEN, IPL_SOFTNET);
struct mbuf_queue pppoeinq = MBUF_QUEUE_INITIALIZER(
IFQ_MAXLEN, IPL_SOFTNET);
void
pppoeintr(void)
{
struct mbuf_list ml;
struct mbuf *m;
NET_ASSERT_LOCKED();
mq_delist(&pppoediscinq, &ml);
while ((m = ml_dequeue(&ml)) != NULL)
pppoe_disc_input(m);
mq_delist(&pppoeinq, &ml);
while ((m = ml_dequeue(&ml)) != NULL)
pppoe_data_input(m);
}
void
pppoeattach(int count)
{
LIST_INIT(&pppoe_softc_list);
SMR_LIST_INIT(&pppoe_sessions);
if_clone_attach(&pppoe_cloner);
}
static void
pppoe_set_state(struct pppoe_softc *sc, int state)
{
KERNEL_ASSERT_LOCKED();
if (sc->sc_state == PPPOE_STATE_SESSION)
SMR_LIST_REMOVE_LOCKED(sc, sc_session_entry);
sc->sc_state = state;
}
int
pppoe_clone_create(struct if_clone *ifc, int unit)
{
struct pppoe_softc *sc, *tmpsc;
u_int32_t unique;
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
snprintf(sc->sc_sppp.pp_if.if_xname,
sizeof(sc->sc_sppp.pp_if.if_xname),
"pppoe%d", unit);
sc->sc_sppp.pp_if.if_softc = sc;
sc->sc_sppp.pp_if.if_mtu = PPPOE_MTU;
sc->sc_sppp.pp_if.if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST;
sc->sc_sppp.pp_if.if_type = IFT_PPP;
sc->sc_sppp.pp_if.if_hdrlen = sizeof(struct ether_header) + PPPOE_HEADERLEN;
sc->sc_sppp.pp_flags |= PP_KEEPALIVE;
sc->sc_sppp.pp_framebytes = PPPOE_HEADERLEN;
sc->sc_sppp.pp_if.if_input = p2p_input;
sc->sc_sppp.pp_if.if_bpf_mtap = p2p_bpf_mtap;
sc->sc_sppp.pp_if.if_ioctl = pppoe_ioctl;
sc->sc_sppp.pp_if.if_enqueue = pppoe_enqueue;
sc->sc_sppp.pp_if.if_start = pppoe_start;
sc->sc_sppp.pp_if.if_rtrequest = p2p_rtrequest;
sc->sc_sppp.pp_if.if_xflags = IFXF_CLONED;
sc->sc_sppp.pp_tls = pppoe_tls;
sc->sc_sppp.pp_tlf = pppoe_tlf;
memcpy(&sc->sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest));
timeout_set_proc(&sc->sc_timeout, pppoe_timeout, sc);
if_counters_alloc(&sc->sc_sppp.pp_if);
if_attach(&sc->sc_sppp.pp_if);
if_alloc_sadl(&sc->sc_sppp.pp_if);
sppp_attach(&sc->sc_sppp.pp_if);
#if NBPFILTER > 0
bpfattach(&sc->sc_bpf, &sc->sc_sppp.pp_if, DLT_PPP_ETHER, 0);
bpfattach(&sc->sc_sppp.pp_if.if_bpf, &sc->sc_sppp.pp_if,
DLT_LOOP, sizeof(uint32_t));
#endif
NET_LOCK();
retry:
unique = arc4random();
LIST_FOREACH(tmpsc, &pppoe_softc_list, sc_list)
if (tmpsc->sc_unique == unique)
goto retry;
sc->sc_unique = unique;
LIST_INSERT_HEAD(&pppoe_softc_list, sc, sc_list);
NET_UNLOCK();
return (0);
}
int
pppoe_clone_destroy(struct ifnet *ifp)
{
struct pppoe_softc *sc = ifp->if_softc;
NET_LOCK();
LIST_REMOVE(sc, sc_list);
NET_UNLOCK();
timeout_del(&sc->sc_timeout);
pppoe_set_state(sc, PPPOE_STATE_INITIAL);
sppp_detach(&sc->sc_sppp.pp_if);
if_detach(ifp);
if (sc->sc_concentrator_name)
free(sc->sc_concentrator_name, M_DEVBUF,
strlen(sc->sc_concentrator_name) + 1);
if (sc->sc_service_name)
free(sc->sc_service_name, M_DEVBUF,
strlen(sc->sc_service_name) + 1);
if (sc->sc_ac_cookie)
free(sc->sc_ac_cookie, M_DEVBUF, sc->sc_ac_cookie_len);
if (sc->sc_relay_sid)
free(sc->sc_relay_sid, M_DEVBUF, sc->sc_relay_sid_len);
smr_barrier();
free(sc, M_DEVBUF, sizeof(*sc));
return (0);
}
static struct pppoe_softc *
pppoe_find_softc_by_session(u_int session, u_int ifidx)
{
struct pppoe_softc *sc;
if (session == 0)
return (NULL);
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
if (sc->sc_state == PPPOE_STATE_SESSION
&& sc->sc_session == session
&& sc->sc_eth_ifidx == ifidx) {
return (sc);
}
}
return (NULL);
}
static struct pppoe_softc *
pppoe_smr_find_by_session(u_int session, u_int ifidx)
{
struct pppoe_softc *sc;
if (session == 0)
return (NULL);
smr_read_enter();
SMR_LIST_FOREACH(sc, &pppoe_sessions, sc_session_entry) {
if (sc->sc_session == session &&
sc->sc_eth_ifidx == ifidx) {
refcnt_take(&sc->sc_sppp.pp_if.if_refcnt);
break;
}
}
smr_read_leave();
return (sc);
}
static struct pppoe_softc *
pppoe_find_softc_by_hunique(u_int8_t *token, size_t len, u_int ifidx)
{
struct pppoe_softc *sc;
u_int32_t hunique;
if (LIST_EMPTY(&pppoe_softc_list))
return (NULL);
if (len != sizeof(hunique))
return (NULL);
memcpy(&hunique, token, len);
LIST_FOREACH(sc, &pppoe_softc_list, sc_list)
if (sc->sc_unique == hunique)
break;
if (sc == NULL) {
printf("pppoe: alien host unique tag, no session found\n");
return (NULL);
}
if (sc->sc_state < PPPOE_STATE_PADI_SENT || sc->sc_state >= PPPOE_STATE_SESSION) {
printf("%s: host unique tag found, but it belongs to a connection in state %d\n",
sc->sc_sppp.pp_if.if_xname, sc->sc_state);
return (NULL);
}
if (sc->sc_eth_ifidx != ifidx) {
printf("%s: wrong interface, not accepting host unique\n",
sc->sc_sppp.pp_if.if_xname);
return (NULL);
}
return (sc);
}
static void
pppoe_dispatch_disc_pkt(struct mbuf *m)
{
struct pppoe_softc *sc;
struct pppoehdr *ph;
struct pppoetag *pt;
struct mbuf *n;
struct ether_header *eh;
const char *err_msg, *devname;
size_t ac_cookie_len;
size_t relay_sid_len;
int off, noff, err, errortag, max_payloadtag;
u_int16_t max_payload;
u_int16_t tag, len;
u_int16_t session, plen;
u_int8_t *ac_cookie;
u_int8_t *relay_sid;
u_int8_t code;
err_msg = NULL;
devname = "pppoe";
off = 0;
errortag = 0;
max_payloadtag = 0;
if (m->m_len < sizeof(*eh)) {
m = m_pullup(m, sizeof(*eh));
if (m == NULL)
goto done;
}
eh = mtod(m, struct ether_header *);
off += sizeof(*eh);
ac_cookie = NULL;
ac_cookie_len = 0;
relay_sid = NULL;
relay_sid_len = 0;
max_payload = 0;
session = 0;
if (m->m_pkthdr.len - off <= PPPOE_HEADERLEN) {
printf("pppoe: packet too short: %d\n", m->m_pkthdr.len);
goto done;
}
n = m_pulldown(m, off, sizeof(*ph), &noff);
if (n == NULL) {
printf("pppoe: could not get PPPoE header\n");
m = NULL;
goto done;
}
ph = (struct pppoehdr *)(mtod(n, caddr_t) + noff);
if (ph->vertype != PPPOE_VERTYPE) {
printf("pppoe: unknown version/type packet: 0x%x\n",
ph->vertype);
goto done;
}
session = ntohs(ph->session);
plen = ntohs(ph->plen);
code = ph->code;
off += sizeof(*ph);
if (plen + off > m->m_pkthdr.len) {
printf("pppoe: packet content does not fit: data available = %d, packet size = %u\n",
m->m_pkthdr.len - off, plen);
goto done;
}
m_adj(m, off + plen - m->m_pkthdr.len);
tag = 0;
len = 0;
sc = NULL;
while (off + sizeof(*pt) <= m->m_pkthdr.len) {
n = m_pulldown(m, off, sizeof(*pt), &noff);
if (n == NULL) {
printf("%s: parse error\n", devname);
m = NULL;
goto done;
}
pt = (struct pppoetag *)(mtod(n, caddr_t) + noff);
tag = ntohs(pt->tag);
len = ntohs(pt->len);
off += sizeof(*pt);
if (off + len > m->m_pkthdr.len) {
printf("%s: tag 0x%x len 0x%x is too long\n",
devname, tag, len);
goto done;
}
switch (tag) {
case PPPOE_TAG_EOL:
goto breakbreak;
case PPPOE_TAG_SNAME:
break;
case PPPOE_TAG_ACNAME:
break;
case PPPOE_TAG_HUNIQUE:
if (sc != NULL)
break;
n = m_pulldown(m, off, len, &noff);
if (n == NULL) {
m = NULL;
err_msg = "TAG HUNIQUE ERROR";
break;
}
sc = pppoe_find_softc_by_hunique(mtod(n, caddr_t) + noff,
len, m->m_pkthdr.ph_ifidx);
if (sc != NULL)
devname = sc->sc_sppp.pp_if.if_xname;
break;
case PPPOE_TAG_ACCOOKIE:
if (ac_cookie == NULL) {
n = m_pulldown(m, off, len,
&noff);
if (n == NULL) {
err_msg = "TAG ACCOOKIE ERROR";
m = NULL;
break;
}
ac_cookie = mtod(n, caddr_t) + noff;
ac_cookie_len = len;
}
break;
case PPPOE_TAG_RELAYSID:
if (relay_sid == NULL) {
n = m_pulldown(m, off, len,
&noff);
if (n == NULL) {
err_msg = "TAG RELAYSID ERROR";
m = NULL;
break;
}
relay_sid = mtod(n, caddr_t) + noff;
relay_sid_len = len;
}
break;
case PPPOE_TAG_MAX_PAYLOAD:
if (!max_payloadtag) {
n = m_pulldown(m, off, len,
&noff);
if (n == NULL || len != sizeof(max_payload)) {
err_msg = "TAG MAX_PAYLOAD ERROR";
m = NULL;
break;
}
memcpy(&max_payload, mtod(n, caddr_t) + noff,
sizeof(max_payload));
max_payloadtag = 1;
}
break;
case PPPOE_TAG_SNAME_ERR:
err_msg = "SERVICE NAME ERROR";
errortag = 1;
break;
case PPPOE_TAG_ACSYS_ERR:
err_msg = "AC SYSTEM ERROR";
errortag = 1;
break;
case PPPOE_TAG_GENERIC_ERR:
err_msg = "GENERIC ERROR";
errortag = 1;
break;
}
if (err_msg) {
log(LOG_INFO, "%s: %s: ", devname, err_msg);
if (errortag && len) {
n = m_pulldown(m, off, len,
&noff);
if (n == NULL) {
m = NULL;
} else {
u_int8_t *et = mtod(n, caddr_t) + noff;
while (len--)
addlog("%c", *et++);
}
}
addlog("\n");
goto done;
}
off += len;
}
breakbreak:
switch (code) {
case PPPOE_CODE_PADI:
case PPPOE_CODE_PADR:
goto done;
case PPPOE_CODE_PADO:
if (sc == NULL) {
if (!LIST_EMPTY(&pppoe_softc_list))
printf("pppoe: received PADO but could not find request for it\n");
goto done;
}
if (sc->sc_state != PPPOE_STATE_PADI_SENT) {
printf("%s: received unexpected PADO\n",
sc->sc_sppp.pp_if.if_xname);
goto done;
}
if (ac_cookie) {
if (sc->sc_ac_cookie)
free(sc->sc_ac_cookie, M_DEVBUF,
sc->sc_ac_cookie_len);
sc->sc_ac_cookie = malloc(ac_cookie_len, M_DEVBUF,
M_DONTWAIT);
if (sc->sc_ac_cookie == NULL) {
sc->sc_ac_cookie_len = 0;
goto done;
}
sc->sc_ac_cookie_len = ac_cookie_len;
memcpy(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
} else if (sc->sc_ac_cookie) {
free(sc->sc_ac_cookie, M_DEVBUF, sc->sc_ac_cookie_len);
sc->sc_ac_cookie = NULL;
sc->sc_ac_cookie_len = 0;
}
if (relay_sid) {
if (sc->sc_relay_sid)
free(sc->sc_relay_sid, M_DEVBUF,
sc->sc_relay_sid_len);
sc->sc_relay_sid = malloc(relay_sid_len, M_DEVBUF,
M_DONTWAIT);
if (sc->sc_relay_sid == NULL) {
sc->sc_relay_sid_len = 0;
goto done;
}
sc->sc_relay_sid_len = relay_sid_len;
memcpy(sc->sc_relay_sid, relay_sid, relay_sid_len);
} else if (sc->sc_relay_sid) {
free(sc->sc_relay_sid, M_DEVBUF, sc->sc_relay_sid_len);
sc->sc_relay_sid = NULL;
sc->sc_relay_sid_len = 0;
}
if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MTU &&
(!max_payloadtag ||
ntohs(max_payload) != sc->sc_sppp.pp_if.if_mtu)) {
printf("%s: No valid PPP-Max-Payload tag received in PADO\n",
sc->sc_sppp.pp_if.if_xname);
sc->sc_sppp.pp_if.if_mtu = PPPOE_MTU;
}
memcpy(&sc->sc_dest, eh->ether_shost, sizeof(sc->sc_dest));
sc->sc_padr_retried = 0;
pppoe_set_state(sc, PPPOE_STATE_PADR_SENT);
if ((err = pppoe_send_padr(sc)) != 0) {
PPPOEDEBUG(("%s: failed to send PADR, error=%d\n",
sc->sc_sppp.pp_if.if_xname, err));
}
timeout_add_sec(&sc->sc_timeout,
PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried));
break;
case PPPOE_CODE_PADS:
if (sc == NULL)
goto done;
KERNEL_ASSERT_LOCKED();
sc->sc_session = session;
timeout_del(&sc->sc_timeout);
PPPOEDEBUG(("%s: session 0x%x connected\n",
sc->sc_sppp.pp_if.if_xname, session));
sc->sc_state = PPPOE_STATE_SESSION;
getmicrouptime(&sc->sc_session_time);
SMR_LIST_INSERT_HEAD_LOCKED(&pppoe_sessions, sc,
sc_session_entry);
sc->sc_sppp.pp_up(&sc->sc_sppp);
break;
case PPPOE_CODE_PADT:
if (sc == NULL)
goto done;
timeout_del(&sc->sc_timeout);
PPPOEDEBUG(("%s: session 0x%x terminated, received PADT\n",
sc->sc_sppp.pp_if.if_xname, session));
pppoe_set_state(sc, PPPOE_STATE_PADR_SENT);
memcpy(&sc->sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest));
if (sc->sc_ac_cookie) {
free(sc->sc_ac_cookie, M_DEVBUF,
sc->sc_ac_cookie_len);
sc->sc_ac_cookie = NULL;
}
if (sc->sc_relay_sid) {
free(sc->sc_relay_sid, M_DEVBUF, sc->sc_relay_sid_len);
sc->sc_relay_sid = NULL;
}
sc->sc_ac_cookie_len = 0;
sc->sc_relay_sid_len = 0;
sc->sc_session = 0;
sc->sc_session_time.tv_sec = 0;
sc->sc_session_time.tv_usec = 0;
sc->sc_sppp.pp_down(&sc->sc_sppp);
break;
default:
printf("%s: unknown code (0x%04x) session = 0x%04x\n",
sc ? sc->sc_sppp.pp_if.if_xname : "pppoe",
code, session);
break;
}
done:
m_freem(m);
}
void
pppoe_disc_input(struct mbuf *m)
{
if (!LIST_EMPTY(&pppoe_softc_list)) {
KASSERT(m->m_flags & M_PKTHDR);
pppoe_dispatch_disc_pkt(m);
} else
m_freem(m);
}
struct mbuf *
pppoe_vinput(struct ifnet *ifp0, struct mbuf *m, struct netstack *ns)
{
struct pppoe_softc *sc;
struct ifnet *ifp;
struct ether_header *eh;
struct pppoehdr *ph;
uint16_t proto;
int hlen = sizeof(*eh) + sizeof(*ph);
int phlen;
int plen;
int af = AF_UNSPEC;
#if NBPFILTER > 0
caddr_t if_bpf;
#endif
time_t now;
smr_read_enter();
sc = SMR_LIST_FIRST(&pppoe_sessions);
smr_read_leave();
if (sc == NULL)
return (m);
if (m->m_pkthdr.len < hlen)
return (m);
if (m->m_len < hlen) {
m = m_pullup(m, hlen);
if (m == NULL)
return (NULL);
}
eh = mtod(m, struct ether_header *);
ph = (struct pppoehdr *)(eh + 1);
if (ph->vertype != PPPOE_VERTYPE)
return (m);
if (ph->code != 0)
return (m);
sc = pppoe_smr_find_by_session(ntohs(ph->session), ifp0->if_index);
if (sc == NULL) {
m_freem(m);
return (NULL);
}
ifp = &sc->sc_sppp.pp_if;
plen = ntohs(ph->plen);
if (plen < sizeof(proto))
goto drop;
phlen = hlen + sizeof(proto);
if (m->m_pkthdr.len < phlen)
goto drop;
if (m->m_len < phlen) {
m = m_pullup(m, phlen);
if (m == NULL)
goto put;
}
proto = *(uint16_t *)(mtod(m, caddr_t) + hlen);
af = sppp_proto_up(ifp, proto);
if (af == AF_UNSPEC)
goto put;
#if NBPFILTER > 0
if_bpf = sc->sc_bpf;
if (if_bpf) {
m_adj(m, sizeof(*eh));
bpf_mtap(sc->sc_bpf, m, BPF_DIRECTION_IN);
m_adj(m, phlen - sizeof(*eh));
} else
#endif
m_adj(m, phlen);
plen -= sizeof(proto);
if (m->m_pkthdr.len < plen) {
counters_inc(ifp->if_counters, ifc_ierrors);
goto drop;
}
if (m->m_pkthdr.len > plen)
m_adj(m, plen - m->m_pkthdr.len);
now = getuptime();
if (sc->sc_sppp.pp_last_activity < now)
sc->sc_sppp.pp_last_activity = now;
m->m_pkthdr.ph_family = af;
if_vinput(ifp, m, ns);
done:
m = NULL;
put:
if_put(ifp);
return (m);
drop:
m_freem(m);
goto done;
}
void
pppoe_data_input(struct mbuf *m)
{
struct pppoe_softc *sc;
struct pppoehdr *ph;
u_int16_t session, plen;
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
u_int8_t shost[ETHER_ADDR_LEN];
#endif
if (LIST_EMPTY(&pppoe_softc_list))
goto drop;
KASSERT(m->m_flags & M_PKTHDR);
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
memcpy(shost, mtod(m, struct ether_header*)->ether_shost, ETHER_ADDR_LEN);
#endif
m_adj(m, sizeof(struct ether_header));
if (m->m_pkthdr.len <= PPPOE_HEADERLEN) {
printf("pppoe (data): dropping too short packet: %d bytes\n",
m->m_pkthdr.len);
goto drop;
}
if (m->m_len < sizeof(*ph)) {
m = m_pullup(m, sizeof(*ph));
if (m == NULL) {
printf("pppoe (data): could not get PPPoE header\n");
return;
}
}
ph = mtod(m, struct pppoehdr *);
if (ph->vertype != PPPOE_VERTYPE) {
printf("pppoe (data): unknown version/type packet: 0x%x\n",
ph->vertype);
goto drop;
}
if (ph->code != 0)
goto drop;
session = ntohs(ph->session);
sc = pppoe_find_softc_by_session(session, m->m_pkthdr.ph_ifidx);
if (sc == NULL) {
#ifdef PPPOE_TERM_UNKNOWN_SESSIONS
printf("pppoe (data): input for unknown session 0x%x, sending PADT\n",
session);
pppoe_send_padt(m->m_pkthdr.ph_ifidx, session, shost, 0);
#endif
goto drop;
}
plen = ntohs(ph->plen);
#if NBPFILTER > 0
if (sc->sc_bpf)
bpf_mtap(sc->sc_bpf, m, BPF_DIRECTION_IN);
#endif
m_adj(m, PPPOE_HEADERLEN);
#ifdef PPPOE_DEBUG
{
struct mbuf *p;
printf("%s: pkthdr.len=%d, pppoe.len=%d",
sc->sc_sppp.pp_if.if_xname,
m->m_pkthdr.len, plen);
p = m;
while (p) {
printf(" l=%d", p->m_len);
p = p->m_next;
}
printf("\n");
}
#endif
if (m->m_pkthdr.len < plen)
goto drop;
m->m_pkthdr.ph_ifidx = sc->sc_sppp.pp_if.if_index;
sc->sc_sppp.pp_if.if_ipackets++;
sppp_input(&sc->sc_sppp.pp_if, m);
return;
drop:
m_freem(m);
}
static int
pppoe_output(struct pppoe_softc *sc, struct mbuf *m)
{
struct sockaddr dst;
struct ether_header *eh;
struct ifnet *eth_if;
u_int16_t etype;
int ret;
if ((eth_if = if_get(sc->sc_eth_ifidx)) == NULL) {
m_freem(m);
return (EIO);
}
if ((eth_if->if_flags & (IFF_UP|IFF_RUNNING))
!= (IFF_UP|IFF_RUNNING)) {
if_put(eth_if);
m_freem(m);
return (ENETDOWN);
}
memset(&dst, 0, sizeof dst);
dst.sa_family = AF_UNSPEC;
eh = (struct ether_header*)&dst.sa_data;
etype = sc->sc_state == PPPOE_STATE_SESSION ? ETHERTYPE_PPPOE : ETHERTYPE_PPPOEDISC;
eh->ether_type = htons(etype);
memcpy(&eh->ether_dhost, &sc->sc_dest, sizeof sc->sc_dest);
PPPOEDEBUG(("%s (%x) state=%d, session=0x%x output -> %s, len=%d\n",
sc->sc_sppp.pp_if.if_xname, etype,
sc->sc_state, sc->sc_session,
ether_sprintf((unsigned char *)&sc->sc_dest), m->m_pkthdr.len));
m->m_flags &= ~(M_BCAST|M_MCAST);
m->m_pkthdr.ph_rtableid = eth_if->if_rdomain;
ret = eth_if->if_output(eth_if, m, &dst, NULL);
if_put(eth_if);
return (ret);
}
static int
pppoe_ioctl(struct ifnet *ifp, unsigned long cmd, caddr_t data)
{
struct proc *p = curproc;
struct pppoe_softc *sc = (struct pppoe_softc *)ifp;
struct ifnet *eth_if;
int error = 0;
switch (cmd) {
case PPPOESETPARMS:
{
struct pppoediscparms *parms = (struct pppoediscparms *)data;
int len;
if ((error = suser(p)) != 0)
return (error);
if (parms->eth_ifname[0] != '\0') {
struct ifnet *eth_if;
eth_if = if_unit(parms->eth_ifname);
if (eth_if == NULL || eth_if->if_type != IFT_ETHER) {
if_put(eth_if);
sc->sc_eth_ifidx = 0;
return (ENXIO);
}
if (sc->sc_sppp.pp_if.if_mtu >
eth_if->if_mtu - PPPOE_OVERHEAD) {
sc->sc_sppp.pp_if.if_mtu = eth_if->if_mtu -
PPPOE_OVERHEAD;
}
sc->sc_eth_ifidx = eth_if->if_index;
if_put(eth_if);
}
if (sc->sc_concentrator_name)
free(sc->sc_concentrator_name, M_DEVBUF,
strlen(sc->sc_concentrator_name) + 1);
sc->sc_concentrator_name = NULL;
len = strlen(parms->ac_name);
if (len > 0 && len < sizeof(parms->ac_name)) {
char *p = malloc(len + 1, M_DEVBUF, M_WAITOK|M_CANFAIL);
if (p == NULL)
return (ENOMEM);
strlcpy(p, parms->ac_name, len + 1);
sc->sc_concentrator_name = p;
}
if (sc->sc_service_name)
free(sc->sc_service_name, M_DEVBUF,
strlen(sc->sc_service_name) + 1);
sc->sc_service_name = NULL;
len = strlen(parms->service_name);
if (len > 0 && len < sizeof(parms->service_name)) {
char *p = malloc(len + 1, M_DEVBUF, M_WAITOK|M_CANFAIL);
if (p == NULL)
return (ENOMEM);
strlcpy(p, parms->service_name, len + 1);
sc->sc_service_name = p;
}
return (0);
}
break;
case PPPOEGETPARMS:
{
struct pppoediscparms *parms = (struct pppoediscparms *)data;
if ((eth_if = if_get(sc->sc_eth_ifidx)) != NULL) {
strlcpy(parms->eth_ifname, eth_if->if_xname,
IFNAMSIZ);
if_put(eth_if);
} else
parms->eth_ifname[0] = '\0';
if (sc->sc_concentrator_name)
strlcpy(parms->ac_name, sc->sc_concentrator_name,
sizeof(parms->ac_name));
else
parms->ac_name[0] = '\0';
if (sc->sc_service_name)
strlcpy(parms->service_name, sc->sc_service_name,
sizeof(parms->service_name));
else
parms->service_name[0] = '\0';
return (0);
}
break;
case PPPOEGETSESSION:
{
struct pppoeconnectionstate *state =
(struct pppoeconnectionstate *)data;
state->state = sc->sc_state;
state->session_id = sc->sc_session;
state->padi_retry_no = sc->sc_padi_retried;
state->padr_retry_no = sc->sc_padr_retried;
state->session_time.tv_sec = sc->sc_session_time.tv_sec;
state->session_time.tv_usec = sc->sc_session_time.tv_usec;
return (0);
}
break;
case SIOCSIFFLAGS:
{
struct ifreq *ifr = (struct ifreq *)data;
if ((ifr->ifr_flags & IFF_UP) == 0
&& sc->sc_state >= PPPOE_STATE_PADI_SENT
&& sc->sc_state < PPPOE_STATE_SESSION) {
timeout_del(&sc->sc_timeout);
pppoe_set_state(sc, PPPOE_STATE_INITIAL);
sc->sc_padi_retried = 0;
sc->sc_padr_retried = 0;
memcpy(&sc->sc_dest, etherbroadcastaddr,
sizeof(sc->sc_dest));
}
return (sppp_ioctl(ifp, cmd, data));
}
case SIOCSIFMTU:
{
struct ifreq *ifr = (struct ifreq *)data;
eth_if = if_get(sc->sc_eth_ifidx);
if (ifr->ifr_mtu > MIN(PPPOE_MAXMTU,
(eth_if == NULL ? PPPOE_MAXMTU :
(eth_if->if_mtu - PPPOE_OVERHEAD))))
error = EINVAL;
else
error = 0;
if_put(eth_if);
if (error != 0)
return (error);
return (sppp_ioctl(ifp, cmd, data));
}
default:
error = sppp_ioctl(ifp, cmd, data);
if (error == ENETRESET) {
error = 0;
if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
(IFF_UP | IFF_RUNNING)) {
if_down(ifp);
if (sc->sc_state >= PPPOE_STATE_PADI_SENT &&
sc->sc_state < PPPOE_STATE_SESSION) {
timeout_del(&sc->sc_timeout);
pppoe_set_state(sc,
PPPOE_STATE_INITIAL);
sc->sc_padi_retried = 0;
sc->sc_padr_retried = 0;
memcpy(&sc->sc_dest,
etherbroadcastaddr,
sizeof(sc->sc_dest));
}
error = sppp_ioctl(ifp, SIOCSIFFLAGS, NULL);
if (error)
return (error);
if_up(ifp);
return (sppp_ioctl(ifp, SIOCSIFFLAGS, NULL));
}
}
return (error);
}
return (0);
}
static struct mbuf *
pppoe_get_mbuf(size_t len)
{
struct mbuf *m;
if (len + sizeof(struct ether_header) > MCLBYTES)
return NULL;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return (NULL);
if (len + sizeof(struct ether_header) > MHLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_free(m);
return (NULL);
}
}
m->m_data += sizeof(struct ether_header);
m->m_len = len;
m->m_pkthdr.len = len;
m->m_pkthdr.ph_ifidx = 0;
return (m);
}
static int
pppoe_send_padi(struct pppoe_softc *sc)
{
struct mbuf *m0;
int len, l1 = 0, l2 = 0;
u_int8_t *p;
if (sc->sc_state > PPPOE_STATE_PADI_SENT)
panic("pppoe_send_padi in state %d", sc->sc_state);
len = 2 + 2 + 2 + 2 + sizeof(sc->sc_unique);
if (sc->sc_service_name != NULL) {
l1 = strlen(sc->sc_service_name);
len += l1;
}
if (sc->sc_concentrator_name != NULL) {
l2 = strlen(sc->sc_concentrator_name);
len += 2 + 2 + l2;
}
if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MTU)
len += 2 + 2 + 2;
m0 = pppoe_get_mbuf(len + PPPOE_HEADERLEN);
if (m0 == NULL)
return (ENOBUFS);
m0->m_pkthdr.pf.prio = sc->sc_sppp.pp_if.if_llprio;
p = mtod(m0, u_int8_t *);
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, len);
PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
if (sc->sc_service_name != NULL) {
PPPOE_ADD_16(p, l1);
memcpy(p, sc->sc_service_name, l1);
p += l1;
} else {
PPPOE_ADD_16(p, 0);
}
if (sc->sc_concentrator_name != NULL) {
PPPOE_ADD_16(p, PPPOE_TAG_ACNAME);
PPPOE_ADD_16(p, l2);
memcpy(p, sc->sc_concentrator_name, l2);
p += l2;
}
PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
PPPOE_ADD_16(p, sizeof(sc->sc_unique));
memcpy(p, &sc->sc_unique, sizeof(sc->sc_unique));
p += sizeof(sc->sc_unique);
if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MTU) {
PPPOE_ADD_16(p, PPPOE_TAG_MAX_PAYLOAD);
PPPOE_ADD_16(p, 2);
PPPOE_ADD_16(p, (u_int16_t)sc->sc_sppp.pp_if.if_mtu);
}
#ifdef PPPOE_DEBUG
if (p - mtod(m0, u_int8_t *) != len + PPPOE_HEADERLEN)
panic("pppoe_send_padi: garbled output len, should be %ld, is %ld",
(long)(len + PPPOE_HEADERLEN), (long)(p - mtod(m0, u_int8_t *)));
#endif
return (pppoe_output(sc, m0));
}
static void
pppoe_timeout(void *arg)
{
struct pppoe_softc *sc = (struct pppoe_softc *)arg;
int x, retry_wait, err;
PPPOEDEBUG(("%s: timeout\n", sc->sc_sppp.pp_if.if_xname));
NET_LOCK();
switch (sc->sc_state) {
case PPPOE_STATE_PADI_SENT:
retry_wait = PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried);
x = splnet();
sc->sc_padi_retried++;
if (sc->sc_padi_retried >= PPPOE_DISC_MAXPADI) {
if ((sc->sc_sppp.pp_if.if_flags & IFF_LINK1) == 0) {
retry_wait = PPPOE_SLOW_RETRY;
} else {
pppoe_abort_connect(sc);
splx(x);
break;
}
}
if ((err = pppoe_send_padi(sc)) != 0) {
sc->sc_padi_retried--;
PPPOEDEBUG(("%s: failed to transmit PADI, error=%d\n",
sc->sc_sppp.pp_if.if_xname, err));
}
timeout_add_sec(&sc->sc_timeout, retry_wait);
splx(x);
break;
case PPPOE_STATE_PADR_SENT:
x = splnet();
sc->sc_padr_retried++;
if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) {
memcpy(&sc->sc_dest, etherbroadcastaddr,
sizeof(sc->sc_dest));
pppoe_set_state(sc, PPPOE_STATE_PADI_SENT);
sc->sc_padr_retried = 0;
if ((err = pppoe_send_padi(sc)) != 0) {
PPPOEDEBUG(("%s: failed to send PADI, error=%d\n",
sc->sc_sppp.pp_if.if_xname, err));
}
timeout_add_sec(&sc->sc_timeout,
PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried));
splx(x);
break;
}
if ((err = pppoe_send_padr(sc)) != 0) {
sc->sc_padr_retried--;
PPPOEDEBUG(("%s: failed to send PADR, error=%d\n",
sc->sc_sppp.pp_if.if_xname, err));
}
timeout_add_sec(&sc->sc_timeout,
PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried));
splx(x);
break;
case PPPOE_STATE_CLOSING:
pppoe_disconnect(sc);
break;
default:
break;
}
NET_UNLOCK();
}
static int
pppoe_connect(struct pppoe_softc *sc)
{
int x, err;
if (sc->sc_state != PPPOE_STATE_INITIAL)
return (EBUSY);
x = splnet();
pppoe_set_state(sc, PPPOE_STATE_PADI_SENT);
sc->sc_padr_retried = 0;
err = pppoe_send_padi(sc);
if (err != 0)
PPPOEDEBUG(("%s: failed to send PADI, error=%d\n",
sc->sc_sppp.pp_if.if_xname, err));
timeout_add_sec(&sc->sc_timeout, PPPOE_DISC_TIMEOUT);
splx(x);
return (err);
}
static int
pppoe_disconnect(struct pppoe_softc *sc)
{
int err, x;
x = splnet();
if (sc->sc_state < PPPOE_STATE_SESSION)
err = EBUSY;
else {
PPPOEDEBUG(("%s: disconnecting\n",
sc->sc_sppp.pp_if.if_xname));
err = pppoe_send_padt(sc->sc_eth_ifidx,
sc->sc_session, (const u_int8_t *)&sc->sc_dest,
sc->sc_sppp.pp_if.if_llprio);
}
pppoe_set_state(sc, PPPOE_STATE_INITIAL);
memcpy(&sc->sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest));
if (sc->sc_ac_cookie) {
free(sc->sc_ac_cookie, M_DEVBUF, sc->sc_ac_cookie_len);
sc->sc_ac_cookie = NULL;
}
sc->sc_ac_cookie_len = 0;
if (sc->sc_relay_sid) {
free(sc->sc_relay_sid, M_DEVBUF, sc->sc_relay_sid_len);
sc->sc_relay_sid = NULL;
}
sc->sc_relay_sid_len = 0;
sc->sc_session = 0;
sc->sc_sppp.pp_down(&sc->sc_sppp);
splx(x);
return (err);
}
static void
pppoe_abort_connect(struct pppoe_softc *sc)
{
printf("%s: could not establish connection\n",
sc->sc_sppp.pp_if.if_xname);
pppoe_set_state(sc, PPPOE_STATE_CLOSING);
sc->sc_sppp.pp_down(&sc->sc_sppp);
memcpy(&sc->sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest));
pppoe_set_state(sc, PPPOE_STATE_INITIAL);
}
static int
pppoe_send_padr(struct pppoe_softc *sc)
{
struct mbuf *m0;
u_int8_t *p;
size_t len, l1 = 0;
if (sc->sc_state != PPPOE_STATE_PADR_SENT)
return (EIO);
len = 2 + 2 + 2 + 2 + sizeof(sc->sc_unique);
if (sc->sc_service_name != NULL) {
l1 = strlen(sc->sc_service_name);
len += l1;
}
if (sc->sc_ac_cookie_len > 0)
len += 2 + 2 + sc->sc_ac_cookie_len;
if (sc->sc_relay_sid_len > 0)
len += 2 + 2 + sc->sc_relay_sid_len;
if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MTU)
len += 2 + 2 + 2;
m0 = pppoe_get_mbuf(len + PPPOE_HEADERLEN);
if (m0 == NULL)
return (ENOBUFS);
m0->m_pkthdr.pf.prio = sc->sc_sppp.pp_if.if_llprio;
p = mtod(m0, u_int8_t *);
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len);
PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
if (sc->sc_service_name != NULL) {
PPPOE_ADD_16(p, l1);
memcpy(p, sc->sc_service_name, l1);
p += l1;
} else {
PPPOE_ADD_16(p, 0);
}
if (sc->sc_ac_cookie_len > 0) {
PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE);
PPPOE_ADD_16(p, sc->sc_ac_cookie_len);
memcpy(p, sc->sc_ac_cookie, sc->sc_ac_cookie_len);
p += sc->sc_ac_cookie_len;
}
if (sc->sc_relay_sid_len > 0) {
PPPOE_ADD_16(p, PPPOE_TAG_RELAYSID);
PPPOE_ADD_16(p, sc->sc_relay_sid_len);
memcpy(p, sc->sc_relay_sid, sc->sc_relay_sid_len);
p += sc->sc_relay_sid_len;
}
PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
PPPOE_ADD_16(p, sizeof(sc->sc_unique));
memcpy(p, &sc->sc_unique, sizeof(sc->sc_unique));
p += sizeof(sc->sc_unique);
if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MTU) {
PPPOE_ADD_16(p, PPPOE_TAG_MAX_PAYLOAD);
PPPOE_ADD_16(p, 2);
PPPOE_ADD_16(p, (u_int16_t)sc->sc_sppp.pp_if.if_mtu);
}
#ifdef PPPOE_DEBUG
if (p - mtod(m0, u_int8_t *) != len + PPPOE_HEADERLEN)
panic("pppoe_send_padr: garbled output len, should be %ld, is %ld",
(long)(len + PPPOE_HEADERLEN), (long)(p - mtod(m0, u_int8_t *)));
#endif
return (pppoe_output(sc, m0));
}
static int
pppoe_send_padt(unsigned int ifidx, u_int session, const u_int8_t *dest, u_int8_t prio)
{
struct ether_header *eh;
struct sockaddr dst;
struct ifnet *eth_if;
struct mbuf *m0;
u_int8_t *p;
int ret;
if ((eth_if = if_get(ifidx)) == NULL)
return (EINVAL);
m0 = pppoe_get_mbuf(PPPOE_HEADERLEN);
if (m0 == NULL) {
if_put(eth_if);
return (ENOBUFS);
}
m0->m_pkthdr.pf.prio = prio;
p = mtod(m0, u_int8_t *);
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADT, session, 0);
memset(&dst, 0, sizeof(dst));
dst.sa_family = AF_UNSPEC;
eh = (struct ether_header *)&dst.sa_data;
eh->ether_type = htons(ETHERTYPE_PPPOEDISC);
memcpy(&eh->ether_dhost, dest, ETHER_ADDR_LEN);
m0->m_flags &= ~(M_BCAST|M_MCAST);
m0->m_pkthdr.ph_rtableid = eth_if->if_rdomain;
ret = eth_if->if_output(eth_if, m0, &dst, NULL);
if_put(eth_if);
return (ret);
}
static void
pppoe_tls(struct sppp *sp)
{
struct pppoe_softc *sc = (void *)sp;
if (sc->sc_state != PPPOE_STATE_INITIAL)
return;
pppoe_connect(sc);
}
static void
pppoe_tlf(struct sppp *sp)
{
struct pppoe_softc *sc = (void *)sp;
if (sc->sc_state < PPPOE_STATE_SESSION)
return;
pppoe_set_state(sc, PPPOE_STATE_CLOSING);
timeout_add_msec(&sc->sc_timeout, 20);
}
int
pppoe_transmit(struct pppoe_softc *sc, struct mbuf *m)
{
size_t len;
uint8_t *p;
#if NBPFILTER > 0
struct ifnet *ifp = &sc->sc_sppp.pp_if;
caddr_t if_bpf;
#endif
len = m->m_pkthdr.len;
M_PREPEND(m, PPPOE_HEADERLEN, M_DONTWAIT);
if (m == NULL)
return (ENOBUFS);
p = mtod(m, u_int8_t *);
PPPOE_ADD_HEADER(p, 0, sc->sc_session, len);
#if NBPFILTER > 0
if_bpf = ifp->if_bpf;
if (if_bpf && m->m_pkthdr.ph_family != AF_UNSPEC) {
struct m_hdr mh;
struct mbuf *n;
int off;
n = m_getptr(m, PPPOE_OVERHEAD, &off);
KASSERT(n != NULL);
mh.mh_flags = 0;
mh.mh_next = n->m_next;
mh.mh_len = n->m_len - off;
mh.mh_data = n->m_data + off;
bpf_mtap_af(if_bpf, m->m_pkthdr.ph_family,
(struct mbuf *)&mh, BPF_DIRECTION_OUT);
}
if_bpf = sc->sc_bpf;
if (if_bpf)
bpf_mtap(if_bpf, m, BPF_DIRECTION_OUT);
#endif
return (pppoe_output(sc, m));
}
int
pppoe_enqueue(struct ifnet *ifp, struct mbuf *m)
{
struct pppoe_softc *sc;
int error;
if (!ifq_is_priq(&ifp->if_snd))
return (if_enqueue_ifq(ifp, m));
sc = ifp->if_softc;
if (sc->sc_state < PPPOE_STATE_SESSION) {
m_freem(m);
return (ENETDOWN);
}
error = pppoe_transmit(sc, m);
if (error != 0)
counters_inc(ifp->if_counters, ifc_oerrors);
return (error);
}
static void
pppoe_start(struct ifnet *ifp)
{
struct pppoe_softc *sc = (void *)ifp;
struct mbuf *m;
if (sppp_isempty(ifp))
return;
if (sc->sc_state < PPPOE_STATE_SESSION) {
sppp_flush(&sc->sc_sppp.pp_if);
return;
}
while ((m = sppp_dequeue(ifp)) != NULL)
pppoe_transmit(sc, m);
}