From 3e8db1fe645f236bad116b565f3d4b8790388e65 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 31 Jul 2017 11:50:46 +0800 Subject: [PATCH] icmp6: Don't use pffasttimo and dispatch fasttimo to netisr0 Reported-by: ivadasz --- sys/netinet/icmp6.h | 1 - sys/netinet6/icmp6.c | 43 ++++++++++++++++++++++++++++++++++++++-- sys/netinet6/in6_proto.c | 2 +- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index 43e1e3ce41..b4838553c1 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -695,7 +695,6 @@ void icmp6_init (void); void icmp6_paramerror (struct mbuf *, int); void icmp6_error (struct mbuf *, int, int, int); int icmp6_input (struct mbuf **, int *, int); -void icmp6_fasttimo (void); void icmp6_reflect (struct mbuf *, size_t); void icmp6_prepare (struct mbuf *); void icmp6_redirect_input (struct mbuf *, int); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index dff8cc1cd4..24b3418bcb 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -85,6 +85,8 @@ #include #include #include +#include +#include #include #include @@ -138,6 +140,8 @@ #define in6p_ip6_nxt inp_ipv6.ip6_nxt #endif +#define ICMP6_FASTTIMO (hz / 5) + /* * ppratecheck() is available, so define it here. */ @@ -172,15 +176,28 @@ static int ni6_store_addrs (struct icmp6_nodeinfo *, struct icmp6_nodeinfo *, struct ifnet *, int); static int icmp6_notify_error (struct mbuf *, int, int, int); +static void icmp6_fasttimo(void *); +static void icmp6_fasttimo_dispatch(netmsg_t); + #ifdef COMPAT_RFC1885 static struct route_in6 icmp6_reflect_rt; #endif +static struct callout icmp6_fasttimo_ch; +static struct netmsg_base icmp6_fasttimo_nmsg; void icmp6_init(void) { + mld6_init(); + + callout_init_mp(&icmp6_fasttimo_ch); + netmsg_init(&icmp6_fasttimo_nmsg, NULL, &netisr_adone_rport, + MSGF_PRIORITY, icmp6_fasttimo_dispatch); + + callout_reset_bycpu(&icmp6_fasttimo_ch, ICMP6_FASTTIMO, + icmp6_fasttimo, NULL, 0); } static void @@ -2119,11 +2136,33 @@ bad: return; } -void -icmp6_fasttimo(void) +static void +icmp6_fasttimo_dispatch(netmsg_t nmsg) { + ASSERT_NETISR_NCPUS(curthread, 0); + + /* Reply ASAP. */ + crit_enter(); + netisr_replymsg(&nmsg->base, 0); + crit_exit(); + mld6_fasttimeo(); + + callout_reset(&icmp6_fasttimo_ch, ICMP6_FASTTIMO, icmp6_fasttimo, NULL); +} + +static void +icmp6_fasttimo(void *dummy __unused) +{ + struct netmsg_base *nmsg = &icmp6_fasttimo_nmsg; + + KKASSERT(mycpuid == 0); + + crit_enter(); + if (nmsg->lmsg.ms_flags & MSGF_DONE) + netisr_sendmsg_oncpu(nmsg); + crit_exit(); } static const char * diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index b2170d76fe..73dae9a4b5 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -225,7 +225,7 @@ struct protosw inet6sw[] = { .pr_ctlport = cpu0_ctlport, .pr_init = icmp6_init, - .pr_fasttimo = icmp6_fasttimo, + .pr_fasttimo = NULL, .pr_slowtimo = NULL, .pr_drain = NULL, -- 2.41.0