svn commit: r361717 - in stable/12/sys: netinet sys
Mark Johnston
markj at FreeBSD.org
Tue Jun 2 00:57:50 UTC 2020
Author: markj
Date: Tue Jun 2 00:57:48 2020
New Revision: 361717
URL: https://svnweb.freebsd.org/changeset/base/361717
Log:
MFC r361263, r361338:
Define a module version for accept filter modules.
PR: 245870
Modified:
stable/12/sys/netinet/accf_data.c
stable/12/sys/netinet/accf_dns.c
stable/12/sys/netinet/accf_http.c
stable/12/sys/sys/socketvar.h
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/netinet/accf_data.c
==============================================================================
--- stable/12/sys/netinet/accf_data.c Tue Jun 2 00:56:10 2020 (r361716)
+++ stable/12/sys/netinet/accf_data.c Tue Jun 2 00:57:48 2020 (r361717)
@@ -42,20 +42,7 @@ __FBSDID("$FreeBSD$");
static int sohasdata(struct socket *so, void *arg, int waitflag);
-static struct accept_filter accf_data_filter = {
- "dataready",
- sohasdata,
- NULL,
- NULL
-};
-
-static moduledata_t accf_data_mod = {
- "accf_data",
- accept_filt_generic_mod_event,
- &accf_data_filter
-};
-
-DECLARE_MODULE(accf_data, accf_data_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
+ACCEPT_FILTER_DEFINE(accf_data, "dataready", sohasdata, NULL, NULL, 1);
static int
sohasdata(struct socket *so, void *arg, int waitflag)
Modified: stable/12/sys/netinet/accf_dns.c
==============================================================================
--- stable/12/sys/netinet/accf_dns.c Tue Jun 2 00:56:10 2020 (r361716)
+++ stable/12/sys/netinet/accf_dns.c Tue Jun 2 00:57:48 2020 (r361717)
@@ -41,6 +41,8 @@
/* check for full DNS request */
static int sohasdns(struct socket *so, void *arg, int waitflag);
+ACCEPT_FILTER_DEFINE(accf_dns, "dnsready", sohasdns, NULL, NULL, 1);
+
struct packet {
struct mbuf *m; /* Current mbuf. */
struct mbuf *n; /* nextpkt mbuf. */
@@ -55,21 +57,6 @@ struct packet {
/* check we can skip over various parts of DNS request */
static int skippacket(struct sockbuf *sb);
-
-static struct accept_filter accf_dns_filter = {
- "dnsready",
- sohasdns,
- NULL,
- NULL
-};
-
-static moduledata_t accf_dns_mod = {
- "accf_dns",
- accept_filt_generic_mod_event,
- &accf_dns_filter
-};
-
-DECLARE_MODULE(accf_dns, accf_dns_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
static int
sohasdns(struct socket *so, void *arg, int waitflag)
Modified: stable/12/sys/netinet/accf_http.c
==============================================================================
--- stable/12/sys/netinet/accf_http.c Tue Jun 2 00:56:10 2020 (r361716)
+++ stable/12/sys/netinet/accf_http.c Tue Jun 2 00:57:48 2020 (r361717)
@@ -54,28 +54,15 @@ static int mbufstrncmp(struct mbuf *m, struct mbuf *np
/* socketbuffer is full */
static int sbfull(struct sockbuf *sb);
-static struct accept_filter accf_http_filter = {
- "httpready",
- sohashttpget,
- NULL,
- NULL
-};
+ACCEPT_FILTER_DEFINE(accf_http, "httpready", sohashttpget, NULL, NULL, 1);
-static moduledata_t accf_http_mod = {
- "accf_http",
- accept_filt_generic_mod_event,
- &accf_http_filter
-};
-
-DECLARE_MODULE(accf_http, accf_http_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
-
static int parse_http_version = 1;
static SYSCTL_NODE(_net_inet_accf, OID_AUTO, http, CTLFLAG_RW, 0,
"HTTP accept filter");
SYSCTL_INT(_net_inet_accf_http, OID_AUTO, parsehttpversion, CTLFLAG_RW,
-&parse_http_version, 1,
-"Parse http version so that non 1.x requests work");
+ &parse_http_version, 1,
+ "Parse http version so that non 1.x requests work");
#ifdef ACCF_HTTP_DEBUG
#define DPRINT(fmt, args...) \
Modified: stable/12/sys/sys/socketvar.h
==============================================================================
--- stable/12/sys/sys/socketvar.h Tue Jun 2 00:56:10 2020 (r361716)
+++ stable/12/sys/sys/socketvar.h Tue Jun 2 00:57:48 2020 (r361717)
@@ -331,6 +331,22 @@ struct accept_filter {
SLIST_ENTRY(accept_filter) accf_next;
};
+#define ACCEPT_FILTER_DEFINE(modname, filtname, cb, create, destroy, ver) \
+ static struct accept_filter modname##_filter = { \
+ .accf_name = filtname, \
+ .accf_callback = cb, \
+ .accf_create = create, \
+ .accf_destroy = destroy, \
+ }; \
+ static moduledata_t modname##_mod = { \
+ .name = __XSTRING(modname), \
+ .evhand = accept_filt_generic_mod_event, \
+ .priv = &modname##_filter, \
+ }; \
+ DECLARE_MODULE(modname, modname##_mod, SI_SUB_DRIVERS, \
+ SI_ORDER_MIDDLE); \
+ MODULE_VERSION(modname, ver)
+
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_ACCF);
MALLOC_DECLARE(M_PCB);
More information about the svn-src-stable-12
mailing list