Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Use m_get_rcvif_psref instead of m_get_rcvif
details: https://anonhg.NetBSD.org/src/rev/c74f6dea9a45
branches: trunk
changeset: 351208:c74f6dea9a45
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue Feb 07 02:33:54 2017 +0000
description:
Use m_get_rcvif_psref instead of m_get_rcvif
Because the critical sections are now sleepable.
Reviewed by knakahara@
diffstat:
sys/net/if_pppoe.c | 46 +++++++++++++++++++++++++++++++---------------
1 files changed, 31 insertions(+), 15 deletions(-)
diffs (110 lines):
diff -r 622fad8d1ff9 -r c74f6dea9a45 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c Tue Feb 07 02:05:26 2017 +0000
+++ b/sys/net/if_pppoe.c Tue Feb 07 02:33:54 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.124 2017/02/01 17:58:47 maxv Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.125 2017/02/07 02:33:54 ozaki-r 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.124 2017/02/01 17:58:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.125 2017/02/07 02:33:54 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "pppoe.h"
@@ -55,6 +55,7 @@
#include <sys/sysctl.h>
#include <sys/rwlock.h>
#include <sys/mutex.h>
+#include <sys/psref.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -640,7 +641,8 @@
break; /* ignored */
case PPPOE_TAG_HUNIQUE: {
struct ifnet *rcvif;
- int s;
+ struct psref psref;
+
if (sc != NULL)
break;
n = m_pulldown(m, off + sizeof(*pt), len, &noff);
@@ -653,10 +655,12 @@
hunique = mtod(n, uint8_t *) + noff;
hunique_len = len;
#endif
- rcvif = m_get_rcvif(m, &s);
- sc = pppoe_find_softc_by_hunique(mtod(n, char *) + noff,
- len, rcvif, RW_READER);
- m_put_rcvif(rcvif, &s);
+ rcvif = m_get_rcvif_psref(m, &psref);
+ if (rcvif != NULL) {
+ sc = pppoe_find_softc_by_hunique(mtod(n, char *) + noff,
+ len, rcvif, RW_READER);
+ }
+ m_put_rcvif_psref(rcvif, &psref);
if (sc != NULL) {
strlcpy(devname, sc->sc_sppp.pp_if.if_xname,
sizeof(devname));
@@ -786,6 +790,9 @@
#endif /* PPPOE_SERVER */
case PPPOE_CODE_PADR:
#ifdef PPPOE_SERVER
+ {
+ struct ifnet *rcvif;
+ struct psref psref;
/*
* get sc from ac_cookie if IFF_PASSIVE
*/
@@ -794,10 +801,15 @@
printf("pppoe: received PADR but not includes ac_cookie\n");
goto done;
}
- sc = pppoe_find_softc_by_hunique(ac_cookie,
- ac_cookie_len,
- m_get_rcvif_NOMPSAFE(m),
- RW_WRITER);
+
+ rcvif = m_get_rcvif_psref(m, &psref);
+ if (__predict_true(rcvif != NULL)) {
+ sc = pppoe_find_softc_by_hunique(ac_cookie,
+ ac_cookie_len,
+ rcvif,
+ RW_WRITER);
+ }
+ m_put_rcvif_psref(rcvif, &psref);
if (sc == NULL) {
/* be quiet if there is not a single pppoe instance */
if (!LIST_EMPTY(&pppoe_softc_list))
@@ -835,6 +847,7 @@
sc->sc_sppp.pp_up(&sc->sc_sppp);
sppp_lock_exit(&sc->sc_sppp);
break;
+ }
#else
/* ignore, we are no access concentrator */
goto done;
@@ -935,11 +948,14 @@
break;
case PPPOE_CODE_PADT: {
struct ifnet *rcvif;
- int s;
+ struct psref psref;
- rcvif = m_get_rcvif(m, &s);
- sc = pppoe_find_softc_by_session(session, rcvif, RW_WRITER);
- m_put_rcvif(rcvif, &s);
+ rcvif = m_get_rcvif_psref(m, &psref);
+ if (__predict_true(rcvif != NULL)) {
+ sc = pppoe_find_softc_by_session(session, rcvif,
+ RW_WRITER);
+ }
+ m_put_rcvif_psref(rcvif, &psref);
if (sc == NULL)
goto done;
Home |
Main Index |
Thread Index |
Old Index