From c6a7dd8e5916c5324ec6172fa54940ce40caf09f Mon Sep 17 00:00:00 2001 From: marcel Date: Sat, 26 Jul 2014 19:27:34 +0000 Subject: [PATCH] The accept filter code is not specific to the FreeBSD IPv4 network stack, so it really should not be under "optional inet". The fact that uipc_accf.c lives under kern/ lends some weight to making it a "standard" file. Moving kern/uipc_accf.c from "optional inet" to "standard" eliminates the need for #ifdef INET in kern/uipc_socket.c. Also, this meant the net.inet.accf.unloadable sysctl needed to move, as net.inet does not exist without networking compiled in (as it lives in netinet/in_proto.c.) The new sysctl has been named net.accf.unloadable. In order to support existing accept filter sysctls, the net.inet.accf node has been added netinet/in_proto.c. Submitted by: Steve Kiernan Obtained from: Juniper Networks, Inc. --- sys/conf/files | 2 +- sys/kern/uipc_accf.c | 5 ++--- sys/kern/uipc_socket.c | 8 ++------ sys/netinet/in_proto.c | 2 ++ 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/sys/conf/files b/sys/conf/files index 2b4ebfbc7901..34d98218050b 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3017,7 +3017,7 @@ kern/tty_outq.c standard kern/tty_pts.c standard kern/tty_tty.c standard kern/tty_ttydisc.c standard -kern/uipc_accf.c optional inet +kern/uipc_accf.c standard kern/uipc_debug.c optional ddb kern/uipc_domain.c standard kern/uipc_mbuf.c standard diff --git a/sys/kern/uipc_accf.c b/sys/kern/uipc_accf.c index 236b60d01cfd..78ddd8641145 100644 --- a/sys/kern/uipc_accf.c +++ b/sys/kern/uipc_accf.c @@ -60,9 +60,8 @@ MALLOC_DEFINE(M_ACCF, "accf", "accept filter data"); static int unloadable = 0; -SYSCTL_DECL(_net_inet); /* XXX: some header should do this for me */ -SYSCTL_NODE(_net_inet, OID_AUTO, accf, CTLFLAG_RW, 0, "Accept filters"); -SYSCTL_INT(_net_inet_accf, OID_AUTO, unloadable, CTLFLAG_RW, &unloadable, 0, +SYSCTL_NODE(_net, OID_AUTO, accf, CTLFLAG_RW, 0, "Accept filters"); +SYSCTL_INT(_net_accf, OID_AUTO, unloadable, CTLFLAG_RW, &unloadable, 0, "Allow unload of accept filters (not recommended)"); /* diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 52c244e97aa2..6abc37a14c68 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -378,11 +378,9 @@ sodealloc(struct socket *so) if (so->so_snd.sb_hiwat) (void)chgsbsize(so->so_cred->cr_uidinfo, &so->so_snd.sb_hiwat, 0, RLIM_INFINITY); -#ifdef INET /* remove acccept filter if one is present. */ if (so->so_accf != NULL) do_setopt_accept_filter(so, NULL); -#endif #ifdef MAC mac_socket_destroy(so); #endif @@ -2402,13 +2400,12 @@ sosetopt(struct socket *so, struct sockopt *sopt) error = ENOPROTOOPT; } else { switch (sopt->sopt_name) { -#ifdef INET case SO_ACCEPTFILTER: error = do_setopt_accept_filter(so, sopt); if (error) goto bad; break; -#endif + case SO_LINGER: error = sooptcopyin(sopt, &l, sizeof l, sizeof l); if (error) @@ -2635,11 +2632,10 @@ sogetopt(struct socket *so, struct sockopt *sopt) return (error); } else { switch (sopt->sopt_name) { -#ifdef INET case SO_ACCEPTFILTER: error = do_getopt_accept_filter(so, sopt); break; -#endif + case SO_LINGER: SOCK_LOCK(so); l.l_onoff = so->so_options & SO_LINGER; diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index e5ebdaa0bab3..94d29e5be679 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -394,3 +394,5 @@ SYSCTL_NODE(_net_inet, IPPROTO_IPCOMP, ipcomp, CTLFLAG_RW, 0, "IPCOMP"); SYSCTL_NODE(_net_inet, IPPROTO_IPIP, ipip, CTLFLAG_RW, 0, "IPIP"); #endif /* IPSEC */ SYSCTL_NODE(_net_inet, IPPROTO_RAW, raw, CTLFLAG_RW, 0, "RAW"); +SYSCTL_NODE(_net_inet, OID_AUTO, accf, CTLFLAG_RW, 0, + "Accept filters");