netfilter: move socket lookup infrastructure to nf_socket_ipv{4,6}.c
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/1 netfilter: move socket lookup infrastructure to nf_socket_ipv{4,6}.c
We need this split to reuse existing codebase for the upcoming nf_tables socket expression.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
Preparing nft_sk.c expression for RFC, following up soon. Posting this for review now though since this is the initial step.
include/net/netfilter/nf_socket.h | 27 ++++ net/ipv4/netfilter/Kconfig | 6 + net/ipv4/netfilter/Makefile | 2 + net/ipv4/netfilter/nf_socket_ipv4.c | 161 +++++++++++++++++++ net/ipv6/netfilter/Kconfig | 6 + net/ipv6/netfilter/Makefile | 2 + net/ipv6/netfilter/nf_socket_ipv6.c | 149 ++++++++++++++++++ net/netfilter/Kconfig | 3 +- net/netfilter/xt_socket.c | 305 ++---------------------------------- 9 files changed, 365 insertions(+), 296 deletions(-) create mode 100644 include/net/netfilter/nf_socket.h create mode 100644 net/ipv4/netfilter/nf_socket_ipv4.c create mode 100644 net/ipv6/netfilter/nf_socket_ipv6.c
include/net/netfilter/nf_socket.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef _NF_SOCK_H_ +#define _NF_SOCK_H_ + +struct net_device ; +struct sk_buff ; +struct sock ; +struct net ; + +static inline bool nf_sk_is_transparent (struct sock *sk) +{ +switch (sk->sk_state) { +case TCP_TIME_WAIT : +return inet_twsk (sk)->tw_transparent; +case TCP_NEW_SYN_RECV : +return inet_rsk (inet_reqsk (sk))->no_srccheck; +default : +return inet_sk (sk)->transparent; + } +} + +struct sock *nf_sk_lookup_slow_v4 (struct net *net,const struct sk_buff *skb, +const struct net_device *indev); + +struct sock *nf_sk_lookup_slow_v6 (struct net *net,const struct sk_buff *skb, +const struct net_device *indev); + +#endif
net/ipv4/netfilter/Kconfig +6 -0
@@ -25,6 +25,12 @@ config NF_CONNTRACK_IPV4 To compile it as a module, choose M here. If unsure, say N. +config NF_SOCKET_IPV4 + tristate "IPv4 socket lookup support" + help + This option enables the IPv4 socket lookup infrastructure. This is + is required by the iptables socket match. + if NF_TABLES config NF_TABLES_IPV4
net/ipv4/netfilter/Makefile +2 -0
@@ -14,6 +14,8 @@ obj-$(CONFIG_NF_NAT_IPV4) += nf_nat_ipv4.o # defrag obj-$(CONFIG_NF_DEFRAG_IPV4) += nf_defrag_ipv4.o +obj-$(CONFIG_NF_SOCKET_IPV4) += nf_socket_ipv4.o + # logging obj-$(CONFIG_NF_LOG_ARP) += nf_log_arp.o obj-$(CONFIG_NF_LOG_IPV4) += nf_log_ipv4.o
net/ipv4/netfilter/nf_socket_ipv4.c new file +161 -0
161 lines not on this page · raw message
net/ipv6/netfilter/Kconfig +6 -0
@@ -25,6 +25,12 @@ config NF_CONNTRACK_IPV6 To compile it as a module, choose M here. If unsure, say N. +config NF_SOCKET_IPV6 + tristate "IPv6 socket lookup support" + help + This option enables the IPv6 socket lookup infrastructure. This + is used by the ip6tables socket match. + if NF_TABLES config NF_TABLES_IPV6
net/ipv6/netfilter/Makefile +2 -0
@@ -24,6 +24,8 @@ obj-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o obj-$(CONFIG_NF_DEFRAG_IPV6) += nf_defrag_ipv6.o +obj-$(CONFIG_NF_SOCKET_IPV6) += nf_socket_ipv6.o + # logging obj-$(CONFIG_NF_LOG_IPV6) += nf_log_ipv6.o
net/ipv6/netfilter/nf_socket_ipv6.c new file +149 -0
149 lines not on this page · raw message
net/netfilter/Kconfig +2 -1
@@ -1426,9 +1426,10 @@ config NETFILTER_XT_MATCH_SOCKET tristate '"socket" match support' depends on NETFILTER_XTABLES depends on NETFILTER_ADVANCED - depends on !NF_CONNTRACK || NF_CONNTRACK depends on IPV6 || IPV6=n depends on IP6_NF_IPTABLES || IP6_NF_IPTABLES=n + depends on NF_SOCKET_IPV4 + depends on NF_SOCKET_IPV6 select NF_DEFRAG_IPV4 select NF_DEFRAG_IPV6 if IP6_NF_IPTABLES != n help
net/netfilter/xt_socket.c +10 -295
378 lines not on this page · raw message
Signature · 1 line
2.1.4