Module Name: src
Committed By: maxv
Date: Sat Oct 27 06:46:43 UTC 2018
Modified Files:
src/sys/net: if_pppoe.c
Log Message:
Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/net/if_pppoe.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.145 src/sys/net/if_pppoe.c:1.146
--- src/sys/net/if_pppoe.c:1.145 Sat Oct 27 05:56:10 2018
+++ src/sys/net/if_pppoe.c Sat Oct 27 06:46:43 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.145 2018/10/27 05:56:10 maxv Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.146 2018/10/27 06:46:43 maxv Exp $ */
/*
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.145 2018/10/27 05:56:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.146 2018/10/27 06:46:43 maxv Exp $");
#ifdef _KERNEL_OPT
#include "pppoe.h"
@@ -572,11 +572,6 @@ pppoe_dispatch_disc_pkt(struct mbuf *m,
struct ifnet *rcvif;
struct psref psref;
- /* as long as we don't know which instance */
- strlcpy(devname, "pppoe", sizeof(devname));
-
- err_msg = NULL;
- errortag = 0;
if (m->m_len < sizeof(*eh)) {
m = m_pullup(m, sizeof(*eh));
if (m == NULL)
@@ -585,37 +580,30 @@ pppoe_dispatch_disc_pkt(struct mbuf *m,
eh = mtod(m, struct ether_header *);
off += sizeof(*eh);
- ac_cookie = NULL;
- ac_cookie_len = 0;
- relay_sid = NULL;
- relay_sid_len = 0;
- hunique = NULL;
- hunique_len = 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) {
- printf("pppoe: could not get PPPoE header\n");
- m = NULL;
+ M_REGION_GET(ph, struct pppoehdr *, m, off, sizeof(*ph));
+ if (ph == NULL) {
goto done;
}
- ph = (struct pppoehdr *)(mtod(n, char *) + noff);
if (ph->vertype != PPPOE_VERTYPE) {
- printf("pppoe: unknown version/type packet: 0x%x\n",
- ph->vertype);
goto done;
}
+
+ ac_cookie = NULL;
+ ac_cookie_len = 0;
+ relay_sid = NULL;
+ relay_sid_len = 0;
+ hunique = NULL;
+ hunique_len = 0;
+
session = ntohs(ph->session);
plen = ntohs(ph->plen);
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); /* ignore trailing garbage */
@@ -623,19 +611,17 @@ pppoe_dispatch_disc_pkt(struct mbuf *m,
tag = 0;
len = 0;
sc = NULL;
+ err_msg = NULL;
+ errortag = 0;
while (off + sizeof(*pt) <= m->m_pkthdr.len) {
- n = m_pulldown(m, off, sizeof(*pt), &noff);
- if (!n) {
- printf("%s: parse error\n", devname);
- m = NULL;
+ M_REGION_GET(pt, struct pppoetag *, m, off, sizeof(*pt));
+ if (pt == NULL) {
goto done;
}
- pt = (struct pppoetag *)(mtod(n, char *) + noff);
+
tag = ntohs(pt->tag);
len = ntohs(pt->len);
if (off + len + sizeof(*pt) > m->m_pkthdr.len) {
- printf("pppoe: tag 0x%x len 0x%x is too long\n",
- tag, len);
goto done;
}
switch (tag) {
@@ -730,11 +716,10 @@ pppoe_dispatch_disc_pkt(struct mbuf *m,
}
}
if (error) {
- printf("%s: %s: %s\n", devname,
- err_msg, error);
+ printf("pppoe: %s: %s\n", err_msg, error);
free(error, M_TEMP);
} else
- printf("%s: %s\n", devname, err_msg);
+ printf("pppoe: %s\n", err_msg);
if (errortag || m == NULL)
goto done;
}
@@ -802,8 +787,6 @@ breakbreak:;
* get sc from ac_cookie if IFF_PASSIVE
*/
if (ac_cookie == NULL) {
- /* be quiet if there is not a single pppoe instance */
- printf("pppoe: received PADR but not includes ac_cookie\n");
goto done;
}
@@ -1064,27 +1047,23 @@ pppoe_data_input(struct mbuf *m)
}
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: 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)
+ if (ph->code != 0) {
goto drop;
+ }
session = ntohs(ph->session);
rcvif = m_get_rcvif_psref(m, &psref);