Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys *_drain() routines may be called with locks held, so ins...



details:   https://anonhg.NetBSD.org/src/rev/ddd2e9439de6
branches:  trunk
changeset: 764775:ddd2e9439de6
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Tue May 03 17:44:30 2011 +0000

description:
*_drain() routines may be called with locks held, so instead of doing
any work in *_drain(), set a drain-needed flag.  Do the work in the
fasttimo handler.

Contributed by Coyote Point Systems, Inc.

diffstat:

 sys/netinet/in_proto.c   |  10 ++++++----
 sys/netinet/ip_input.c   |  21 +++++++++++++++++++--
 sys/netinet/ip_var.h     |   4 +++-
 sys/netinet/tcp_subr.c   |  21 +++++++++++++++++++--
 sys/netinet/tcp_var.h    |   4 +++-
 sys/netinet6/frag6.c     |  21 +++++++++++++++++++--
 sys/netinet6/in6_proto.c |  10 ++++++----
 sys/netinet6/ip6_var.h   |   4 +++-
 8 files changed, 78 insertions(+), 17 deletions(-)

diffs (truncated from 303 to 300 lines):

diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet/in_proto.c
--- a/sys/netinet/in_proto.c    Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet/in_proto.c    Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_proto.c,v 1.100 2011/03/31 19:40:52 dyoung Exp $    */
+/*     $NetBSD: in_proto.c,v 1.101 2011/05/03 17:44:31 dyoung Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.100 2011/03/31 19:40:52 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.101 2011/05/03 17:44:31 dyoung Exp $");
 
 #include "opt_mrouting.h"
 #include "opt_eon.h"                   /* ISO CLNL over IP */
@@ -215,8 +215,9 @@
 {      .pr_domain = &inetdomain,
        .pr_init = ip_init,
        .pr_output = ip_output,
+       .pr_fasttimo = ip_fasttimo,
        .pr_slowtimo = ip_slowtimo,
-       .pr_drain = ip_drain,
+       .pr_drain = ip_drainstub,
 },
 {      .pr_type = SOCK_DGRAM,
        .pr_domain = &inetdomain,
@@ -237,8 +238,9 @@
        .pr_ctloutput = tcp_ctloutput,
        .pr_usrreq = tcp_usrreq,
        .pr_init = tcp_init,
+       .pr_fasttimo = tcp_fasttimo,
        .pr_slowtimo = tcp_slowtimo,
-       .pr_drain = tcp_drain,
+       .pr_drain = tcp_drainstub,
 },
 {      .pr_type = SOCK_RAW,
        .pr_domain = &inetdomain,
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet/ip_input.c
--- a/sys/netinet/ip_input.c    Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet/ip_input.c    Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_input.c,v 1.294 2011/04/14 20:32:04 dyoung Exp $    */
+/*     $NetBSD: ip_input.c,v 1.295 2011/05/03 17:44:31 dyoung Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.294 2011/04/14 20:32:04 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.295 2011/05/03 17:44:31 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
@@ -278,6 +278,8 @@
        struct  in_addr route[MAX_IPOPTLEN/sizeof(struct in_addr)];
 } ip_srcrt;
 
+static int ip_drainwanted;
+
 static void save_rte(u_char *, struct in_addr);
 
 #ifdef MBUFTRACE
@@ -1282,6 +1284,21 @@
        [PRC_PARAMPROB] = ENOPROTOOPT,
 };
 
+void
+ip_fasttimo(void)
+{
+       if (ip_drainwanted) {
+               ip_drain();
+               ip_drainwanted = 0;
+       }
+}
+
+void
+ip_drainstub(void)
+{
+       ip_drainwanted = 1;
+}
+
 /*
  * Forward a packet.  If some error occurs return the sender
  * an icmp packet.  Note we can't always generate a meaningful
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet/ip_var.h
--- a/sys/netinet/ip_var.h      Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet/ip_var.h      Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_var.h,v 1.96 2010/11/05 00:21:51 rmind Exp $        */
+/*     $NetBSD: ip_var.h,v 1.97 2011/05/03 17:44:31 dyoung Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -185,6 +185,7 @@
 int     ip_ctloutput(int, struct socket *, struct sockopt *);
 int     ip_dooptions(struct mbuf *);
 void    ip_drain(void);
+void    ip_drainstub(void);
 void    ip_forward(struct mbuf *, int);
 void    ip_freemoptions(struct ip_moptions *);
 int     ip_getmoptions(struct ip_moptions *, struct sockopt *);
@@ -206,6 +207,7 @@
           struct mbuf *);
 int     ip_setmoptions(struct ip_moptions **, const struct sockopt *);
 void    ip_slowtimo(void);
+void    ip_fasttimo(void);
 struct mbuf *
         ip_srcroute(void);
 int     ip_sysctl(int *, u_int, void *, size_t *, void *, size_t);
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c    Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet/tcp_subr.c    Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_subr.c,v 1.239 2011/04/20 13:35:51 gdt Exp $       */
+/*     $NetBSD: tcp_subr.c,v 1.240 2011/05/03 17:44:31 dyoung Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.239 2011/04/20 13:35:51 gdt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.240 2011/05/03 17:44:31 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -234,6 +234,8 @@
 
 static struct pool tcpcb_pool;
 
+static int tcp_drainwanted;
+
 #ifdef TCP_CSUM_COUNTERS
 #include <sys/device.h>
 
@@ -1292,6 +1294,21 @@
        return (rv);
 }
 
+void
+tcp_fasttimo(void)
+{
+       if (tcp_drainwanted) {
+               tcp_drain();
+               tcp_drainwanted = 0;
+       }
+}
+
+void
+tcp_drainstub(void)
+{
+       tcp_drainwanted = 1;
+}
+
 /*
  * Protocol drain routine.  Called when memory is in short supply.
  * Don't acquire softnet_lock as can be called from hardware
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h     Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet/tcp_var.h     Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_var.h,v 1.164 2011/04/20 13:35:52 gdt Exp $        */
+/*     $NetBSD: tcp_var.h,v 1.165 2011/05/03 17:44:31 dyoung Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -890,6 +890,7 @@
            char *);
 #endif
 void    tcp_drain(void);
+void    tcp_drainstub(void);
 void    tcp_established(struct tcpcb *);
 void    tcp_init(void);
 #ifdef INET6
@@ -929,6 +930,7 @@
            int, u_char *, u_int);
 #endif
 void    tcp_slowtimo(void);
+void    tcp_fasttimo(void);
 struct mbuf *
         tcp_template(struct tcpcb *);
 void    tcp_trace(short, short, struct tcpcb *, struct mbuf *, int);
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet6/frag6.c
--- a/sys/netinet6/frag6.c      Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet6/frag6.c      Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frag6.c,v 1.48 2011/01/22 18:26:36 mlelstv Exp $       */
+/*     $NetBSD: frag6.c,v 1.49 2011/05/03 17:44:30 dyoung Exp $        */
 /*     $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $  */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.48 2011/01/22 18:26:36 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.49 2011/05/03 17:44:30 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,6 +65,8 @@
 static void frag6_freef(struct ip6q *);
 
 static int ip6q_locked;
+static int frag6_drainwanted;
+
 u_int frag6_nfragpackets;
 u_int frag6_nfrags;
 struct ip6q ip6q;      /* ip6 reassemble queue */
@@ -670,6 +672,15 @@
        p6->ip6q_next->ip6q_prev = p6->ip6q_prev;
 }
 
