Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Remove printfs that are too easily reachable, switch...
details: https://anonhg.NetBSD.org/src/rev/4e17551e293f
branches: trunk
changeset: 836613:4e17551e293f
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Oct 27 06:46:43 2018 +0000
description:
Remove printfs that are too easily reachable, switch to M_REGION_GET,
and simplify the initialization. No real functional change.
diffstat:
sys/net/if_pppoe.c | 67 ++++++++++++++++++-----------------------------------
1 files changed, 23 insertions(+), 44 deletions(-)
diffs (158 lines):
diff -r 45edd92a75e4 -r 4e17551e293f sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c Sat Oct 27 06:35:54 2018 +0000
+++ b/sys/net/if_pppoe.c Sat Oct 27 06:46:43 2018 +0000
@@ -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 @@
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 @@
eh = mtod(m, struct ether_header *);
off += sizeof(*eh);
+ if (m->m_pkthdr.len - off <= PPPOE_HEADERLEN) {
+ goto done;
+ }
+
+ M_REGION_GET(ph, struct pppoehdr *, m, off, sizeof(*ph));
+ if (ph == NULL) {
+ goto done;
+ }
+ if (ph->vertype != PPPOE_VERTYPE) {
+ goto done;
+ }
+
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;
- 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;
- }
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 @@
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 @@
}
}
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 @@
* 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 @@
}
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);
Home |
Main Index |
Thread Index |
Old Index