Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Tidy up
details: https://anonhg.NetBSD.org/src/rev/065ee3658c5b
branches: trunk
changeset: 343288:065ee3658c5b
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Jan 28 04:37:01 2016 +0000
description:
Tidy up
- KNF
- Remove obsolete ifdefs for other OSes
- Remove unnecessary else block
No functional change.
diffstat:
sys/net/if_atmsubr.c | 130 +++++++++++++++++++++++---------------------------
1 files changed, 59 insertions(+), 71 deletions(-)
diffs (212 lines):
diff -r 91ad908689ca -r 065ee3658c5b sys/net/if_atmsubr.c
--- a/sys/net/if_atmsubr.c Thu Jan 28 03:32:29 2016 +0000
+++ b/sys/net/if_atmsubr.c Thu Jan 28 04:37:01 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_atmsubr.c,v 1.54 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: if_atmsubr.c,v 1.55 2016/01/28 04:37:01 ozaki-r Exp $ */
/*
* Copyright (c) 1996 Charles D. Cranor and Washington University.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_atmsubr.c,v 1.54 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atmsubr.c,v 1.55 2016/01/28 04:37:01 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -108,7 +108,7 @@
* do it before prepending link headers.
*/
IFQ_CLASSIFY(&ifp->if_snd, m,
- (dst != NULL ? dst->sa_family : AF_UNSPEC), &pktattr);
+ (dst != NULL ? dst->sa_family : AF_UNSPEC), &pktattr);
/*
* check for non-native ATM traffic (dst != NULL)
@@ -154,13 +154,8 @@
break;
default:
-#if defined(__NetBSD__) || defined(__OpenBSD__)
printf("%s: can't handle af%d\n", ifp->if_xname,
dst->sa_family);
-#elif defined(__FreeBSD__) || defined(__bsdi__)
- printf("%s%d: can't handle af%d\n", ifp->if_name,
- ifp->if_unit, dst->sa_family);
-#endif
senderr(EAFNOSUPPORT);
}
@@ -169,7 +164,8 @@
*/
sz = sizeof(atmdst);
atm_flags = ATM_PH_FLAGS(&atmdst);
- if (atm_flags & ATM_PH_LLCSNAP) sz += 8; /* sizeof snap == 8 */
+ if (atm_flags & ATM_PH_LLCSNAP)
+ sz += 8; /* sizeof snap == 8 */
M_PREPEND(m, sz, M_DONTWAIT);
if (m == 0)
senderr(ENOBUFS);
@@ -178,7 +174,7 @@
if (atm_flags & ATM_PH_LLCSNAP) {
atmllc = (struct atmllc *)(ad + 1);
memcpy(atmllc->llchdr, ATMLLC_HDR,
- sizeof(atmllc->llchdr));
+ sizeof(atmllc->llchdr));
ATM_LLC_SETTYPE(atmllc, etype);
}
}
@@ -210,59 +206,57 @@
if (rxhand) {
#ifdef NATM
- struct natmpcb *npcb = rxhand;
- struct ifqueue *inq;
- int s, isr = 0;
-
- s = splnet(); /* in case 2 atm cards @ diff lvls */
- npcb->npcb_inq++; /* count # in queue */
- splx(s);
- isr = NETISR_NATM;
- inq = &natmintrq;
- m->m_pkthdr.rcvif = rxhand; /* XXX: overload */
+ struct natmpcb *npcb = rxhand;
+ struct ifqueue *inq;
+ int s, isr = 0;
- s = splnet();
- if (IF_QFULL(inq)) {
- IF_DROP(inq);
- m_freem(m);
- } else {
- IF_ENQUEUE(inq, m);
- schednetisr(isr);
- }
- splx(s);
-#else
- printf("atm_input: NATM detected but not configured in kernel\n");
- m_freem(m);
-#endif
- return;
+ s = splnet(); /* in case 2 atm cards @ diff lvls */
+ npcb->npcb_inq++; /* count # in queue */
+ splx(s);
+ isr = NETISR_NATM;
+ inq = &natmintrq;
+ m->m_pkthdr.rcvif = rxhand; /* XXX: overload */
- } else {
- /*
- * handle LLC/SNAP header, if present
- */
- if (ATM_PH_FLAGS(ah) & ATM_PH_LLCSNAP) {
- struct atmllc *alc;
- if (m->m_len < sizeof(*alc) && (m = m_pullup(m, sizeof(*alc))) == 0)
- return; /* failed */
- alc = mtod(m, struct atmllc *);
- if (memcmp(alc, ATMLLC_HDR, 6)) {
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- printf("%s: recv'd invalid LLC/SNAP frame [vp=%d,vc=%d]\n",
- ifp->if_xname, ATM_PH_VPI(ah), ATM_PH_VCI(ah));
-#elif defined(__FreeBSD__) || defined(__bsdi__)
- printf("%s%d: recv'd invalid LLC/SNAP frame [vp=%d,vc=%d]\n",
- ifp->if_name, ifp->if_unit, ATM_PH_VPI(ah), ATM_PH_VCI(ah));
+ s = splnet();
+ if (IF_QFULL(inq)) {
+ IF_DROP(inq);
+ m_freem(m);
+ } else {
+ IF_ENQUEUE(inq, m);
+ schednetisr(isr);
+ }
+ splx(s);
+#else
+ printf("%s: NATM detected but not configured in kernel\n",
+ __func__);
+ m_freem(m);
#endif
- m_freem(m);
- return;
- }
- etype = ATM_LLC_TYPE(alc);
- m_adj(m, sizeof(*alc));
- }
+ return;
+ }
- switch (etype) {
+ /*
+ * handle LLC/SNAP header, if present
+ */
+ if (ATM_PH_FLAGS(ah) & ATM_PH_LLCSNAP) {
+ struct atmllc *alc;
+ if (m->m_len < sizeof(*alc) &&
+ (m = m_pullup(m, sizeof(*alc))) == NULL)
+ return; /* failed */
+ alc = mtod(m, struct atmllc *);
+ if (memcmp(alc, ATMLLC_HDR, 6)) {
+ printf(
+ "%s: recv'd invalid LLC/SNAP frame [vp=%d,vc=%d]\n",
+ ifp->if_xname, ATM_PH_VPI(ah), ATM_PH_VCI(ah));
+ m_freem(m);
+ return;
+ }
+ etype = ATM_LLC_TYPE(alc);
+ m_adj(m, sizeof(*alc));
+ }
+
+ switch (etype) {
#ifdef INET
- case ETHERTYPE_IP:
+ case ETHERTYPE_IP:
#ifdef GATEWAY
if (ipflow_fastforward(m))
return;
@@ -271,18 +265,17 @@
break;
#endif /* INET */
#ifdef INET6
- case ETHERTYPE_IPV6:
-#ifdef GATEWAY
+ case ETHERTYPE_IPV6:
+#ifdef GATEWAY
if (ip6flow_fastforward(&m))
return;
#endif
pktq = ip6_pktq;
break;
#endif
- default:
- m_freem(m);
- return;
- }
+ default:
+ m_freem(m);
+ return;
}
if (__predict_false(!pktq_enqueue(pktq, m, 0))) {
@@ -324,19 +317,14 @@
struct pvcsif *pvcsif;
if (pvc_number >= pvc_max_number)
- return (NULL);
+ return NULL;
pvcsif = malloc(sizeof(struct pvcsif),
M_DEVBUF, M_WAITOK|M_ZERO);
if (pvcsif == NULL)
- return (NULL);
+ return NULL;
-#ifdef __NetBSD__
snprintf(pvcsif->sif_if.if_xname, sizeof(pvcsif->sif_if.if_xname),
"pvc%d", pvc_number++);
-#else
- pvcsif->sif_if.if_name = "pvc";
- pvcsif->sif_if.if_unit = pvc_number++;
-#endif
return (&pvcsif->sif_if);
}
#endif /* ATM_PVCEXT */
Home |
Main Index |
Thread Index |
Old Index