From 5d6e356cb05900f328872aa4456f6cc8f58aa2d7 Mon Sep 17 00:00:00 2001 From: "Jonathan T. Looney" Date: Thu, 16 Apr 2020 20:17:24 +0000 Subject: [PATCH] Avoid calling protocol drain routines more than once per reclamation event. mb_reclaim() calls the protocol drain routines for each protocol in each domain. Some protocols exist in more than one domain and share drain routines. In the case of SCTP, it also uses the same drain routine for its SOCK_SEQPACKET and SOCK_STREAM entries in the same domain. On systems with INET, INET6, and SCTP all defined, mb_reclaim() calls sctp_drain() four times. On systems with INET and INET6 defined, mb_reclaim() calls tcp_drain() twice. mb_reclaim() is the only in-tree caller of the pr_drain protocol entry. Eliminate this duplication by ensuring that each pr_drain routine is only specified for one protocol entry in one domain. Reviewed by: tuexen MFC after: 2 weeks Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D24418 --- sys/netinet/in_proto.c | 2 +- sys/netinet6/in6_proto.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index 49e02c3c5b06..d4e7a881f025 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -163,7 +163,7 @@ struct protosw inetsw[] = { .pr_input = sctp_input, .pr_ctlinput = sctp_ctlinput, .pr_ctloutput = sctp_ctloutput, - .pr_drain = sctp_drain, + .pr_drain = NULL, /* Covered by the SOCK_SEQPACKET entry. */ .pr_usrreqs = &sctp_usrreqs }, #endif /* SCTP */ diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 0583ffd901ea..23cd010ea7a3 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -172,11 +172,11 @@ struct protosw inet6sw[] = { .pr_input = tcp6_input, .pr_ctlinput = tcp6_ctlinput, .pr_ctloutput = tcp_ctloutput, -#ifndef INET /* don't call initialization and timeout routines twice */ +#ifndef INET /* don't call initialization, timeout, and drain routines twice */ .pr_init = tcp_init, .pr_slowtimo = tcp_slowtimo, -#endif .pr_drain = tcp_drain, +#endif .pr_usrreqs = &tcp6_usrreqs, }, #ifdef SCTP @@ -188,8 +188,8 @@ struct protosw inet6sw[] = { .pr_input = sctp6_input, .pr_ctlinput = sctp6_ctlinput, .pr_ctloutput = sctp_ctloutput, +#ifndef INET /* Do not call initialization and drain routines twice. */ .pr_drain = sctp_drain, -#ifndef INET /* Do not call initialization twice. */ .pr_init = sctp_init, #endif .pr_usrreqs = &sctp6_usrreqs @@ -202,7 +202,7 @@ struct protosw inet6sw[] = { .pr_input = sctp6_input, .pr_ctlinput = sctp6_ctlinput, .pr_ctloutput = sctp_ctloutput, - .pr_drain = sctp_drain, + .pr_drain = NULL, /* Covered by the SOCK_SEQPACKET entry. */ .pr_usrreqs = &sctp6_usrreqs }, #endif /* SCTP */