Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net KNF. No functional change.
details: https://anonhg.NetBSD.org/src/rev/22345ee5bcba
branches: trunk
changeset: 330256:22345ee5bcba
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Tue Jul 01 15:03:58 2014 +0000
description:
KNF. No functional change.
diffstat:
sys/net/if_ppp.c | 2320 +++++++++++++++++++++++++++--------------------------
1 files changed, 1172 insertions(+), 1148 deletions(-)
diffs (truncated from 2706 to 300 lines):
diff -r 79bc915d74e0 -r 22345ee5bcba sys/net/if_ppp.c
--- a/sys/net/if_ppp.c Tue Jul 01 14:04:40 2014 +0000
+++ b/sys/net/if_ppp.c Tue Jul 01 15:03:58 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ppp.c,v 1.145 2014/06/30 12:56:51 ozaki-r Exp $ */
+/* $NetBSD: if_ppp.c,v 1.146 2014/07/01 15:03:58 msaitoh Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.145 2014/06/30 12:56:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.146 2014/07/01 15:03:58 msaitoh Exp $");
#include "ppp.h"
@@ -182,12 +182,12 @@
*/
#define M_IS_CLUSTER(m) ((m)->m_flags & M_EXT)
-#define M_DATASTART(m) \
- (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
+#define M_DATASTART(m) \
+ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_buf : \
(m)->m_flags & M_PKTHDR ? (m)->m_pktdat : (m)->m_dat)
-#define M_DATASIZE(m) \
- (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
+#define M_DATASIZE(m) \
+ (M_IS_CLUSTER(m) ? (m)->m_ext.ext_size : \
(m)->m_flags & M_PKTHDR ? MHLEN: MLEN)
/*
@@ -198,8 +198,8 @@
#define M_HIGHPRI M_LINK0 /* output packet for sc_fastq */
#define M_ERRMARK M_LINK1 /* rx packet following lost/corrupted pkt */
-static int ppp_clone_create(struct if_clone *, int);
-static int ppp_clone_destroy(struct ifnet *);
+static int ppp_clone_create(struct if_clone *, int);
+static int ppp_clone_destroy(struct ifnet *);
static struct ppp_softc *ppp_create(const char *, int);
@@ -226,111 +226,111 @@
void
pppattach(void)
{
- extern struct linesw ppp_disc;
+ extern struct linesw ppp_disc;
- if (ttyldisc_attach(&ppp_disc) != 0)
- panic("pppattach");
+ if (ttyldisc_attach(&ppp_disc) != 0)
+ panic("pppattach");
- mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE);
- LIST_INIT(&ppp_softc_list);
- if_clone_attach(&ppp_cloner);
- RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init);
+ mutex_init(&ppp_list_lock, MUTEX_DEFAULT, IPL_NONE);
+ LIST_INIT(&ppp_softc_list);
+ if_clone_attach(&ppp_cloner);
+ RUN_ONCE(&ppp_compressor_mtx_init, ppp_compressor_init);
}
static struct ppp_softc *
ppp_create(const char *name, int unit)
{
- struct ppp_softc *sc, *sci, *scl = NULL;
+ struct ppp_softc *sc, *sci, *scl = NULL;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAIT|M_ZERO);
- mutex_enter(&ppp_list_lock);
- if (unit == -1) {
- int i = 0;
- LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
- scl = sci;
- if (i < sci->sc_unit) {
- unit = i;
- break;
- } else {
+ mutex_enter(&ppp_list_lock);
+ if (unit == -1) {
+ int i = 0;
+ LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
+ scl = sci;
+ if (i < sci->sc_unit) {
+ unit = i;
+ break;
+ } else {
#ifdef DIAGNOSTIC
- KASSERT(i == sci->sc_unit);
+ KASSERT(i == sci->sc_unit);
#endif
- i++;
- }
+ i++;
+ }
+ }
+ if (unit == -1)
+ unit = i;
+ } else {
+ LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
+ scl = sci;
+ if (unit < sci->sc_unit)
+ break;
+ else if (unit == sci->sc_unit) {
+ free(sc, M_DEVBUF);
+ return NULL;
+ }
+ }
}
- if (unit == -1)
- unit = i;
- } else {
- LIST_FOREACH(sci, &ppp_softc_list, sc_iflist) {
- scl = sci;
- if (unit < sci->sc_unit)
- break;
- else if (unit == sci->sc_unit) {
- free(sc, M_DEVBUF);
- return NULL;
- }
- }
- }
- if (sci != NULL)
- LIST_INSERT_BEFORE(sci, sc, sc_iflist);
- else if (scl != NULL)
- LIST_INSERT_AFTER(scl, sc, sc_iflist);
- else
- LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist);
+ if (sci != NULL)
+ LIST_INSERT_BEFORE(sci, sc, sc_iflist);
+ else if (scl != NULL)
+ LIST_INSERT_AFTER(scl, sc, sc_iflist);
+ else
+ LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_iflist);
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_list_lock);
- if_initname(&sc->sc_if, name, sc->sc_unit = unit);
- callout_init(&sc->sc_timo_ch, 0);
- sc->sc_if.if_softc = sc;
- sc->sc_if.if_mtu = PPP_MTU;
- sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- sc->sc_if.if_type = IFT_PPP;
- sc->sc_if.if_hdrlen = PPP_HDRLEN;
- sc->sc_if.if_dlt = DLT_NULL;
- sc->sc_if.if_ioctl = pppsioctl;
- sc->sc_if.if_output = pppoutput;
+ if_initname(&sc->sc_if, name, sc->sc_unit = unit);
+ callout_init(&sc->sc_timo_ch, 0);
+ sc->sc_if.if_softc = sc;
+ sc->sc_if.if_mtu = PPP_MTU;
+ sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
+ sc->sc_if.if_type = IFT_PPP;
+ sc->sc_if.if_hdrlen = PPP_HDRLEN;
+ sc->sc_if.if_dlt = DLT_NULL;
+ sc->sc_if.if_ioctl = pppsioctl;
+ sc->sc_if.if_output = pppoutput;
#ifdef ALTQ
- sc->sc_if.if_start = ppp_ifstart;
+ sc->sc_if.if_start = ppp_ifstart;
#endif
- IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN);
- sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
- sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
- sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
- /* Ratio of 1:2 packets between the regular and the fast queue */
- sc->sc_maxfastq = 2;
- IFQ_SET_READY(&sc->sc_if.if_snd);
- if_attach(&sc->sc_if);
- if_alloc_sadl(&sc->sc_if);
- bpf_attach(&sc->sc_if, DLT_NULL, 0);
- return sc;
+ IFQ_SET_MAXLEN(&sc->sc_if.if_snd, IFQ_MAXLEN);
+ sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
+ sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
+ sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
+ /* Ratio of 1:2 packets between the regular and the fast queue */
+ sc->sc_maxfastq = 2;
+ IFQ_SET_READY(&sc->sc_if.if_snd);
+ if_attach(&sc->sc_if);
+ if_alloc_sadl(&sc->sc_if);
+ bpf_attach(&sc->sc_if, DLT_NULL, 0);
+ return sc;
}
static int
ppp_clone_create(struct if_clone *ifc, int unit)
{
- return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0;
+ return ppp_create(ifc->ifc_name, unit) == NULL ? EEXIST : 0;
}
static int
ppp_clone_destroy(struct ifnet *ifp)
{
- struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc;
+ struct ppp_softc *sc = (struct ppp_softc *)ifp->if_softc;
- if (sc->sc_devp != NULL)
- return EBUSY; /* Not removing it */
+ if (sc->sc_devp != NULL)
+ return EBUSY; /* Not removing it */
- mutex_enter(&ppp_list_lock);
- LIST_REMOVE(sc, sc_iflist);
- mutex_exit(&ppp_list_lock);
+ mutex_enter(&ppp_list_lock);
+ LIST_REMOVE(sc, sc_iflist);
+ mutex_exit(&ppp_list_lock);
- bpf_detach(ifp);
- if_detach(ifp);
+ bpf_detach(ifp);
+ if_detach(ifp);
- free(sc, M_DEVBUF);
- return 0;
+ free(sc, M_DEVBUF);
+ return 0;
}
/*
@@ -339,49 +339,50 @@
struct ppp_softc *
pppalloc(pid_t pid)
{
- struct ppp_softc *sc = NULL, *scf;
- int i;
+ struct ppp_softc *sc = NULL, *scf;
+ int i;
- mutex_enter(&ppp_list_lock);
- LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) {
- if (scf->sc_xfer == pid) {
- scf->sc_xfer = 0;
- mutex_exit(&ppp_list_lock);
- return scf;
+ mutex_enter(&ppp_list_lock);
+ LIST_FOREACH(scf, &ppp_softc_list, sc_iflist) {
+ if (scf->sc_xfer == pid) {
+ scf->sc_xfer = 0;
+ mutex_exit(&ppp_list_lock);
+ return scf;
+ }
+ if (scf->sc_devp == NULL && sc == NULL)
+ sc = scf;
}
- if (scf->sc_devp == NULL && sc == NULL)
- sc = scf;
- }
- mutex_exit(&ppp_list_lock);
+ mutex_exit(&ppp_list_lock);
- if (sc == NULL)
- sc = ppp_create(ppp_cloner.ifc_name, -1);
+ if (sc == NULL)
+ sc = ppp_create(ppp_cloner.ifc_name, -1);
- sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc);
- if (sc->sc_si == NULL) {
- printf("%s: unable to establish softintr\n", sc->sc_if.if_xname);
- return (NULL);
- }
- sc->sc_flags = 0;
- sc->sc_mru = PPP_MRU;
- sc->sc_relinq = NULL;
- (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats));
+ sc->sc_si = softint_establish(SOFTINT_NET, pppintr, sc);
+ if (sc->sc_si == NULL) {
+ printf("%s: unable to establish softintr\n",
+ sc->sc_if.if_xname);
+ return (NULL);
+ }
+ sc->sc_flags = 0;
+ sc->sc_mru = PPP_MRU;
+ sc->sc_relinq = NULL;
+ (void)memset(&sc->sc_stats, 0, sizeof(sc->sc_stats));
#ifdef VJC
- sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT);
- if (sc->sc_comp)
- sl_compress_init(sc->sc_comp);
+ sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT);
+ if (sc->sc_comp)
+ sl_compress_init(sc->sc_comp);
#endif
#ifdef PPP_COMPRESS
- sc->sc_xc_state = NULL;
- sc->sc_rc_state = NULL;
+ sc->sc_xc_state = NULL;
+ sc->sc_rc_state = NULL;
Home |
Main Index |
Thread Index |
Old Index