+void
+frag6_fasttimo(void)
+{
+       if (frag6_drainwanted) {
+               frag6_drain();
+               frag6_drainwanted = 0;
+       }
+}
+
 /*
  * IPv6 reassembling timer processing;
  * if a timer expires on a reassembly
@@ -722,6 +733,12 @@
        mutex_exit(softnet_lock);
 }
 
+void
+frag6_drainstub(void)
+{
+       frag6_drainwanted = 1;
+}
+
 /*
  * Drain off all datagram fragments.
  */
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet6/in6_proto.c
--- a/sys/netinet6/in6_proto.c  Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet6/in6_proto.c  Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_proto.c,v 1.90 2011/03/31 19:40:52 dyoung Exp $    */
+/*     $NetBSD: in6_proto.c,v 1.91 2011/05/03 17:44:30 dyoung Exp $    */
 /*     $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $      */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.90 2011/03/31 19:40:52 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.91 2011/05/03 17:44:30 dyoung Exp $");
 
 #include "opt_gateway.h"
 #include "opt_inet.h"
@@ -193,8 +193,9 @@
 {      .pr_domain = &inet6domain,
        .pr_protocol = IPPROTO_IPV6,
        .pr_init = ip6_init,
+       .pr_fasttimo = frag6_fasttimo,
        .pr_slowtimo = frag6_slowtimo,
-       .pr_drain = frag6_drain,
+       .pr_drain = frag6_drainstub,
 },
 {      .pr_type = SOCK_DGRAM,
        .pr_domain = &inet6domain,
@@ -216,8 +217,9 @@
        .pr_usrreq = tcp_usrreq,
 #ifndef INET   /* don't call initialization and timeout routines twice */
        .pr_init = tcp_init,
+       .pr_fasttimo = tcp_fasttimo,
        .pr_slowtimo = tcp_slowtimo,
-       .pr_drain = tcp_drain,
+       .pr_drain = tcp_drainstub,
 #endif
 },
 {      .pr_type = SOCK_RAW,
diff -r e350a72c2291 -r ddd2e9439de6 sys/netinet6/ip6_var.h
--- a/sys/netinet6/ip6_var.h    Tue May 03 16:25:19 2011 +0000
+++ b/sys/netinet6/ip6_var.h    Tue May 03 17:44:30 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_var.h,v 1.53 2009/05/06 21:41:59 elad Exp $        */
+/*     $NetBSD: ip6_var.h,v 1.54 2011/05/03 17:44:30 dyoung Exp $      */
 /*     $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $        */
 
 /*
@@ -358,7 +358,9 @@
 void   frag6_init(void);
 int    frag6_input(struct mbuf **, int *, int);
 void   frag6_slowtimo(void);
+void   frag6_fasttimo(void);
 void   frag6_drain(void);
+void   frag6_drainstub(void);



Home | Main Index | Thread Index | Old Index