netfilter 00/79: netfilter update
Subsystems (6)
Hi Dave,
following is my netfilter update for 2.6.28, containing:
- a large number of patches for network namespace support from Alexey Dobrian. We're getting close to full netns support.
- Decoupling of netfilter family values from real protocol numbers as preparatory work for making ebtables and arptables use the x_tables infrastructure
- A set of patches from Jan Engelhardt to make ebtables and arptables use the x_tables infrastructure.
- A set of patches from Jan Engelhardt to support and use AF-independant matches and targets.
- ipt_recent IPv6 support from Jan Engelhardt
- Some cleanups (Kconfig, constifying) in the *tables area from Jan
- The TPROXY patches from Krisztian Kovacs
These patches are also available in a git-tree at, based on the latest net-next-2.6.git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6.git
Please apply or pull, thanks.
Documentation/feature-removal-schedule.txt | 3 +
Documentation/networking/tproxy.txt | 85 +++++
include/linux/netfilter.h | 97 ++----
include/linux/netfilter/Kbuild | 1 +
include/linux/netfilter/nf_conntrack_proto_gre.h | 2 +-
include/linux/netfilter/x_tables.h | 161 +++++++---
include/linux/netfilter/xt_TPROXY.h | 14 +
include/linux/netfilter/xt_recent.h | 26 ++
include/linux/netfilter_bridge/ebtables.h | 76 +++--
include/linux/netfilter_ipv4/ipt_recent.h | 28 +-
include/net/net_namespace.h | 6 +
include/net/netfilter/ipv4/nf_defrag_ipv4.h | 6 +
include/net/netfilter/nf_conntrack.h | 34 ++-
include/net/netfilter/nf_conntrack_acct.h | 10 +-
include/net/netfilter/nf_conntrack_core.h | 11 +-
include/net/netfilter/nf_conntrack_ecache.h | 26 +-
include/net/netfilter/nf_conntrack_expect.h | 22 +-
include/net/netfilter/nf_conntrack_l4proto.h | 21 +-
include/net/netfilter/nf_log.h | 8 +-
include/net/netfilter/nf_queue.h | 6 +-
include/net/netfilter/nf_tproxy_core.h | 32 ++
include/net/netns/conntrack.h | 30 ++
include/net/netns/ipv4.h | 3 +
net/bridge/br_netfilter.c | 4 +-
net/bridge/netfilter/Kconfig | 30 +--
net/bridge/netfilter/ebt_802_3.c | 47 ++--
net/bridge/netfilter/ebt_among.c | 85 +++---
net/bridge/netfilter/ebt_arp.c | 73 ++--
net/bridge/netfilter/ebt_arpreply.c | 49 ++--
net/bridge/netfilter/ebt_dnat.c | 57 ++--
net/bridge/netfilter/ebt_ip.c | 72 ++--
net/bridge/netfilter/ebt_ip6.c | 76 ++---
net/bridge/netfilter/ebt_limit.c | 45 ++--
net/bridge/netfilter/ebt_log.c | 57 ++--
net/bridge/netfilter/ebt_mark.c | 41 ++--
net/bridge/netfilter/ebt_mark_m.c | 45 ++--
net/bridge/netfilter/ebt_nflog.c | 44 ++--
net/bridge/netfilter/ebt_pkttype.c | 41 +--
net/bridge/netfilter/ebt_redirect.c | 63 ++--
net/bridge/netfilter/ebt_snat.c | 52 ++--
net/bridge/netfilter/ebt_stp.c | 78 +++---
net/bridge/netfilter/ebt_ulog.c | 58 ++--
net/bridge/netfilter/ebt_vlan.c | 61 ++--
net/bridge/netfilter/ebtables.c | 313 ++++++++----------
net/core/net_namespace.c | 1 +
net/ipv4/netfilter.c | 7 +-
net/ipv4/netfilter/Kconfig | 128 ++++----
net/ipv4/netfilter/Makefile | 4 +-
net/ipv4/netfilter/arp_tables.c | 116 ++++---
net/ipv4/netfilter/arpt_mangle.c | 15 +-
net/ipv4/netfilter/arptable_filter.c | 8 +-
net/ipv4/netfilter/ip_tables.c | 177 +++++-----
net/ipv4/netfilter/ipt_CLUSTERIP.c | 29 +-
net/ipv4/netfilter/ipt_ECN.c | 17 +-
net/ipv4/netfilter/ipt_LOG.c | 21 +-
net/ipv4/netfilter/ipt_MASQUERADE.c | 30 +-
net/ipv4/netfilter/ipt_NETMAP.c | 26 +-
net/ipv4/netfilter/ipt_REDIRECT.c | 21 +-
net/ipv4/netfilter/ipt_REJECT.c | 19 +-
net/ipv4/netfilter/ipt_TTL.c | 15 +-
net/ipv4/netfilter/ipt_ULOG.c | 23 +-
net/ipv4/netfilter/ipt_addrtype.c | 35 +--
net/ipv4/netfilter/ipt_ah.c | 24 +-
net/ipv4/netfilter/ipt_ecn.c | 20 +-
net/ipv4/netfilter/ipt_ttl.c | 9 +-
net/ipv4/netfilter/iptable_filter.c | 6 +-
net/ipv4/netfilter/iptable_mangle.c | 10 +-
net/ipv4/netfilter/iptable_raw.c | 4 +-
net/ipv4/netfilter/iptable_security.c | 6 +-
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 68 +----
.../netfilter/nf_conntrack_l3proto_ipv4_compat.c | 73 +++--
net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 22 +-
net/ipv4/netfilter/nf_defrag_ipv4.c | 96 ++++++
net/ipv4/netfilter/nf_nat_core.c | 72 +++--
net/ipv4/netfilter/nf_nat_helper.c | 2 +-
net/ipv4/netfilter/nf_nat_pptp.c | 3 +-
net/ipv4/netfilter/nf_nat_rule.c | 92 +++---
net/ipv6/netfilter.c | 2 +-
net/ipv6/netfilter/Kconfig | 77 ++---
net/ipv6/netfilter/ip6_tables.c | 173 +++++-----
net/ipv6/netfilter/ip6t_HL.c | 15 +-
net/ipv6/netfilter/ip6t_LOG.c | 22 +-
net/ipv6/netfilter/ip6t_REJECT.c | 39 +--
net/ipv6/netfilter/ip6t_ah.c | 21 +-
net/ipv6/netfilter/ip6t_eui64.c | 11 +-
net/ipv6/netfilter/ip6t_frag.c | 21 +-
net/ipv6/netfilter/ip6t_hbh.c | 25 +-
net/ipv6/netfilter/ip6t_hl.c | 9 +-
net/ipv6/netfilter/ip6t_ipv6header.c | 16 +-
net/ipv6/netfilter/ip6t_mh.c | 25 +-
net/ipv6/netfilter/ip6t_rt.c | 21 +-
net/ipv6/netfilter/ip6table_filter.c | 6 +-
net/ipv6/netfilter/ip6table_mangle.c | 31 ++-
net/ipv6/netfilter/ip6table_raw.c | 20 +-
net/ipv6/netfilter/ip6table_security.c | 6 +-
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 24 +-
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 19 +-
net/netfilter/Kconfig | 236 +++++++------
net/netfilter/Makefile | 6 +
net/netfilter/core.c | 18 +-
net/netfilter/nf_conntrack_acct.c | 100 ++++--
net/netfilter/nf_conntrack_core.c | 344 ++++++++++++--------
net/netfilter/nf_conntrack_ecache.c | 26 +-
net/netfilter/nf_conntrack_expect.c | 104 ++++---
net/netfilter/nf_conntrack_ftp.c | 9 +-
net/netfilter/nf_conntrack_h323_main.c | 6 +-
net/netfilter/nf_conntrack_helper.c | 40 ++-
net/netfilter/nf_conntrack_netlink.c | 31 +-
net/netfilter/nf_conntrack_pptp.c | 36 ++-
net/netfilter/nf_conntrack_proto.c | 10 +-
net/netfilter/nf_conntrack_proto_dccp.c | 20 +-
net/netfilter/nf_conntrack_proto_generic.c | 2 +-
net/netfilter/nf_conntrack_proto_gre.c | 101 +++++--
net/netfilter/nf_conntrack_proto_sctp.c | 6 +-
net/netfilter/nf_conntrack_proto_tcp.c | 35 +-
net/netfilter/nf_conntrack_proto_udp.c | 16 +-
net/netfilter/nf_conntrack_proto_udplite.c | 20 +-
net/netfilter/nf_conntrack_sip.c | 3 +-
net/netfilter/nf_conntrack_standalone.c | 146 +++++---
net/netfilter/nf_internals.h | 4 +-
net/netfilter/nf_log.c | 18 +-
net/netfilter/nf_queue.c | 22 +-
net/netfilter/nf_sockopt.c | 18 +-
net/netfilter/nf_tproxy_core.c | 96 ++++++
net/netfilter/nfnetlink_log.c | 4 +-
net/netfilter/x_tables.c | 145 +++++----
net/netfilter/xt_CLASSIFY.c | 44 +--
net/netfilter/xt_CONNMARK.c | 78 ++----
net/netfilter/xt_CONNSECMARK.c | 63 ++---
net/netfilter/xt_DSCP.c | 59 ++--
net/netfilter/xt_MARK.c | 76 +----
net/netfilter/xt_NFLOG.c | 46 +--
net/netfilter/xt_NFQUEUE.c | 10 +-
net/netfilter/xt_NOTRACK.c | 30 +--
net/netfilter/xt_RATEEST.c | 56 +---
net/netfilter/xt_SECMARK.c | 52 +--
net/netfilter/xt_TCPMSS.c | 38 +--
net/netfilter/xt_TCPOPTSTRIP.c | 16 +-
net/netfilter/xt_TPROXY.c | 102 ++++++
net/netfilter/xt_TRACE.c | 30 +--
net/netfilter/xt_comment.c | 31 +--
net/netfilter/xt_connbytes.c | 56 +--
net/netfilter/xt_connlimit.c | 80 ++---
net/netfilter/xt_connmark.c | 68 +---
net/netfilter/xt_conntrack.c | 62 ++---
net/netfilter/xt_dccp.c | 27 +-
net/netfilter/xt_dscp.c | 51 +--
net/netfilter/xt_esp.c | 25 +-
net/netfilter/xt_hashlimit.c | 104 +++----
net/netfilter/xt_helper.c | 54 +--
net/netfilter/xt_iprange.c | 27 +-
net/netfilter/xt_length.c | 18 +-
net/netfilter/xt_limit.c | 54 +--
net/netfilter/xt_mac.c | 41 +--
net/netfilter/xt_mark.c | 46 +---
net/netfilter/xt_multiport.c | 71 ++---
net/netfilter/xt_owner.c | 51 +---
net/netfilter/xt_physdev.c | 49 +--
net/netfilter/xt_pkttype.c | 37 +--
net/netfilter/xt_policy.c | 34 +--
net/netfilter/xt_quota.c | 43 +--
net/netfilter/xt_rateest.c | 58 +---
net/netfilter/xt_realm.c | 9 +-
.../ipt_recent.c => netfilter/xt_recent.c} | 348 +++++++++++++++-----
net/netfilter/xt_sctp.c | 27 +-
net/netfilter/xt_socket.c | 185 +++++++++++
net/netfilter/xt_state.c | 24 +-
net/netfilter/xt_statistic.c | 45 +--
net/netfilter/xt_string.c | 53 +---
net/netfilter/xt_tcpmss.c | 17 +-
net/netfilter/xt_tcpudp.c | 64 ++---
net/netfilter/xt_time.c | 41 +--
net/netfilter/xt_u32.c | 33 +--
net/sched/act_ipt.c | 46 ++--
174 files changed, 4281 insertions(+), 3901 deletions(-)
create mode 100644 Documentation/networking/tproxy.txt
create mode 100644 include/linux/netfilter/xt_TPROXY.h
create mode 100644 include/linux/netfilter/xt_recent.h
create mode 100644 include/net/netfilter/ipv4/nf_defrag_ipv4.h
create mode 100644 include/net/netfilter/nf_tproxy_core.h
create mode 100644 include/net/netns/conntrack.h
create mode 100644 net/ipv4/netfilter/nf_defrag_ipv4.c
create mode 100644 net/netfilter/nf_tproxy_core.c
create mode 100644 net/netfilter/xt_TPROXY.c
rename net/{ipv4/netfilter/ipt_recent.c => netfilter/xt_recent.c} (51%)
create mode 100644 net/netfilter/xt_socket.cAlexey Dobriyan (38):
netfilter: netns: remove nf_*_net() wrappers
netfilter: netns: ip6table_raw in netns for real
netfilter: netns: ip6table_mangle in netns for real
netfilter: netns: ip6t_REJECT in netns for real
netfilter: netns nf_conntrack: add netns boilerplate
netfilter: netns nf_conntrack: add ->ct_net -- pointer from conntrack to netns
netfilter: netns nf_conntrack: per-netns conntrack count
netfilter: netns nf_conntrack: per-netns conntrack hash
netfilter: netns: fix {ip,6}_route_me_harder() in netns
netfilter: netns nf_conntrack: per-netns expectations
netfilter: netns nf_conntrack: per-netns unconfirmed list
netfilter: netns nf_conntrack: pass netns pointer to nf_conntrack_in()
netfilter: netns nf_conntrack: pass netns pointer to L4 protocol's ->error hook
netfilter: netns nf_conntrack: per-netns /proc/net/nf_conntrack, /proc/net/stat/nf_conntrack
netfilter: netns nf_conntrack: per-netns /proc/net/nf_conntrack_expect
netfilter: netns nf_conntrack: per-netns /proc/net/ip_conntrack, /proc/net/stat/ip_conntrack, /proc/net/ip_conntrack_expect
netns: export netns list
netfilter: netns nf_conntrack: unregister helper in every netns
netfilter: netns nf_conntrack: cleanup after L3 and L4 proto unregister in every netns
netfilter: netns nf_conntrack: pass conntrack to nf_conntrack_event_cache() not skb
netfilter: netns nf_conntrack: per-netns event cache
netfilter: netns nf_conntrack: per-netns statistics
netfilter: netns nf_conntrack: per-netns /proc/net/stat/nf_conntrack, /proc/net/stat/ip_conntrack
netfilter: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_count sysctl
netfilter: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_checksum sysctl
netfilter: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_log_invalid sysctl
netfilter: netns nf_conntrack: per-netns conntrack accounting
netfilter: netns nf_conntrack: final netns tweaks
netfilter: netns nf_conntrack: SIP conntracking in netns
netfilter: netns nf_conntrack: H323 conntracking in netns
netfilter: netns nf_conntrack: GRE conntracking in netns
netfilter: netns nf_conntrack: PPTP conntracking in netns
netfilter: netns nat: fix ipt_MASQUERADE in netns
netfilter: netns nat: per-netns NAT table
netfilter: netns nat: per-netns bysource hash
netfilter: netns nf_conntrack: fixup DNAT in netns
netfilter: netns nat: PPTP NAT in netns
netfilter: enable netfilter in netns
Jan Engelhardt (36):
netfilter: Use unsigned types for hooknum and pf vars
netfilter: rename ipt_recent to xt_recent
netfilter: xt_recent: IPv6 support
netfilter: Introduce NFPROTO_* constants
netfilter: x_tables: use NFPROTO_* in extensions
netfilter: implement NFPROTO_UNSPEC as a wildcard for extensions
netfilter: ebtables: do centralized size checking
netfilter: change return types of check functions for Ebtables extensions
netfilter: change return types of match functions for ebtables extensions
netfilter: Change return types of targets/watchers for Ebtables extensions
netfilter: add dummy members to Ebtables code to ease transition to Xtables
netfilter: ebt_among: obtain match size through different means
netfilter: change Ebtables function signatures to match Xtables's
netfilter: move Ebtables to use Xtables
netfilter: x_tables: output bad hook mask in hexadecimal
netfilter: ebtables: use generic table checking
netfilter: implement hotdrop for Ebtables
netfilter: remove unused Ebtables functions
netfilter: remove redundant casts from Ebtables
netfilter: ebtables: fix one wrong return value
netfilter: xtables: do centralized checkentry call (1/2)
netfilter: ip6tables: fix name of hopbyhop in Kconfig
netfilter: ip6tables: fix Kconfig entry dependency for ip6t_LOG
netfilter: ebtables: make BRIDGE_NF_EBTABLES a menuconfig option
netfilter: xtables: sort extensions alphabetically in Kconfig
netfilter: xtables: use "if" blocks in Kconfig
netfilter: xtables: move extension arguments into compound structure (1/6)
netfilter: xtables: move extension arguments into compound structure (2/6)
netfilter: xtables: move extension arguments into compound structure (3/6)
netfilter: xtables: move extension arguments into compound structure (4/6)
netfilter: xtables: move extension arguments into compound structure (5/6)
netfilter: xtables: move extension arguments into compound structure (6/6)
netfilter: xtables: provide invoked family value to extensions
netfilter: xtables: cut down on static data for family-independent extensions
netfilter: xtables: use NFPROTO_UNSPEC in more extensions
netfilter: xtables: remove bogus mangle table dependency of connmark
KOVACS Krisztian (5):
netfilter: split netfilter IPv4 defragmentation into a separate module
netfilter: iptables tproxy core
netfilter: iptables socket match
netfilter: iptables TPROXY target
netfilter: Add documentation for tproxy
netfilter 01/79: Use unsigned types for hooknum and pf vars
commit 76108cea065cda58366d16a7eb6ca90d717a1396
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:00 2008 +0200
netfilter: Use unsigned types for hooknum and pf vars
and (try to) consistently use u_int8_t for the L3 family.
include/linux/netfilter.h +16 -14
@@ -92,8 +92,8 @@ struct nf_hook_ops/* User fills in from here down. */ nf_hookfn *hook;struct module *owner; -int pf; -int hooknum; +u_int8_t pf; +unsigned int hooknum;/* Hooks are ordered in ascending priority. */ int priority; };
@@ -102,7 +102,7 @@ struct nf_sockopt_ops {struct list_head list; -int pf; +u_int8_t pf;/* Non-inclusive ranges: use 0/0/NULL to never get called. */ int set_optmin;
@@ -140,7 +140,7 @@ extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[];extern struct list_head nf_hooks[NPROTO ][NF_MAX_HOOKS ]; -int nf_hook_slow (int pf,unsigned int hook,struct sk_buff *skb, +int nf_hook_slow (u_int8_t pf,unsigned int hook,struct sk_buff *skb,struct net_device *indev,struct net_device *outdev,int (*okfn)(struct sk_buff *),int thresh);
@@ -151,7 +151,7 @@ int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb,* okfn must be invoked by the caller in this case. Any other return * value indicates the packet has been consumed by the hook. */ -static inline int nf_hook_thresh(int pf, unsigned int hook, +static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook, struct sk_buff *skb, struct net_device *indev, struct net_device *outdev,
@@ -167,7 +167,7 @@ static inline int nf_hook_thresh(int pf, unsigned int hook,return nf_hook_slow (pf, hook, skb, indev, outdev, okfn, thresh); } -static inline int nf_hook (int pf,unsigned int hook,struct sk_buff *skb, +static inline int nf_hook (u_int8_t pf,unsigned int hook,struct sk_buff *skb,struct net_device *indev,struct net_device *outdev,int (*okfn)(struct sk_buff *)) {
@@ -212,14 +212,14 @@ __ret;})NF_HOOK_THRESH (pf, hook, skb, indev, outdev, okfn,INT_MIN ) /* Call setsockopt() */ -int nf_setsockopt (struct sock *sk,int pf,int optval,char __user *opt, +int nf_setsockopt (struct sock *sk,u_int8_t pf,int optval,char __user *opt,int len); -int nf_getsockopt (struct sock *sk,int pf,int optval,char __user *opt, +int nf_getsockopt (struct sock *sk,u_int8_t pf,int optval,char __user *opt,int *len); -int compat_nf_setsockopt (struct sock *sk,int pf,int optval, +int compat_nf_setsockopt (struct sock *sk,u_int8_t pf,int optval,char __user *opt,int len); -int compat_nf_getsockopt (struct sock *sk,int pf,int optval, +int compat_nf_getsockopt (struct sock *sk,u_int8_t pf,int optval,char __user *opt,int *len);/* Call this before modifying an existing packet: ensures it is
@@ -292,7 +292,7 @@ extern void nf_unregister_afinfo(const struct nf_afinfo *afinfo);extern void (*ip_nat_decode_session)(struct sk_buff *,struct flowi *);static inline void -nf_nat_decode_session (struct sk_buff *skb,struct flowi *fl,int family) +nf_nat_decode_session (struct sk_buff *skb,struct flowi *fl,u_int8_t family) {#ifdef CONFIG_NF_NAT_NEEDED void (*decodefn)(struct sk_buff *,struct flowi *);
@@ -315,7 +315,7 @@ extern struct proc_dir_entry *proc_net_netfilter;#else /* !CONFIG_NETFILTER */ #define NF_HOOK (pf, hook, skb, indev, outdev, okfn) (okfn)(skb)#define NF_HOOK_COND (pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb) -static inline int nf_hook_thresh(int pf, unsigned int hook, +static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook, struct sk_buff *skb, struct net_device *indev, struct net_device *outdev,
@@ -324,7 +324,7 @@ static inline int nf_hook_thresh(int pf, unsigned int hook, {return okfn (skb); } -static inline int nf_hook (int pf,unsigned int hook,struct sk_buff *skb, +static inline int nf_hook (u_int8_t pf,unsigned int hook,struct sk_buff *skb,struct net_device *indev,struct net_device *outdev,int (*okfn)(struct sk_buff *)) {
@@ -332,7 +332,9 @@ static inline int nf_hook(int pf, unsigned int hook, struct sk_buff *skb, }struct flowi ;static inline void -nf_nat_decode_session (struct sk_buff *skb,struct flowi *fl,int family) {} +nf_nat_decode_session (struct sk_buff *skb,struct flowi *fl,u_int8_t family) +{ +}#endif /*CONFIG_NETFILTER*/ #if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE )
include/linux/netfilter/x_tables.h +14 -14
@@ -292,7 +292,7 @@ struct xt_table/* Set this to THIS_MODULE if you are a module, otherwise NULL */ struct module *me; -int af;/* address/protocol family */ +u_int8_t af;/* address/protocol family */ };#include <linux/netfilter_ipv4.h>
@@ -346,19 +346,19 @@ extern struct xt_table_info *xt_replace_table(struct xt_table *table,struct xt_table_info *newinfo, int *error); -extern struct xt_match *xt_find_match (int af,const char *name,u8 revision); -extern struct xt_target *xt_find_target (int af,const char *name,u8 revision); -extern struct xt_target *xt_request_find_target (int af,const char *name, +extern struct xt_match *xt_find_match (u8 af,const char *name,u8 revision); +extern struct xt_target *xt_find_target (u8 af,const char *name,u8 revision); +extern struct xt_target *xt_request_find_target (u8 af,const char *name,u8 revision); -extern int xt_find_revision (int af,const char *name,u8 revision,int target, -int *err); +extern int xt_find_revision (u8 af,const char *name,u8 revision, +int target,int *err); -extern struct xt_table *xt_find_table_lock (struct net *net,int af, +extern struct xt_table *xt_find_table_lock (struct net *net,u_int8_t af,const char *name);extern void xt_table_unlock (struct xt_table *t); -extern int xt_proto_init (struct net *net,int af); -extern void xt_proto_fini (struct net *net,int af); +extern int xt_proto_init (struct net *net,u_int8_t af); +extern void xt_proto_fini (struct net *net,u_int8_t af);extern struct xt_table_info *xt_alloc_table_info (unsigned int size);extern void xt_free_table_info (struct xt_table_info *info);
@@ -423,12 +423,12 @@ struct compat_xt_counters_info#define COMPAT_XT_ALIGN (s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \ & ~(__alignof__(struct compat_xt_counters)-1)) -extern void xt_compat_lock (int af); -extern void xt_compat_unlock (int af); +extern void xt_compat_lock (u_int8_t af); +extern void xt_compat_unlock (u_int8_t af); -extern int xt_compat_add_offset (int af,unsigned int offset,short delta); -extern void xt_compat_flush_offsets (int af); -extern short xt_compat_calc_jump (int af,unsigned int offset); +extern int xt_compat_add_offset (u_int8_t af,unsigned int offset,short delta); +extern void xt_compat_flush_offsets (u_int8_t af); +extern short xt_compat_calc_jump (u_int8_t af,unsigned int offset);extern int xt_compat_match_offset (const struct xt_match *match); extern int xt_compat_match_from_user(struct xt_entry_match *m,
include/net/netfilter/nf_conntrack_core.h +1 -1
@@ -20,7 +20,7 @@/* This header is used to share core functionality between the standalone connection tracking module, and the compatibility layer's use of connection tracking. */ -extern unsigned int nf_conntrack_in (int pf, +extern unsigned int nf_conntrack_in (u_int8_t pf,unsigned int hooknum,struct sk_buff *skb);
include/net/netfilter/nf_conntrack_expect.h +1 -1
@@ -86,7 +86,7 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);/* Allocate space for an expectation: this is mandatory before calling nf_ct_expect_related. You will have to call put afterwards. */ struct nf_conntrack_expect *nf_ct_expect_alloc (struct nf_conn *me); -void nf_ct_expect_init (struct nf_conntrack_expect *,unsigned int ,int , +void nf_ct_expect_init (struct nf_conntrack_expect *,unsigned int ,u_int8_t ,const union nf_inet_addr *,const union nf_inet_addr *,u_int8_t ,const __be16 *,const __be16 *);
include/net/netfilter/nf_conntrack_l4proto.h +2 -2
@@ -39,7 +39,7 @@ struct nf_conntrack_l4protoconst struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum);/* Called when a new connection for this protocol found;
@@ -52,7 +52,7 @@ struct nf_conntrack_l4protoint (*error)(struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo, -int pf,unsigned int hooknum); +u_int8_t pf,unsigned int hooknum);/* Print out the per-protocol part of the tuple. Return like seq_* */ int (*print_tuple)(struct seq_file *s,
include/net/netfilter/nf_log.h +4 -4
@@ -28,7 +28,7 @@ struct nf_loginfo { } u; }; -typedef void nf_logfn(unsigned int pf, +typedef void nf_logfn(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
@@ -43,12 +43,12 @@ struct nf_logger { };/* Function to register/unregister log function. */ -int nf_log_register (int pf,const struct nf_logger *logger); +int nf_log_register (u_int8_t pf,const struct nf_logger *logger);void nf_log_unregister (const struct nf_logger *logger); -void nf_log_unregister_pf (int pf); +void nf_log_unregister_pf (u_int8_t pf);/* Calls the registered backend logging function */ -void nf_log_packet(int pf, +void nf_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
include/net/netfilter/nf_queue.h +3 -3
@@ -8,7 +8,7 @@ struct nf_queue_entry {unsigned int id;struct nf_hook_ops *elem; -int pf; +u_int8_t pf;unsigned int hook;struct net_device *indev;struct net_device *outdev;
@@ -24,9 +24,9 @@ struct nf_queue_handler {char *name; }; -extern int nf_register_queue_handler (int pf, +extern int nf_register_queue_handler (u_int8_t pf,const struct nf_queue_handler *qh); -extern int nf_unregister_queue_handler (int pf, +extern int nf_unregister_queue_handler (u_int8_t pf,const struct nf_queue_handler *qh);extern void nf_unregister_queue_handlers (const struct nf_queue_handler *qh);extern void nf_reinject (struct nf_queue_entry *entry,unsigned int verdict);
net/bridge/br_netfilter.c +2 -2
@@ -657,7 +657,7 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb, {struct nf_bridge_info *nf_bridge;struct net_device *parent; -int pf; +u_int8_t pf;if (!skb->nf_bridge)return NF_ACCEPT ;
@@ -791,7 +791,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb, {struct nf_bridge_info *nf_bridge = skb->nf_bridge;struct net_device *realoutdev =bridge_parent (skb->dev); -int pf; +u_int8_t pf;#ifdef CONFIG_NETFILTER_DEBUG /* Be very paranoid. This probably won't happen anymore, but let's
net/bridge/netfilter/ebt_log.c +1 -1
@@ -84,7 +84,7 @@ print_ports(const struct sk_buff *skb, uint8_t protocol, int offset)#define myNIPQUAD (a) a[0], a[1], a[2], a[3]static void -ebt_log_packet (unsigned int pf,unsigned int hooknum, +ebt_log_packet (u_int8_t pf,unsigned int hooknum,const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const struct nf_loginfo *loginfo,const char *prefix)
net/bridge/netfilter/ebt_ulog.c +1 -1
@@ -223,7 +223,7 @@ alloc_failure: }/* this function is registered with the netfilter core */ -static void ebt_log_packet (unsigned int pf,unsigned int hooknum, +static void ebt_log_packet (u_int8_t pf,unsigned int hooknum,const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const struct nf_loginfo *li,const char *prefix)
net/ipv4/netfilter/ipt_LOG.c +1 -1
@@ -375,7 +375,7 @@ static struct nf_loginfo default_loginfo = { }; static void -ipt_log_packet(unsigned int pf, +ipt_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
net/ipv4/netfilter/ipt_ULOG.c +1 -1
@@ -292,7 +292,7 @@ ulog_tg(struct sk_buff *skb, const struct net_device *in,return XT_CONTINUE ; } -static void ipt_logfn(unsigned int pf, +static void ipt_logfn(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +2 -2
@@ -79,7 +79,7 @@ static int icmp_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) {/* Try to delete connection immediately after all replies:
@@ -173,7 +173,7 @@ icmp_error_message(struct sk_buff *skb,/* Small and modified version of icmp_rcv */ static int icmp_error (struct sk_buff *skb,unsigned int dataoff, -enum ip_conntrack_info *ctinfo,int pf,unsigned int hooknum) +enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum) {const struct icmphdr *icmph;struct icmphdr _ih;
net/ipv6/netfilter/ip6t_LOG.c +1 -1
@@ -385,7 +385,7 @@ static struct nf_loginfo default_loginfo = { }; static void -ip6t_log_packet(unsigned int pf, +ip6t_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +2 -2
@@ -81,7 +81,7 @@ static int icmpv6_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) {/* Try to delete connection immediately after all replies:
@@ -173,7 +173,7 @@ icmpv6_error_message(struct sk_buff *skb,static int icmpv6_error (struct sk_buff *skb,unsigned int dataoff, -enum ip_conntrack_info *ctinfo,int pf,unsigned int hooknum) +enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum) {const struct icmp6hdr *icmp6h;struct icmp6hdr _ih;
net/netfilter/core.c +2 -2
@@ -113,7 +113,7 @@ EXPORT_SYMBOL(nf_unregister_hooks); unsigned int nf_iterate(struct list_head *head, struct sk_buff *skb, - int hook, + unsigned int hook, const struct net_device *indev, const struct net_device *outdev, struct list_head **i,
@@ -155,7 +155,7 @@ unsigned int nf_iterate(struct list_head *head,/* Returns 1 if okfn() needs to be executed by the caller, * -EPERM for NF_DROP, 0 otherwise. */ -int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb, +int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb, struct net_device *indev, struct net_device *outdev, int (*okfn)(struct sk_buff *),
net/netfilter/nf_conntrack_core.c +3 -3
@@ -665,7 +665,7 @@ resolve_normal_ct(struct sk_buff *skb, }unsigned int -nf_conntrack_in (int pf,unsigned int hooknum,struct sk_buff *skb) +nf_conntrack_in (u_int8_t pf,unsigned int hooknum,struct sk_buff *skb) {struct nf_conn *ct;enum ip_conntrack_info ctinfo;
@@ -683,7 +683,7 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff *skb) }/* rcu_read_lock()ed by nf_hook_slow */ - l3proto =__nf_ct_l3proto_find ((u_int16_t )pf); + l3proto =__nf_ct_l3proto_find (pf); ret = l3proto->get_l4proto (skb,skb_network_offset (skb), &dataoff, &protonum);if (ret <=0 ) {
@@ -693,7 +693,7 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff *skb)return -ret; } - l4proto =__nf_ct_l4proto_find ((u_int16_t )pf, protonum); + l4proto =__nf_ct_l4proto_find (pf, protonum);/* It may be an special packet, error, unclean... * inverse of the return code tells to the netfilter
net/netfilter/nf_conntrack_expect.c +1 -1
@@ -241,7 +241,7 @@ struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me)EXPORT_SYMBOL_GPL (nf_ct_expect_alloc);void nf_ct_expect_init (struct nf_conntrack_expect *exp,unsigned int class, -int family, +u_int8_t family,const union nf_inet_addr *saddr,const union nf_inet_addr *daddr,u_int8_t proto,const __be16 *src,const __be16 *dst)
net/netfilter/nf_conntrack_h323_main.c +2 -1
@@ -709,7 +709,8 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct,/* If the calling party is on the same side of the forward-to party, * we don't need to track the second call */ static int callforward_do_filter (const union nf_inet_addr *src, -const union nf_inet_addr *dst,int family) +const union nf_inet_addr *dst, +u_int8_t family) {const struct nf_afinfo *afinfo;struct flowi fl1, fl2;
net/netfilter/nf_conntrack_proto_dccp.c +2 -2
@@ -461,7 +461,7 @@ static u64 dccp_ack_seq(const struct dccp_hdr *dh)static int dccp_packet (struct nf_conn *ct,const struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info ctinfo, -int pf,unsigned int hooknum) +u_int8_t pf,unsigned int hooknum) {enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo);struct dccp_hdr _dh, *dh;
@@ -546,7 +546,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, }static int dccp_error (struct sk_buff *skb,unsigned int dataoff, -enum ip_conntrack_info *ctinfo,int pf, +enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum) {struct dccp_hdr _dh, *dh;
net/netfilter/nf_conntrack_proto_generic.c +1 -1
@@ -45,7 +45,7 @@ static int packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) {nf_ct_refresh_acct (ct ,ctinfo ,skb ,nf_ct_generic_timeout );
net/netfilter/nf_conntrack_proto_gre.c +1 -1
@@ -219,7 +219,7 @@ static int gre_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) {/* If we've seen traffic both ways, this is a GRE connection.
net/netfilter/nf_conntrack_proto_sctp.c +1 -1
@@ -287,7 +287,7 @@ static int sctp_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) { enum sctp_conntrack new_state, old_state;
net/netfilter/nf_conntrack_proto_tcp.c +3 -3
@@ -486,7 +486,7 @@ static bool tcp_in_window(const struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, const struct tcphdr *tcph, - int pf) + u_int8_t pf) { struct ip_ct_tcp_state *sender = &state->seen[dir];struct ip_ct_tcp_state *receiver = &state->seen[!dir];
@@ -749,7 +749,7 @@ static const u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + 1] =static int tcp_error (struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo, -int pf, +u_int8_t pf,unsigned int hooknum) {const struct tcphdr *th;
@@ -804,7 +804,7 @@ static int tcp_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) { struct nf_conntrack_tuple *tuple;
net/netfilter/nf_conntrack_proto_udp.c +2 -2
@@ -66,7 +66,7 @@ static int udp_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) {/* If we've seen traffic both ways, this is some kind of UDP
@@ -91,7 +91,7 @@ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,static int udp_error (struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo, -int pf, +u_int8_t pf,unsigned int hooknum) {unsigned int udplen = skb->len - dataoff;
net/netfilter/nf_conntrack_proto_udplite.c +2 -2
@@ -65,7 +65,7 @@ static int udplite_packet(struct nf_conn *ct,const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, - int pf, + u_int8_t pf, unsigned int hooknum) {/* If we've seen traffic both ways, this is some kind of UDP
@@ -91,7 +91,7 @@ static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb,static int udplite_error (struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo, -int pf, +u_int8_t pf,unsigned int hooknum) {unsigned int udplen = skb->len - dataoff;
net/netfilter/nf_internals.h +2 -2
@@ -15,7 +15,7 @@/* core.c */ extern unsigned int nf_iterate(struct list_head *head, struct sk_buff *skb, - int hook, + unsigned int hook, const struct net_device *indev, const struct net_device *outdev, struct list_head **i,
@@ -25,7 +25,7 @@ extern unsigned int nf_iterate(struct list_head *head,/* nf_queue.c */ extern int nf_queue(struct sk_buff *skb, struct list_head *elem, - int pf, unsigned int hook, + u_int8_t pf, unsigned int hook, struct net_device *indev, struct net_device *outdev, int (*okfn)(struct sk_buff *),
net/netfilter/nf_log.c +3 -3
@@ -20,7 +20,7 @@ static DEFINE_MUTEX(nf_log_mutex);/* return EBUSY if somebody else is registered, EEXIST if the same logger * is registred, 0 on success. */ -int nf_log_register (int pf,const struct nf_logger *logger) +int nf_log_register (u_int8_t pf,const struct nf_logger *logger) {int ret;
@@ -45,7 +45,7 @@ int nf_log_register(int pf, const struct nf_logger *logger) }EXPORT_SYMBOL (nf_log_register); -void nf_log_unregister_pf (int pf) +void nf_log_unregister_pf (u_int8_t pf) {if (pf >=NPROTO )return ;
@@ -73,7 +73,7 @@ void nf_log_unregister(const struct nf_logger *logger) }EXPORT_SYMBOL (nf_log_unregister); -void nf_log_packet(int pf, +void nf_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
net/netfilter/nf_queue.c +5 -5
@@ -22,7 +22,7 @@ static DEFINE_MUTEX(queue_handler_mutex);/* return EBUSY when somebody else is registered, return EEXIST if the * same handler is registered, return 0 in case of success. */ -int nf_register_queue_handler (int pf,const struct nf_queue_handler *qh) +int nf_register_queue_handler (u_int8_t pf,const struct nf_queue_handler *qh) {int ret;
@@ -45,7 +45,7 @@ int nf_register_queue_handler(int pf, const struct nf_queue_handler *qh)EXPORT_SYMBOL (nf_register_queue_handler);/* The caller must flush their queue before this */ -int nf_unregister_queue_handler (int pf,const struct nf_queue_handler *qh) +int nf_unregister_queue_handler (u_int8_t pf,const struct nf_queue_handler *qh) {if (pf >=NPROTO )return -EINVAL ;
@@ -67,7 +67,7 @@ EXPORT_SYMBOL(nf_unregister_queue_handler);void nf_unregister_queue_handlers (const struct nf_queue_handler *qh) { -int pf; +u_int8_t pf;mutex_lock (&queue_handler_mutex);for (pf =0 ; pf <NPROTO ; pf++) {
@@ -107,7 +107,7 @@ static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)*/ static int __nf_queue(struct sk_buff *skb, struct list_head *elem, - int pf, unsigned int hook, + u_int8_t pf, unsigned int hook, struct net_device *indev, struct net_device *outdev, int (*okfn)(struct sk_buff *),
@@ -191,7 +191,7 @@ err: int nf_queue(struct sk_buff *skb, struct list_head *elem, - int pf, unsigned int hook, + u_int8_t pf, unsigned int hook, struct net_device *indev, struct net_device *outdev, int (*okfn)(struct sk_buff *),
net/netfilter/nf_sockopt.c +8 -7
@@ -60,7 +60,7 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg) }EXPORT_SYMBOL (nf_unregister_sockopt); -static struct nf_sockopt_ops *nf_sockopt_find (struct sock *sk,int pf, +static struct nf_sockopt_ops *nf_sockopt_find (struct sock *sk,u_int8_t pf,int val,int get) {struct nf_sockopt_ops *ops;
@@ -96,7 +96,7 @@ out: }/* Call get/setsockopt() */ -static int nf_sockopt (struct sock *sk,int pf,int val, +static int nf_sockopt (struct sock *sk,u_int8_t pf,int val,char __user *opt,int *len,int get) {struct nf_sockopt_ops *ops;
@@ -115,21 +115,22 @@ static int nf_sockopt(struct sock *sk, int pf, int val,return ret; } -int nf_setsockopt (struct sock *sk,int pf,int val,char __user *opt, +int nf_setsockopt (struct sock *sk,u_int8_t pf,int val,char __user *opt,int len) {return nf_sockopt (sk, pf, val, opt, &len,0 ); }EXPORT_SYMBOL (nf_setsockopt); -int nf_getsockopt (struct sock *sk,int pf,int val,char __user *opt,int *len) +int nf_getsockopt (struct sock *sk,u_int8_t pf,int val,char __user *opt, +int *len) {return nf_sockopt (sk, pf, val, opt, len,1 ); }EXPORT_SYMBOL (nf_getsockopt);#ifdef CONFIG_COMPAT -static int compat_nf_sockopt (struct sock *sk,int pf,int val, +static int compat_nf_sockopt (struct sock *sk,u_int8_t pf,int val,char __user *opt,int *len,int get) {struct nf_sockopt_ops *ops;
@@ -155,14 +156,14 @@ static int compat_nf_sockopt(struct sock *sk, int pf, int val,return ret; } -int compat_nf_setsockopt (struct sock *sk,int pf, +int compat_nf_setsockopt (struct sock *sk,u_int8_t pf,int val,char __user *opt,int len) {return compat_nf_sockopt (sk, pf, val, opt, &len,0 ); }EXPORT_SYMBOL (compat_nf_setsockopt); -int compat_nf_getsockopt (struct sock *sk,int pf, +int compat_nf_getsockopt (struct sock *sk,u_int8_t pf,int val,char __user *opt,int *len) {return compat_nf_sockopt (sk, pf, val, opt, len,1 );
net/netfilter/nfnetlink_log.c +2 -2
@@ -359,7 +359,7 @@ static inline int __build_packet_message(struct nfulnl_instance *inst, const struct sk_buff *skb, unsigned int data_len, - unsigned int pf, + u_int8_t pf, unsigned int hooknum, const struct net_device *indev, const struct net_device *outdev,
@@ -534,7 +534,7 @@ static struct nf_loginfo default_loginfo = {/* log handler for internal netfilter logging api */ static void -nfulnl_log_packet(unsigned int pf, +nfulnl_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in,
net/netfilter/x_tables.c +25 -22
177 lines not on this page · raw message
net/netfilter/xt_connlimit.c +1 -1
@@ -82,7 +82,7 @@ static inline bool already_closed(const struct nf_conn *conn)static inline unsigned int same_source_net (const union nf_inet_addr *addr,const union nf_inet_addr *mask, -const union nf_inet_addr *u3,unsigned int family) +const union nf_inet_addr *u3,u_int8_t family) {if (family ==AF_INET ) {return (addr->ip & mask->ip) == (u3->ip & mask->ip);
net/netfilter/xt_conntrack.c +4 -4
@@ -133,7 +133,7 @@ conntrack_addrcmp(const union nf_inet_addr *kaddr,static inline bool conntrack_mt_origsrc (const struct nf_conn *ct,const struct xt_conntrack_mtinfo1 *info, -unsigned int family) +u_int8_t family) {return conntrack_addrcmp (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple.src.u3, &info->origsrc_addr, &info->origsrc_mask, family);
@@ -142,7 +142,7 @@ conntrack_mt_origsrc(const struct nf_conn *ct,static inline bool conntrack_mt_origdst (const struct nf_conn *ct,const struct xt_conntrack_mtinfo1 *info, -unsigned int family) +u_int8_t family) {return conntrack_addrcmp (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple.dst.u3, &info->origdst_addr, &info->origdst_mask, family);
@@ -151,7 +151,7 @@ conntrack_mt_origdst(const struct nf_conn *ct,static inline bool conntrack_mt_replsrc (const struct nf_conn *ct,const struct xt_conntrack_mtinfo1 *info, -unsigned int family) +u_int8_t family) {return conntrack_addrcmp (&ct->tuplehash[IP_CT_DIR_REPLY ].tuple.src.u3, &info->replsrc_addr, &info->replsrc_mask, family);
@@ -160,7 +160,7 @@ conntrack_mt_replsrc(const struct nf_conn *ct,static inline bool conntrack_mt_repldst (const struct nf_conn *ct,const struct xt_conntrack_mtinfo1 *info, -unsigned int family) +u_int8_t family) {return conntrack_addrcmp (&ct->tuplehash[IP_CT_DIR_REPLY ].tuple.dst.u3, &info->repldst_addr, &info->repldst_mask, family);
net/netfilter/xt_hashlimit.c +5 -6
@@ -80,7 +80,7 @@ struct dsthash_ent {struct xt_hashlimit_htable {struct hlist_node node;/* global list of all htables */ atomic_t use; -int family; +u_int8_t family;struct hashlimit_cfg1 cfg;/* config */
@@ -185,7 +185,7 @@ dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent) }static void htable_gc (unsigned long htlong); -static int htable_create_v0 (struct xt_hashlimit_info *minfo,int family) +static int htable_create_v0 (struct xt_hashlimit_info *minfo,u_int8_t family) {struct xt_hashlimit_htable *hinfo;unsigned int size;
@@ -258,8 +258,7 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, int family)return 0 ; } -static int htable_create (struct xt_hashlimit_mtinfo1 *minfo, -unsigned int family) +static int htable_create (struct xt_hashlimit_mtinfo1 *minfo,u_int8_t family) {struct xt_hashlimit_htable *hinfo;unsigned int size;
@@ -378,7 +377,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo) }static struct xt_hashlimit_htable *htable_find_get (const char *name, -int family) +u_int8_t family) {struct xt_hashlimit_htable *hinfo;struct hlist_node *pos;
@@ -901,7 +900,7 @@ static void dl_seq_stop(struct seq_file *s, void *v)spin_unlock_bh (&htable->lock); } -static int dl_seq_real_show (struct dsthash_ent *ent,int family, +static int dl_seq_real_show (struct dsthash_ent *ent,u_int8_t family,struct seq_file *s) {/* recalculate to show accurate numbers */
netfilter 02/79: rename ipt_recent to xt_recent
In reply to Patrick McHardycommit e948b20a71a06a740c925d6ea22b59b4e17cfa0c
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:00 2008 +0200
netfilter: rename ipt_recent to xt_recent
Like with other modules (such as ipt_state), ipt_recent.h is changed to forward definitions to (IOW include) xt_recent.h, and xt_recent.c is changed to use the new constant names.
include/linux/netfilter/Kbuild +1 -0
@@ -32,6 +32,7 @@ header-y += xt_owner.h header-y += xt_pkttype.h header-y += xt_rateest.h header-y += xt_realm.h +header-y += xt_recent.h header-y += xt_sctp.h header-y += xt_state.h header-y += xt_statistic.h
include/linux/netfilter/xt_recent.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef _LINUX_NETFILTER_XT_RECENT_H +#define _LINUX_NETFILTER_XT_RECENT_H 1 + +enum { +XT_RECENT_CHECK =1 <<0 , +XT_RECENT_SET =1 <<1 , +XT_RECENT_UPDATE =1 <<2 , +XT_RECENT_REMOVE =1 <<3 , +XT_RECENT_TTL =1 <<4 , + +XT_RECENT_SOURCE =0 , +XT_RECENT_DEST =1 , + +XT_RECENT_NAME_LEN =200 , +}; + +struct xt_recent_mtinfo { +u_int32_t seconds; +u_int32_t hit_count; +u_int8_t check_set; +u_int8_t invert; +char name[XT_RECENT_NAME_LEN ]; +u_int8_t side; +}; + +#endif /* _LINUX_NETFILTER_XT_RECENT_H */
include/linux/netfilter_ipv4/ipt_recent.h +11 -17
@@ -1,27 +1,21 @@#ifndef _IPT_RECENT_H#define _IPT_RECENT_H -#define RECENT_NAME "ipt_recent" -#define RECENT_VER "v0.3.1" +#include <linux/netfilter/xt_recent.h> -#define IPT_RECENT_CHECK 1 -#define IPT_RECENT_SET 2 -#define IPT_RECENT_UPDATE 4 -#define IPT_RECENT_REMOVE 8 -#define IPT_RECENT_TTL 16 +#define ipt_recent_info xt_recent_mtinfo -#define IPT_RECENT_SOURCE 0 -#define IPT_RECENT_DEST 1 +enum { +IPT_RECENT_CHECK =XT_RECENT_CHECK , +IPT_RECENT_SET =XT_RECENT_SET , +IPT_RECENT_UPDATE =XT_RECENT_UPDATE , +IPT_RECENT_REMOVE =XT_RECENT_REMOVE , +IPT_RECENT_TTL =XT_RECENT_TTL , -#define IPT_RECENT_NAME_LEN 200 +IPT_RECENT_SOURCE =XT_RECENT_SOURCE , +IPT_RECENT_DEST =XT_RECENT_DEST , -struct ipt_recent_info { -u_int32_t seconds; -u_int32_t hit_count; -u_int8_t check_set; -u_int8_t invert; -char name[IPT_RECENT_NAME_LEN ]; -u_int8_t side; +IPT_RECENT_NAME_LEN =XT_RECENT_NAME_LEN , };#endif /*_IPT_RECENT_H*/
net/ipv4/netfilter/Kconfig +0 -13
@@ -57,19 +57,6 @@ config IP_NF_IPTABLES To compile it as a module, choose M here. If unsure, say N. # The matches. -config IP_NF_MATCH_RECENT - tristate '"recent" match support' - depends on IP_NF_IPTABLES - depends on NETFILTER_ADVANCED - help - This match is used for creating one or many lists of recently - used addresses and then matching against that/those list(s). - - Short options are available by using 'iptables -m recent -h' - Official Website: <http://snowman.net/projects/ipt_recent/> - - To compile it as a module, choose M here. If unsure, say N. - config IP_NF_MATCH_ECN tristate '"ecn" match support' depends on IP_NF_IPTABLES
net/ipv4/netfilter/Makefile +0 -1
@@ -48,7 +48,6 @@ obj-$(CONFIG_IP_NF_SECURITY) += iptable_security.o obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o -obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o # targets
net/ipv4/netfilter/ipt_recent.c deleted +0 -501
501 lines not on this page · raw message
net/netfilter/Kconfig +11 -0
@@ -732,6 +732,17 @@ config NETFILTER_XT_MATCH_REALM If you want to compile it as a module, say M here and read <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. +config NETFILTER_XT_MATCH_RECENT + tristate '"recent" match support' + depends on NETFILTER_XTABLES + depends on NETFILTER_ADVANCED + ---help--- + This match is used for creating one or many lists of recently + used addresses and then matching against that/those list(s). + + Short options are available by using 'iptables -m recent -h' + Official Website: <http://snowman.net/projects/ipt_recent/> + config NETFILTER_XT_MATCH_SCTP tristate '"sctp" protocol match support (EXPERIMENTAL)' depends on NETFILTER_XTABLES && EXPERIMENTAL
net/netfilter/Makefile +1 -0
@@ -76,6 +76,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o obj-$(CONFIG_NETFILTER_XT_MATCH_QUOTA) += xt_quota.o obj-$(CONFIG_NETFILTER_XT_MATCH_RATEEST) += xt_rateest.o obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o +obj-$(CONFIG_NETFILTER_XT_MATCH_RECENT) += xt_recent.o obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
net/netfilter/xt_recent.c new file +502 -0
502 lines not on this page · raw message
netfilter 03/79: xt_recent: IPv6 support
In reply to Patrick McHardycommit 079aa88fe7172b7650c7cf2c0bc01662bafea236
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:00 2008 +0200
netfilter: xt_recent: IPv6 support
This updates xt_recent to support the IPv6 address family. The new /proc/net/xt_recent directory must be used for this. The old proc interface can also be configured out.
Documentation/feature-removal-schedule.txt +3 -0
@@ -250,6 +250,9 @@ What (Why): - xt_mark match revision 0 (superseded by xt_mark match revision 1) + - xt_recent: the old ipt_recent proc dir + (superseded by /proc/net/xt_recent) + When: January 2009 or Linux 2.7.0, whichever comes first Why: Superseded by newer revisions or modules Who: Jan Engelhardt <[email protected]>
net/netfilter/Kconfig +7 -0
@@ -743,6 +743,13 @@ config NETFILTER_XT_MATCH_RECENT Short options are available by using 'iptables -m recent -h' Official Website: <http://snowman.net/projects/ipt_recent/> +config NETFILTER_XT_MATCH_RECENT_PROC_COMPAT + bool 'Enable obsolete /proc/net/ipt_recent' + depends on NETFILTER_XT_MATCH_RECENT && PROC_FS + ---help--- + This option enables the old /proc/net/ipt_recent interface, + which has been obsoleted by /proc/net/xt_recent. + config NETFILTER_XT_MATCH_SCTP tristate '"sctp" protocol match support (EXPERIMENTAL)' depends on NETFILTER_XTABLES && EXPERIMENTAL
net/netfilter/xt_recent.c +246 -54
479 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
netfilter 04/79: Introduce NFPROTO_* constants
In reply to Patrick McHardycommit 7e9c6eeb136a46dfd941852803b3a9dd78939b69
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:00 2008 +0200
netfilter: Introduce NFPROTO_* constants
The netfilter subsystem only supports a handful of protocols (much less than PF_*) and even non-PF protocols like ARP and pseudo-protocols like PF_BRIDGE. By creating NFPROTO_*, we can earn a few memory savings on arrays that previously were always PF_MAX-sized and keep the pseudo-protocols to ourselves.
include/linux/netfilter.h +12 -2
@@ -52,6 +52,16 @@ enum nf_inet_hooks {NF_INET_NUMHOOKS }; +enum { +NFPROTO_UNSPEC =0 , +NFPROTO_IPV4 =2 , +NFPROTO_ARP =3 , +NFPROTO_BRIDGE =7 , +NFPROTO_IPV6 =10 , +NFPROTO_DECNET =12 , +NFPROTO_NUMPROTO , +}; +union nf_inet_addr {__u32 all[4 ];__be32 ip;
@@ -138,7 +148,7 @@ extern struct ctl_path nf_net_netfilter_sysctl_path[];extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[];#endif /* CONFIG_SYSCTL */ -extern struct list_head nf_hooks[NPROTO ][NF_MAX_HOOKS ]; +extern struct list_head nf_hooks[NFPROTO_NUMPROTO ][NF_MAX_HOOKS ]; int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb, struct net_device *indev, struct net_device *outdev,
@@ -247,7 +257,7 @@ struct nf_afinfo {int route_key_size; }; -extern const struct nf_afinfo *nf_afinfo[NPROTO ]; +extern const struct nf_afinfo *nf_afinfo[NFPROTO_NUMPROTO ];static inline const struct nf_afinfo *nf_get_afinfo (unsigned short family) {return rcu_dereference (nf_afinfo[family]);
net/netfilter/core.c +3 -3
@@ -26,7 +26,7 @@static DEFINE_MUTEX (afinfo_mutex); -const struct nf_afinfo *nf_afinfo[NPROTO ]__read_mostly ; +const struct nf_afinfo *nf_afinfo[NFPROTO_NUMPROTO ]__read_mostly ;EXPORT_SYMBOL (nf_afinfo);int nf_register_afinfo (const struct nf_afinfo *afinfo)
@@ -51,7 +51,7 @@ void nf_unregister_afinfo(const struct nf_afinfo *afinfo) }EXPORT_SYMBOL_GPL (nf_unregister_afinfo); -struct list_head nf_hooks[NPROTO ][NF_MAX_HOOKS ]__read_mostly ; +struct list_head nf_hooks[NFPROTO_NUMPROTO ][NF_MAX_HOOKS ]__read_mostly ;EXPORT_SYMBOL (nf_hooks);static DEFINE_MUTEX (nf_hook_mutex);
@@ -264,7 +264,7 @@ EXPORT_SYMBOL(proc_net_netfilter);void __init netfilter_init (void ) {int i, h; -for (i =0 ; i <NPROTO ; i++) { +for (i =0 ; i <ARRAY_SIZE (nf_hooks); i++) {for (h =0 ; h <NF_MAX_HOOKS ; h++)INIT_LIST_HEAD (&nf_hooks[i][h]); }
net/netfilter/nf_log.c +6 -6
@@ -15,7 +15,7 @@#define NF_LOG_PREFIXLEN 128 -static const struct nf_logger *nf_loggers[NPROTO ]__read_mostly ; +static const struct nf_logger *nf_loggers[NFPROTO_NUMPROTO ]__read_mostly ;static DEFINE_MUTEX (nf_log_mutex);/* return EBUSY if somebody else is registered, EEXIST if the same logger
@@ -24,7 +24,7 @@ int nf_log_register(u_int8_t pf, const struct nf_logger *logger) {int ret; -if (pf >=NPROTO ) +if (pf >=ARRAY_SIZE (nf_loggers))return -EINVAL ;/* Any setup of logging members must be done before
@@ -47,7 +47,7 @@ EXPORT_SYMBOL(nf_log_register);void nf_log_unregister_pf (u_int8_t pf) { -if (pf >=NPROTO ) +if (pf >=ARRAY_SIZE (nf_loggers))return ;mutex_lock (&nf_log_mutex);rcu_assign_pointer (nf_loggers[pf],NULL );
@@ -63,7 +63,7 @@ void nf_log_unregister(const struct nf_logger *logger)int i;mutex_lock (&nf_log_mutex); -for (i =0 ; i <NPROTO ; i++) { +for (i =0 ; i <ARRAY_SIZE (nf_loggers); i++) {if (nf_loggers[i] == logger)rcu_assign_pointer (nf_loggers[i],NULL ); }
@@ -103,7 +103,7 @@ static void *seq_start(struct seq_file *seq, loff_t *pos) {rcu_read_lock (); -if (*pos >=NPROTO ) +if (*pos >=ARRAY_SIZE (nf_loggers))return NULL ;return pos;
@@ -113,7 +113,7 @@ static void *seq_next(struct seq_file *s, void *v, loff_t *pos) { (*pos)++; -if (*pos >=NPROTO ) +if (*pos >=ARRAY_SIZE (nf_loggers))return NULL ;return pos;
net/netfilter/nf_queue.c +6 -6
@@ -16,7 +16,7 @@* long term mutex. The handler must provide an an outfn() to accept packets * for queueing and must reinject all packets it receives, no matter what. */ -static const struct nf_queue_handler *queue_handler[NPROTO ]; +static const struct nf_queue_handler *queue_handler[NFPROTO_NUMPROTO ]__read_mostly ;static DEFINE_MUTEX (queue_handler_mutex);
@@ -26,7 +26,7 @@ int nf_register_queue_handler(u_int8_t pf, const struct nf_queue_handler *qh) {int ret; -if (pf >=NPROTO ) +if (pf >=ARRAY_SIZE (queue_handler))return -EINVAL ;mutex_lock (&queue_handler_mutex);
@@ -47,7 +47,7 @@ EXPORT_SYMBOL(nf_register_queue_handler);/* The caller must flush their queue before this */ int nf_unregister_queue_handler (u_int8_t pf,const struct nf_queue_handler *qh) { -if (pf >=NPROTO ) +if (pf >=ARRAY_SIZE (queue_handler))return -EINVAL ;mutex_lock (&queue_handler_mutex);
@@ -70,7 +70,7 @@ void nf_unregister_queue_handlers(const struct nf_queue_handler *qh)u_int8_t pf;mutex_lock (&queue_handler_mutex); -for (pf =0 ; pf <NPROTO ; pf++) { +for (pf =0 ; pf <ARRAY_SIZE (queue_handler); pf++) {if (queue_handler[pf] == qh)rcu_assign_pointer (queue_handler[pf],NULL ); }
@@ -285,7 +285,7 @@ EXPORT_SYMBOL(nf_reinject);#ifdef CONFIG_PROC_FS static void *seq_start (struct seq_file *seq,loff_t *pos) { -if (*pos >=NPROTO ) +if (*pos >=ARRAY_SIZE (queue_handler))return NULL ;return pos;
@@ -295,7 +295,7 @@ static void *seq_next(struct seq_file *s, void *v, loff_t *pos) { (*pos)++; -if (*pos >=NPROTO ) +if (*pos >=ARRAY_SIZE (queue_handler))return NULL ;return pos;
net/netfilter/x_tables.c +10 -8
@@ -58,10 +58,12 @@ static struct xt_af *xt; #define duprintf(format, args...)#endif -static const char *const xt_prefix[NPROTO ] = { - [AF_INET ] ="ip" , - [AF_INET6 ] ="ip6" , - [NF_ARP ] ="arp" , +static const char *const xt_prefix[NFPROTO_NUMPROTO ] = { + [NFPROTO_UNSPEC ] ="x" , + [NFPROTO_IPV4 ] ="ip" , + [NFPROTO_ARP ] ="arp" , + [NFPROTO_BRIDGE ] ="eb" , + [NFPROTO_IPV6 ] ="ip6" , };/* Registration hooks for targets. */
@@ -932,7 +934,7 @@ int xt_proto_init(struct net *net, u_int8_t af)struct proc_dir_entry *proc;#endif -if (af >=NPROTO ) +if (af >=ARRAY_SIZE (xt_prefix))return -EINVAL ;
@@ -1001,7 +1003,7 @@ static int __net_init xt_net_init(struct net *net) {int i; -for (i =0 ; i <NPROTO ; i++) +for (i =0 ; i <NFPROTO_NUMPROTO ; i++)INIT_LIST_HEAD (&net->xt.tables[i]);return 0 ; }
@@ -1014,11 +1016,11 @@ static int __init xt_init(void) {int i, rv; - xt =kmalloc (sizeof (struct xt_af ) *NPROTO ,GFP_KERNEL ); + xt =kmalloc (sizeof (struct xt_af ) *NFPROTO_NUMPROTO ,GFP_KERNEL );if (!xt)return -ENOMEM ; -for (i =0 ; i <NPROTO ; i++) { +for (i =0 ; i <NFPROTO_NUMPROTO ; i++) {mutex_init (&xt[i].mutex);#ifdef CONFIG_COMPAT mutex_init (&xt[i].compat_mutex);
netfilter 05/79: x_tables: use NFPROTO_* in extensions
In reply to Patrick McHardycommit ee999d8b9573df1b547aacdc6d79f86eb79c25cd
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:01 2008 +0200
netfilter: x_tables: use NFPROTO_* in extensions
net/bridge/netfilter/ebt_log.c +3 -3
@@ -206,10 +206,10 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr, li.u.log.logflags = info->bitmask;if (info->bitmask &EBT_LOG_NFLOG ) -nf_log_packet (PF_BRIDGE , hooknr, skb, in, out, &li, +nf_log_packet (NFPROTO_BRIDGE , hooknr, skb, in, out, &li,"%s" , info->prefix);else -ebt_log_packet (PF_BRIDGE , hooknr, skb, in, out, &li, +ebt_log_packet (NFPROTO_BRIDGE , hooknr, skb, in, out, &li, info->prefix); }
@@ -234,7 +234,7 @@ static int __init ebt_log_init(void) ret =ebt_register_watcher (&log);if (ret <0 )return ret; -nf_log_register (PF_BRIDGE , &ebt_log_logger); +nf_log_register (NFPROTO_BRIDGE , &ebt_log_logger);return 0 ; }
net/bridge/netfilter/ebt_ulog.c +1 -1
@@ -310,7 +310,7 @@ static int __init ebt_ulog_init(void)netlink_kernel_release (ebtulognl);if (ret ==0 ) -nf_log_register (PF_BRIDGE , &ebt_ulog_logger); +nf_log_register (NFPROTO_BRIDGE , &ebt_ulog_logger);return ret; }
net/ipv4/netfilter/arp_tables.c +30 -28
200 lines not on this page · raw message
net/ipv4/netfilter/arpt_mangle.c +1 -1
@@ -75,7 +75,7 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,static struct xt_target arpt_mangle_reg__read_mostly = { .name ="mangle" , - .family =NF_ARP , + .family =NFPROTO_ARP , .target = target, .targetsize =sizeof (struct arpt_mangle ), .checkentry = checkentry,
net/ipv4/netfilter/arptable_filter.c +4 -4
@@ -51,7 +51,7 @@ static struct xt_table packet_filter = { .lock = __RW_LOCK_UNLOCKED(packet_filter.lock), .private = NULL, .me = THIS_MODULE, - .af = NF_ARP, + .af = NFPROTO_ARP, };/* The work comes in here from netfilter.c */
@@ -89,21 +89,21 @@ static struct nf_hook_ops arpt_ops[] __read_mostly = { { .hook = arpt_in_hook, .owner = THIS_MODULE, - .pf = NF_ARP, + .pf = NFPROTO_ARP, .hooknum = NF_ARP_IN, .priority = NF_IP_PRI_FILTER, }, { .hook = arpt_out_hook, .owner = THIS_MODULE, - .pf = NF_ARP, + .pf = NFPROTO_ARP, .hooknum = NF_ARP_OUT, .priority = NF_IP_PRI_FILTER, }, { .hook = arpt_forward_hook, .owner = THIS_MODULE, - .pf = NF_ARP, + .pf = NFPROTO_ARP, .hooknum = NF_ARP_FORWARD, .priority = NF_IP_PRI_FILTER, },
net/ipv4/netfilter/ipt_CLUSTERIP.c +2 -2
@@ -445,7 +445,7 @@ struct compat_ipt_clusterip_tgt_infostatic struct xt_target clusterip_tg_reg__read_mostly = { .name ="CLUSTERIP" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = clusterip_tg, .checkentry = clusterip_tg_check, .destroy = clusterip_tg_destroy,
@@ -546,7 +546,7 @@ arp_mangle(unsigned int hook,static struct nf_hook_ops cip_arp_ops__read_mostly = { .hook = arp_mangle, - .pf =NF_ARP , + .pf =NFPROTO_ARP , .hooknum =NF_ARP_OUT , .priority =-1 };
net/ipv4/netfilter/ipt_ECN.c +1 -1
@@ -124,7 +124,7 @@ ecn_tg_check(const char *tablename, const void *e_void,static struct xt_target ecn_tg_reg__read_mostly = { .name ="ECN" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = ecn_tg, .targetsize =sizeof (struct ipt_ECN_info ), .table ="mangle" ,
net/ipv4/netfilter/ipt_LOG.c +3 -3
@@ -437,7 +437,7 @@ log_tg(struct sk_buff *skb, const struct net_device *in, li.u.log.level = loginfo->level; li.u.log.logflags = loginfo->logflags; -ipt_log_packet (PF_INET , hooknum, skb, in, out, &li, +ipt_log_packet (NFPROTO_IPV4 , hooknum, skb, in, out, &li, loginfo->prefix);return XT_CONTINUE ; }
@@ -463,7 +463,7 @@ log_tg_check(const char *tablename, const void *e,static struct xt_target log_tg_reg__read_mostly = { .name ="LOG" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = log_tg, .targetsize =sizeof (struct ipt_log_info ), .checkentry = log_tg_check,
@@ -483,7 +483,7 @@ static int __init log_tg_init(void) ret =xt_register_target (&log_tg_reg);if (ret <0 )return ret; -nf_log_register (PF_INET , &ipt_log_logger); +nf_log_register (NFPROTO_IPV4 , &ipt_log_logger);return 0 ; }
net/ipv4/netfilter/ipt_MASQUERADE.c +1 -1
@@ -153,7 +153,7 @@ static struct notifier_block masq_inet_notifier = {static struct xt_target masquerade_tg_reg__read_mostly = { .name ="MASQUERADE" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = masquerade_tg, .targetsize =sizeof (struct nf_nat_multi_range_compat ), .table ="nat" ,
net/ipv4/netfilter/ipt_NETMAP.c +1 -1
@@ -75,7 +75,7 @@ netmap_tg(struct sk_buff *skb, const struct net_device *in,static struct xt_target netmap_tg_reg__read_mostly = { .name ="NETMAP" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = netmap_tg, .targetsize =sizeof (struct nf_nat_multi_range_compat ), .table ="nat" ,
net/ipv4/netfilter/ipt_REDIRECT.c +1 -1
@@ -92,7 +92,7 @@ redirect_tg(struct sk_buff *skb, const struct net_device *in,static struct xt_target redirect_tg_reg__read_mostly = { .name ="REDIRECT" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = redirect_tg, .targetsize =sizeof (struct nf_nat_multi_range_compat ), .table ="nat" ,
net/ipv4/netfilter/ipt_REJECT.c +1 -1
@@ -201,7 +201,7 @@ reject_tg_check(const char *tablename, const void *e_void,static struct xt_target reject_tg_reg__read_mostly = { .name ="REJECT" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = reject_tg, .targetsize =sizeof (struct ipt_reject_info ), .table ="filter" ,
net/ipv4/netfilter/ipt_TTL.c +1 -1
@@ -80,7 +80,7 @@ ttl_tg_check(const char *tablename, const void *e,static struct xt_target ttl_tg_reg__read_mostly = { .name ="TTL" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = ttl_tg, .targetsize =sizeof (struct ipt_TTL_info ), .table ="mangle" ,
net/ipv4/netfilter/ipt_ULOG.c +2 -2
@@ -374,7 +374,7 @@ static int ulog_tg_compat_to_user(void __user *dst, void *src)static struct xt_target ulog_tg_reg__read_mostly = { .name ="ULOG" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = ulog_tg, .targetsize =sizeof (struct ipt_ulog_info ), .checkentry = ulog_tg_check,
@@ -419,7 +419,7 @@ static int __init ulog_tg_init(void)return ret; }if (nflog) -nf_log_register (PF_INET , &ipt_ulog_logger); +nf_log_register (NFPROTO_IPV4 , &ipt_ulog_logger);return 0 ; }
net/ipv4/netfilter/ipt_addrtype.c +2 -2
@@ -108,14 +108,14 @@ addrtype_mt_checkentry_v1(const char *tablename, const void *ip_void,static struct xt_match addrtype_mt_reg[]__read_mostly = { { .name ="addrtype" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = addrtype_mt_v0, .matchsize =sizeof (struct ipt_addrtype_info ), .me =THIS_MODULE }, { .name ="addrtype" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .revision =1 , .match = addrtype_mt_v1, .checkentry = addrtype_mt_checkentry_v1,
net/ipv4/netfilter/ipt_ah.c +1 -1
@@ -83,7 +83,7 @@ ah_mt_check(const char *tablename, const void *ip_void,static struct xt_match ah_mt_reg__read_mostly = { .name ="ah" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = ah_mt, .matchsize =sizeof (struct ipt_ah ), .proto =IPPROTO_AH ,
net/ipv4/netfilter/ipt_ecn.c +1 -1
@@ -114,7 +114,7 @@ ecn_mt_check(const char *tablename, const void *ip_void,static struct xt_match ecn_mt_reg__read_mostly = { .name ="ecn" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = ecn_mt, .matchsize =sizeof (struct ipt_ecn_info ), .checkentry = ecn_mt_check,
net/ipv4/netfilter/ipt_ttl.c +1 -1
@@ -46,7 +46,7 @@ ttl_mt(const struct sk_buff *skb, const struct net_device *in,static struct xt_match ttl_mt_reg__read_mostly = { .name ="ttl" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = ttl_mt, .matchsize =sizeof (struct ipt_ttl_info ), .me =THIS_MODULE ,
net/ipv6/netfilter/ip6t_HL.c +1 -1
@@ -78,7 +78,7 @@ hl_tg6_check(const char *tablename, const void *entry,static struct xt_target hl_tg6_reg__read_mostly = { .name ="HL" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .target = hl_tg6, .targetsize =sizeof (struct ip6t_HL_info ), .table ="mangle" ,
net/ipv6/netfilter/ip6t_LOG.c +4 -3
@@ -449,7 +449,8 @@ log_tg6(struct sk_buff *skb, const struct net_device *in, li.u.log.level = loginfo->level; li.u.log.logflags = loginfo->logflags; -ip6t_log_packet (PF_INET6 , hooknum, skb, in, out, &li, loginfo->prefix); +ip6t_log_packet (NFPROTO_IPV6 , hooknum, skb, in, out, + &li, loginfo->prefix);return XT_CONTINUE ; }
@@ -475,7 +476,7 @@ log_tg6_check(const char *tablename, const void *entry,static struct xt_target log_tg6_reg__read_mostly = { .name ="LOG" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .target = log_tg6, .targetsize =sizeof (struct ip6t_log_info ), .checkentry = log_tg6_check,
@@ -495,7 +496,7 @@ static int __init log_tg6_init(void) ret =xt_register_target (&log_tg6_reg);if (ret <0 )return ret; -nf_log_register (PF_INET6 , &ip6t_logger); +nf_log_register (NFPROTO_IPV6 , &ip6t_logger);return 0 ; }
net/ipv6/netfilter/ip6t_REJECT.c +1 -1
@@ -237,7 +237,7 @@ reject_tg6_check(const char *tablename, const void *entry,static struct xt_target reject_tg6_reg__read_mostly = { .name ="REJECT" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .target = reject_tg6, .targetsize =sizeof (struct ip6t_reject_info ), .table ="filter" ,
net/ipv6/netfilter/ip6t_ah.c +1 -1
@@ -110,7 +110,7 @@ ah_mt6_check(const char *tablename, const void *entry,static struct xt_match ah_mt6_reg__read_mostly = { .name ="ah" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = ah_mt6, .matchsize =sizeof (struct ip6t_ah ), .checkentry = ah_mt6_check,
net/ipv6/netfilter/ip6t_eui64.c +1 -1
@@ -60,7 +60,7 @@ eui64_mt6(const struct sk_buff *skb, const struct net_device *in,static struct xt_match eui64_mt6_reg__read_mostly = { .name ="eui64" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = eui64_mt6, .matchsize =sizeof (int ), .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) |
net/ipv6/netfilter/ip6t_frag.c +1 -1
@@ -127,7 +127,7 @@ frag_mt6_check(const char *tablename, const void *ip,static struct xt_match frag_mt6_reg__read_mostly = { .name ="frag" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = frag_mt6, .matchsize =sizeof (struct ip6t_frag ), .checkentry = frag_mt6_check,
net/ipv6/netfilter/ip6t_hbh.c +2 -2
@@ -187,7 +187,7 @@ hbh_mt6_check(const char *tablename, const void *entry,static struct xt_match hbh_mt6_reg[]__read_mostly = { { .name ="hbh" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = hbh_mt6, .matchsize =sizeof (struct ip6t_opts ), .checkentry = hbh_mt6_check,
@@ -196,7 +196,7 @@ static struct xt_match hbh_mt6_reg[] __read_mostly = { }, { .name = "dst", - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = hbh_mt6, .matchsize = sizeof(struct ip6t_opts), .checkentry = hbh_mt6_check,
net/ipv6/netfilter/ip6t_hl.c +1 -1
@@ -51,7 +51,7 @@ hl_mt6(const struct sk_buff *skb, const struct net_device *in,static struct xt_match hl_mt6_reg__read_mostly = { .name ="hl" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = hl_mt6, .matchsize =sizeof (struct ip6t_hl_info ), .me =THIS_MODULE ,
net/ipv6/netfilter/ip6t_ipv6header.c +1 -1
@@ -138,7 +138,7 @@ ipv6header_mt6_check(const char *tablename, const void *ip,static struct xt_match ipv6header_mt6_reg__read_mostly = { .name ="ipv6header" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = ipv6header_mt6, .matchsize =sizeof (struct ip6t_ipv6header_info ), .checkentry = ipv6header_mt6_check,
net/ipv6/netfilter/ip6t_mh.c +1 -1
@@ -84,7 +84,7 @@ mh_mt6_check(const char *tablename, const void *entry,static struct xt_match mh_mt6_reg__read_mostly = { .name ="mh" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .checkentry = mh_mt6_check, .match = mh_mt6, .matchsize =sizeof (struct ip6t_mh ),
net/ipv6/netfilter/ip6t_rt.c +1 -1
@@ -214,7 +214,7 @@ rt_mt6_check(const char *tablename, const void *entry,static struct xt_match rt_mt6_reg__read_mostly = { .name ="rt" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = rt_mt6, .matchsize =sizeof (struct ip6t_rt ), .checkentry = rt_mt6_check,
net/netfilter/xt_CLASSIFY.c +2 -2
@@ -39,7 +39,7 @@ classify_tg(struct sk_buff *skb, const struct net_device *in,static struct xt_target classify_tg_reg[]__read_mostly = { { - .family =AF_INET , + .family =NFPROTO_IPV4 , .name ="CLASSIFY" , .target = classify_tg, .targetsize =sizeof (struct xt_classify_target_info ),
@@ -51,7 +51,7 @@ static struct xt_target classify_tg_reg[] __read_mostly = { }, { .name = "CLASSIFY", - .family = AF_INET6, + .family = NFPROTO_IPV6, .target = classify_tg, .targetsize = sizeof(struct xt_classify_target_info), .table = "mangle",
net/netfilter/xt_CONNMARK.c +4 -4
@@ -197,7 +197,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { { .name = "CONNMARK", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = connmark_tg_check_v0, .destroy = connmark_tg_destroy, .target = connmark_tg_v0,
@@ -212,7 +212,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { { .name = "CONNMARK", .revision = 0, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connmark_tg_check_v0, .destroy = connmark_tg_destroy, .target = connmark_tg_v0,
@@ -227,7 +227,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { { .name = "CONNMARK", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = connmark_tg_check, .target = connmark_tg, .targetsize = sizeof(struct xt_connmark_tginfo1),
@@ -237,7 +237,7 @@ static struct xt_target connmark_tg_reg[] __read_mostly = { { .name = "CONNMARK", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connmark_tg_check, .target = connmark_tg, .targetsize = sizeof(struct xt_connmark_tginfo1),
net/netfilter/xt_CONNSECMARK.c +2 -2
@@ -127,7 +127,7 @@ connsecmark_tg_destroy(const struct xt_target *target, void *targinfo)static struct xt_target connsecmark_tg_reg[]__read_mostly = { { .name ="CONNSECMARK" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = connsecmark_tg_check, .destroy = connsecmark_tg_destroy, .target = connsecmark_tg,
@@ -136,7 +136,7 @@ static struct xt_target connsecmark_tg_reg[] __read_mostly = { }, { .name = "CONNSECMARK", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connsecmark_tg_check, .destroy = connsecmark_tg_destroy, .target = connsecmark_tg,
net/netfilter/xt_DSCP.c +5 -5
@@ -165,7 +165,7 @@ tos_tg6(struct sk_buff *skb, const struct net_device *in,static struct xt_target dscp_tg_reg[]__read_mostly = { { .name ="DSCP" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = dscp_tg_check, .target = dscp_tg, .targetsize =sizeof (struct xt_DSCP_info ),
@@ -174,7 +174,7 @@ static struct xt_target dscp_tg_reg[] __read_mostly = { }, { .name = "DSCP", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = dscp_tg_check, .target = dscp_tg6, .targetsize = sizeof(struct xt_DSCP_info),
@@ -184,7 +184,7 @@ static struct xt_target dscp_tg_reg[] __read_mostly = { { .name = "TOS", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .table = "mangle", .target = tos_tg_v0, .targetsize = sizeof(struct ipt_tos_target_info),
@@ -194,7 +194,7 @@ static struct xt_target dscp_tg_reg[] __read_mostly = { { .name = "TOS", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .table = "mangle", .target = tos_tg, .targetsize = sizeof(struct xt_tos_target_info),
@@ -203,7 +203,7 @@ static struct xt_target dscp_tg_reg[] __read_mostly = { { .name = "TOS", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .table = "mangle", .target = tos_tg6, .targetsize = sizeof(struct xt_tos_target_info),
net/netfilter/xt_MARK.c +6 -6
@@ -161,7 +161,7 @@ static int mark_tg_compat_to_user_v1(void __user *dst, void *src)static struct xt_target mark_tg_reg[]__read_mostly = { { .name ="MARK" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .revision =0 , .checkentry = mark_tg_check_v0, .target = mark_tg_v0,
@@ -176,7 +176,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { }, { .name = "MARK", - .family = AF_INET, + .family = NFPROTO_IPV4, .revision = 1, .checkentry = mark_tg_check_v1, .target = mark_tg_v1,
@@ -191,7 +191,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { }, { .name = "MARK", - .family = AF_INET6, + .family = NFPROTO_IPV6, .revision = 0, .checkentry = mark_tg_check_v0, .target = mark_tg_v0,
@@ -206,7 +206,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { }, { .name = "MARK", - .family = AF_INET6, + .family = NFPROTO_IPV6, .revision = 1, .checkentry = mark_tg_check_v1, .target = mark_tg_v1,
@@ -222,7 +222,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { { .name = "MARK", .revision = 2, - .family = AF_INET, + .family = NFPROTO_IPV4, .target = mark_tg, .targetsize = sizeof(struct xt_mark_tginfo2), .me = THIS_MODULE,
@@ -230,7 +230,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { { .name = "MARK", .revision = 2, - .family = AF_INET6, + .family = NFPROTO_IPV6, .target = mark_tg, .targetsize = sizeof(struct xt_mark_tginfo2), .me = THIS_MODULE,
net/netfilter/xt_NFLOG.c +2 -2
@@ -55,7 +55,7 @@ nflog_tg_check(const char *tablename, const void *entry,static struct xt_target nflog_tg_reg[]__read_mostly = { { .name ="NFLOG" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = nflog_tg_check, .target = nflog_tg, .targetsize =sizeof (struct xt_nflog_info ),
@@ -63,7 +63,7 @@ static struct xt_target nflog_tg_reg[] __read_mostly = { }, { .name = "NFLOG", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = nflog_tg_check, .target = nflog_tg, .targetsize = sizeof(struct xt_nflog_info),
net/netfilter/xt_NFQUEUE.c +2 -2
@@ -36,14 +36,14 @@ nfqueue_tg(struct sk_buff *skb, const struct net_device *in,static struct xt_target nfqueue_tg_reg[]__read_mostly = { { .name ="NFQUEUE" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = nfqueue_tg, .targetsize =sizeof (struct xt_NFQ_info ), .me =THIS_MODULE , }, { .name ="NFQUEUE" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .target = nfqueue_tg, .targetsize =sizeof (struct xt_NFQ_info ), .me =THIS_MODULE ,
net/netfilter/xt_NOTRACK.c +2 -2
@@ -35,14 +35,14 @@ notrack_tg(struct sk_buff *skb, const struct net_device *in,static struct xt_target notrack_tg_reg[]__read_mostly = { { .name ="NOTRACK" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = notrack_tg, .table ="raw" , .me =THIS_MODULE , }, { .name ="NOTRACK" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .target = notrack_tg, .table ="raw" , .me =THIS_MODULE ,
net/netfilter/xt_RATEEST.c +2 -2
@@ -159,7 +159,7 @@ static void xt_rateest_tg_destroy(const struct xt_target *target,static struct xt_target xt_rateest_target[]__read_mostly = { { - .family =AF_INET , + .family =NFPROTO_IPV4 , .name ="RATEEST" , .target = xt_rateest_tg, .checkentry = xt_rateest_tg_checkentry,
@@ -168,7 +168,7 @@ static struct xt_target xt_rateest_target[] __read_mostly = { .me = THIS_MODULE, }, { - .family = AF_INET6, + .family = NFPROTO_IPV6, .name = "RATEEST", .target = xt_rateest_tg, .checkentry = xt_rateest_tg_checkentry,
net/netfilter/xt_SECMARK.c +2 -2
@@ -128,7 +128,7 @@ static void secmark_tg_destroy(const struct xt_target *target, void *targinfo)static struct xt_target secmark_tg_reg[]__read_mostly = { { .name ="SECMARK" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = secmark_tg_check, .destroy = secmark_tg_destroy, .target = secmark_tg,
@@ -137,7 +137,7 @@ static struct xt_target secmark_tg_reg[] __read_mostly = { }, { .name = "SECMARK", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = secmark_tg_check, .destroy = secmark_tg_destroy, .target = secmark_tg,
net/netfilter/xt_TCPMSS.c +2 -2
@@ -289,7 +289,7 @@ tcpmss_tg6_check(const char *tablename, const void *entry,static struct xt_target tcpmss_tg_reg[]__read_mostly = { { - .family =AF_INET , + .family =NFPROTO_IPV4 , .name ="TCPMSS" , .checkentry = tcpmss_tg4_check, .target = tcpmss_tg4,
@@ -299,7 +299,7 @@ static struct xt_target tcpmss_tg_reg[] __read_mostly = { },#if defined(CONFIG_IP6_NF_IPTABLES ) || defined(CONFIG_IP6_NF_IPTABLES_MODULE ) { - .family = AF_INET6, + .family = NFPROTO_IPV6, .name = "TCPMSS", .checkentry = tcpmss_tg6_check, .target = tcpmss_tg6,
net/netfilter/xt_TCPOPTSTRIP.c +2 -2
@@ -106,7 +106,7 @@ tcpoptstrip_tg6(struct sk_buff *skb, const struct net_device *in,static struct xt_target tcpoptstrip_tg_reg[]__read_mostly = { { .name ="TCPOPTSTRIP" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .table ="mangle" , .proto =IPPROTO_TCP , .target = tcpoptstrip_tg4,
@@ -116,7 +116,7 @@ static struct xt_target tcpoptstrip_tg_reg[] __read_mostly = {#if defined(CONFIG_IP6_NF_MANGLE ) || defined(CONFIG_IP6_NF_MANGLE_MODULE ) { .name = "TCPOPTSTRIP", - .family = AF_INET6, + .family = NFPROTO_IPV6, .table = "mangle", .proto = IPPROTO_TCP, .target = tcpoptstrip_tg6,
net/netfilter/xt_TRACE.c +2 -2
@@ -22,14 +22,14 @@ trace_tg(struct sk_buff *skb, const struct net_device *in,static struct xt_target trace_tg_reg[]__read_mostly = { { .name ="TRACE" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .target = trace_tg, .table ="raw" , .me =THIS_MODULE , }, { .name ="TRACE" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .target = trace_tg, .table ="raw" , .me =THIS_MODULE ,
net/netfilter/xt_comment.c +2 -2
@@ -28,14 +28,14 @@ comment_mt(const struct sk_buff *skb, const struct net_device *in,static struct xt_match comment_mt_reg[]__read_mostly = { { .name ="comment" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = comment_mt, .matchsize =sizeof (struct xt_comment_info ), .me =THIS_MODULE }, { .name ="comment" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = comment_mt, .matchsize =sizeof (struct xt_comment_info ), .me =THIS_MODULE
net/netfilter/xt_connbytes.c +2 -2
@@ -130,7 +130,7 @@ connbytes_mt_destroy(const struct xt_match *match, void *matchinfo)static struct xt_match connbytes_mt_reg[]__read_mostly = { { .name ="connbytes" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = connbytes_mt_check, .match = connbytes_mt, .destroy = connbytes_mt_destroy,
@@ -139,7 +139,7 @@ static struct xt_match connbytes_mt_reg[] __read_mostly = { }, { .name = "connbytes", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connbytes_mt_check, .match = connbytes_mt, .destroy = connbytes_mt_destroy,
net/netfilter/xt_connlimit.c +5 -5
@@ -84,7 +84,7 @@ same_source_net(const union nf_inet_addr *addr,const union nf_inet_addr *mask, const union nf_inet_addr *u3, u_int8_t family) { - if (family == AF_INET) { + if (family == NFPROTO_IPV4) { return (addr->ip & mask->ip) == (u3->ip & mask->ip); } else {union nf_inet_addr lh, rh;
@@ -114,7 +114,7 @@ static int count_them(struct xt_connlimit_data *data,int matches =0 ; -if (match->family ==AF_INET6 ) +if (match->family ==NFPROTO_IPV6 ) hash = &data->iphash[connlimit_iphash6 (addr, mask)];else hash = &data->iphash[connlimit_iphash (addr->ip & mask->ip)];
@@ -198,7 +198,7 @@ connlimit_mt(const struct sk_buff *skb, const struct net_device *in, match->family, &tuple)) goto hotdrop; -if (match->family ==AF_INET6 ) { +if (match->family ==NFPROTO_IPV6 ) {const struct ipv6hdr *iph =ipv6_hdr (skb);memcpy (&addr.ip6, &iph->saddr,sizeof (iph->saddr)); }else {
@@ -276,7 +276,7 @@ connlimit_mt_destroy(const struct xt_match *match, void *matchinfo)static struct xt_match connlimit_mt_reg[]__read_mostly = { { .name ="connlimit" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = connlimit_mt_check, .match = connlimit_mt, .matchsize =sizeof (struct xt_connlimit_info ),
@@ -285,7 +285,7 @@ static struct xt_match connlimit_mt_reg[] __read_mostly = { }, { .name = "connlimit", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connlimit_mt_check, .match = connlimit_mt, .matchsize = sizeof(struct xt_connlimit_info),
net/netfilter/xt_connmark.c +4 -4
@@ -140,7 +140,7 @@ static struct xt_match connmark_mt_reg[] __read_mostly = { { .name = "connmark", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = connmark_mt_check_v0, .match = connmark_mt_v0, .destroy = connmark_mt_destroy,
@@ -155,7 +155,7 @@ static struct xt_match connmark_mt_reg[] __read_mostly = { { .name = "connmark", .revision = 0, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connmark_mt_check_v0, .match = connmark_mt_v0, .destroy = connmark_mt_destroy,
@@ -170,7 +170,7 @@ static struct xt_match connmark_mt_reg[] __read_mostly = { { .name = "connmark", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = connmark_mt_check, .match = connmark_mt, .matchsize = sizeof(struct xt_connmark_mtinfo1),
@@ -180,7 +180,7 @@ static struct xt_match connmark_mt_reg[] __read_mostly = { { .name = "connmark", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = connmark_mt_check, .match = connmark_mt, .matchsize = sizeof(struct xt_connmark_mtinfo1),
net/netfilter/xt_conntrack.c +5 -5
@@ -121,9 +121,9 @@ conntrack_addrcmp(const union nf_inet_addr *kaddr, const union nf_inet_addr *uaddr, const union nf_inet_addr *umask, unsigned int l3proto) { - if (l3proto == AF_INET) + if (l3proto == NFPROTO_IPV4) return ((kaddr->ip ^ uaddr->ip) & umask->ip) == 0; - else if (l3proto == AF_INET6) + else if (l3proto == NFPROTO_IPV6) return ipv6_masked_addr_cmp(&kaddr->in6, &umask->in6, &uaddr->in6) == 0; else
@@ -356,7 +356,7 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = { { .name = "conntrack", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = conntrack_mt_v0, .checkentry = conntrack_mt_check, .destroy = conntrack_mt_destroy,
@@ -371,7 +371,7 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = { { .name = "conntrack", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .matchsize = sizeof(struct xt_conntrack_mtinfo1), .match = conntrack_mt, .checkentry = conntrack_mt_check,
@@ -381,7 +381,7 @@ static struct xt_match conntrack_mt_reg[] __read_mostly = { { .name = "conntrack", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .matchsize = sizeof(struct xt_conntrack_mtinfo1), .match = conntrack_mt, .checkentry = conntrack_mt_check,
net/netfilter/xt_dccp.c +2 -2
@@ -138,7 +138,7 @@ dccp_mt_check(const char *tablename, const void *inf,static struct xt_match dccp_mt_reg[]__read_mostly = { { .name ="dccp" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = dccp_mt_check, .match = dccp_mt, .matchsize =sizeof (struct xt_dccp_info ),
@@ -147,7 +147,7 @@ static struct xt_match dccp_mt_reg[] __read_mostly = { }, { .name = "dccp", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = dccp_mt_check, .match = dccp_mt, .matchsize = sizeof(struct xt_dccp_info),
net/netfilter/xt_dscp.c +6 -6
@@ -80,7 +80,7 @@ static bool tos_mt(const struct sk_buff *skb, const struct net_device *in, {const struct xt_tos_match_info *info = matchinfo; -if (match->family ==AF_INET ) +if (match->family ==NFPROTO_IPV4 )return ((ip_hdr (skb)->tos & info->tos_mask) == info->tos_value) ^ !!info->invert;else
@@ -91,7 +91,7 @@ static bool tos_mt(const struct sk_buff *skb, const struct net_device *in,static struct xt_match dscp_mt_reg[]__read_mostly = { { .name ="dscp" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = dscp_mt_check, .match = dscp_mt, .matchsize =sizeof (struct xt_dscp_info ),
@@ -99,7 +99,7 @@ static struct xt_match dscp_mt_reg[] __read_mostly = { }, { .name = "dscp", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = dscp_mt_check, .match = dscp_mt6, .matchsize = sizeof(struct xt_dscp_info),
@@ -108,7 +108,7 @@ static struct xt_match dscp_mt_reg[] __read_mostly = { { .name = "tos", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = tos_mt_v0, .matchsize = sizeof(struct ipt_tos_info), .me = THIS_MODULE,
@@ -116,7 +116,7 @@ static struct xt_match dscp_mt_reg[] __read_mostly = { { .name = "tos", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = tos_mt, .matchsize = sizeof(struct xt_tos_match_info), .me = THIS_MODULE,
@@ -124,7 +124,7 @@ static struct xt_match dscp_mt_reg[] __read_mostly = { { .name = "tos", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = tos_mt, .matchsize = sizeof(struct xt_tos_match_info), .me = THIS_MODULE,
net/netfilter/xt_esp.c +2 -2
@@ -88,7 +88,7 @@ esp_mt_check(const char *tablename, const void *ip_void,static struct xt_match esp_mt_reg[]__read_mostly = { { .name ="esp" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = esp_mt_check, .match = esp_mt, .matchsize =sizeof (struct xt_esp ),
@@ -97,7 +97,7 @@ static struct xt_match esp_mt_reg[] __read_mostly = { }, { .name = "esp", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = esp_mt_check, .match = esp_mt, .matchsize = sizeof(struct xt_esp),
net/netfilter/xt_hashlimit.c +19 -21
@@ -218,7 +218,7 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, u_int8_t family) hinfo->cfg.gc_interval = minfo->cfg.gc_interval; hinfo->cfg.expire = minfo->cfg.expire; -if (family ==AF_INET ) +if (family ==NFPROTO_IPV4 ) hinfo->cfg.srcmask = hinfo->cfg.dstmask =32 ;else hinfo->cfg.srcmask = hinfo->cfg.dstmask =128 ;
@@ -237,11 +237,10 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, u_int8_t family) hinfo->family = family; hinfo->rnd_initialized =0 ;spin_lock_init (&hinfo->lock); - hinfo->pde = -proc_create_data (minfo->name,0 , - family ==AF_INET ? hashlimit_procdir4 : - hashlimit_procdir6, - &dl_file_ops, hinfo); + hinfo->pde =proc_create_data (minfo->name,0 , + (family ==NFPROTO_IPV4 ) ? + hashlimit_procdir4 : hashlimit_procdir6, + &dl_file_ops, hinfo);if (!hinfo->pde) {vfree (hinfo);return -1 ;
@@ -300,11 +299,10 @@ static int htable_create(struct xt_hashlimit_mtinfo1 *minfo, u_int8_t family) hinfo->rnd_initialized =0 ;spin_lock_init (&hinfo->lock); - hinfo->pde = -proc_create_data (minfo->name,0 , - family ==AF_INET ? hashlimit_procdir4 : - hashlimit_procdir6, - &dl_file_ops, hinfo); + hinfo->pde =proc_create_data (minfo->name,0 , + (family ==NFPROTO_IPV4 ) ? + hashlimit_procdir4 : hashlimit_procdir6, + &dl_file_ops, hinfo);if (hinfo->pde ==NULL ) {vfree (hinfo);return -1 ;
@@ -370,7 +368,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)/* remove proc entry */ remove_proc_entry (hinfo->pde->name, - hinfo->family ==AF_INET ? hashlimit_procdir4 : + hinfo->family ==NFPROTO_IPV4 ? hashlimit_procdir4 : hashlimit_procdir6);htable_selective_cleanup (hinfo, select_all);vfree (hinfo);
@@ -501,7 +499,7 @@ hashlimit_init_dst(const struct xt_hashlimit_htable *hinfo,memset (dst,0 ,sizeof (*dst));switch (hinfo->family) { -case AF_INET : +case NFPROTO_IPV4 :if (hinfo->cfg.mode &XT_HASHLIMIT_HASH_DIP ) dst->ip.dst =maskl (ip_hdr (skb)->daddr, hinfo->cfg.dstmask);
@@ -515,7 +513,7 @@ hashlimit_init_dst(const struct xt_hashlimit_htable *hinfo, nexthdr =ip_hdr (skb)->protocol;break ;#if defined(CONFIG_IP6_NF_IPTABLES ) || defined(CONFIG_IP6_NF_IPTABLES_MODULE ) -case AF_INET6 : +case NFPROTO_IPV6 :if (hinfo->cfg.mode &XT_HASHLIMIT_HASH_DIP ) {memcpy (&dst->ip6.dst, &ipv6_hdr (skb)->daddr,sizeof (dst->ip6.dst));
@@ -737,7 +735,7 @@ hashlimit_mt_check(const char *tablename, const void *inf,return false;if (info->name[sizeof (info->name)-1 ] !='\0' )return false; -if (match->family ==AF_INET ) { +if (match->family ==NFPROTO_IPV4 ) {if (info->cfg.srcmask >32 || info->cfg.dstmask >32 )return false; }else {
@@ -805,7 +803,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = { { .name = "hashlimit", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = hashlimit_mt_v0, .matchsize = sizeof(struct xt_hashlimit_info),#ifdef CONFIG_COMPAT
@@ -820,7 +818,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = { { .name = "hashlimit", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = hashlimit_mt, .matchsize = sizeof(struct xt_hashlimit_mtinfo1), .checkentry = hashlimit_mt_check,
@@ -830,7 +828,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = {#if defined(CONFIG_IP6_NF_IPTABLES ) || defined(CONFIG_IP6_NF_IPTABLES_MODULE ) { .name = "hashlimit", - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = hashlimit_mt_v0, .matchsize = sizeof(struct xt_hashlimit_info),#ifdef CONFIG_COMPAT
@@ -845,7 +843,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = { { .name = "hashlimit", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = hashlimit_mt, .matchsize = sizeof(struct xt_hashlimit_mtinfo1), .checkentry = hashlimit_mt_check,
@@ -907,7 +905,7 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,rateinfo_recalc (ent, jiffies);switch (family) { -case AF_INET : +case NFPROTO_IPV4 : return seq_printf(s, "%ld %u.%u.%u.%u:%u->" "%u.%u.%u.%u:%u %u %u %u\n", (long)(ent->expires - jiffies)/HZ,
@@ -918,7 +916,7 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, ent->rateinfo.credit, ent->rateinfo.credit_cap, ent->rateinfo.cost);#if defined(CONFIG_IP6_NF_IPTABLES ) || defined(CONFIG_IP6_NF_IPTABLES_MODULE ) -case AF_INET6 : +case NFPROTO_IPV6 : return seq_printf(s, "%ld " NIP6_FMT ":%u->" NIP6_FMT ":%u %u %u %u\n", (long)(ent->expires - jiffies)/HZ,
net/netfilter/xt_helper.c +2 -2
@@ -81,7 +81,7 @@ static void helper_mt_destroy(const struct xt_match *match, void *matchinfo)static struct xt_match helper_mt_reg[]__read_mostly = { { .name ="helper" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = helper_mt_check, .match = helper_mt, .destroy = helper_mt_destroy,
@@ -90,7 +90,7 @@ static struct xt_match helper_mt_reg[] __read_mostly = { }, { .name = "helper", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = helper_mt_check, .match = helper_mt, .destroy = helper_mt_destroy,
net/netfilter/xt_iprange.c +3 -3
@@ -141,7 +141,7 @@ static struct xt_match iprange_mt_reg[] __read_mostly = { { .name = "iprange", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = iprange_mt_v0, .matchsize = sizeof(struct ipt_iprange_info), .me = THIS_MODULE,
@@ -149,7 +149,7 @@ static struct xt_match iprange_mt_reg[] __read_mostly = { { .name = "iprange", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = iprange_mt4, .matchsize = sizeof(struct xt_iprange_mtinfo), .me = THIS_MODULE,
@@ -157,7 +157,7 @@ static struct xt_match iprange_mt_reg[] __read_mostly = { { .name = "iprange", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = iprange_mt6, .matchsize = sizeof(struct xt_iprange_mtinfo), .me = THIS_MODULE,
net/netfilter/xt_length.c +2 -2
@@ -48,14 +48,14 @@ length_mt6(const struct sk_buff *skb, const struct net_device *in,static struct xt_match length_mt_reg[]__read_mostly = { { .name ="length" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = length_mt, .matchsize =sizeof (struct xt_length_info ), .me =THIS_MODULE , }, { .name ="length" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = length_mt6, .matchsize =sizeof (struct xt_length_info ), .me =THIS_MODULE ,
net/netfilter/xt_limit.c +2 -2
@@ -170,7 +170,7 @@ static int limit_mt_compat_to_user(void __user *dst, void *src)static struct xt_match limit_mt_reg[]__read_mostly = { { .name ="limit" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = limit_mt_check, .match = limit_mt, .matchsize =sizeof (struct xt_rateinfo ),
@@ -183,7 +183,7 @@ static struct xt_match limit_mt_reg[] __read_mostly = { }, { .name = "limit", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = limit_mt_check, .match = limit_mt, .matchsize = sizeof(struct xt_rateinfo),
net/netfilter/xt_mac.c +2 -2
@@ -42,7 +42,7 @@ mac_mt(const struct sk_buff *skb, const struct net_device *in,static struct xt_match mac_mt_reg[]__read_mostly = { { .name ="mac" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = mac_mt, .matchsize =sizeof (struct xt_mac_info ), .hooks = (1 << NF_INET_PRE_ROUTING) |
@@ -52,7 +52,7 @@ static struct xt_match mac_mt_reg[] __read_mostly = { }, { .name = "mac", - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = mac_mt, .matchsize = sizeof(struct xt_mac_info), .hooks = (1 << NF_INET_PRE_ROUTING) |
net/netfilter/xt_mark.c +4 -4
@@ -92,7 +92,7 @@ static struct xt_match mark_mt_reg[] __read_mostly = { { .name = "mark", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = mark_mt_check_v0, .match = mark_mt_v0, .matchsize = sizeof(struct xt_mark_info),
@@ -106,7 +106,7 @@ static struct xt_match mark_mt_reg[] __read_mostly = { { .name = "mark", .revision = 0, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = mark_mt_check_v0, .match = mark_mt_v0, .matchsize = sizeof(struct xt_mark_info),
@@ -120,7 +120,7 @@ static struct xt_match mark_mt_reg[] __read_mostly = { { .name = "mark", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = mark_mt, .matchsize = sizeof(struct xt_mark_mtinfo1), .me = THIS_MODULE,
@@ -128,7 +128,7 @@ static struct xt_match mark_mt_reg[] __read_mostly = { { .name = "mark", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = mark_mt, .matchsize = sizeof(struct xt_mark_mtinfo1), .me = THIS_MODULE,
net/netfilter/xt_multiport.c +4 -4
@@ -216,7 +216,7 @@ multiport_mt6_check(const char *tablename, const void *info,static struct xt_match multiport_mt_reg[]__read_mostly = { { .name ="multiport" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .revision =0 , .checkentry = multiport_mt_check_v0, .match = multiport_mt_v0,
@@ -225,7 +225,7 @@ static struct xt_match multiport_mt_reg[] __read_mostly = { }, { .name = "multiport", - .family = AF_INET, + .family = NFPROTO_IPV4, .revision = 1, .checkentry = multiport_mt_check, .match = multiport_mt,
@@ -234,7 +234,7 @@ static struct xt_match multiport_mt_reg[] __read_mostly = { }, { .name = "multiport", - .family = AF_INET6, + .family = NFPROTO_IPV6, .revision = 0, .checkentry = multiport_mt6_check_v0, .match = multiport_mt_v0,
@@ -243,7 +243,7 @@ static struct xt_match multiport_mt_reg[] __read_mostly = { }, { .name = "multiport", - .family = AF_INET6, + .family = NFPROTO_IPV6, .revision = 1, .checkentry = multiport_mt6_check, .match = multiport_mt,
net/netfilter/xt_owner.c +4 -4
@@ -153,7 +153,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = { { .name = "owner", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = owner_mt_v0, .matchsize = sizeof(struct ipt_owner_info), .checkentry = owner_mt_check_v0,
@@ -164,7 +164,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = { { .name = "owner", .revision = 0, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = owner_mt6_v0, .matchsize = sizeof(struct ip6t_owner_info), .checkentry = owner_mt6_check_v0,
@@ -175,7 +175,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = { { .name = "owner", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = owner_mt, .matchsize = sizeof(struct xt_owner_match_info), .hooks = (1 << NF_INET_LOCAL_OUT) |
@@ -185,7 +185,7 @@ static struct xt_match owner_mt_reg[] __read_mostly = { { .name = "owner", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = owner_mt, .matchsize = sizeof(struct xt_owner_match_info), .hooks = (1 << NF_INET_LOCAL_OUT) |
net/netfilter/xt_physdev.c +2 -2
@@ -121,7 +121,7 @@ physdev_mt_check(const char *tablename, const void *ip,static struct xt_match physdev_mt_reg[]__read_mostly = { { .name ="physdev" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = physdev_mt_check, .match = physdev_mt, .matchsize =sizeof (struct xt_physdev_info ),
@@ -129,7 +129,7 @@ static struct xt_match physdev_mt_reg[] __read_mostly = { }, { .name = "physdev", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = physdev_mt_check, .match = physdev_mt, .matchsize = sizeof(struct xt_physdev_info),
net/netfilter/xt_pkttype.c +4 -4
@@ -33,10 +33,10 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in,if (skb->pkt_type !=PACKET_LOOPBACK ) type = skb->pkt_type; -else if (match->family ==AF_INET && +else if (match->family ==NFPROTO_IPV4 &&ipv4_is_multicast (ip_hdr (skb)->daddr)) type =PACKET_MULTICAST ; -else if (match->family ==AF_INET6 && +else if (match->family ==NFPROTO_IPV6 &&ipv6_hdr (skb)->daddr.s6_addr[0 ] ==0xFF ) type =PACKET_MULTICAST ;else
@@ -48,14 +48,14 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in,static struct xt_match pkttype_mt_reg[]__read_mostly = { { .name ="pkttype" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = pkttype_mt, .matchsize =sizeof (struct xt_pkttype_info ), .me =THIS_MODULE , }, { .name ="pkttype" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = pkttype_mt, .matchsize =sizeof (struct xt_pkttype_info ), .me =THIS_MODULE ,
net/netfilter/xt_policy.c +4 -4
@@ -26,9 +26,9 @@ xt_addr_cmp(const union nf_inet_addr *a1, const union nf_inet_addr *m, const union nf_inet_addr *a2, unsigned short family) { switch (family) { -case AF_INET : +case NFPROTO_IPV4 :return ((a1->ip ^ a2->ip) & m->ip) ==0 ; -case AF_INET6 : +case NFPROTO_IPV6 :return ipv6_masked_addr_cmp (&a1->in6, &m->in6, &a2->in6) ==0 ; }return false;
@@ -165,7 +165,7 @@ policy_mt_check(const char *tablename, const void *ip_void,static struct xt_match policy_mt_reg[]__read_mostly = { { .name ="policy" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = policy_mt_check, .match = policy_mt, .matchsize =sizeof (struct xt_policy_info ),
@@ -173,7 +173,7 @@ static struct xt_match policy_mt_reg[] __read_mostly = { }, { .name = "policy", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = policy_mt_check, .match = policy_mt, .matchsize = sizeof(struct xt_policy_info),
net/netfilter/xt_quota.c +2 -2
@@ -57,7 +57,7 @@ quota_mt_check(const char *tablename, const void *entry,static struct xt_match quota_mt_reg[]__read_mostly = { { .name ="quota" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = quota_mt_check, .match = quota_mt, .matchsize =sizeof (struct xt_quota_info ),
@@ -65,7 +65,7 @@ static struct xt_match quota_mt_reg[] __read_mostly = { }, { .name = "quota", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = quota_mt_check, .match = quota_mt, .matchsize = sizeof(struct xt_quota_info),
net/netfilter/xt_rateest.c +2 -2
@@ -139,7 +139,7 @@ static void xt_rateest_mt_destroy(const struct xt_match *match,static struct xt_match xt_rateest_match[]__read_mostly = { { - .family =AF_INET , + .family =NFPROTO_IPV4 , .name ="rateest" , .match = xt_rateest_mt, .checkentry = xt_rateest_mt_checkentry,
@@ -148,7 +148,7 @@ static struct xt_match xt_rateest_match[] __read_mostly = { .me = THIS_MODULE, }, { - .family = AF_INET6, + .family = NFPROTO_IPV6, .name = "rateest", .match = xt_rateest_mt, .checkentry = xt_rateest_mt_checkentry,
net/netfilter/xt_realm.c +1 -1
@@ -39,7 +39,7 @@ static struct xt_match realm_mt_reg __read_mostly = { .matchsize = sizeof(struct xt_realm_info), .hooks = (1 <<NF_INET_POST_ROUTING ) | (1 <<NF_INET_FORWARD ) | (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN), - .family = AF_INET, + .family = NFPROTO_IPV4, .me =THIS_MODULE };
net/netfilter/xt_recent.c +11 -10
@@ -124,7 +124,7 @@ recent_entry_lookup(const struct recent_table *table,struct recent_entry *e;unsigned int h; -if (family ==AF_INET ) +if (family ==NFPROTO_IPV4 ) h =recent_entry_hash4 (addrp);else h =recent_entry_hash6 (addrp);
@@ -165,7 +165,7 @@ recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr, e->nstamps =1 ; e->index =1 ; e->family = family; -if (family ==AF_INET ) +if (family ==NFPROTO_IPV4 )list_add_tail (&e->list, &t->iphash[recent_entry_hash4 (addr)]);else list_add_tail (&e->list, &t->iphash[recent_entry_hash6 (addr)]);
@@ -216,7 +216,7 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,u_int8_t ttl;bool ret = info->invert; -if (match->family ==AF_INET ) { +if (match->family ==NFPROTO_IPV4 ) {const struct iphdr *iph =ip_hdr (skb);if (info->side ==XT_RECENT_DEST )
@@ -429,7 +429,7 @@ static int recent_seq_show(struct seq_file *seq, void *v)unsigned int i; i = (e->index -1 ) % ip_pkt_list_tot; -if (e->family ==AF_INET ) +if (e->family ==NFPROTO_IPV4 )seq_printf (seq,"src=" NIPQUAD_FMT " ttl: %u last_seen: %lu " "oldest_pkt: %u" ,NIPQUAD (e->addr.ip), e->ttl, e->stamps[i], e->index);
@@ -519,10 +519,11 @@ static ssize_t recent_old_proc_write(struct file *file, addr =in_aton (c);spin_lock_bh (&recent_lock); - e =recent_entry_lookup (t, (const void *)&addr,PF_INET ,0 ); + e =recent_entry_lookup (t, (const void *)&addr,NFPROTO_IPV4 ,0 );if (e ==NULL ) {if (add) -recent_entry_init (t, (const void *)&addr,PF_INET ,0 ); +recent_entry_init (t, (const void *)&addr, +NFPROTO_IPV4 ,0 ); }else {if (add)recent_entry_update (t, e);
@@ -585,10 +586,10 @@ recent_mt_proc_write(struct file *file, const char __user *input, ++c; --size;if (strnchr (c, size,':' ) !=NULL ) { - family =AF_INET6 ; + family =NFPROTO_IPV6 ; succ =in6_pton (c, size, (void *)&addr,'\n' ,NULL ); }else { - family =AF_INET ; + family =NFPROTO_IPV4 ; succ =in4_pton (c, size, (void *)&addr,'\n' ,NULL ); }
@@ -628,7 +629,7 @@ static struct xt_match recent_mt_reg[] __read_mostly = { { .name = "recent", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .match = recent_mt, .matchsize = sizeof(struct xt_recent_mtinfo), .checkentry = recent_mt_check,
@@ -638,7 +639,7 @@ static struct xt_match recent_mt_reg[] __read_mostly = { { .name = "recent", .revision = 0, - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = recent_mt, .matchsize = sizeof(struct xt_recent_mtinfo), .checkentry = recent_mt_check,
net/netfilter/xt_sctp.c +2 -2
@@ -169,7 +169,7 @@ sctp_mt_check(const char *tablename, const void *inf,static struct xt_match sctp_mt_reg[]__read_mostly = { { .name ="sctp" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = sctp_mt_check, .match = sctp_mt, .matchsize =sizeof (struct xt_sctp_info ),
@@ -178,7 +178,7 @@ static struct xt_match sctp_mt_reg[] __read_mostly = { }, { .name = "sctp", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = sctp_mt_check, .match = sctp_mt, .matchsize = sizeof(struct xt_sctp_info),
net/netfilter/xt_state.c +2 -2
@@ -61,7 +61,7 @@ static void state_mt_destroy(const struct xt_match *match, void *matchinfo)static struct xt_match state_mt_reg[]__read_mostly = { { .name ="state" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = state_mt_check, .match = state_mt, .destroy = state_mt_destroy,
@@ -70,7 +70,7 @@ static struct xt_match state_mt_reg[] __read_mostly = { }, { .name = "state", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = state_mt_check, .match = state_mt, .destroy = state_mt_destroy,
net/netfilter/xt_statistic.c +2 -2
@@ -69,7 +69,7 @@ statistic_mt_check(const char *tablename, const void *entry,static struct xt_match statistic_mt_reg[]__read_mostly = { { .name ="statistic" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = statistic_mt_check, .match = statistic_mt, .matchsize =sizeof (struct xt_statistic_info ),
@@ -77,7 +77,7 @@ static struct xt_match statistic_mt_reg[] __read_mostly = { }, { .name = "statistic", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = statistic_mt_check, .match = statistic_mt, .matchsize = sizeof(struct xt_statistic_info),
net/netfilter/xt_string.c +4 -4
@@ -85,7 +85,7 @@ static struct xt_match string_mt_reg[] __read_mostly = { { .name = "string", .revision = 0, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = string_mt_check, .match = string_mt, .destroy = string_mt_destroy,
@@ -95,7 +95,7 @@ static struct xt_match string_mt_reg[] __read_mostly = { { .name = "string", .revision = 1, - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = string_mt_check, .match = string_mt, .destroy = string_mt_destroy,
@@ -105,7 +105,7 @@ static struct xt_match string_mt_reg[] __read_mostly = { { .name = "string", .revision = 0, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = string_mt_check, .match = string_mt, .destroy = string_mt_destroy,
@@ -115,7 +115,7 @@ static struct xt_match string_mt_reg[] __read_mostly = { { .name = "string", .revision = 1, - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = string_mt_check, .match = string_mt, .destroy = string_mt_destroy,
net/netfilter/xt_tcpmss.c +2 -2
@@ -83,7 +83,7 @@ dropit:static struct xt_match tcpmss_mt_reg[]__read_mostly = { { .name ="tcpmss" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = tcpmss_mt, .matchsize =sizeof (struct xt_tcpmss_match_info ), .proto =IPPROTO_TCP ,
@@ -91,7 +91,7 @@ static struct xt_match tcpmss_mt_reg[] __read_mostly = { }, { .name = "tcpmss", - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = tcpmss_mt, .matchsize = sizeof(struct xt_tcpmss_match_info), .proto = IPPROTO_TCP,
net/netfilter/xt_tcpudp.c +6 -6
@@ -186,7 +186,7 @@ udp_mt_check(const char *tablename, const void *info,static struct xt_match tcpudp_mt_reg[]__read_mostly = { { .name ="tcp" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .checkentry = tcp_mt_check, .match = tcp_mt, .matchsize =sizeof (struct xt_tcp ),
@@ -195,7 +195,7 @@ static struct xt_match tcpudp_mt_reg[] __read_mostly = { }, { .name = "tcp", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = tcp_mt_check, .match = tcp_mt, .matchsize = sizeof(struct xt_tcp),
@@ -204,7 +204,7 @@ static struct xt_match tcpudp_mt_reg[] __read_mostly = { }, { .name = "udp", - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = udp_mt_check, .match = udp_mt, .matchsize = sizeof(struct xt_udp),
@@ -213,7 +213,7 @@ static struct xt_match tcpudp_mt_reg[] __read_mostly = { }, { .name = "udp", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = udp_mt_check, .match = udp_mt, .matchsize = sizeof(struct xt_udp),
@@ -222,7 +222,7 @@ static struct xt_match tcpudp_mt_reg[] __read_mostly = { }, { .name = "udplite", - .family = AF_INET, + .family = NFPROTO_IPV4, .checkentry = udp_mt_check, .match = udp_mt, .matchsize = sizeof(struct xt_udp),
@@ -231,7 +231,7 @@ static struct xt_match tcpudp_mt_reg[] __read_mostly = { }, { .name = "udplite", - .family = AF_INET6, + .family = NFPROTO_IPV6, .checkentry = udp_mt_check, .match = udp_mt, .matchsize = sizeof(struct xt_udp),
net/netfilter/xt_time.c +2 -2
@@ -240,7 +240,7 @@ time_mt_check(const char *tablename, const void *ip,static struct xt_match time_mt_reg[]__read_mostly = { { .name ="time" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = time_mt, .matchsize =sizeof (struct xt_time_info ), .checkentry = time_mt_check,
@@ -248,7 +248,7 @@ static struct xt_match time_mt_reg[] __read_mostly = { }, { .name = "time", - .family = AF_INET6, + .family = NFPROTO_IPV6, .match = time_mt, .matchsize = sizeof(struct xt_time_info), .checkentry = time_mt_check,
net/netfilter/xt_u32.c +2 -2
@@ -102,14 +102,14 @@ u32_mt(const struct sk_buff *skb, const struct net_device *in,static struct xt_match u32_mt_reg[]__read_mostly = { { .name ="u32" , - .family =AF_INET , + .family =NFPROTO_IPV4 , .match = u32_mt, .matchsize =sizeof (struct xt_u32 ), .me =THIS_MODULE , }, { .name ="u32" , - .family =AF_INET6 , + .family =NFPROTO_IPV6 , .match = u32_mt, .matchsize =sizeof (struct xt_u32 ), .me =THIS_MODULE ,
netfilter 06/79: implement NFPROTO_UNSPEC as a wildcard for extensions
In reply to Patrick McHardycommit 55b69e91040c685a064198bd76e59885b7ad26c6
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:01 2008 +0200
netfilter: implement NFPROTO_UNSPEC as a wildcard for extensions
When a match or target is looked up using xt_find_{match,target}, Xtables will also search the NFPROTO_UNSPEC module list. This allows for protocol-independent extensions (like xt_time) to be reused from other components (e.g. arptables, ebtables).
Extensions that take different codepaths depending on match->family or target->family of course cannot use NFPROTO_UNSPEC within the registration structure (e.g. xt_pkttype).
net/netfilter/x_tables.c +10 -0
@@ -209,6 +209,11 @@ struct xt_match *xt_find_match(u8 af, const char *name, u8 revision) } }mutex_unlock (&xt[af].mutex); + +if (af !=NFPROTO_UNSPEC ) +/* Try searching again in the family-independent list */ +return xt_find_match (NFPROTO_UNSPEC , name, revision); +return ERR_PTR (err); }EXPORT_SYMBOL (xt_find_match);
@@ -234,6 +239,11 @@ struct xt_target *xt_find_target(u8 af, const char *name, u8 revision) } }mutex_unlock (&xt[af].mutex); + +if (af !=NFPROTO_UNSPEC ) +/* Try searching again in the family-independent list */ +return xt_find_target (NFPROTO_UNSPEC , name, revision); +return ERR_PTR (err); }EXPORT_SYMBOL (xt_find_target);
net/netfilter/xt_CLASSIFY.c +12 -26
@@ -37,40 +37,26 @@ classify_tg(struct sk_buff *skb, const struct net_device *in,return XT_CONTINUE ; } -static struct xt_target classify_tg_reg[]__read_mostly = { - { - .family =NFPROTO_IPV4 , - .name ="CLASSIFY" , - .target = classify_tg, - .targetsize =sizeof (struct xt_classify_target_info ), - .table ="mangle" , - .hooks = (1 <<NF_INET_LOCAL_OUT ) | - (1 <<NF_INET_FORWARD ) | - (1 <<NF_INET_POST_ROUTING ), - .me =THIS_MODULE , - }, - { - .name ="CLASSIFY" , - .family =NFPROTO_IPV6 , - .target = classify_tg, - .targetsize =sizeof (struct xt_classify_target_info ), - .table ="mangle" , - .hooks = (1 <<NF_INET_LOCAL_OUT ) | - (1 <<NF_INET_FORWARD ) | - (1 <<NF_INET_POST_ROUTING ), - .me =THIS_MODULE , - }, +static struct xt_target classify_tg_reg__read_mostly = { + .name ="CLASSIFY" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .table ="mangle" , + .hooks = (1 <<NF_INET_LOCAL_OUT ) | (1 <<NF_INET_FORWARD ) | + (1 <<NF_INET_POST_ROUTING ), + .target = classify_tg, + .targetsize =sizeof (struct xt_classify_target_info ), + .me =THIS_MODULE , };static int __init classify_tg_init (void ) { -return xt_register_targets (classify_tg_reg, -ARRAY_SIZE (classify_tg_reg)); +return xt_register_target (&classify_tg_reg); } static void __exit classify_tg_exit(void) { -xt_unregister_targets (classify_tg_reg,ARRAY_SIZE (classify_tg_reg)); +xt_unregister_target (&classify_tg_reg); }module_init (classify_tg_init);
net/netfilter/xt_MARK.c +1 -9
@@ -222,15 +222,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { { .name = "MARK", .revision = 2, - .family = NFPROTO_IPV4, - .target = mark_tg, - .targetsize = sizeof(struct xt_mark_tginfo2), - .me = THIS_MODULE, - }, - { - .name = "MARK", - .revision = 2, - .family = NFPROTO_IPV6, + .family = NFPROTO_UNSPEC, .target = mark_tg, .targetsize = sizeof(struct xt_mark_tginfo2), .me = THIS_MODULE,
net/netfilter/xt_RATEEST.c +11 -22
@@ -157,25 +157,15 @@ static void xt_rateest_tg_destroy(const struct xt_target *target,xt_rateest_put (info->est); } -static struct xt_target xt_rateest_target[]__read_mostly = { - { - .family =NFPROTO_IPV4 , - .name ="RATEEST" , - .target = xt_rateest_tg, - .checkentry = xt_rateest_tg_checkentry, - .destroy = xt_rateest_tg_destroy, - .targetsize =sizeof (struct xt_rateest_target_info ), - .me =THIS_MODULE , - }, - { - .family =NFPROTO_IPV6 , - .name ="RATEEST" , - .target = xt_rateest_tg, - .checkentry = xt_rateest_tg_checkentry, - .destroy = xt_rateest_tg_destroy, - .targetsize =sizeof (struct xt_rateest_target_info ), - .me =THIS_MODULE , - }, +static struct xt_target xt_rateest_tg_reg__read_mostly = { + .name ="RATEEST" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .target = xt_rateest_tg, + .checkentry = xt_rateest_tg_checkentry, + .destroy = xt_rateest_tg_destroy, + .targetsize =sizeof (struct xt_rateest_target_info ), + .me =THIS_MODULE , };static int __init xt_rateest_tg_init (void )
@@ -186,13 +176,12 @@ static int __init xt_rateest_tg_init(void)INIT_HLIST_HEAD (&rateest_hash[i]);get_random_bytes (&jhash_rnd,sizeof (jhash_rnd)); -return xt_register_targets (xt_rateest_target, -ARRAY_SIZE (xt_rateest_target)); +return xt_register_target (&xt_rateest_tg_reg); } static void __exit xt_rateest_tg_fini(void) { -xt_unregister_targets (xt_rateest_target,ARRAY_SIZE (xt_rateest_target)); +xt_unregister_target (&xt_rateest_tg_reg); }
net/netfilter/xt_SECMARK.c +11 -21
@@ -125,35 +125,25 @@ static void secmark_tg_destroy(const struct xt_target *target, void *targinfo) } } -static struct xt_target secmark_tg_reg[]__read_mostly = { - { - .name ="SECMARK" , - .family =NFPROTO_IPV4 , - .checkentry = secmark_tg_check, - .destroy = secmark_tg_destroy, - .target = secmark_tg, - .targetsize =sizeof (struct xt_secmark_target_info ), - .me =THIS_MODULE , - }, - { - .name ="SECMARK" , - .family =NFPROTO_IPV6 , - .checkentry = secmark_tg_check, - .destroy = secmark_tg_destroy, - .target = secmark_tg, - .targetsize =sizeof (struct xt_secmark_target_info ), - .me =THIS_MODULE , - }, +static struct xt_target secmark_tg_reg__read_mostly = { + .name ="SECMARK" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .checkentry = secmark_tg_check, + .destroy = secmark_tg_destroy, + .target = secmark_tg, + .targetsize =sizeof (struct xt_secmark_target_info ), + .me =THIS_MODULE , };static int __init secmark_tg_init (void ) { -return xt_register_targets (secmark_tg_reg,ARRAY_SIZE (secmark_tg_reg)); +return xt_register_target (&secmark_tg_reg); } static void __exit secmark_tg_exit(void) { -xt_unregister_targets (secmark_tg_reg,ARRAY_SIZE (secmark_tg_reg)); +xt_unregister_target (&secmark_tg_reg); }module_init (secmark_tg_init);
net/netfilter/xt_TRACE.c +9 -17
@@ -19,31 +19,23 @@ trace_tg(struct sk_buff *skb, const struct net_device *in,return XT_CONTINUE ; } -static struct xt_target trace_tg_reg[]__read_mostly = { - { - .name ="TRACE" , - .family =NFPROTO_IPV4 , - .target = trace_tg, - .table ="raw" , - .me =THIS_MODULE , - }, - { - .name ="TRACE" , - .family =NFPROTO_IPV6 , - .target = trace_tg, - .table ="raw" , - .me =THIS_MODULE , - }, +static struct xt_target trace_tg_reg__read_mostly = { + .name ="TRACE" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .table ="raw" , + .target = trace_tg, + .me =THIS_MODULE , };static int __init trace_tg_init (void ) { -return xt_register_targets (trace_tg_reg,ARRAY_SIZE (trace_tg_reg)); +return xt_register_target (&trace_tg_reg); } static void __exit trace_tg_exit(void) { -xt_unregister_targets (trace_tg_reg,ARRAY_SIZE (trace_tg_reg)); +xt_unregister_target (&trace_tg_reg); }module_init (trace_tg_init);
net/netfilter/xt_limit.c +13 -27
@@ -167,43 +167,29 @@ static int limit_mt_compat_to_user(void __user *dst, void *src) }#endif /* CONFIG_COMPAT */ -static struct xt_match limit_mt_reg[]__read_mostly = { - { - .name ="limit" , - .family =NFPROTO_IPV4 , - .checkentry = limit_mt_check, - .match = limit_mt, - .matchsize =sizeof (struct xt_rateinfo ), +static struct xt_match limit_mt_reg__read_mostly = { + .name ="limit" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .match = limit_mt, + .checkentry = limit_mt_check, + .matchsize =sizeof (struct xt_rateinfo ), #ifdef CONFIG_COMPAT - .compatsize =sizeof (struct compat_xt_rateinfo ), - .compat_from_user = limit_mt_compat_from_user, - .compat_to_user = limit_mt_compat_to_user, + .compatsize =sizeof (struct compat_xt_rateinfo ), + .compat_from_user = limit_mt_compat_from_user, + .compat_to_user = limit_mt_compat_to_user, #endif - .me =THIS_MODULE , - }, - { - .name ="limit" , - .family =NFPROTO_IPV6 , - .checkentry = limit_mt_check, - .match = limit_mt, - .matchsize =sizeof (struct xt_rateinfo ), -#ifdef CONFIG_COMPAT - .compatsize =sizeof (struct compat_xt_rateinfo ), - .compat_from_user = limit_mt_compat_from_user, - .compat_to_user = limit_mt_compat_to_user, -#endif - .me =THIS_MODULE , - }, + .me =THIS_MODULE , };static int __init limit_mt_init (void ) { -return xt_register_matches (limit_mt_reg,ARRAY_SIZE (limit_mt_reg)); +return xt_register_match (&limit_mt_reg); } static void __exit limit_mt_exit(void) { -xt_unregister_matches (limit_mt_reg,ARRAY_SIZE (limit_mt_reg)); +xt_unregister_match (&limit_mt_reg); }module_init (limit_mt_init);
net/netfilter/xt_mark.c +2 -24
@@ -92,7 +92,7 @@ static struct xt_match mark_mt_reg[] __read_mostly = { { .name = "mark", .revision = 0, - .family = NFPROTO_IPV4, + .family = NFPROTO_UNSPEC, .checkentry = mark_mt_check_v0, .match = mark_mt_v0, .matchsize = sizeof(struct xt_mark_info),
@@ -104,31 +104,9 @@ static struct xt_match mark_mt_reg[] __read_mostly = { .me = THIS_MODULE, }, { - .name = "mark", - .revision = 0, - .family = NFPROTO_IPV6, - .checkentry = mark_mt_check_v0, - .match = mark_mt_v0, - .matchsize =sizeof (struct xt_mark_info ), -#ifdef CONFIG_COMPAT - .compatsize =sizeof (struct compat_xt_mark_info ), - .compat_from_user = mark_mt_compat_from_user_v0, - .compat_to_user = mark_mt_compat_to_user_v0, -#endif - .me = THIS_MODULE, - }, - { - .name ="mark" , - .revision = 1, - .family = NFPROTO_IPV4, - .match = mark_mt, - .matchsize = sizeof(struct xt_mark_mtinfo1), - .me = THIS_MODULE, - }, - { .name = "mark", .revision = 1, - .family = NFPROTO_IPV6, + .family = NFPROTO_UNSPEC, .match = mark_mt, .matchsize = sizeof(struct xt_mark_mtinfo1), .me = THIS_MODULE,
net/netfilter/xt_quota.c +10 -19
@@ -54,33 +54,24 @@ quota_mt_check(const char *tablename, const void *entry,return true; } -static struct xt_match quota_mt_reg[]__read_mostly = { - { - .name ="quota" , - .family =NFPROTO_IPV4 , - .checkentry = quota_mt_check, - .match = quota_mt, - .matchsize =sizeof (struct xt_quota_info ), - .me =THIS_MODULE - }, - { - .name ="quota" , - .family =NFPROTO_IPV6 , - .checkentry = quota_mt_check, - .match = quota_mt, - .matchsize =sizeof (struct xt_quota_info ), - .me =THIS_MODULE - }, +static struct xt_match quota_mt_reg__read_mostly = { + .name ="quota" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .match = quota_mt, + .checkentry = quota_mt_check, + .matchsize =sizeof (struct xt_quota_info ), + .me =THIS_MODULE , };static int __init quota_mt_init (void ) { -return xt_register_matches (quota_mt_reg,ARRAY_SIZE (quota_mt_reg)); +return xt_register_match ("a_mt_reg); } static void __exit quota_mt_exit(void) { -xt_unregister_matches (quota_mt_reg,ARRAY_SIZE (quota_mt_reg)); +xt_unregister_match ("a_mt_reg); }module_init (quota_mt_init);
net/netfilter/xt_rateest.c +11 -22
@@ -137,36 +137,25 @@ static void xt_rateest_mt_destroy(const struct xt_match *match,xt_rateest_put (info->est2); } -static struct xt_match xt_rateest_match[]__read_mostly = { - { - .family =NFPROTO_IPV4 , - .name ="rateest" , - .match = xt_rateest_mt, - .checkentry = xt_rateest_mt_checkentry, - .destroy = xt_rateest_mt_destroy, - .matchsize =sizeof (struct xt_rateest_match_info ), - .me =THIS_MODULE , - }, - { - .family =NFPROTO_IPV6 , - .name ="rateest" , - .match = xt_rateest_mt, - .checkentry = xt_rateest_mt_checkentry, - .destroy = xt_rateest_mt_destroy, - .matchsize =sizeof (struct xt_rateest_match_info ), - .me =THIS_MODULE , - }, +static struct xt_match xt_rateest_mt_reg__read_mostly = { + .name ="rateest" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .match = xt_rateest_mt, + .checkentry = xt_rateest_mt_checkentry, + .destroy = xt_rateest_mt_destroy, + .matchsize =sizeof (struct xt_rateest_match_info ), + .me =THIS_MODULE , };static int __init xt_rateest_mt_init (void ) { -return xt_register_matches (xt_rateest_match, -ARRAY_SIZE (xt_rateest_match)); +return xt_register_match (&xt_rateest_mt_reg); } static void __exit xt_rateest_mt_fini(void) { -xt_unregister_matches (xt_rateest_match,ARRAY_SIZE (xt_rateest_match)); +xt_unregister_match (&xt_rateest_mt_reg); }MODULE_AUTHOR ("Patrick McHardy <[email protected]>" );
net/netfilter/xt_statistic.c +10 -21
@@ -66,35 +66,24 @@ statistic_mt_check(const char *tablename, const void *entry,return true; } -static struct xt_match statistic_mt_reg[]__read_mostly = { - { - .name ="statistic" , - .family =NFPROTO_IPV4 , - .checkentry = statistic_mt_check, - .match = statistic_mt, - .matchsize =sizeof (struct xt_statistic_info ), - .me =THIS_MODULE , - }, - { - .name ="statistic" , - .family =NFPROTO_IPV6 , - .checkentry = statistic_mt_check, - .match = statistic_mt, - .matchsize =sizeof (struct xt_statistic_info ), - .me =THIS_MODULE , - }, +static struct xt_match xt_statistic_mt_reg__read_mostly = { + .name ="statistic" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .match = statistic_mt, + .checkentry = statistic_mt_check, + .matchsize =sizeof (struct xt_statistic_info ), + .me =THIS_MODULE , };static int __init statistic_mt_init (void ) { -return xt_register_matches (statistic_mt_reg, -ARRAY_SIZE (statistic_mt_reg)); +return xt_register_match (&xt_statistic_mt_reg); } static void __exit statistic_mt_exit(void) { -xt_unregister_matches (statistic_mt_reg, -ARRAY_SIZE (statistic_mt_reg)); +xt_unregister_match (&xt_statistic_mt_reg); }module_init (statistic_mt_init);
net/netfilter/xt_string.c +6 -25
@@ -81,11 +81,11 @@ static void string_mt_destroy(const struct xt_match *match, void *matchinfo)textsearch_destroy (STRING_TEXT_PRIV (matchinfo)->config); } -static struct xt_match string_mt_reg[]__read_mostly = { +static struct xt_match xt_string_mt_reg[]__read_mostly = { { .name ="string" , .revision =0 , - .family =NFPROTO_IPV4 , + .family =NFPROTO_UNSPEC , .checkentry = string_mt_check, .match = string_mt, .destroy = string_mt_destroy,
@@ -95,27 +95,7 @@ static struct xt_match string_mt_reg[] __read_mostly = { { .name = "string", .revision = 1, - .family = NFPROTO_IPV4, - .checkentry = string_mt_check, - .match = string_mt, - .destroy = string_mt_destroy, - .matchsize = sizeof(struct xt_string_info), - .me =THIS_MODULE - }, - { - .name = "string", - .revision = 0, - .family = NFPROTO_IPV6, - .checkentry = string_mt_check, - .match = string_mt, - .destroy = string_mt_destroy, - .matchsize = sizeof(struct xt_string_info), - .me =THIS_MODULE - }, - { - .name = "string", - .revision = 1, - .family = NFPROTO_IPV6, + .family = NFPROTO_UNSPEC, .checkentry = string_mt_check, .match = string_mt, .destroy = string_mt_destroy,
@@ -126,12 +106,13 @@ static struct xt_match string_mt_reg[] __read_mostly = {static int __init string_mt_init (void ) { -return xt_register_matches (string_mt_reg,ARRAY_SIZE (string_mt_reg)); +return xt_register_matches (xt_string_mt_reg, +ARRAY_SIZE (xt_string_mt_reg)); } static void __exit string_mt_exit(void) { -xt_unregister_matches (string_mt_reg,ARRAY_SIZE (string_mt_reg)); +xt_unregister_matches (xt_string_mt_reg,ARRAY_SIZE (xt_string_mt_reg)); }module_init (string_mt_init);
net/netfilter/xt_time.c +9 -19
@@ -237,33 +237,23 @@ time_mt_check(const char *tablename, const void *ip,return true; } -static struct xt_match time_mt_reg[]__read_mostly = { - { - .name ="time" , - .family =NFPROTO_IPV4 , - .match = time_mt, - .matchsize =sizeof (struct xt_time_info ), - .checkentry = time_mt_check, - .me =THIS_MODULE , - }, - { - .name ="time" , - .family =NFPROTO_IPV6 , - .match = time_mt, - .matchsize =sizeof (struct xt_time_info ), - .checkentry = time_mt_check, - .me =THIS_MODULE , - }, +static struct xt_match xt_time_mt_reg__read_mostly = { + .name ="time" , + .family =NFPROTO_UNSPEC , + .match = time_mt, + .checkentry = time_mt_check, + .matchsize =sizeof (struct xt_time_info ), + .me =THIS_MODULE , };static int __init time_mt_init (void ) { -return xt_register_matches (time_mt_reg,ARRAY_SIZE (time_mt_reg)); +return xt_register_match (&xt_time_mt_reg); } static void __exit time_mt_exit(void) { -xt_unregister_matches (time_mt_reg,ARRAY_SIZE (time_mt_reg)); +xt_unregister_match (&xt_time_mt_reg); }module_init (time_mt_init);
net/netfilter/xt_u32.c +9 -17
@@ -99,31 +99,23 @@ u32_mt(const struct sk_buff *skb, const struct net_device *in,return ret ^ data->invert; } -static struct xt_match u32_mt_reg[]__read_mostly = { - { - .name ="u32" , - .family =NFPROTO_IPV4 , - .match = u32_mt, - .matchsize =sizeof (struct xt_u32 ), - .me =THIS_MODULE , - }, - { - .name ="u32" , - .family =NFPROTO_IPV6 , - .match = u32_mt, - .matchsize =sizeof (struct xt_u32 ), - .me =THIS_MODULE , - }, +static struct xt_match xt_u32_mt_reg__read_mostly = { + .name ="u32" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .match = u32_mt, + .matchsize =sizeof (struct xt_u32 ), + .me =THIS_MODULE , };static int __init u32_mt_init (void ) { -return xt_register_matches (u32_mt_reg,ARRAY_SIZE (u32_mt_reg)); +return xt_register_match (&xt_u32_mt_reg); } static void __exit u32_mt_exit(void) { -xt_unregister_matches (u32_mt_reg,ARRAY_SIZE (u32_mt_reg)); +xt_unregister_match (&xt_u32_mt_reg); }module_init (u32_mt_init);
netfilter 07/79: netns: remove nf_*_net() wrappers
In reply to Patrick McHardycommit 48dc7865aa3db9404aedc8677d9daf8f8f469ab0
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:01 2008 +0200
netfilter: netns: remove nf_*_net() wrappers
Now that dev_net() exists, the usefullness of them is even less. Also they're a big problem in resolving circular header dependencies necessary for NOTRACK-in-netns patch. See below.
include/linux/netfilter.h +0 -53
@@ -5,13 +5,11 @@#include <linux/init.h> #include <linux/skbuff.h> #include <linux/net.h> -#include <linux/netdevice.h> #include <linux/if.h> #include <linux/in.h> #include <linux/in6.h> #include <linux/wait.h> #include <linux/list.h> -#include <net/net_namespace.h> #endif #include <linux/types.h> #include <linux/compiler.h>
@@ -355,56 +353,5 @@ extern void (*nf_ct_destroy)(struct nf_conntrack *);static inline void nf_ct_attach (struct sk_buff *new,struct sk_buff *skb) {}#endif -static inline struct net *nf_pre_routing_net (const struct net_device *in, -const struct net_device *out) -{ -#ifdef CONFIG_NET_NS -return in->nd_net; -#else -return &init_net; -#endif -} - -static inline struct net *nf_local_in_net (const struct net_device *in, -const struct net_device *out) -{ -#ifdef CONFIG_NET_NS -return in->nd_net; -#else -return &init_net; -#endif -} - -static inline struct net *nf_forward_net (const struct net_device *in, -const struct net_device *out) -{ -#ifdef CONFIG_NET_NS -BUG_ON (in->nd_net != out->nd_net); -return in->nd_net; -#else -return &init_net; -#endif -} - -static inline struct net *nf_local_out_net (const struct net_device *in, -const struct net_device *out) -{ -#ifdef CONFIG_NET_NS -return out->nd_net; -#else -return &init_net; -#endif -} - -static inline struct net *nf_post_routing_net (const struct net_device *in, -const struct net_device *out) -{ -#ifdef CONFIG_NET_NS -return out->nd_net; -#else -return &init_net; -#endif -} -#endif /*__KERNEL__*/ #endif /*__LINUX_NETFILTER_H*/
net/ipv4/netfilter/iptable_filter.c +3 -3
@@ -70,7 +70,7 @@ ipt_local_in_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_local_in_net (in, out)->ipv4.iptable_filter); +dev_net (in)->ipv4.iptable_filter); } static unsigned int
@@ -81,7 +81,7 @@ ipt_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_forward_net (in, out)->ipv4.iptable_filter); +dev_net (in)->ipv4.iptable_filter); } static unsigned int
@@ -101,7 +101,7 @@ ipt_local_out_hook(unsigned int hook, }return ipt_do_table (skb, hook, in, out, -nf_local_out_net (in, out)->ipv4.iptable_filter); +dev_net (out)->ipv4.iptable_filter); }static struct nf_hook_ops ipt_ops[]__read_mostly = {
net/ipv4/netfilter/iptable_mangle.c +5 -5
@@ -81,7 +81,7 @@ ipt_pre_routing_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_pre_routing_net (in, out)->ipv4.iptable_mangle); +dev_net (in)->ipv4.iptable_mangle); } static unsigned int
@@ -92,7 +92,7 @@ ipt_post_routing_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_post_routing_net (in, out)->ipv4.iptable_mangle); +dev_net (out)->ipv4.iptable_mangle); } static unsigned int
@@ -103,7 +103,7 @@ ipt_local_in_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_local_in_net (in, out)->ipv4.iptable_mangle); +dev_net (in)->ipv4.iptable_mangle); } static unsigned int
@@ -114,7 +114,7 @@ ipt_forward_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_forward_net (in, out)->ipv4.iptable_mangle); +dev_net (in)->ipv4.iptable_mangle); } static unsigned int
@@ -147,7 +147,7 @@ ipt_local_hook(unsigned int hook, tos = iph->tos; ret =ipt_do_table (skb, hook, in, out, -nf_local_out_net (in, out)->ipv4.iptable_mangle); +dev_net (out)->ipv4.iptable_mangle);/* Reroute for ANY change. */ if (ret !=NF_DROP && ret !=NF_STOLEN && ret !=NF_QUEUE ) { iph =ip_hdr (skb);
net/ipv4/netfilter/iptable_raw.c +2 -2
@@ -53,7 +53,7 @@ ipt_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_pre_routing_net (in, out)->ipv4.iptable_raw); +dev_net (in)->ipv4.iptable_raw); } static unsigned int
@@ -72,7 +72,7 @@ ipt_local_hook(unsigned int hook,return NF_ACCEPT ; }return ipt_do_table (skb, hook, in, out, -nf_local_out_net (in, out)->ipv4.iptable_raw); +dev_net (out)->ipv4.iptable_raw); }/* 'raw' is the very first table. */
net/ipv4/netfilter/iptable_security.c +3 -3
@@ -73,7 +73,7 @@ ipt_local_in_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_local_in_net (in, out)->ipv4.iptable_security); +dev_net (in)->ipv4.iptable_security); } static unsigned int
@@ -84,7 +84,7 @@ ipt_forward_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ipt_do_table (skb, hook, in, out, -nf_forward_net (in, out)->ipv4.iptable_security); +dev_net (in)->ipv4.iptable_security); } static unsigned int
@@ -103,7 +103,7 @@ ipt_local_out_hook(unsigned int hook,return NF_ACCEPT ; }return ipt_do_table (skb, hook, in, out, -nf_local_out_net (in, out)->ipv4.iptable_security); +dev_net (out)->ipv4.iptable_security); }static struct nf_hook_ops ipt_ops[]__read_mostly = {
net/ipv6/netfilter/ip6table_filter.c +3 -3
@@ -68,7 +68,7 @@ ip6t_local_in_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ip6t_do_table (skb, hook, in, out, -nf_local_in_net (in, out)->ipv6.ip6table_filter); +dev_net (in)->ipv6.ip6table_filter); } static unsigned int
@@ -79,7 +79,7 @@ ip6t_forward_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ip6t_do_table (skb, hook, in, out, -nf_forward_net (in, out)->ipv6.ip6table_filter); +dev_net (in)->ipv6.ip6table_filter); } static unsigned int
@@ -100,7 +100,7 @@ ip6t_local_out_hook(unsigned int hook,#endif return ip6t_do_table (skb, hook, in, out, -nf_local_out_net (in, out)->ipv6.ip6table_filter); +dev_net (out)->ipv6.ip6table_filter); }static struct nf_hook_ops ip6t_ops[]__read_mostly = {
net/ipv6/netfilter/ip6table_security.c +3 -3
@@ -72,7 +72,7 @@ ip6t_local_in_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ip6t_do_table (skb, hook, in, out, -nf_local_in_net (in, out)->ipv6.ip6table_security); +dev_net (in)->ipv6.ip6table_security); } static unsigned int
@@ -83,7 +83,7 @@ ip6t_forward_hook(unsigned int hook, int (*okfn)(struct sk_buff *)) {return ip6t_do_table (skb, hook, in, out, -nf_forward_net (in, out)->ipv6.ip6table_security); +dev_net (in)->ipv6.ip6table_security); } static unsigned int
@@ -95,7 +95,7 @@ ip6t_local_out_hook(unsigned int hook, {/* TBD: handle short packets via raw socket */ return ip6t_do_table (skb, hook, in, out, -nf_local_out_net (in, out)->ipv6.ip6table_security); +dev_net (out)->ipv6.ip6table_security); }static struct nf_hook_ops ip6t_ops[]__read_mostly = {
netfilter 08/79: netns: ip6table_raw in netns for real
In reply to Patrick McHardycommit 1339dd91719f3e841b113ddaccd30fd87b9d2332
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:01 2008 +0200
netfilter: netns: ip6table_raw in netns for real
net/ipv6/netfilter/ip6table_raw.c +16 -4
@@ -45,25 +45,37 @@ static struct xt_table packet_raw = {/* The work comes in here from netfilter.c. */ static unsigned int -ip6t_hook (unsigned int hook, +ip6t_pre_routing_hook (unsigned int hook,struct sk_buff *skb,const struct net_device *in,const struct net_device *out,int (*okfn)(struct sk_buff *)) { -return ip6t_do_table (skb, hook, in, out, init_net.ipv6.ip6table_raw); +return ip6t_do_table (skb, hook, in, out, +dev_net (in)->ipv6.ip6table_raw); +} + +static unsigned int +ip6t_local_out_hook (unsigned int hook, +struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +int (*okfn)(struct sk_buff *)) +{ +return ip6t_do_table (skb, hook, in, out, +dev_net (out)->ipv6.ip6table_raw); }static struct nf_hook_ops ip6t_ops[]__read_mostly = { { - .hook = ip6t_hook, + .hook = ip6t_pre_routing_hook, .pf =PF_INET6 , .hooknum =NF_INET_PRE_ROUTING , .priority =NF_IP6_PRI_FIRST , .owner =THIS_MODULE , }, { - .hook = ip6t_hook, + .hook = ip6t_local_out_hook, .pf =PF_INET6 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP6_PRI_FIRST ,
netfilter 09/79: netns: ip6table_mangle in netns for real
In reply to Patrick McHardycommit 7dd1b8dad84c9561fe8949ed5db4de15aee877eb
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:02 2008 +0200
netfilter: netns: ip6table_mangle in netns for real
net/ipv6/netfilter/ip6table_mangle.c +22 -9
@@ -67,17 +67,29 @@ static struct xt_table packet_mangler = {/* The work comes in here from netfilter.c. */ static unsigned int -ip6t_route_hook (unsigned int hook, +ip6t_in_hook (unsigned int hook,struct sk_buff *skb,const struct net_device *in,const struct net_device *out,int (*okfn)(struct sk_buff *)) { -return ip6t_do_table (skb, hook, in, out, init_net.ipv6.ip6table_mangle); +return ip6t_do_table (skb, hook, in, out, +dev_net (in)->ipv6.ip6table_mangle); }static unsigned int -ip6t_local_hook(unsigned int hook, +ip6t_post_routing_hook (unsigned int hook, +struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +int (*okfn)(struct sk_buff *)) +{ +return ip6t_do_table (skb, hook, in, out, +dev_net (out)->ipv6.ip6table_mangle); +} + +static unsigned int +ip6t_local_out_hook(unsigned int hook, struct sk_buff *skb, const struct net_device *in, const struct net_device *out,
@@ -108,7 +120,8 @@ ip6t_local_hook(unsigned int hook,/* flowlabel and prio (includes version, which shouldn't change either */ flowlabel = *((u_int32_t *)ipv6_hdr (skb)); - ret =ip6t_do_table (skb, hook, in, out, init_net.ipv6.ip6table_mangle); + ret =ip6t_do_table (skb, hook, in, out, +dev_net (out)->ipv6.ip6table_mangle); if (ret != NF_DROP && ret != NF_STOLEN && (memcmp(&ipv6_hdr(skb)->saddr, &saddr, sizeof(saddr))
@@ -122,35 +135,35 @@ ip6t_local_hook(unsigned int hook,static struct nf_hook_ops ip6t_ops[]__read_mostly = { { - .hook = ip6t_route_hook, + .hook = ip6t_in_hook, .owner =THIS_MODULE , .pf =PF_INET6 , .hooknum =NF_INET_PRE_ROUTING , .priority =NF_IP6_PRI_MANGLE , }, { - .hook = ip6t_route_hook, + .hook = ip6t_in_hook, .owner =THIS_MODULE , .pf =PF_INET6 , .hooknum =NF_INET_LOCAL_IN , .priority =NF_IP6_PRI_MANGLE , }, { - .hook = ip6t_route_hook, + .hook = ip6t_in_hook, .owner =THIS_MODULE , .pf =PF_INET6 , .hooknum =NF_INET_FORWARD , .priority =NF_IP6_PRI_MANGLE , }, { - .hook = ip6t_local_hook, + .hook = ip6t_local_out_hook, .owner =THIS_MODULE , .pf =PF_INET6 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP6_PRI_MANGLE , }, { - .hook = ip6t_route_hook, + .hook = ip6t_post_routing_hook, .owner =THIS_MODULE , .pf =PF_INET6 , .hooknum =NF_INET_POST_ROUTING ,
netfilter 10/79: netns: ip6t_REJECT in netns for real
In reply to Patrick McHardycommit e10aad9998e463df8e25ec749538faf3324dd31b
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:02 2008 +0200
netfilter: netns: ip6t_REJECT in netns for real
net/ipv6/netfilter/ip6t_REJECT.c +12 -10
@@ -35,7 +35,7 @@ MODULE_DESCRIPTION("Xtables: packet \"rejection\" target for IPv6");MODULE_LICENSE ("GPL" );/* Send RST reply */ -static void send_reset (struct sk_buff *oldskb) +static void send_reset (struct net *net,struct sk_buff *oldskb) {struct sk_buff *nskb;struct tcphdr otcph, *tcph;
@@ -94,7 +94,7 @@ static void send_reset(struct sk_buff *oldskb) fl.fl_ip_sport = otcph.dest; fl.fl_ip_dport = otcph.source;security_skb_classify_flow (oldskb, &fl); - dst =ip6_route_output (&init_net,NULL , &fl); + dst =ip6_route_output (net,NULL , &fl);if (dst ==NULL )return ;if (dst->error ||xfrm_lookup (&dst, &fl,NULL ,0 ))
@@ -163,10 +163,11 @@ static void send_reset(struct sk_buff *oldskb) }static inline void -send_unreach (struct sk_buff *skb_in,unsigned char code,unsigned int hooknum) +send_unreach (struct net *net,struct sk_buff *skb_in,unsigned char code, +unsigned int hooknum) {if (hooknum ==NF_INET_LOCAL_OUT && skb_in->dev ==NULL ) - skb_in->dev = init_net.loopback_dev; + skb_in->dev = net->loopback_dev;icmpv6_send (skb_in,ICMPV6_DEST_UNREACH , code,0 ,NULL ); }
@@ -177,6 +178,7 @@ reject_tg6(struct sk_buff *skb, const struct net_device *in, const struct xt_target *target, const void *targinfo) { const struct ip6t_reject_info *reject = targinfo; +struct net *net =dev_net (in ? in : out);pr_debug ("%s: medium point\n" , __func__);/* WARNING: This code causes reentry within ip6tables.
@@ -184,25 +186,25 @@ reject_tg6(struct sk_buff *skb, const struct net_device *in,must return an absolute verdict. --RR */ switch (reject->with) {case IP6T_ICMP6_NO_ROUTE : -send_unreach (skb,ICMPV6_NOROUTE , hooknum); +send_unreach (net, skb,ICMPV6_NOROUTE , hooknum);break ;case IP6T_ICMP6_ADM_PROHIBITED : -send_unreach (skb,ICMPV6_ADM_PROHIBITED , hooknum); +send_unreach (net, skb,ICMPV6_ADM_PROHIBITED , hooknum);break ;case IP6T_ICMP6_NOT_NEIGHBOUR : -send_unreach (skb,ICMPV6_NOT_NEIGHBOUR , hooknum); +send_unreach (net, skb,ICMPV6_NOT_NEIGHBOUR , hooknum);break ;case IP6T_ICMP6_ADDR_UNREACH : -send_unreach (skb,ICMPV6_ADDR_UNREACH , hooknum); +send_unreach (net, skb,ICMPV6_ADDR_UNREACH , hooknum);break ;case IP6T_ICMP6_PORT_UNREACH : -send_unreach (skb,ICMPV6_PORT_UNREACH , hooknum); +send_unreach (net, skb,ICMPV6_PORT_UNREACH , hooknum);break ;case IP6T_ICMP6_ECHOREPLY :/* Do nothing */ break ;case IP6T_TCP_RESET : -send_reset (skb); +send_reset (net, skb);break ;default :if (net_ratelimit ())
netfilter 11/79: netns nf_conntrack: add netns boilerplate
In reply to Patrick McHardycommit dfdb8d791877052bbb527d9688d94a064721d8f7
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:02 2008 +0200
netfilter: netns nf_conntrack: add netns boilerplate
One comment: #ifdefs around #include is necessary to overcome amazing compile breakages in NOTRACK-in-netns patch (see below).
include/net/net_namespace.h +6 -0
@@ -16,6 +16,9 @@#include <net/netns/ipv6.h> #include <net/netns/dccp.h> #include <net/netns/x_tables.h> +#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) +#include <net/netns/conntrack.h> +#endif struct proc_dir_entry ;struct net_device ;
@@ -67,6 +70,9 @@ struct net {#endif #ifdef CONFIG_NETFILTER struct netns_xt xt; +#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) +struct netns_ct ct; +#endif #endif struct net_generic *gen; };
include/net/netfilter/nf_conntrack_core.h +2 -2
@@ -24,8 +24,8 @@ extern unsigned int nf_conntrack_in(u_int8_t pf,unsigned int hooknum, struct sk_buff *skb); -extern int nf_conntrack_init (void ); -extern void nf_conntrack_cleanup (void ); +extern int nf_conntrack_init (struct net *net); +extern void nf_conntrack_cleanup (struct net *net);extern int nf_conntrack_proto_init (void );extern void nf_conntrack_proto_fini (void );
include/net/netns/conntrack.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __NETNS_CONNTRACK_H +#define __NETNS_CONNTRACK_H + +struct netns_ct { +}; +#endif
net/netfilter/nf_conntrack_core.c +2 -2
@@ -1006,7 +1006,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_flush);/* Mishearing the voices in his head, our hero wonders how he's supposed to kill the mall. */ -void nf_conntrack_cleanup (void ) +void nf_conntrack_cleanup (struct net *net) {rcu_assign_pointer (ip_ct_attach,NULL );
@@ -1120,7 +1120,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_set_hashsize);module_param_call (hashsize, nf_conntrack_set_hashsize, param_get_uint, &nf_conntrack_htable_size,0600 ); -int __init nf_conntrack_init (void ) +int nf_conntrack_init (struct net *net) {int max_factor =8 ;int ret;
net/netfilter/nf_conntrack_expect.c +2 -2
@@ -537,7 +537,7 @@ static const struct file_operations exp_file_ops = { };#endif /* CONFIG_PROC_FS */ -static int __init exp_proc_init (void ) +static int exp_proc_init (void ) {#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc;
@@ -558,7 +558,7 @@ static void exp_proc_remove(void)module_param_named (expect_hashsize, nf_ct_expect_hsize, uint,0600 ); -int __init nf_conntrack_expect_init (void ) +int nf_conntrack_expect_init (void ) {int err = -ENOMEM ;
net/netfilter/nf_conntrack_standalone.c +18 -3
@@ -440,11 +440,26 @@ static void nf_conntrack_standalone_fini_sysctl(void) }#endif /* CONFIG_SYSCTL */ +static int nf_conntrack_net_init (struct net *net) +{ +return nf_conntrack_init (net); +} + +static void nf_conntrack_net_exit (struct net *net) +{ +nf_conntrack_cleanup (net); +} + +static struct pernet_operations nf_conntrack_net_ops = { + .init = nf_conntrack_net_init, + .exit = nf_conntrack_net_exit, +}; +static int __init nf_conntrack_standalone_init (void ) {int ret; - ret =nf_conntrack_init (); + ret =register_pernet_subsys (&nf_conntrack_net_ops);if (ret <0 ) goto out; ret =nf_conntrack_standalone_init_proc ();
@@ -458,7 +473,7 @@ static int __init nf_conntrack_standalone_init(void) out_sysctl:nf_conntrack_standalone_fini_proc (); out_proc: -nf_conntrack_cleanup (); +unregister_pernet_subsys (&nf_conntrack_net_ops); out:return ret; }
@@ -467,7 +482,7 @@ static void __exit nf_conntrack_standalone_fini(void) {nf_conntrack_standalone_fini_sysctl ();nf_conntrack_standalone_fini_proc (); -nf_conntrack_cleanup (); +unregister_pernet_subsys (&nf_conntrack_net_ops); }module_init (nf_conntrack_standalone_init);
netfilter 12/79: netns nf_conntrack: add ->ct_net pointer from conntrack to netns
In reply to Patrick McHardycommit 5a1fb391d881905e89623d78858d05b248cbc86a
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:02 2008 +0200
netfilter: netns nf_conntrack: add ->ct_net pointer from conntrack to netns
Conntrack (struct nf_conn) gets pointer to netns: ->ct_net -- netns in which it was created. It comes from netdevice.
->ct_net is write-once field.
Every conntrack in system has ->ct_net initialized, no exceptions.
->ct_net doesn't pin netns: conntracks are recycled after timeouts and pinning background traffic will prevent netns from even starting shutdown sequence.
Right now every conntrack is created in init_net.
include/net/netfilter/nf_conntrack.h +16 -2
@@ -123,7 +123,9 @@ struct nf_conn/* Extensions */ struct nf_ct_ext *ext; - +#ifdef CONFIG_NET_NS +struct net *ct_net; +#endif struct rcu_head rcu; };
@@ -147,6 +149,17 @@ static inline u_int8_t nf_ct_protonum(const struct nf_conn *ct)/* get master conntrack via master expectation */ #define master_ct (conntr) (conntr->master) +extern struct net init_net; + +static inline struct net *nf_ct_net (const struct nf_conn *ct) +{ +#ifdef CONFIG_NET_NS +return ct->ct_net; +#else +return &init_net; +#endif +} +/* Alter reply tuple (maybe alter helper). */ extern void nf_conntrack_alter_reply(struct nf_conn *ct,
@@ -251,7 +264,8 @@ extern void nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data);extern void nf_conntrack_free (struct nf_conn *ct);extern struct nf_conn * -nf_conntrack_alloc (const struct nf_conntrack_tuple *orig, +nf_conntrack_alloc (struct net *net, +const struct nf_conntrack_tuple *orig,const struct nf_conntrack_tuple *repl,gfp_t gfp);
net/netfilter/nf_conntrack_core.c +13 -4
@@ -464,7 +464,8 @@ static noinline int early_drop(unsigned int hash)return dropped; } -struct nf_conn *nf_conntrack_alloc (const struct nf_conntrack_tuple *orig, +struct nf_conn *nf_conntrack_alloc (struct net *net, +const struct nf_conntrack_tuple *orig,const struct nf_conntrack_tuple *repl,gfp_t gfp) {
@@ -503,6 +504,9 @@ struct nf_conn *nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, ct->tuplehash[IP_CT_DIR_REPLY ].tuple = *repl;/* Don't set timer yet: wait for confirmation */ setup_timer (&ct->timeout, death_by_timeout, (unsigned long )ct); +#ifdef CONFIG_NET_NS + ct->ct_net = net; +#endif INIT_RCU_HEAD (&ct->rcu);return ct;
@@ -528,7 +532,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_free);/* Allocate a new conntrack: we return -ENOMEM if classification failed due to stress. Otherwise it really is unclassifiable. */ static struct nf_conntrack_tuple_hash * -init_conntrack(const struct nf_conntrack_tuple *tuple, +init_conntrack(struct net *net, + const struct nf_conntrack_tuple *tuple, struct nf_conntrack_l3proto *l3proto, struct nf_conntrack_l4proto *l4proto, struct sk_buff *skb,
@@ -544,7 +549,7 @@ init_conntrack(const struct nf_conntrack_tuple *tuple,return NULL ; } - ct =nf_conntrack_alloc (tuple, &repl_tuple,GFP_ATOMIC ); + ct =nf_conntrack_alloc (net, tuple, &repl_tuple,GFP_ATOMIC );if (ct ==NULL ||IS_ERR (ct)) {pr_debug ("Can't allocate conntrack.\n" );return (struct nf_conntrack_tuple_hash *)ct;
@@ -631,7 +636,8 @@ resolve_normal_ct(struct sk_buff *skb,/* look for tuple match */ h =nf_conntrack_find_get (&tuple);if (!h) { - h =init_conntrack (&tuple, l3proto, l4proto, skb, dataoff); + h =init_conntrack (&init_net, &tuple, l3proto, l4proto, skb, + dataoff);if (!h)return NULL ;if (IS_ERR (h))
@@ -1185,6 +1191,9 @@ int nf_conntrack_init(struct net *net)/* Set up fake conntrack: - to never be deleted, not in any hashes */ +#ifdef CONFIG_NET_NS + nf_conntrack_untracked.ct_net = &init_net; +#endif atomic_set (&nf_conntrack_untracked.ct_general.use,1 );/* - and look it like as a confirmed connection */ set_bit (IPS_CONFIRMED_BIT , &nf_conntrack_untracked.status);
net/netfilter/nf_conntrack_netlink.c +1 -1
@@ -1125,7 +1125,7 @@ ctnetlink_create_conntrack(struct nlattr *cda[],struct nf_conn_help *help;struct nf_conntrack_helper *helper; - ct =nf_conntrack_alloc (otuple, rtuple,GFP_KERNEL ); + ct =nf_conntrack_alloc (&init_net, otuple, rtuple,GFP_KERNEL );if (ct ==NULL ||IS_ERR (ct))return -ENOMEM ;
netfilter 13/79: netns nf_conntrack: per-netns conntrack count
In reply to Patrick McHardycommit 49ac8713b6d064adf7474080fdccebd7cce76be0
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:03 2008 +0200
netfilter: netns nf_conntrack: per-netns conntrack count
Sysctls and proc files are stubbed to init_net's one. This is temporary.
include/net/netfilter/nf_conntrack.h +0 -1
@@ -288,7 +288,6 @@ static inline int nf_ct_is_untracked(const struct sk_buff *skb)extern int nf_conntrack_set_hashsize (const char *val,struct kernel_param *kp);extern unsigned int nf_conntrack_htable_size;extern int nf_conntrack_checksum; -extern atomic_t nf_conntrack_count;extern int nf_conntrack_max; DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
include/net/netns/conntrack.h +3 -0
@@ -1,6 +1,9 @@#ifndef __NETNS_CONNTRACK_H#define __NETNS_CONNTRACK_H +#include <asm/atomic.h> +struct netns_ct { +atomic_t count; };#endif
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -1
@@ -254,7 +254,7 @@ static ctl_table ip_ct_sysctl_table[] = { { .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT, .procname = "ip_conntrack_count", - .data = &nf_conntrack_count, + .data = &init_net.ct.count, .maxlen = sizeof(int), .mode = 0444, .proc_handler = &proc_dointvec,
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +1 -1
@@ -314,7 +314,7 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v)static int ct_cpu_seq_show (struct seq_file *seq,void *v) { -unsigned int nr_conntracks =atomic_read (&nf_conntrack_count); +unsigned int nr_conntracks =atomic_read (&init_net.ct.count);const struct ip_conntrack_stat *st = v;if (v ==SEQ_START_TOKEN ) {
net/netfilter/nf_conntrack_core.c +8 -10
@@ -44,10 +44,6 @@DEFINE_SPINLOCK (nf_conntrack_lock);EXPORT_SYMBOL_GPL (nf_conntrack_lock); -/* nf_conntrack_standalone needs this */ -atomic_t nf_conntrack_count =ATOMIC_INIT (0 ); -EXPORT_SYMBOL_GPL (nf_conntrack_count); -unsigned int nf_conntrack_htable_size__read_mostly ;EXPORT_SYMBOL_GPL (nf_conntrack_htable_size);
@@ -477,13 +473,13 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, }/* We don't want any race condition at early drop stage */ -atomic_inc (&nf_conntrack_count); +atomic_inc (&net->ct.count);if (nf_conntrack_max && -unlikely (atomic_read (&nf_conntrack_count) > nf_conntrack_max)) { +unlikely (atomic_read (&net->ct.count) > nf_conntrack_max)) {unsigned int hash =hash_conntrack (orig);if (!early_drop (hash)) { -atomic_dec (&nf_conntrack_count); +atomic_dec (&net->ct.count);if (net_ratelimit ())printk (KERN_WARNING "nf_conntrack: table full, dropping"
@@ -495,7 +491,7 @@ struct nf_conn *nf_conntrack_alloc(struct net *net, ct =kmem_cache_zalloc (nf_conntrack_cachep, gfp);if (ct ==NULL ) {pr_debug ("nf_conntrack_alloc: Can't alloc conntrack.\n" ); -atomic_dec (&nf_conntrack_count); +atomic_dec (&net->ct.count);return ERR_PTR (-ENOMEM ); }
@@ -516,10 +512,11 @@ EXPORT_SYMBOL_GPL(nf_conntrack_alloc);static void nf_conntrack_free_rcu (struct rcu_head *head) { struct nf_conn *ct = container_of(head, struct nf_conn, rcu); +struct net *net =nf_ct_net (ct);nf_ct_ext_free (ct);kmem_cache_free (nf_conntrack_cachep, ct); -atomic_dec (&nf_conntrack_count); +atomic_dec (&net->ct.count); }void nf_conntrack_free (struct nf_conn *ct)
@@ -1024,7 +1021,7 @@ void nf_conntrack_cleanup(struct net *net)nf_ct_event_cache_flush (); i_see_dead_people:nf_conntrack_flush (); -if (atomic_read (&nf_conntrack_count) !=0 ) { +if (atomic_read (&net->ct.count) !=0 ) {schedule (); goto i_see_dead_people; }
@@ -1148,6 +1145,7 @@ int nf_conntrack_init(struct net *net)* entries. */ max_factor =4 ; } +atomic_set (&net->ct.count,0 ); nf_conntrack_hash =nf_ct_alloc_hashtable (&nf_conntrack_htable_size, &nf_conntrack_vmalloc);if (!nf_conntrack_hash) {
net/netfilter/nf_conntrack_standalone.c +2 -2
@@ -226,7 +226,7 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v)static int ct_cpu_seq_show (struct seq_file *seq,void *v) { -unsigned int nr_conntracks =atomic_read (&nf_conntrack_count); +unsigned int nr_conntracks =atomic_read (&init_net.ct.count);const struct ip_conntrack_stat *st = v;if (v ==SEQ_START_TOKEN ) {
@@ -338,7 +338,7 @@ static ctl_table nf_ct_sysctl_table[] = { { .ctl_name = NET_NF_CONNTRACK_COUNT, .procname = "nf_conntrack_count", - .data = &nf_conntrack_count, + .data = &init_net.ct.count, .maxlen = sizeof(int), .mode = 0444, .proc_handler = &proc_dointvec,
netfilter 14/79: netns nf_conntrack: per-netns conntrack hash
In reply to Patrick McHardycommit 400dad39d1c33fe797e47326d87a3f54d0ac5181
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:03 2008 +0200
netfilter: netns nf_conntrack: per-netns conntrack hash
* make per-netns conntrack hash
Other solution is to add ->ct_net pointer to tuplehashes and still has one hash, I tried that it's ugly and requires more code deep down in protocol modules et al.
* propagate netns pointer to where needed, e. g. to conntrack iterators.
include/net/netfilter/nf_conntrack.h +3 -3
@@ -195,11 +195,11 @@ extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, unsigned int size);extern struct nf_conntrack_tuple_hash * -__nf_conntrack_find (const struct nf_conntrack_tuple *tuple); +__nf_conntrack_find (struct net *net,const struct nf_conntrack_tuple *tuple);extern void nf_conntrack_hash_insert (struct nf_conn *ct); -extern void nf_conntrack_flush (void ); +extern void nf_conntrack_flush (struct net *net); extern bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff, u_int16_t l3num,
@@ -261,7 +261,7 @@ extern struct nf_conn nf_conntrack_untracked;/* Iterate over all conntracks: if iter returns true, it's deleted. */ extern void -nf_ct_iterate_cleanup (int (*iter)(struct nf_conn *i,void *data),void *data); +nf_ct_iterate_cleanup (struct net *net,int (*iter)(struct nf_conn *i,void *data),void *data);extern void nf_conntrack_free (struct nf_conn *ct);extern struct nf_conn * nf_conntrack_alloc(struct net *net,
include/net/netfilter/nf_conntrack_core.h +1 -2
@@ -48,7 +48,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,/* Find a connection corresponding to a tuple. */ extern struct nf_conntrack_tuple_hash * -nf_conntrack_find_get (const struct nf_conntrack_tuple *tuple); +nf_conntrack_find_get (struct net *net,const struct nf_conntrack_tuple *tuple);extern int __nf_conntrack_confirm (struct sk_buff *skb);
@@ -71,7 +71,6 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,const struct nf_conntrack_l3proto *l3proto, const struct nf_conntrack_l4proto *proto); -extern struct hlist_head *nf_conntrack_hash;extern spinlock_t nf_conntrack_lock ;extern struct hlist_head unconfirmed;
include/net/netns/conntrack.h +2 -0
@@ -5,5 +5,7 @@struct netns_ct {atomic_t count; +struct hlist_head *hash; +int hash_vmalloc; };#endif
net/ipv4/netfilter/ipt_MASQUERADE.c +2 -1
@@ -129,7 +129,8 @@ static int masq_device_event(struct notifier_block *this,and forget them. */ NF_CT_ASSERT (dev->ifindex !=0 ); -nf_ct_iterate_cleanup (device_cmp, (void *)(long )dev->ifindex); +nf_ct_iterate_cleanup (&init_net, device_cmp, + (void *)(long )dev->ifindex); }return NOTIFY_DONE ;
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -1
@@ -323,7 +323,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)return -EINVAL ; } - h =nf_conntrack_find_get (&tuple); + h =nf_conntrack_find_get (sock_net (sk), &tuple);if (h) {struct sockaddr_in sin;struct nf_conn *ct =nf_ct_tuplehash_to_ctrack (h);
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +2 -2
@@ -32,7 +32,7 @@ static struct hlist_node *ct_get_first(struct seq_file *seq)for (st->bucket =0 ; st->bucket < nf_conntrack_htable_size; st->bucket++) { - n =rcu_dereference (nf_conntrack_hash[st->bucket].first); + n =rcu_dereference (init_net.ct.hash[st->bucket].first);if (n)return n; }
@@ -48,7 +48,7 @@ static struct hlist_node *ct_get_next(struct seq_file *seq,while (head ==NULL ) {if (++st->bucket >= nf_conntrack_htable_size)return NULL ; - head =rcu_dereference (nf_conntrack_hash[st->bucket].first); + head =rcu_dereference (init_net.ct.hash[st->bucket].first); }return head; }
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -155,7 +155,7 @@ icmp_error_message(struct sk_buff *skb, *ctinfo =IP_CT_RELATED ; - h =nf_conntrack_find_get (&innertuple); + h =nf_conntrack_find_get (&init_net, &innertuple);if (!h) {pr_debug ("icmp_error_message: no match\n" );return -NF_ACCEPT ;
net/ipv4/netfilter/nf_nat_core.c +1 -1
@@ -643,7 +643,7 @@ static int clean_nat(struct nf_conn *i, void *data) static void __exit nf_nat_cleanup(void) { -nf_ct_iterate_cleanup (&clean_nat,NULL ); +nf_ct_iterate_cleanup (&init_net, &clean_nat,NULL );synchronize_rcu ();nf_ct_free_hashtable (bysource, nf_nat_vmalloced, nf_nat_htable_size);nf_ct_l3proto_put (l3proto);
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -156,7 +156,7 @@ icmpv6_error_message(struct sk_buff *skb, *ctinfo =IP_CT_RELATED ; - h =nf_conntrack_find_get (&intuple); + h =nf_conntrack_find_get (&init_net, &intuple);if (!h) {pr_debug ("icmpv6_error: no match\n" );return -NF_ACCEPT ;
net/netfilter/nf_conntrack_core.c +38 -36
236 lines not on this page · raw message
net/netfilter/nf_conntrack_helper.c +1 -1
@@ -159,7 +159,7 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)hlist_for_each_entry (h, n, &unconfirmed, hnode)unhelp (h, me);for (i =0 ; i < nf_conntrack_htable_size; i++) { -hlist_for_each_entry (h, n, &nf_conntrack_hash[i], hnode) +hlist_for_each_entry (h, n, &init_net.ct.hash[i], hnode)unhelp (h, me); }spin_unlock_bh (&nf_conntrack_lock);
net/netfilter/nf_conntrack_netlink.c +8 -8
@@ -549,7 +549,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) last = (struct nf_conn *)cb->args[1 ];for (; cb->args[0 ] < nf_conntrack_htable_size; cb->args[0 ]++) { restart: -hlist_for_each_entry_rcu (h, n, &nf_conntrack_hash[cb->args[0 ]], +hlist_for_each_entry_rcu (h, n, &init_net.ct.hash[cb->args[0 ]], hnode) {if (NF_CT_DIRECTION (h) !=IP_CT_DIR_ORIGINAL )continue ;
@@ -794,14 +794,14 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb, err =ctnetlink_parse_tuple (cda, &tuple,CTA_TUPLE_REPLY , u3); else {/* Flush the whole table */ -nf_conntrack_flush (); +nf_conntrack_flush (&init_net);return 0 ; }if (err <0 )return err; - h =nf_conntrack_find_get (&tuple); + h =nf_conntrack_find_get (&init_net, &tuple);if (!h)return -ENOENT ;
@@ -847,7 +847,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,if (err <0 )return err; - h =nf_conntrack_find_get (&tuple); + h =nf_conntrack_find_get (&init_net, &tuple);if (!h)return -ENOENT ;
@@ -1213,9 +1213,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,spin_lock_bh (&nf_conntrack_lock);if (cda[CTA_TUPLE_ORIG ]) - h =__nf_conntrack_find (&otuple); + h =__nf_conntrack_find (&init_net, &otuple);else if (cda[CTA_TUPLE_REPLY ]) - h =__nf_conntrack_find (&rtuple); + h =__nf_conntrack_find (&init_net, &rtuple);if (h ==NULL ) {struct nf_conntrack_tuple master;
@@ -1230,7 +1230,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,if (err <0 ) goto out_unlock; - master_h =__nf_conntrack_find (&master); + master_h =__nf_conntrack_find (&init_net, &master);if (master_h ==NULL ) { err = -ENOENT ; goto out_unlock;
@@ -1670,7 +1670,7 @@ ctnetlink_create_expect(struct nlattr *cda[], u_int8_t u3)return err;/* Look for master conntrack of this expectation */ - h =nf_conntrack_find_get (&master_tuple); + h =nf_conntrack_find_get (&init_net, &master_tuple);if (!h)return -ENOENT ; ct =nf_ct_tuplehash_to_ctrack (h);
net/netfilter/nf_conntrack_pptp.c +1 -1
@@ -143,7 +143,7 @@ static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)pr_debug ("trying to timeout ct or exp for tuple " );nf_ct_dump_tuple (t); - h =nf_conntrack_find_get (t); + h =nf_conntrack_find_get (&init_net, t);if (h) { sibling =nf_ct_tuplehash_to_ctrack (h);pr_debug ("setting timeout of conntrack %p to 0\n" , sibling);
net/netfilter/nf_conntrack_proto.c +2 -2
@@ -219,7 +219,7 @@ void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto)synchronize_rcu ();/* Remove all contrack entries for this protocol */ -nf_ct_iterate_cleanup (kill_l3proto, proto); +nf_ct_iterate_cleanup (&init_net, kill_l3proto, proto); }EXPORT_SYMBOL_GPL (nf_conntrack_l3proto_unregister);
@@ -328,7 +328,7 @@ void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *l4proto)synchronize_rcu ();/* Remove all contrack entries for this protocol */ -nf_ct_iterate_cleanup (kill_l4proto, l4proto); +nf_ct_iterate_cleanup (&init_net, kill_l4proto, l4proto); }EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_unregister);
net/netfilter/nf_conntrack_standalone.c +2 -2
@@ -51,7 +51,7 @@ static struct hlist_node *ct_get_first(struct seq_file *seq)for (st->bucket =0 ; st->bucket < nf_conntrack_htable_size; st->bucket++) { - n =rcu_dereference (nf_conntrack_hash[st->bucket].first); + n =rcu_dereference (init_net.ct.hash[st->bucket].first);if (n)return n; }
@@ -67,7 +67,7 @@ static struct hlist_node *ct_get_next(struct seq_file *seq,while (head ==NULL ) {if (++st->bucket >= nf_conntrack_htable_size)return NULL ; - head =rcu_dereference (nf_conntrack_hash[st->bucket].first); + head =rcu_dereference (init_net.ct.hash[st->bucket].first); }return head; }
net/netfilter/xt_connlimit.c +1 -1
@@ -123,7 +123,7 @@ static int count_them(struct xt_connlimit_data *data,/* check the saved connections */ list_for_each_entry_safe (conn, tmp, hash, list) { - found =__nf_conntrack_find (&conn->tuple); + found =__nf_conntrack_find (&init_net, &conn->tuple); found_ct =NULL ;if (found !=NULL )
netfilter 15/79: netns: fix {ip,6}_route_me_harder() in netns
In reply to Patrick McHardycommit b21f89019399ff75d9c239010e38b840eb6e01e7
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:03 2008 +0200
netfilter: netns: fix {ip,6}_route_me_harder() in netns
Take netns from skb->dst->dev. It should be safe because, they are called from LOCAL_OUT hook where dst is valid (though, I'm not exactly sure about IPVS and queueing packets to userspace).
[Patrick: its safe everywhere since they already expect skb->dst to be set]
net/ipv4/netfilter.c +4 -3
@@ -12,6 +12,7 @@/* route_me_harder function, used by iptable_nat, iptable_mangle + ip_queue */ int ip_route_me_harder (struct sk_buff *skb,unsigned addr_type) { +struct net *net =dev_net (skb->dst->dev);const struct iphdr *iph =ip_hdr (skb);struct rtable *rt;struct flowi fl = {};
@@ -19,7 +20,7 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)unsigned int hh_len;unsigned int type; - type =inet_addr_type (&init_net, iph->saddr); + type =inet_addr_type (net, iph->saddr);if (skb->sk &&inet_sk (skb->sk)->transparent) type =RTN_LOCAL ;if (addr_type ==RTN_UNSPEC )
@@ -36,7 +37,7 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type) fl.oif = skb->sk ? skb->sk->sk_bound_dev_if :0 ; fl.mark = skb->mark; fl.flags = skb->sk ?inet_sk_flowi_flags (skb->sk) :0 ; -if (ip_route_output_key (&init_net, &rt, &fl) !=0 ) +if (ip_route_output_key (net, &rt, &fl) !=0 )return -1 ;/* Drop old route. */
@@ -46,7 +47,7 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)/* non-local src, find valid iif to satisfy * rp-filter when calling ip_route_input. */ fl.nl_u.ip4_u.daddr = iph->saddr; -if (ip_route_output_key (&init_net, &rt, &fl) !=0 ) +if (ip_route_output_key (net, &rt, &fl) !=0 )return -1 ; odst = skb->dst;
net/ipv6/netfilter.c +1 -1
@@ -23,7 +23,7 @@ int ip6_route_me_harder(struct sk_buff *skb) .saddr = iph->saddr, } }, }; - dst =ip6_route_output (&init_net, skb->sk, &fl); + dst =ip6_route_output (dev_net (skb->dst->dev), skb->sk, &fl);#ifdef CONFIG_XFRM if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
netfilter 16/79: netns nf_conntrack: per-netns expectations
In reply to Patrick McHardycommit 9b03f38d0487f3908696242286d934c9b38f9d2a
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:03 2008 +0200
netfilter: netns nf_conntrack: per-netns expectations
Make per-netns a) expectation hash and b) expectations count.
Expectations always belongs to netns to which it's master conntrack belong. This is natural and doesn't bloat expectation.
Proc files and leaf users are stubbed to init_net, this is temporary.
include/net/netfilter/nf_conntrack_expect.h +14 -6
@@ -6,7 +6,6 @@#define _NF_CONNTRACK_EXPECT_H#include <net/netfilter/nf_conntrack.h> -extern struct hlist_head *nf_ct_expect_hash;extern unsigned int nf_ct_expect_hsize;extern unsigned int nf_ct_expect_max;
@@ -56,6 +55,15 @@ struct nf_conntrack_expectstruct rcu_head rcu; }; +static inline struct net *nf_ct_exp_net (struct nf_conntrack_expect *exp) +{ +#ifdef CONFIG_NET_NS +return exp->master->ct_net;/* by definition */ +#else +return &init_net; +#endif +} +struct nf_conntrack_expect_policy {unsigned int max_expected;
@@ -67,17 +75,17 @@ struct nf_conntrack_expect_policy#define NF_CT_EXPECT_PERMANENT 0x1#define NF_CT_EXPECT_INACTIVE 0x2 -int nf_conntrack_expect_init (void ); -void nf_conntrack_expect_fini (void ); +int nf_conntrack_expect_init (struct net *net); +void nf_conntrack_expect_fini (struct net *net);struct nf_conntrack_expect * -__nf_ct_expect_find (const struct nf_conntrack_tuple *tuple); +__nf_ct_expect_find (struct net *net,const struct nf_conntrack_tuple *tuple);struct nf_conntrack_expect * -nf_ct_expect_find_get (const struct nf_conntrack_tuple *tuple); +nf_ct_expect_find_get (struct net *net,const struct nf_conntrack_tuple *tuple);struct nf_conntrack_expect * -nf_ct_find_expectation (const struct nf_conntrack_tuple *tuple); +nf_ct_find_expectation (struct net *net,const struct nf_conntrack_tuple *tuple);void nf_ct_unlink_expect (struct nf_conntrack_expect *exp);void nf_ct_remove_expectations (struct nf_conn *ct);
include/net/netns/conntrack.h +3 -0
@@ -5,7 +5,10 @@struct netns_ct {atomic_t count; +unsigned int expect_count;struct hlist_head *hash; +struct hlist_head *expect_hash;int hash_vmalloc; +int expect_vmalloc; };#endif
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +4 -2
@@ -177,11 +177,12 @@ struct ct_expect_iter_state {static struct hlist_node *ct_expect_get_first (struct seq_file *seq) { +struct net *net = &init_net;struct ct_expect_iter_state *st = seq->private;struct hlist_node *n;for (st->bucket =0 ; st->bucket < nf_ct_expect_hsize; st->bucket++) { - n =rcu_dereference (nf_ct_expect_hash[st->bucket].first); + n =rcu_dereference (net->ct.expect_hash[st->bucket].first);if (n)return n; }
@@ -191,13 +192,14 @@ static struct hlist_node *ct_expect_get_first(struct seq_file *seq)static struct hlist_node *ct_expect_get_next (struct seq_file *seq,struct hlist_node *head) { +struct net *net = &init_net;struct ct_expect_iter_state *st = seq->private; head =rcu_dereference (head->next);while (head ==NULL ) {if (++st->bucket >= nf_ct_expect_hsize)return NULL ; - head =rcu_dereference (nf_ct_expect_hash[st->bucket].first); + head =rcu_dereference (net->ct.expect_hash[st->bucket].first); }return head; }
net/ipv4/netfilter/nf_nat_pptp.c +1 -1
@@ -73,7 +73,7 @@ static void pptp_nat_expected(struct nf_conn *ct,pr_debug ("trying to unexpect other dir: " );nf_ct_dump_tuple_ip (&t); - other_exp =nf_ct_expect_find_get (&t); + other_exp =nf_ct_expect_find_get (&init_net, &t);if (other_exp) {nf_ct_unexpect_related (other_exp);nf_ct_expect_put (other_exp);
net/netfilter/nf_conntrack_core.c +4 -4
@@ -562,7 +562,7 @@ init_conntrack(struct net *net,nf_ct_acct_ext_add (ct,GFP_ATOMIC );spin_lock_bh (&nf_conntrack_lock); - exp =nf_ct_find_expectation (tuple); + exp =nf_ct_find_expectation (net, tuple);if (exp) {pr_debug ("conntrack: expectation arrives ct=%p exp=%p\n" , ct, exp);
@@ -1038,7 +1038,7 @@ void nf_conntrack_cleanup(struct net *net) nf_conntrack_htable_size);nf_conntrack_acct_fini (); -nf_conntrack_expect_fini (); +nf_conntrack_expect_fini (net);nf_conntrack_helper_fini ();nf_conntrack_proto_fini (); }
@@ -1173,7 +1173,7 @@ int nf_conntrack_init(struct net *net)if (ret <0 ) goto err_free_conntrack_slab; - ret =nf_conntrack_expect_init (); + ret =nf_conntrack_expect_init (net);if (ret <0 ) goto out_fini_proto;
@@ -1203,7 +1203,7 @@ int nf_conntrack_init(struct net *net) out_fini_helper:nf_conntrack_helper_fini (); out_fini_expect: -nf_conntrack_expect_fini (); +nf_conntrack_expect_fini (net); out_fini_proto:nf_conntrack_proto_fini (); err_free_conntrack_slab:
net/netfilter/nf_conntrack_expect.c +28 -27
193 lines not on this page · raw message
net/netfilter/nf_conntrack_h323_main.c +1 -1
@@ -1219,7 +1219,7 @@ static struct nf_conntrack_expect *find_expect(struct nf_conn *ct, tuple.dst.u.tcp.port = port; tuple.dst.protonum =IPPROTO_TCP ; - exp =__nf_ct_expect_find (&tuple); + exp =__nf_ct_expect_find (&init_net, &tuple);if (exp && exp->master == ct)return exp;return NULL ;
net/netfilter/nf_conntrack_helper.c +1 -1
@@ -145,7 +145,7 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)/* Get rid of expectations */ for (i =0 ; i < nf_ct_expect_hsize; i++) {hlist_for_each_entry_safe (exp, n, next, - &nf_ct_expect_hash[i], hnode) { + &init_net.ct.expect_hash[i], hnode) {struct nf_conn_help *help =nfct_help (exp->master);if ((help->helper == me || exp->helper == me) &&del_timer (&exp->timeout)) {
net/netfilter/nf_conntrack_netlink.c +7 -6
@@ -1458,6 +1458,7 @@ static int ctnetlink_exp_done(struct netlink_callback *cb)static int ctnetlink_exp_dump_table (struct sk_buff *skb,struct netlink_callback *cb) { +struct net *net = &init_net;struct nf_conntrack_expect *exp, *last;struct nfgenmsg *nfmsg =NLMSG_DATA (cb->nlh);struct hlist_node *n;
@@ -1467,7 +1468,7 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb) last = (struct nf_conntrack_expect *)cb->args[1 ];for (; cb->args[0 ] < nf_ct_expect_hsize; cb->args[0 ]++) { restart: -hlist_for_each_entry (exp, n, &nf_ct_expect_hash[cb->args[0 ]], +hlist_for_each_entry (exp, n, &net->ct.expect_hash[cb->args[0 ]], hnode) {if (l3proto && exp->tuple.src.l3num != l3proto)continue ;
@@ -1529,7 +1530,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,if (err <0 )return err; - exp =nf_ct_expect_find_get (&tuple); + exp =nf_ct_expect_find_get (&init_net, &tuple);if (!exp)return -ENOENT ;
@@ -1583,7 +1584,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,return err;/* bump usage count to 2 */ - exp =nf_ct_expect_find_get (&tuple); + exp =nf_ct_expect_find_get (&init_net, &tuple);if (!exp)return -ENOENT ;
@@ -1613,7 +1614,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb, }for (i =0 ; i < nf_ct_expect_hsize; i++) {hlist_for_each_entry_safe (exp, n, next, - &nf_ct_expect_hash[i], + &init_net.ct.expect_hash[i], hnode) { m_help =nfct_help (exp->master); if (m_help->helper == h
@@ -1629,7 +1630,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,spin_lock_bh (&nf_conntrack_lock);for (i =0 ; i < nf_ct_expect_hsize; i++) {hlist_for_each_entry_safe (exp, n, next, - &nf_ct_expect_hash[i], + &init_net.ct.expect_hash[i], hnode) {if (del_timer (&exp->timeout)) {nf_ct_unlink_expect (exp);
@@ -1724,7 +1725,7 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,return err;spin_lock_bh (&nf_conntrack_lock); - exp =__nf_ct_expect_find (&tuple); + exp =__nf_ct_expect_find (&init_net, &tuple);if (!exp) {spin_unlock_bh (&nf_conntrack_lock);
net/netfilter/nf_conntrack_pptp.c +2 -2
@@ -121,7 +121,7 @@ static void pptp_expectfn(struct nf_conn *ct,pr_debug ("trying to unexpect other dir: " );nf_ct_dump_tuple (&inv_t); - exp_other =nf_ct_expect_find_get (&inv_t); + exp_other =nf_ct_expect_find_get (&init_net, &inv_t);if (exp_other) {/* delete other expectation. */ pr_debug ("found\n" );
@@ -154,7 +154,7 @@ static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)nf_ct_put (sibling);return 1 ; }else { - exp =nf_ct_expect_find_get (t); + exp =nf_ct_expect_find_get (&init_net, t);if (exp) {pr_debug ("unexpect_related of expect %p\n" , exp);nf_ct_unexpect_related (exp);
net/netfilter/nf_conntrack_sip.c +1 -1
@@ -775,7 +775,7 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb,rcu_read_lock (); do { - exp = __nf_ct_expect_find(&tuple); + exp = __nf_ct_expect_find(&init_net, &tuple); if (!exp || exp->master == ct || nfct_help(exp->master)->helper != nfct_help(ct)->helper ||
netfilter 17/79: netns nf_conntrack: per-netns unconfirmed list
In reply to Patrick McHardycommit 63c9a26264be108b52de087724673f8664570e34
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:04 2008 +0200
netfilter: netns nf_conntrack: per-netns unconfirmed list
What is confirmed connection in one netns can very well be unconfirmed in another one.
include/net/netfilter/nf_conntrack_core.h +0 -1
@@ -72,6 +72,5 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, const struct nf_conntrack_l4proto *proto);extern spinlock_t nf_conntrack_lock ; -extern struct hlist_head unconfirmed;#endif /* _NF_CONNTRACK_CORE_H */
include/net/netns/conntrack.h +2 -0
@@ -1,6 +1,7 @@#ifndef __NETNS_CONNTRACK_H#define __NETNS_CONNTRACK_H +#include <linux/list.h> #include <asm/atomic.h> struct netns_ct {
@@ -8,6 +9,7 @@ struct netns_ct {unsigned int expect_count;struct hlist_head *hash;struct hlist_head *expect_hash; +struct hlist_head unconfirmed;int hash_vmalloc;int expect_vmalloc; };
net/netfilter/nf_conntrack_core.c +4 -3
@@ -54,7 +54,6 @@ struct nf_conn nf_conntrack_untracked __read_mostly;EXPORT_SYMBOL_GPL (nf_conntrack_untracked);unsigned int nf_ct_log_invalid__read_mostly ; -HLIST_HEAD (unconfirmed);static struct kmem_cache *nf_conntrack_cachep__read_mostly ; DEFINE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
@@ -596,7 +595,8 @@ init_conntrack(struct net *net, }/* Overload tuple linked list to put us in unconfirmed list. */ -hlist_add_head (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].hnode, &unconfirmed); +hlist_add_head (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].hnode, + &net->ct.unconfirmed);spin_unlock_bh (&nf_conntrack_lock);
@@ -957,7 +957,7 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data), goto found; } } -hlist_for_each_entry (h, n, &unconfirmed, hnode) { +hlist_for_each_entry (h, n, &net->ct.unconfirmed, hnode) { ct =nf_ct_tuplehash_to_ctrack (h);if (iter (ct, data))set_bit (IPS_DYING_BIT , &ct->status);
@@ -1154,6 +1154,7 @@ int nf_conntrack_init(struct net *net)printk (KERN_ERR "Unable to create nf_conntrack_hash\n" ); goto err_out; } +INIT_HLIST_HEAD (&net->ct.unconfirmed); nf_conntrack_max = max_factor * nf_conntrack_htable_size;
net/netfilter/nf_conntrack_helper.c +1 -1
@@ -156,7 +156,7 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me) }/* Get rid of expecteds, set helpers to NULL. */ -hlist_for_each_entry (h, n, &unconfirmed, hnode) +hlist_for_each_entry (h, n, &init_net.ct.unconfirmed, hnode)unhelp (h, me);for (i =0 ; i < nf_conntrack_htable_size; i++) {hlist_for_each_entry (h, n, &init_net.ct.hash[i], hnode)
netfilter 18/79: netns nf_conntrack: pass netns pointer to nf_conntrack_in()
In reply to Patrick McHardycommit a702a65fc1376fc1f6757ec2a6960348af3f1876
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:04 2008 +0200
netfilter: netns nf_conntrack: pass netns pointer to nf_conntrack_in()
It's deducible from skb->dev or skb->dst->dev, but we know netns at the moment of call, so pass it down and use for finding and creating conntracks.
include/net/netfilter/nf_conntrack_core.h +2 -1
@@ -20,7 +20,8 @@/* This header is used to share core functionality between the standalone connection tracking module, and the compatibility layer's use of connection tracking. */ -extern unsigned int nf_conntrack_in (u_int8_t pf, +extern unsigned int nf_conntrack_in (struct net *net, +u_int8_t pf,unsigned int hooknum,struct sk_buff *skb);
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +2 -2
@@ -172,7 +172,7 @@ static unsigned int ipv4_conntrack_in(unsigned int hooknum, const struct net_device *out, int (*okfn)(struct sk_buff *)) { - return nf_conntrack_in(PF_INET, hooknum, skb); + return nf_conntrack_in(dev_net(in), PF_INET, hooknum, skb); } static unsigned int ipv4_conntrack_local(unsigned int hooknum,
@@ -188,7 +188,7 @@ static unsigned int ipv4_conntrack_local(unsigned int hooknum,printk ("ipt_hook: happy cracking.\n" );return NF_ACCEPT ; } -return nf_conntrack_in (PF_INET , hooknum, skb); +return nf_conntrack_in (dev_net (out),PF_INET , hooknum, skb); }/* Connection tracking may drop packets, but never alters them, so
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +16 -8
@@ -211,11 +211,10 @@ static unsigned int ipv6_defrag(unsigned int hooknum,return NF_STOLEN ; } -static unsigned int ipv6_conntrack_in (unsigned int hooknum, -struct sk_buff *skb, -const struct net_device *in, -const struct net_device *out, -int (*okfn)(struct sk_buff *)) +static unsigned int __ipv6_conntrack_in (struct net *net, +unsigned int hooknum, +struct sk_buff *skb, +int (*okfn)(struct sk_buff *)) {struct sk_buff *reasm = skb->nfct_reasm;
@@ -225,7 +224,7 @@ static unsigned int ipv6_conntrack_in(unsigned int hooknum,if (!reasm->nfct) {unsigned int ret; - ret =nf_conntrack_in (PF_INET6 , hooknum, reasm); + ret =nf_conntrack_in (net,PF_INET6 , hooknum, reasm);if (ret !=NF_ACCEPT )return ret; }
@@ -235,7 +234,16 @@ static unsigned int ipv6_conntrack_in(unsigned int hooknum,return NF_ACCEPT ; } -return nf_conntrack_in (PF_INET6 , hooknum, skb); +return nf_conntrack_in (net,PF_INET6 , hooknum, skb); +} + +static unsigned int ipv6_conntrack_in (unsigned int hooknum, +struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +int (*okfn)(struct sk_buff *)) +{ +return __ipv6_conntrack_in (dev_net (in), hooknum, skb, okfn); } static unsigned int ipv6_conntrack_local(unsigned int hooknum,
@@ -250,7 +258,7 @@ static unsigned int ipv6_conntrack_local(unsigned int hooknum,printk ("ipv6_conntrack_local: packet too short\n" );return NF_ACCEPT ; } -return ipv6_conntrack_in (hooknum, skb, in, out, okfn); +return __ipv6_conntrack_in (dev_net (out), hooknum, skb, okfn); }static struct nf_hook_ops ipv6_conntrack_ops[]__read_mostly = {
net/netfilter/nf_conntrack_core.c +8 -7
@@ -611,7 +611,8 @@ init_conntrack(struct net *net,/* On success, returns conntrack ptr, sets skb->nfct and ctinfo */ static inline struct nf_conn * -resolve_normal_ct(struct sk_buff *skb, +resolve_normal_ct(struct net *net, + struct sk_buff *skb, unsigned int dataoff, u_int16_t l3num, u_int8_t protonum,
@@ -632,10 +633,9 @@ resolve_normal_ct(struct sk_buff *skb, }/* look for tuple match */ - h =nf_conntrack_find_get (&init_net, &tuple); + h =nf_conntrack_find_get (net, &tuple);if (!h) { - h =init_conntrack (&init_net, &tuple, l3proto, l4proto, skb, - dataoff); + h =init_conntrack (net, &tuple, l3proto, l4proto, skb, dataoff);if (!h)return NULL ;if (IS_ERR (h))
@@ -669,7 +669,8 @@ resolve_normal_ct(struct sk_buff *skb, }unsigned int -nf_conntrack_in (u_int8_t pf,unsigned int hooknum,struct sk_buff *skb) +nf_conntrack_in (struct net *net,u_int8_t pf,unsigned int hooknum, +struct sk_buff *skb) {struct nf_conn *ct;enum ip_conntrack_info ctinfo;
@@ -709,8 +710,8 @@ nf_conntrack_in(u_int8_t pf, unsigned int hooknum, struct sk_buff *skb)return -ret; } - ct =resolve_normal_ct (skb, dataoff, pf, protonum, l3proto, l4proto, - &set_reply, &ctinfo); + ct =resolve_normal_ct (net, skb, dataoff, pf, protonum, + l3proto, l4proto, &set_reply, &ctinfo);if (!ct) {/* Not valid part of a connection */ NF_CT_STAT_INC_ATOMIC (invalid);
netfilter 19/79: netns nf_conntrack: pass netns pointer to L4 protocol's ->error hook
In reply to Patrick McHardycommit 74c51a1497033e6ff7b8096797daca233a4a30df
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:05 2008 +0200
netfilter: netns nf_conntrack: pass netns pointer to L4 protocol's ->error hook
Again, it's deducible from skb, but we're going to use it for nf_conntrack_checksum and statistics, so just pass it from upper layer.
include/net/netfilter/nf_conntrack_l4proto.h +1 -1
@@ -50,7 +50,7 @@ struct nf_conntrack_l4proto/* Called when a conntrack entry is destroyed */ void (*destroy)(struct nf_conn *ct); -int (*error)(struct sk_buff *skb,unsigned int dataoff, +int (*error)(struct net *net,struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum);
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +4 -4
@@ -123,7 +123,7 @@ static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb,/* Returns conntrack if it dealt with ICMP, and filled in skb fields */ static int -icmp_error_message (struct sk_buff *skb, +icmp_error_message (struct net *net,struct sk_buff *skb,enum ip_conntrack_info *ctinfo,unsigned int hooknum) {
@@ -155,7 +155,7 @@ icmp_error_message(struct sk_buff *skb, *ctinfo =IP_CT_RELATED ; - h =nf_conntrack_find_get (&init_net, &innertuple); + h =nf_conntrack_find_get (net, &innertuple);if (!h) {pr_debug ("icmp_error_message: no match\n" );return -NF_ACCEPT ;
@@ -172,7 +172,7 @@ icmp_error_message(struct sk_buff *skb,/* Small and modified version of icmp_rcv */ static int -icmp_error (struct sk_buff *skb,unsigned int dataoff, +icmp_error (struct net *net,struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum) {const struct icmphdr *icmph;
@@ -217,7 +217,7 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff, && icmph->type != ICMP_REDIRECT)return NF_ACCEPT ; -return icmp_error_message (skb, ctinfo, hooknum); +return icmp_error_message (net, skb, ctinfo, hooknum); }#if defined(CONFIG_NF_CT_NETLINK ) || defined(CONFIG_NF_CT_NETLINK_MODULE )
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +5 -4
@@ -122,7 +122,8 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb, }static int -icmpv6_error_message (struct sk_buff *skb, +icmpv6_error_message (struct net *net, +struct sk_buff *skb,unsigned int icmp6off,enum ip_conntrack_info *ctinfo,unsigned int hooknum)
@@ -156,7 +157,7 @@ icmpv6_error_message(struct sk_buff *skb, *ctinfo =IP_CT_RELATED ; - h =nf_conntrack_find_get (&init_net, &intuple); + h =nf_conntrack_find_get (net, &intuple);if (!h) {pr_debug ("icmpv6_error: no match\n" );return -NF_ACCEPT ;
@@ -172,7 +173,7 @@ icmpv6_error_message(struct sk_buff *skb, }static int -icmpv6_error (struct sk_buff *skb,unsigned int dataoff, +icmpv6_error (struct net *net,struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum) {const struct icmp6hdr *icmp6h;
@@ -197,7 +198,7 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff,if (icmp6h->icmp6_type >=128 )return NF_ACCEPT ; -return icmpv6_error_message (skb, dataoff, ctinfo, hooknum); +return icmpv6_error_message (net, skb, dataoff, ctinfo, hooknum); }#if defined(CONFIG_NF_CT_NETLINK ) || defined(CONFIG_NF_CT_NETLINK_MODULE )
net/netfilter/nf_conntrack_core.c +7 -5
@@ -703,11 +703,13 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,/* It may be an special packet, error, unclean... * inverse of the return code tells to the netfilter * core what to do with the packet. */ -if (l4proto->error !=NULL && - (ret = l4proto->error (skb, dataoff, &ctinfo, pf, hooknum)) <=0 ) { -NF_CT_STAT_INC_ATOMIC (error); -NF_CT_STAT_INC_ATOMIC (invalid); -return -ret; +if (l4proto->error !=NULL ) { + ret = l4proto->error (net, skb, dataoff, &ctinfo, pf, hooknum); +if (ret <=0 ) { +NF_CT_STAT_INC_ATOMIC (error); +NF_CT_STAT_INC_ATOMIC (invalid); +return -ret; + } } ct = resolve_normal_ct(net, skb, dataoff, pf, protonum,
net/netfilter/nf_conntrack_proto_dccp.c +3 -3
@@ -545,9 +545,9 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,return NF_ACCEPT ; } -static int dccp_error (struct sk_buff *skb,unsigned int dataoff, -enum ip_conntrack_info *ctinfo,u_int8_t pf, -unsigned int hooknum) +static int dccp_error (struct net *net,struct sk_buff *skb, +unsigned int dataoff,enum ip_conntrack_info *ctinfo, +u_int8_t pf,unsigned int hooknum) {struct dccp_hdr _dh, *dh;unsigned int dccp_len = skb->len - dataoff;
net/netfilter/nf_conntrack_proto_tcp.c +2 -1
@@ -746,7 +746,8 @@ static const u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + 1] = };/* Protect conntrack agaist broken packets. Code taken from ipt_unclean.c. */ -static int tcp_error(struct sk_buff *skb, +static int tcp_error(struct net *net, + struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info *ctinfo, u_int8_t pf,
net/netfilter/nf_conntrack_proto_udp.c +1 -1
@@ -89,7 +89,7 @@ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,return true; } -static int udp_error (struct sk_buff *skb,unsigned int dataoff, +static int udp_error (struct net *net,struct sk_buff *skb,unsigned int dataoff,enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum)
net/netfilter/nf_conntrack_proto_udplite.c +3 -1
@@ -89,7 +89,9 @@ static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb,return true; } -static int udplite_error (struct sk_buff *skb,unsigned int dataoff, +static int udplite_error (struct net *net, +struct sk_buff *skb, +unsigned int dataoff,enum ip_conntrack_info *ctinfo,u_int8_t pf,unsigned int hooknum)
netfilter 20/79: netns nf_conntrack: per-netns /proc/net/nf_conntrack, /proc/net/stat/nf_conntrack
In reply to Patrick McHardycommit b2ce2c7479d9b60dd268203e56bb738e78fd5fda
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:05 2008 +0200
netfilter: netns nf_conntrack: per-netns /proc/net/nf_conntrack, /proc/net/stat/nf_conntrack
net/netfilter/nf_conntrack_standalone.c +31 -20
@@ -40,18 +40,20 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,EXPORT_SYMBOL_GPL (print_tuple);struct ct_iter_state { +struct seq_net_private p;unsigned int bucket; };static struct hlist_node *ct_get_first (struct seq_file *seq) { +struct net *net =seq_file_net (seq);struct ct_iter_state *st = seq->private;struct hlist_node *n;for (st->bucket =0 ; st->bucket < nf_conntrack_htable_size; st->bucket++) { - n =rcu_dereference (init_net.ct.hash[st->bucket].first); + n =rcu_dereference (net->ct.hash[st->bucket].first);if (n)return n; }
@@ -61,13 +63,14 @@ static struct hlist_node *ct_get_first(struct seq_file *seq)static struct hlist_node *ct_get_next (struct seq_file *seq,struct hlist_node *head) { +struct net *net =seq_file_net (seq);struct ct_iter_state *st = seq->private; head =rcu_dereference (head->next);while (head ==NULL ) {if (++st->bucket >= nf_conntrack_htable_size)return NULL ; - head =rcu_dereference (init_net.ct.hash[st->bucket].first); + head =rcu_dereference (net->ct.hash[st->bucket].first); }return head; }
@@ -177,7 +180,7 @@ static const struct seq_operations ct_seq_ops = {static int ct_open (struct inode *inode,struct file *file) { -return seq_open_private (file, &ct_seq_ops, +return seq_open_net (inode, file, &ct_seq_ops,sizeof (struct ct_iter_state )); }
@@ -186,7 +189,7 @@ static const struct file_operations ct_file_ops = { .open = ct_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release_private, + .release = seq_release_net, };static void *ct_cpu_seq_start (struct seq_file *seq,loff_t *pos)
@@ -277,38 +280,38 @@ static const struct file_operations ct_cpu_seq_fops = { .release = seq_release, }; -static int nf_conntrack_standalone_init_proc (void ) +static int nf_conntrack_standalone_init_proc (struct net *net) {struct proc_dir_entry *pde; - pde =proc_net_fops_create (&init_net,"nf_conntrack" ,0440 , &ct_file_ops); + pde =proc_net_fops_create (net,"nf_conntrack" ,0440 , &ct_file_ops);if (!pde) goto out_nf_conntrack; - pde =proc_create ("nf_conntrack" ,S_IRUGO , init_net.proc_net_stat, + pde =proc_create ("nf_conntrack" ,S_IRUGO , net->proc_net_stat, &ct_cpu_seq_fops);if (!pde) goto out_stat_nf_conntrack;return 0 ; out_stat_nf_conntrack: -proc_net_remove (&init_net,"nf_conntrack" ); +proc_net_remove (net,"nf_conntrack" ); out_nf_conntrack:return -ENOMEM ; } -static void nf_conntrack_standalone_fini_proc (void ) +static void nf_conntrack_standalone_fini_proc (struct net *net) { -remove_proc_entry ("nf_conntrack" , init_net.proc_net_stat); -proc_net_remove (&init_net,"nf_conntrack" ); +remove_proc_entry ("nf_conntrack" , net->proc_net_stat); +proc_net_remove (net,"nf_conntrack" ); }#else -static int nf_conntrack_standalone_init_proc (void ) +static int nf_conntrack_standalone_init_proc (struct net *net) {return 0 ; } -static void nf_conntrack_standalone_fini_proc (void ) +static void nf_conntrack_standalone_fini_proc (struct net *net) { }#endif /* CONFIG_PROC_FS */
@@ -442,11 +445,25 @@ static void nf_conntrack_standalone_fini_sysctl(void)static int nf_conntrack_net_init (struct net *net) { -return nf_conntrack_init (net); +int ret; + + ret =nf_conntrack_init (net); +if (ret <0 ) + goto out_init; + ret =nf_conntrack_standalone_init_proc (net); +if (ret <0 ) + goto out_proc; +return 0 ; + +out_proc: +nf_conntrack_cleanup (net); +out_init: +return ret; }static void nf_conntrack_net_exit (struct net *net) { +nf_conntrack_standalone_fini_proc (net);nf_conntrack_cleanup (net); }
@@ -462,17 +479,12 @@ static int __init nf_conntrack_standalone_init(void) ret =register_pernet_subsys (&nf_conntrack_net_ops);if (ret <0 ) goto out; - ret =nf_conntrack_standalone_init_proc (); -if (ret <0 ) - goto out_proc; ret =nf_conntrack_standalone_init_sysctl ();if (ret <0 ) goto out_sysctl;return 0 ; out_sysctl: -nf_conntrack_standalone_fini_proc (); -out_proc:unregister_pernet_subsys (&nf_conntrack_net_ops); out:return ret;
@@ -481,7 +493,6 @@ out: static void __exit nf_conntrack_standalone_fini(void) {nf_conntrack_standalone_fini_sysctl (); -nf_conntrack_standalone_fini_proc ();unregister_pernet_subsys (&nf_conntrack_net_ops); }
netfilter 21/79: netns nf_conntrack: per-netns /proc/net/nf_conntrack_expect
In reply to Patrick McHardycommit dc5129f8df7cc3f2f04b322728d71c42795d34cc
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:06 2008 +0200
netfilter: netns nf_conntrack: per-netns /proc/net/nf_conntrack_expect
net/netfilter/nf_conntrack_expect.c +11 -10
@@ -423,12 +423,13 @@ EXPORT_SYMBOL_GPL(nf_ct_expect_related);#ifdef CONFIG_PROC_FS struct ct_expect_iter_state { +struct seq_net_private p;unsigned int bucket; };static struct hlist_node *ct_expect_get_first (struct seq_file *seq) { -struct net *net = &init_net; +struct net *net =seq_file_net (seq);struct ct_expect_iter_state *st = seq->private;struct hlist_node *n;
@@ -443,7 +444,7 @@ static struct hlist_node *ct_expect_get_first(struct seq_file *seq)static struct hlist_node *ct_expect_get_next (struct seq_file *seq,struct hlist_node *head) { -struct net *net = &init_net; +struct net *net =seq_file_net (seq);struct ct_expect_iter_state *st = seq->private; head =rcu_dereference (head->next);
@@ -524,7 +525,7 @@ static const struct seq_operations exp_seq_ops = {static int exp_open (struct inode *inode,struct file *file) { -return seq_open_private (file, &exp_seq_ops, +return seq_open_net (inode, file, &exp_seq_ops,sizeof (struct ct_expect_iter_state )); }
@@ -533,26 +534,26 @@ static const struct file_operations exp_file_ops = { .open = exp_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release_private, + .release = seq_release_net, };#endif /* CONFIG_PROC_FS */ -static int exp_proc_init (void ) +static int exp_proc_init (struct net *net) {#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc; - proc =proc_net_fops_create (&init_net,"nf_conntrack_expect" ,0440 , &exp_file_ops); + proc =proc_net_fops_create (net,"nf_conntrack_expect" ,0440 , &exp_file_ops);if (!proc)return -ENOMEM ;#endif /* CONFIG_PROC_FS */ return 0 ; } -static void exp_proc_remove (void ) +static void exp_proc_remove (struct net *net) {#ifdef CONFIG_PROC_FS -proc_net_remove (&init_net,"nf_conntrack_expect" ); +proc_net_remove (net,"nf_conntrack_expect" );#endif /* CONFIG_PROC_FS */ }
@@ -581,7 +582,7 @@ int nf_conntrack_expect_init(struct net *net)if (!nf_ct_expect_cachep) goto err2; - err =exp_proc_init (); + err =exp_proc_init (net);if (err <0 ) goto err3;
@@ -598,7 +599,7 @@ err1:void nf_conntrack_expect_fini (struct net *net) { -exp_proc_remove (); +exp_proc_remove (net);kmem_cache_destroy (nf_ct_expect_cachep);nf_ct_free_hashtable (net->ct.expect_hash, net->ct.expect_vmalloc, nf_ct_expect_hsize);
netfilter 22/79: netns nf_conntrack: per-netns /proc/net/ip_conntrack, /proc/net/stat/ip_conntrack, /proc/net/ip_conntrack_expect
In reply to Patrick McHardycommit 5e6b29972b7e9c9c39882227e36fe0cd3463fe96
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:06 2008 +0200
netfilter: netns nf_conntrack: per-netns /proc/net/ip_conntrack, /proc/net/stat/ip_conntrack, /proc/net/ip_conntrack_expect
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +38 -19
@@ -21,18 +21,20 @@#include <net/netfilter/nf_conntrack_acct.h> struct ct_iter_state { +struct seq_net_private p;unsigned int bucket; };static struct hlist_node *ct_get_first (struct seq_file *seq) { +struct net *net =seq_file_net (seq);struct ct_iter_state *st = seq->private;struct hlist_node *n;for (st->bucket =0 ; st->bucket < nf_conntrack_htable_size; st->bucket++) { - n =rcu_dereference (init_net.ct.hash[st->bucket].first); + n =rcu_dereference (net->ct.hash[st->bucket].first);if (n)return n; }
@@ -42,13 +44,14 @@ static struct hlist_node *ct_get_first(struct seq_file *seq)static struct hlist_node *ct_get_next (struct seq_file *seq,struct hlist_node *head) { +struct net *net =seq_file_net (seq);struct ct_iter_state *st = seq->private; head =rcu_dereference (head->next);while (head ==NULL ) {if (++st->bucket >= nf_conntrack_htable_size)return NULL ; - head =rcu_dereference (init_net.ct.hash[st->bucket].first); + head =rcu_dereference (net->ct.hash[st->bucket].first); }return head; }
@@ -158,8 +161,8 @@ static const struct seq_operations ct_seq_ops = {static int ct_open (struct inode *inode,struct file *file) { -return seq_open_private (file, &ct_seq_ops, -sizeof (struct ct_iter_state )); +return seq_open_net (inode, file, &ct_seq_ops, +sizeof (struct ct_iter_state )); }static const struct file_operations ct_file_ops = {
@@ -167,17 +170,18 @@ static const struct file_operations ct_file_ops = { .open = ct_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release_private, + .release = seq_release_net, };/* expects */ struct ct_expect_iter_state { +struct seq_net_private p;unsigned int bucket; };static struct hlist_node *ct_expect_get_first (struct seq_file *seq) { -struct net *net = &init_net; +struct net *net =seq_file_net (seq);struct ct_expect_iter_state *st = seq->private;struct hlist_node *n;
@@ -192,7 +196,7 @@ static struct hlist_node *ct_expect_get_first(struct seq_file *seq)static struct hlist_node *ct_expect_get_next (struct seq_file *seq,struct hlist_node *head) { -struct net *net = &init_net; +struct net *net =seq_file_net (seq);struct ct_expect_iter_state *st = seq->private; head =rcu_dereference (head->next);
@@ -267,8 +271,8 @@ static const struct seq_operations exp_seq_ops = {static int exp_open (struct inode *inode,struct file *file) { -return seq_open_private (file, &exp_seq_ops, -sizeof (struct ct_expect_iter_state )); +return seq_open_net (inode, file, &exp_seq_ops, +sizeof (struct ct_expect_iter_state )); }static const struct file_operations ip_exp_file_ops = {
@@ -276,7 +280,7 @@ static const struct file_operations ip_exp_file_ops = { .open = exp_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release_private, + .release = seq_release_net, };static void *ct_cpu_seq_start (struct seq_file *seq,loff_t *pos)
@@ -367,36 +371,51 @@ static const struct file_operations ct_cpu_seq_fops = { .release = seq_release, }; -int __init nf_conntrack_ipv4_compat_init (void ) +static int __net_init ip_conntrack_net_init (struct net *net) {struct proc_dir_entry *proc, *proc_exp, *proc_stat; - proc =proc_net_fops_create (&init_net,"ip_conntrack" ,0440 , &ct_file_ops); + proc =proc_net_fops_create (net,"ip_conntrack" ,0440 , &ct_file_ops);if (!proc) goto err1; - proc_exp =proc_net_fops_create (&init_net,"ip_conntrack_expect" ,0440 , + proc_exp =proc_net_fops_create (net,"ip_conntrack_expect" ,0440 , &ip_exp_file_ops);if (!proc_exp) goto err2; proc_stat =proc_create ("ip_conntrack" ,S_IRUGO , - init_net.proc_net_stat, &ct_cpu_seq_fops); + net->proc_net_stat, &ct_cpu_seq_fops);if (!proc_stat) goto err3;return 0 ; err3: -proc_net_remove (&init_net,"ip_conntrack_expect" ); +proc_net_remove (net,"ip_conntrack_expect" ); err2: -proc_net_remove (&init_net,"ip_conntrack" ); +proc_net_remove (net,"ip_conntrack" ); err1:return -ENOMEM ; } +static void __net_exit ip_conntrack_net_exit(struct net *net) +{ +remove_proc_entry ("ip_conntrack" , net->proc_net_stat); +proc_net_remove (net,"ip_conntrack_expect" ); +proc_net_remove (net,"ip_conntrack" ); +} + +static struct pernet_operations ip_conntrack_net_ops = { + .init = ip_conntrack_net_init, + .exit = ip_conntrack_net_exit, +}; + +int __init nf_conntrack_ipv4_compat_init (void ) +{ +return register_pernet_subsys (&ip_conntrack_net_ops); +} + void __exit nf_conntrack_ipv4_compat_fini(void) { -remove_proc_entry ("ip_conntrack" , init_net.proc_net_stat); -proc_net_remove (&init_net,"ip_conntrack_expect" ); -proc_net_remove (&init_net,"ip_conntrack" ); +unregister_pernet_subsys (&ip_conntrack_net_ops); }
netns 23/79: export netns list
In reply to Patrick McHardycommit b76a461f11eb5f32d37a9c8eae7b2f3b3f261b43
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:06 2008 +0200
netns: export netns list
Conntrack code will use it for
a) removing expectations and helpers when corresponding module is removed, and
b) removing conntracks when L3 protocol conntrack module is removed.
net/core/net_namespace.c +1 -0
@@ -18,6 +18,7 @@ static struct list_head *first_device = &pernet_list;static DEFINE_MUTEX (net_mutex);LIST_HEAD (net_namespace_list); +EXPORT_SYMBOL_GPL (net_namespace_list);struct net init_net;EXPORT_SYMBOL (init_net);
netfilter 24/79: netns nf_conntrack: unregister helper in every netns
In reply to Patrick McHardycommit 68047937677f2dffb5c47b57ce8baba5714b2142
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:06 2008 +0200
netfilter: netns nf_conntrack: unregister helper in every netns
net/netfilter/nf_conntrack_helper.c +24 -16
@@ -123,29 +123,18 @@ int nf_conntrack_helper_register(struct nf_conntrack_helper *me) }EXPORT_SYMBOL_GPL (nf_conntrack_helper_register); -void nf_conntrack_helper_unregister (struct nf_conntrack_helper *me) +static void __nf_conntrack_helper_unregister (struct nf_conntrack_helper *me, +struct net *net) {struct nf_conntrack_tuple_hash *h;struct nf_conntrack_expect *exp;const struct hlist_node *n, *next;unsigned int i; -mutex_lock (&nf_ct_helper_mutex); -hlist_del_rcu (&me->hnode); - nf_ct_helper_count--; -mutex_unlock (&nf_ct_helper_mutex); - -/* Make sure every nothing is still using the helper unless its a -* connection in the hash. -*/ -synchronize_rcu (); - -spin_lock_bh (&nf_conntrack_lock); -/* Get rid of expectations */ for (i =0 ; i < nf_ct_expect_hsize; i++) {hlist_for_each_entry_safe (exp, n, next, - &init_net.ct.expect_hash[i], hnode) { + &net->ct.expect_hash[i], hnode) {struct nf_conn_help *help =nfct_help (exp->master);if ((help->helper == me || exp->helper == me) &&del_timer (&exp->timeout)) {
@@ -156,12 +145,31 @@ void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me) }/* Get rid of expecteds, set helpers to NULL. */ -hlist_for_each_entry (h, n, &init_net.ct.unconfirmed, hnode) +hlist_for_each_entry (h, n, &net->ct.unconfirmed, hnode)unhelp (h, me);for (i =0 ; i < nf_conntrack_htable_size; i++) { -hlist_for_each_entry (h, n, &init_net.ct.hash[i], hnode) +hlist_for_each_entry (h, n, &net->ct.hash[i], hnode)unhelp (h, me); } +} + +void nf_conntrack_helper_unregister (struct nf_conntrack_helper *me) +{ +struct net *net; + +mutex_lock (&nf_ct_helper_mutex); +hlist_del_rcu (&me->hnode); + nf_ct_helper_count--; +mutex_unlock (&nf_ct_helper_mutex); + +/* Make sure every nothing is still using the helper unless its a +* connection in the hash. +*/ +synchronize_rcu (); + +spin_lock_bh (&nf_conntrack_lock); +for_each_net (net) +__nf_conntrack_helper_unregister (me, net);spin_unlock_bh (&nf_conntrack_lock); }EXPORT_SYMBOL_GPL (nf_conntrack_helper_unregister);
netfilter 25/79: netns nf_conntrack: cleanup after L3 and L4 proto unregister in every netns
In reply to Patrick McHardycommit 678d66753091a4102910392fb6198a6c6ce7f510
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:07 2008 +0200
netfilter: netns nf_conntrack: cleanup after L3 and L4 proto unregister in every netns
net/netfilter/nf_conntrack_proto.c +8 -2
@@ -207,6 +207,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_register);void nf_conntrack_l3proto_unregister (struct nf_conntrack_l3proto *proto) { +struct net *net; +BUG_ON (proto->l3proto >=AF_MAX );mutex_lock (&nf_ct_proto_mutex);
@@ -219,7 +221,8 @@ void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto)synchronize_rcu ();/* Remove all contrack entries for this protocol */ -nf_ct_iterate_cleanup (&init_net, kill_l3proto, proto); +for_each_net (net) +nf_ct_iterate_cleanup (net, kill_l3proto, proto); }EXPORT_SYMBOL_GPL (nf_conntrack_l3proto_unregister);
@@ -316,6 +319,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_register);void nf_conntrack_l4proto_unregister (struct nf_conntrack_l4proto *l4proto) { +struct net *net; +BUG_ON (l4proto->l3proto >=PF_MAX );mutex_lock (&nf_ct_proto_mutex);
@@ -328,7 +333,8 @@ void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *l4proto)synchronize_rcu ();/* Remove all contrack entries for this protocol */ -nf_ct_iterate_cleanup (&init_net, kill_l4proto, l4proto); +for_each_net (net) +nf_ct_iterate_cleanup (net, kill_l4proto, l4proto); }EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_unregister);
netfilter 26/79: netns nf_conntrack: pass conntrack to nf_conntrack_event_cache() not skb
In reply to Patrick McHardycommit a71996fccce4b2086a26036aa3c915365ca36926
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:07 2008 +0200
netfilter: netns nf_conntrack: pass conntrack to nf_conntrack_event_cache() not skb
This is cleaner, we already know conntrack to which event is relevant.
include/net/netfilter/nf_conntrack_ecache.h +1 -3
@@ -28,10 +28,8 @@ extern void __nf_ct_event_cache_init(struct nf_conn *ct);extern void nf_ct_event_cache_flush (void );static inline void -nf_conntrack_event_cache (enum ip_conntrack_events event, -const struct sk_buff *skb) +nf_conntrack_event_cache (enum ip_conntrack_events event,struct nf_conn *ct) { -struct nf_conn *ct = (struct nf_conn *)skb->nfct;struct nf_conntrack_ecache *ecache;local_bh_disable ();
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -91,7 +91,7 @@ static int icmp_packet(struct nf_conn *ct,nf_ct_kill_acct (ct, ctinfo, skb); }else {atomic_inc (&ct->proto.icmp.count); -nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb); +nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , ct);nf_ct_refresh_acct (ct, ctinfo, skb, nf_ct_icmp_timeout); }
net/ipv4/netfilter/nf_nat_helper.c +1 -1
@@ -193,7 +193,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb,nf_conntrack_tcp_update (skb,ip_hdrlen (skb), ct,CTINFO2DIR (ctinfo)); -nf_conntrack_event_cache (IPCT_NATSEQADJ , skb); +nf_conntrack_event_cache (IPCT_NATSEQADJ , ct); }return 1 ; }
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -93,7 +93,7 @@ static int icmpv6_packet(struct nf_conn *ct,nf_ct_kill_acct (ct, ctinfo, skb); }else {atomic_inc (&ct->proto.icmp.count); -nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb); +nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , ct);nf_ct_refresh_acct (ct, ctinfo, skb, nf_ct_icmpv6_timeout); }
net/netfilter/nf_conntrack_core.c +5 -5
@@ -370,14 +370,14 @@ __nf_conntrack_confirm(struct sk_buff *skb)spin_unlock_bh (&nf_conntrack_lock); help =nfct_help (ct);if (help && help->helper) -nf_conntrack_event_cache (IPCT_HELPER , skb); +nf_conntrack_event_cache (IPCT_HELPER , ct);#ifdef CONFIG_NF_NAT_NEEDED if (test_bit (IPS_SRC_NAT_DONE_BIT , &ct->status) ||test_bit (IPS_DST_NAT_DONE_BIT , &ct->status)) -nf_conntrack_event_cache (IPCT_NATINFO , skb); +nf_conntrack_event_cache (IPCT_NATINFO , ct);#endif nf_conntrack_event_cache (master_ct (ct) ? -IPCT_RELATED :IPCT_NEW , skb); +IPCT_RELATED :IPCT_NEW , ct);return NF_ACCEPT ; out:
@@ -740,7 +740,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, }if (set_reply && !test_and_set_bit (IPS_SEEN_REPLY_BIT , &ct->status)) -nf_conntrack_event_cache (IPCT_STATUS , skb); +nf_conntrack_event_cache (IPCT_STATUS , ct);return ret; }
@@ -853,7 +853,7 @@ acct:/* must be unlocked when calling event cache */ if (event) -nf_conntrack_event_cache (event, skb); +nf_conntrack_event_cache (event, ct); }EXPORT_SYMBOL_GPL (__nf_ct_refresh_acct);
net/netfilter/nf_conntrack_ftp.c +5 -4
@@ -318,7 +318,8 @@ static int find_nl_seq(u32 seq, const struct nf_ct_ftp_master *info, int dir) }/* We don't update if it's older than what we have. */ -static void update_nl_seq (u32 nl_seq,struct nf_ct_ftp_master *info,int dir, +static void update_nl_seq (struct nf_conn *ct,u32 nl_seq, +struct nf_ct_ftp_master *info,int dir,struct sk_buff *skb) {unsigned int i, oldest =NUM_SEQ_TO_REMEMBER ;
@@ -336,11 +337,11 @@ static void update_nl_seq(u32 nl_seq, struct nf_ct_ftp_master *info, int dir,if (info->seq_aft_nl_num[dir] <NUM_SEQ_TO_REMEMBER ) { info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq; -nf_conntrack_event_cache (IPCT_HELPINFO_VOLATILE , skb); +nf_conntrack_event_cache (IPCT_HELPINFO_VOLATILE , ct); }else if (oldest !=NUM_SEQ_TO_REMEMBER &&after (nl_seq, info->seq_aft_nl[dir][oldest])) { info->seq_aft_nl[dir][oldest] = nl_seq; -nf_conntrack_event_cache (IPCT_HELPINFO_VOLATILE , skb); +nf_conntrack_event_cache (IPCT_HELPINFO_VOLATILE , ct); } }
@@ -509,7 +510,7 @@ out_update_nl:/* Now if this ends in \n, update ftp info. Seq may have been * adjusted by NAT code. */ if (ends_in_nl) -update_nl_seq (seq, ct_ftp_info, dir, skb); +update_nl_seq (ct, seq, ct_ftp_info, dir, skb); out:spin_unlock_bh (&nf_ftp_lock);return ret;
net/netfilter/nf_conntrack_proto_gre.c +1 -1
@@ -229,7 +229,7 @@ static int gre_packet(struct nf_conn *ct, ct->proto.gre.stream_timeout);/* Also, more likely to be important, and not a probe. */ set_bit (IPS_ASSURED_BIT , &ct->status); -nf_conntrack_event_cache (IPCT_STATUS , skb); +nf_conntrack_event_cache (IPCT_STATUS , ct); }else nf_ct_refresh_acct (ct, ctinfo, skb, ct->proto.gre.timeout);
net/netfilter/nf_conntrack_proto_sctp.c +2 -2
@@ -369,7 +369,7 @@ static int sctp_packet(struct nf_conn *ct, ct->proto.sctp.state = new_state;if (old_state != new_state) -nf_conntrack_event_cache (IPCT_PROTOINFO , skb); +nf_conntrack_event_cache (IPCT_PROTOINFO , ct); }write_unlock_bh (&sctp_lock);
@@ -380,7 +380,7 @@ static int sctp_packet(struct nf_conn *ct, new_state == SCTP_CONNTRACK_ESTABLISHED) {pr_debug ("Setting assured bit\n" );set_bit (IPS_ASSURED_BIT , &ct->status); -nf_conntrack_event_cache (IPCT_STATUS , skb); +nf_conntrack_event_cache (IPCT_STATUS , ct); }return NF_ACCEPT ;
net/netfilter/nf_conntrack_proto_tcp.c +3 -3
@@ -969,9 +969,9 @@ static int tcp_packet(struct nf_conn *ct, timeout = tcp_timeouts[new_state];write_unlock_bh (&tcp_lock); -nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , skb); +nf_conntrack_event_cache (IPCT_PROTOINFO_VOLATILE , ct);if (new_state != old_state) -nf_conntrack_event_cache (IPCT_PROTOINFO , skb); +nf_conntrack_event_cache (IPCT_PROTOINFO , ct);if (!test_bit (IPS_SEEN_REPLY_BIT , &ct->status)) {/* If only reply is a RST, we can consider ourselves not to
@@ -990,7 +990,7 @@ static int tcp_packet(struct nf_conn *ct,after SYN_RECV or a valid answer for a picked up connection. */ set_bit (IPS_ASSURED_BIT , &ct->status); -nf_conntrack_event_cache (IPCT_STATUS , skb); +nf_conntrack_event_cache (IPCT_STATUS , ct); }nf_ct_refresh_acct (ct, ctinfo, skb, timeout);
net/netfilter/nf_conntrack_proto_udp.c +1 -1
@@ -75,7 +75,7 @@ static int udp_packet(struct nf_conn *ct,nf_ct_refresh_acct (ct, ctinfo, skb, nf_ct_udp_timeout_stream);/* Also, more likely to be important, and not a probe */ if (!test_and_set_bit (IPS_ASSURED_BIT , &ct->status)) -nf_conntrack_event_cache (IPCT_STATUS , skb); +nf_conntrack_event_cache (IPCT_STATUS , ct); }else nf_ct_refresh_acct (ct, ctinfo, skb, nf_ct_udp_timeout);
net/netfilter/nf_conntrack_proto_udplite.c +1 -1
@@ -75,7 +75,7 @@ static int udplite_packet(struct nf_conn *ct, nf_ct_udplite_timeout_stream);/* Also, more likely to be important, and not a probe */ if (!test_and_set_bit (IPS_ASSURED_BIT , &ct->status)) -nf_conntrack_event_cache (IPCT_STATUS , skb); +nf_conntrack_event_cache (IPCT_STATUS , ct); }else nf_ct_refresh_acct (ct, ctinfo, skb, nf_ct_udplite_timeout);
net/netfilter/xt_CONNMARK.c +4 -4
@@ -54,7 +54,7 @@ connmark_tg_v0(struct sk_buff *skb, const struct net_device *in, newmark = (ct->mark & ~markinfo->mask) | markinfo->mark;if (newmark != ct->mark) { ct->mark = newmark; -nf_conntrack_event_cache (IPCT_MARK , skb); +nf_conntrack_event_cache (IPCT_MARK , ct); }break ;case XT_CONNMARK_SAVE :
@@ -62,7 +62,7 @@ connmark_tg_v0(struct sk_buff *skb, const struct net_device *in, (skb->mark & markinfo->mask);if (ct->mark != newmark) { ct->mark = newmark; -nf_conntrack_event_cache (IPCT_MARK , skb); +nf_conntrack_event_cache (IPCT_MARK , ct); }break ;case XT_CONNMARK_RESTORE :
@@ -95,7 +95,7 @@ connmark_tg(struct sk_buff *skb, const struct net_device *in, newmark = (ct->mark & ~info->ctmask) ^ info->ctmark;if (ct->mark != newmark) { ct->mark = newmark; -nf_conntrack_event_cache (IPCT_MARK , skb); +nf_conntrack_event_cache (IPCT_MARK , ct); }break ;case XT_CONNMARK_SAVE :
@@ -103,7 +103,7 @@ connmark_tg(struct sk_buff *skb, const struct net_device *in, (skb->mark & info->nfmask);if (ct->mark != newmark) { ct->mark = newmark; -nf_conntrack_event_cache (IPCT_MARK , skb); +nf_conntrack_event_cache (IPCT_MARK , ct); }break ;case XT_CONNMARK_RESTORE :
net/netfilter/xt_CONNSECMARK.c +1 -1
@@ -43,7 +43,7 @@ static void secmark_save(const struct sk_buff *skb) ct =nf_ct_get (skb, &ctinfo);if (ct && !ct->secmark) { ct->secmark = skb->secmark; -nf_conntrack_event_cache (IPCT_SECMARK , skb); +nf_conntrack_event_cache (IPCT_SECMARK , ct); } } }
netfilter 27/79: netns nf_conntrack: per-netns event cache
In reply to Patrick McHardycommit 6058fa6bb96a5b6145cba10c5171f09c2783ca69
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:07 2008 +0200
netfilter: netns nf_conntrack: per-netns event cache
Heh, last minute proof-reading of this patch made me think, that this is actually unneeded, simply because "ct" pointers will be different for different conntracks in different netns, just like they are different in one netns.
Not so sure anymore.
[Patrick: pointers will be different, flushing can only be done while
inactive though and thus it needs to be per netns]
include/net/netfilter/nf_conntrack_ecache.h +16 -6
@@ -8,6 +8,7 @@#include <linux/notifier.h> #include <linux/interrupt.h> +#include <net/net_namespace.h> #include <net/netfilter/nf_conntrack_expect.h> #ifdef CONFIG_NF_CONNTRACK_EVENTS
@@ -15,9 +16,6 @@ struct nf_conntrack_ecache {struct nf_conn *ct;unsigned int events; }; -DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache); - -#define CONNTRACK_ECACHE (x) (__get_cpu_var(nf_conntrack_ecache).x)extern struct atomic_notifier_head nf_conntrack_chain;extern int nf_conntrack_register_notifier (struct notifier_block *nb);
@@ -25,15 +23,16 @@ extern int nf_conntrack_unregister_notifier(struct notifier_block *nb);extern void nf_ct_deliver_cached_events (const struct nf_conn *ct);extern void __nf_ct_event_cache_init (struct nf_conn *ct); -extern void nf_ct_event_cache_flush (void ); +extern void nf_ct_event_cache_flush (struct net *net);static inline void nf_conntrack_event_cache (enum ip_conntrack_events event,struct nf_conn *ct) { +struct net *net =nf_ct_net (ct);struct nf_conntrack_ecache *ecache;local_bh_disable (); - ecache = &__get_cpu_var (nf_conntrack_ecache); + ecache =per_cpu_ptr (net->ct.ecache,raw_smp_processor_id ());if (ct != ecache->ct)__nf_ct_event_cache_init (ct); ecache->events |= event;
@@ -58,6 +57,9 @@ nf_ct_expect_event(enum ip_conntrack_expect_events event,atomic_notifier_call_chain (&nf_ct_expect_chain, event, exp); } +extern int nf_conntrack_ecache_init (struct net *net); +extern void nf_conntrack_ecache_fini (struct net *net); +#else /* CONFIG_NF_CONNTRACK_EVENTS */ static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
@@ -67,7 +69,15 @@ static inline void nf_conntrack_event(enum ip_conntrack_events event, static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {} static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event, struct nf_conntrack_expect *exp) {} -static inline void nf_ct_event_cache_flush (void ) {} +static inline void nf_ct_event_cache_flush(struct net *net) {} + +static inline int nf_conntrack_ecache_init(struct net *net) +{ + return 0; + +static inline void nf_conntrack_ecache_fini(struct net *net) +{ +} #endif /* CONFIG_NF_CONNTRACK_EVENTS */ #endif /*_NF_CONNTRACK_ECACHE_H*/
include/net/netns/conntrack.h +5 -0
@@ -4,12 +4,17 @@#include <linux/list.h> #include <asm/atomic.h> +struct nf_conntrack_ecache ; +struct netns_ct {atomic_t count;unsigned int expect_count;struct hlist_head *hash;struct hlist_head *expect_hash;struct hlist_head unconfirmed; +#ifdef CONFIG_NF_CONNTRACK_EVENTS +struct nf_conntrack_ecache *ecache; +#endif int hash_vmalloc;int expect_vmalloc; };
net/netfilter/nf_conntrack_core.c +9 -3
@@ -1023,7 +1023,8 @@ void nf_conntrack_cleanup(struct net *net)delete... */ synchronize_net (); -nf_ct_event_cache_flush (); +nf_ct_event_cache_flush (net); +nf_conntrack_ecache_fini (net); i_see_dead_people:nf_conntrack_flush (net);if (atomic_read (&net->ct.count) !=0 ) {
@@ -1151,11 +1152,14 @@ int nf_conntrack_init(struct net *net) max_factor =4 ; }atomic_set (&net->ct.count,0 ); + ret =nf_conntrack_ecache_init (net); +if (ret <0 ) + goto err_ecache; net->ct.hash =nf_ct_alloc_hashtable (&nf_conntrack_htable_size, &net->ct.hash_vmalloc);if (!net->ct.hash) {printk (KERN_ERR "Unable to create nf_conntrack_hash\n" ); - goto err_out; + goto err_hash; }INIT_HLIST_HEAD (&net->ct.unconfirmed);
@@ -1215,6 +1219,8 @@ err_free_conntrack_slab: err_free_hash:nf_ct_free_hashtable (net->ct.hash, net->ct.hash_vmalloc, nf_conntrack_htable_size); -err_out: +err_hash: +nf_conntrack_ecache_fini (net); +err_ecache:return -ENOMEM ; }
net/netfilter/nf_conntrack_ecache.c +19 -7
@@ -29,9 +29,6 @@ EXPORT_SYMBOL_GPL(nf_conntrack_chain);ATOMIC_NOTIFIER_HEAD (nf_ct_expect_chain);EXPORT_SYMBOL_GPL (nf_ct_expect_chain); -DEFINE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache); -EXPORT_PER_CPU_SYMBOL_GPL (nf_conntrack_ecache); -/* deliver cached events and clear cache entry - must be called with locally * disabled softirqs */ static inline void
@@ -51,10 +48,11 @@ __nf_ct_deliver_cached_events(struct nf_conntrack_ecache *ecache)* by code prior to async packet handling for freeing the skb */ void nf_ct_deliver_cached_events (const struct nf_conn *ct) { +struct net *net =nf_ct_net (ct);struct nf_conntrack_ecache *ecache;local_bh_disable (); - ecache = &__get_cpu_var (nf_conntrack_ecache); + ecache =per_cpu_ptr (net->ct.ecache,raw_smp_processor_id ());if (ecache->ct == ct)__nf_ct_deliver_cached_events (ecache);local_bh_enable ();
@@ -64,10 +62,11 @@ EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);/* Deliver cached events for old pending events, if current conntrack != old */ void __nf_ct_event_cache_init (struct nf_conn *ct) { +struct net *net =nf_ct_net (ct);struct nf_conntrack_ecache *ecache;/* take care of delivering potentially old events */ - ecache = &__get_cpu_var (nf_conntrack_ecache); + ecache =per_cpu_ptr (net->ct.ecache,raw_smp_processor_id ());BUG_ON (ecache->ct == ct);if (ecache->ct)__nf_ct_deliver_cached_events (ecache);
@@ -79,18 +78,31 @@ EXPORT_SYMBOL_GPL(__nf_ct_event_cache_init);/* flush the event cache - touches other CPU's data and must not be called * while packets are still passing through the code */ -void nf_ct_event_cache_flush (void ) +void nf_ct_event_cache_flush (struct net *net) {struct nf_conntrack_ecache *ecache;int cpu;for_each_possible_cpu (cpu) { - ecache = &per_cpu (nf_conntrack_ecache, cpu); + ecache =per_cpu_ptr (net->ct.ecache, cpu);if (ecache->ct)nf_ct_put (ecache->ct); } } +int nf_conntrack_ecache_init (struct net *net) +{ + net->ct.ecache = alloc_percpu(struct nf_conntrack_ecache); +if (!net->ct.ecache) +return -ENOMEM ; +return 0 ; +} + +void nf_conntrack_ecache_fini (struct net *net) +{ +free_percpu (net->ct.ecache); +} +int nf_conntrack_register_notifier (struct notifier_block *nb) {return atomic_notifier_chain_register (&nf_conntrack_chain, nb);
netfilter 28/79: netns nf_conntrack: per-netns statistics
In reply to Patrick McHardycommit 0d55af8791bfb42e04cc456b348910582f230343
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:07 2008 +0200
netfilter: netns nf_conntrack: per-netns statistics
include/net/netfilter/nf_conntrack.h +4 -4
@@ -290,12 +290,12 @@ extern unsigned int nf_conntrack_htable_size;extern int nf_conntrack_checksum;extern int nf_conntrack_max; -DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat); -#define NF_CT_STAT_INC (count) (__get_cpu_var(nf_conntrack_stat).count++) -#define NF_CT_STAT_INC_ATOMIC (count) \ +#define NF_CT_STAT_INC (net, count) \ + (per_cpu_ptr((net)->ct.stat, raw_smp_processor_id())->count++) +#define NF_CT_STAT_INC_ATOMIC (net, count) \ do { \ local_bh_disable(); \ - __get_cpu_var(nf_conntrack_stat).count++; \ + per_cpu_ptr((net)->ct.stat, raw_smp_processor_id())->count++; \ local_bh_enable(); \ } while (0)
include/net/netns/conntrack.h +1 -0
@@ -12,6 +12,7 @@ struct netns_ct {struct hlist_head *hash;struct hlist_head *expect_hash;struct hlist_head unconfirmed; +struct ip_conntrack_stat *stat;#ifdef CONFIG_NF_CONNTRACK_EVENTS struct nf_conntrack_ecache *ecache;#endif
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +2 -2
@@ -294,7 +294,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)if (!cpu_possible (cpu))continue ; *pos = cpu+1 ; -return &per_cpu (nf_conntrack_stat, cpu); +return per_cpu_ptr (init_net.ct.stat, cpu); }return NULL ;
@@ -308,7 +308,7 @@ static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)if (!cpu_possible (cpu))continue ; *pos = cpu+1 ; -return &per_cpu (nf_conntrack_stat, cpu); +return per_cpu_ptr (init_net.ct.stat, cpu); }return NULL ;
net/netfilter/nf_conntrack_core.c +27 -22
179 lines not on this page · raw message
net/netfilter/nf_conntrack_expect.c +2 -2
@@ -53,7 +53,7 @@ void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) master_help->expecting[exp->class]--;nf_ct_expect_put (exp); -NF_CT_STAT_INC (expect_delete); +NF_CT_STAT_INC (net, expect_delete); }EXPORT_SYMBOL_GPL (nf_ct_unlink_expect);
@@ -326,7 +326,7 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp)add_timer (&exp->timeout);atomic_inc (&exp->use); -NF_CT_STAT_INC (expect_create); +NF_CT_STAT_INC (net, expect_create); }/* Race with expectations being used means we could have none to find; OK. */
net/netfilter/nf_conntrack_standalone.c +2 -2
@@ -203,7 +203,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)if (!cpu_possible (cpu))continue ; *pos = cpu +1 ; -return &per_cpu (nf_conntrack_stat, cpu); +return per_cpu_ptr (init_net.ct.stat, cpu); }return NULL ;
@@ -217,7 +217,7 @@ static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)if (!cpu_possible (cpu))continue ; *pos = cpu +1 ; -return &per_cpu (nf_conntrack_stat, cpu); +return per_cpu_ptr (init_net.ct.stat, cpu); }return NULL ;
netfilter 29/79: netns nf_conntrack: per-netns /proc/net/stat/nf_conntrack, /proc/net/stat/ip_conntrack
In reply to Patrick McHardycommit 8e9df80180b73d4107bf8fbf28b1633c541d2770
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:08 2008 +0200
netfilter: netns nf_conntrack: per-netns /proc/net/stat/nf_conntrack, /proc/net/stat/ip_conntrack
Show correct conntrack count, while I'm at it.
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +9 -5
@@ -285,6 +285,7 @@ static const struct file_operations ip_exp_file_ops = {static void *ct_cpu_seq_start (struct seq_file *seq,loff_t *pos) { +struct net *net =seq_file_net (seq);int cpu;if (*pos ==0 )
@@ -294,7 +295,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)if (!cpu_possible (cpu))continue ; *pos = cpu+1 ; -return per_cpu_ptr (init_net.ct.stat, cpu); +return per_cpu_ptr (net->ct.stat, cpu); }return NULL ;
@@ -302,13 +303,14 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)static void *ct_cpu_seq_next (struct seq_file *seq,void *v,loff_t *pos) { +struct net *net =seq_file_net (seq);int cpu;for (cpu = *pos; cpu <NR_CPUS ; ++cpu) {if (!cpu_possible (cpu))continue ; *pos = cpu+1 ; -return per_cpu_ptr (init_net.ct.stat, cpu); +return per_cpu_ptr (net->ct.stat, cpu); }return NULL ;
@@ -320,7 +322,8 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v)static int ct_cpu_seq_show (struct seq_file *seq,void *v) { -unsigned int nr_conntracks =atomic_read (&init_net.ct.count); +struct net *net =seq_file_net (seq); +unsigned int nr_conntracks =atomic_read (&net->ct.count);const struct ip_conntrack_stat *st = v;if (v ==SEQ_START_TOKEN ) {
@@ -360,7 +363,8 @@ static const struct seq_operations ct_cpu_seq_ops = {static int ct_cpu_seq_open (struct inode *inode,struct file *file) { -return seq_open (file, &ct_cpu_seq_ops); +return seq_open_net (inode, file, &ct_cpu_seq_ops, +sizeof (struct seq_net_private )); }static const struct file_operations ct_cpu_seq_fops = {
@@ -368,7 +372,7 @@ static const struct file_operations ct_cpu_seq_fops = { .open = ct_cpu_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = seq_release_net, };static int __net_init ip_conntrack_net_init (struct net *net)
net/netfilter/nf_conntrack_standalone.c +9 -5
@@ -194,6 +194,7 @@ static const struct file_operations ct_file_ops = {static void *ct_cpu_seq_start (struct seq_file *seq,loff_t *pos) { +struct net *net =seq_file_net (seq);int cpu;if (*pos ==0 )
@@ -203,7 +204,7 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)if (!cpu_possible (cpu))continue ; *pos = cpu +1 ; -return per_cpu_ptr (init_net.ct.stat, cpu); +return per_cpu_ptr (net->ct.stat, cpu); }return NULL ;
@@ -211,13 +212,14 @@ static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)static void *ct_cpu_seq_next (struct seq_file *seq,void *v,loff_t *pos) { +struct net *net =seq_file_net (seq);int cpu;for (cpu = *pos; cpu <NR_CPUS ; ++cpu) {if (!cpu_possible (cpu))continue ; *pos = cpu +1 ; -return per_cpu_ptr (init_net.ct.stat, cpu); +return per_cpu_ptr (net->ct.stat, cpu); }return NULL ;
@@ -229,7 +231,8 @@ static void ct_cpu_seq_stop(struct seq_file *seq, void *v)static int ct_cpu_seq_show (struct seq_file *seq,void *v) { -unsigned int nr_conntracks =atomic_read (&init_net.ct.count); +struct net *net =seq_file_net (seq); +unsigned int nr_conntracks =atomic_read (&net->ct.count);const struct ip_conntrack_stat *st = v;if (v ==SEQ_START_TOKEN ) {
@@ -269,7 +272,8 @@ static const struct seq_operations ct_cpu_seq_ops = {static int ct_cpu_seq_open (struct inode *inode,struct file *file) { -return seq_open (file, &ct_cpu_seq_ops); +return seq_open_net (inode, file, &ct_cpu_seq_ops, +sizeof (struct seq_net_private )); }static const struct file_operations ct_cpu_seq_fops = {
@@ -277,7 +281,7 @@ static const struct file_operations ct_cpu_seq_fops = { .open = ct_cpu_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = seq_release_net, };static int nf_conntrack_standalone_init_proc (struct net *net)
netfilter 30/79: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_count sysctl
In reply to Patrick McHardycommit 802507071b72ed5025747126099cbc6d1542f596
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:08 2008 +0200
netfilter: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_count sysctl
Note, sysctl table is always duplicated, this is simpler and less special-cased.
include/net/netns/conntrack.h +4 -0
@@ -4,6 +4,7 @@#include <linux/list.h> #include <asm/atomic.h> +struct ctl_table_header ;struct nf_conntrack_ecache ;struct netns_ct {
@@ -16,6 +17,9 @@ struct netns_ct {#ifdef CONFIG_NF_CONNTRACK_EVENTS struct nf_conntrack_ecache *ecache;#endif +#ifdef CONFIG_SYSCTL +struct ctl_table_header *sysctl_header; +#endif int hash_vmalloc;int expect_vmalloc; };
net/netfilter/nf_conntrack_standalone.c +41 -32
127 lines not on this page · raw message
netfilter 31/79: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_checksum sysctl
In reply to Patrick McHardycommit c04d05529a6e0bf97183a2caf76a0c7f07f5b78c
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:08 2008 +0200
netfilter: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_checksum sysctl
include/net/netfilter/nf_conntrack.h +0 -1
@@ -287,7 +287,6 @@ static inline int nf_ct_is_untracked(const struct sk_buff *skb)extern int nf_conntrack_set_hashsize (const char *val,struct kernel_param *kp);extern unsigned int nf_conntrack_htable_size; -extern int nf_conntrack_checksum;extern int nf_conntrack_max;#define NF_CT_STAT_INC (net, count) \
include/net/netns/conntrack.h +1 -0
@@ -17,6 +17,7 @@ struct netns_ct {#ifdef CONFIG_NF_CONNTRACK_EVENTS struct nf_conntrack_ecache *ecache;#endif +int sysctl_checksum;#ifdef CONFIG_SYSCTL struct ctl_table_header *sysctl_header;#endif
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -1
@@ -270,7 +270,7 @@ static ctl_table ip_ct_sysctl_table[] = { { .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM, .procname = "ip_conntrack_checksum", - .data = &nf_conntrack_checksum, + .data = &init_net.ct.sysctl_checksum, .maxlen = sizeof(int), .mode = 0644, .proc_handler = &proc_dointvec,
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -188,7 +188,7 @@ icmp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, }/* See ip_conntrack_proto_tcp.c */ -if (nf_conntrack_checksum && hooknum ==NF_INET_PRE_ROUTING && +if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_ip_checksum (skb, hooknum, dataoff,0 )) {if (LOG_INVALID (IPPROTO_ICMP )) nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -187,7 +187,7 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,return -NF_ACCEPT ; } -if (nf_conntrack_checksum && hooknum ==NF_INET_PRE_ROUTING && +if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_ip6_checksum (skb, hooknum, dataoff,IPPROTO_ICMPV6 )) {nf_log_packet (PF_INET6 ,0 , skb,NULL ,NULL ,NULL ,"nf_ct_icmpv6: ICMPv6 checksum failed\n" );
net/netfilter/nf_conntrack_proto_dccp.c +1 -1
@@ -575,7 +575,7 @@ static int dccp_error(struct net *net, struct sk_buff *skb, } } -if (nf_conntrack_checksum && hooknum ==NF_INET_PRE_ROUTING && +if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum_partial (skb, hooknum, dataoff, cscov,IPPROTO_DCCP , pf)) { msg ="nf_ct_dccp: bad checksum " ;
net/netfilter/nf_conntrack_proto_tcp.c +1 -1
@@ -780,7 +780,7 @@ static int tcp_error(struct net *net,* because the checksum is assumed to be correct. */ /* FIXME: Source route IP option packets --RR */ -if (nf_conntrack_checksum && hooknum ==NF_INET_PRE_ROUTING && +if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum (skb, hooknum, dataoff,IPPROTO_TCP , pf)) {if (LOG_INVALID (IPPROTO_TCP )) nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
net/netfilter/nf_conntrack_proto_udp.c +1 -1
@@ -123,7 +123,7 @@ static int udp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,* We skip checking packets on the outgoing path * because the checksum is assumed to be correct. * FIXME: Source route IP option packets --RR */ -if (nf_conntrack_checksum && hooknum ==NF_INET_PRE_ROUTING && +if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum (skb, hooknum, dataoff,IPPROTO_UDP , pf)) {if (LOG_INVALID (IPPROTO_UDP )) nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
net/netfilter/nf_conntrack_proto_udplite.c +1 -1
@@ -129,7 +129,7 @@ static int udplite_error(struct net *net, }/* Checksum invalid? Ignore. */ -if (nf_conntrack_checksum && hooknum ==NF_INET_PRE_ROUTING && +if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum_partial (skb, hooknum, dataoff, cscov,IPPROTO_UDP , pf)) {if (LOG_INVALID (IPPROTO_UDPLITE ))
net/netfilter/nf_conntrack_standalone.c +3 -4
@@ -322,9 +322,6 @@ static void nf_conntrack_standalone_fini_proc(struct net *net)/* Sysctl support */ -int nf_conntrack_checksum__read_mostly =1 ; -EXPORT_SYMBOL_GPL (nf_conntrack_checksum); -#ifdef CONFIG_SYSCTL /* Log invalid packets of a given protocol */ static int log_invalid_proto_min =0 ;
@@ -360,7 +357,7 @@ static ctl_table nf_ct_sysctl_table[] = { { .ctl_name = NET_NF_CONNTRACK_CHECKSUM, .procname = "nf_conntrack_checksum", - .data = &nf_conntrack_checksum, + .data = &init_net.ct.sysctl_checksum, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = &proc_dointvec,
@@ -425,6 +422,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) goto out_kmemdup; table[1 ].data = &net->ct.count; + table[3 ].data = &net->ct.sysctl_checksum; net->ct.sysctl_header =register_net_sysctl_table (net, nf_net_netfilter_sysctl_path, table);
@@ -474,6 +472,7 @@ static int nf_conntrack_net_init(struct net *net) ret =nf_conntrack_standalone_init_proc (net);if (ret <0 ) goto out_proc; + net->ct.sysctl_checksum =1 ; ret =nf_conntrack_standalone_init_sysctl (net);if (ret <0 ) goto out_sysctl;
netfilter 32/79: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_log_invalid sysctl
In reply to Patrick McHardycommit c2a2c7e0cc39e7f9336cd67e8307a110bdba82f3
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:08 2008 +0200
netfilter: netns nf_conntrack: per-netns net.netfilter.nf_conntrack_log_invalid sysctl
include/net/netfilter/nf_conntrack_l4proto.h +7 -8
@@ -117,20 +117,19 @@ extern int nf_ct_port_nlattr_to_tuple(struct nlattr *tb[], struct nf_conntrack_tuple *t);extern const struct nla_policy nf_ct_port_nla_policy[]; -/* Log invalid packets */ -extern unsigned int nf_ct_log_invalid; -#ifdef CONFIG_SYSCTL #ifdef DEBUG_INVALID_PACKETS -#define LOG_INVALID (proto) \ - (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) +#define LOG_INVALID (net, proto) \ + ((net)->ct.sysctl_log_invalid == (proto) || \ + (net)->ct.sysctl_log_invalid == IPPROTO_RAW)#else -#define LOG_INVALID (proto) \ - ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \ +#define LOG_INVALID (net, proto) \ + (((net)->ct.sysctl_log_invalid == (proto) || \ + (net)->ct.sysctl_log_invalid == IPPROTO_RAW) \ && net_ratelimit())#endif #else -#define LOG_INVALID (proto) 0 +#define LOG_INVALID (net, proto) 0#endif /* CONFIG_SYSCTL */ #endif /*_NF_CONNTRACK_PROTOCOL_H*/
include/net/netns/conntrack.h +1 -0
@@ -18,6 +18,7 @@ struct netns_ct {struct nf_conntrack_ecache *ecache;#endif int sysctl_checksum; +unsigned int sysctl_log_invalid;/* Log invalid packets */ #ifdef CONFIG_SYSCTL struct ctl_table_header *sysctl_header;#endif
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -1
@@ -278,7 +278,7 @@ static ctl_table ip_ct_sysctl_table[] = { { .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID, .procname = "ip_conntrack_log_invalid", - .data = &nf_ct_log_invalid, + .data = &init_net.ct.sysctl_log_invalid, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = &proc_dointvec_minmax,
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +3 -3
@@ -181,7 +181,7 @@ icmp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,/* Not enough header? */ icmph =skb_header_pointer (skb,ip_hdrlen (skb),sizeof (_ih), &_ih);if (icmph ==NULL ) { -if (LOG_INVALID (IPPROTO_ICMP )) +if (LOG_INVALID (net,IPPROTO_ICMP ))nf_log_packet (PF_INET ,0 , skb,NULL ,NULL ,NULL ,"nf_ct_icmp: short packet " );return -NF_ACCEPT ;
@@ -190,7 +190,7 @@ icmp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,/* See ip_conntrack_proto_tcp.c */ if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_ip_checksum (skb, hooknum, dataoff,0 )) { -if (LOG_INVALID (IPPROTO_ICMP )) +if (LOG_INVALID (net,IPPROTO_ICMP ))nf_log_packet (PF_INET ,0 , skb,NULL ,NULL ,NULL ,"nf_ct_icmp: bad HW ICMP checksum " );return -NF_ACCEPT ;
@@ -203,7 +203,7 @@ icmp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,* discarded. */ if (icmph->type >NR_ICMP_TYPES ) { -if (LOG_INVALID (IPPROTO_ICMP )) +if (LOG_INVALID (net,IPPROTO_ICMP ))nf_log_packet (PF_INET ,0 , skb,NULL ,NULL ,NULL ,"nf_ct_icmp: invalid ICMP type " );return -NF_ACCEPT ;
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -181,7 +181,7 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff, icmp6h =skb_header_pointer (skb, dataoff,sizeof (_ih), &_ih);if (icmp6h ==NULL ) { -if (LOG_INVALID (IPPROTO_ICMPV6 )) +if (LOG_INVALID (net,IPPROTO_ICMPV6 ))nf_log_packet (PF_INET6 ,0 , skb,NULL ,NULL ,NULL ,"nf_ct_icmpv6: short packet " );return -NF_ACCEPT ;
net/netfilter/nf_conntrack_core.c +0 -1
@@ -53,7 +53,6 @@ EXPORT_SYMBOL_GPL(nf_conntrack_max);struct nf_conn nf_conntrack_untracked__read_mostly ;EXPORT_SYMBOL_GPL (nf_conntrack_untracked); -unsigned int nf_ct_log_invalid__read_mostly ;static struct kmem_cache *nf_conntrack_cachep__read_mostly ;static int nf_conntrack_hash_rnd_initted;
net/netfilter/nf_conntrack_proto_dccp.c +6 -4
@@ -418,6 +418,7 @@ static bool dccp_invert_tuple(struct nf_conntrack_tuple *inv,static bool dccp_new (struct nf_conn *ct,const struct sk_buff *skb,unsigned int dataoff) { +struct net *net =nf_ct_net (ct);struct dccp_hdr _dh, *dh;const char *msg;u_int8_t state;
@@ -445,7 +446,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,return true; out_invalid: -if (LOG_INVALID (IPPROTO_DCCP )) +if (LOG_INVALID (net,IPPROTO_DCCP ))nf_log_packet (nf_ct_l3num (ct),0 , skb,NULL ,NULL ,NULL , msg);return false; }
@@ -463,6 +464,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff, enum ip_conntrack_info ctinfo, u_int8_t pf, unsigned int hooknum) { + struct net *net = nf_ct_net(ct);enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo);struct dccp_hdr _dh, *dh;u_int8_t type, old_state, new_state;
@@ -524,13 +526,13 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, ct->proto.dccp.last_pkt = type;write_unlock_bh (&dccp_lock); -if (LOG_INVALID (IPPROTO_DCCP )) +if (LOG_INVALID (net,IPPROTO_DCCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_dccp: invalid packet ignored " );return NF_ACCEPT ;case CT_DCCP_INVALID :write_unlock_bh (&dccp_lock); -if (LOG_INVALID (IPPROTO_DCCP )) +if (LOG_INVALID (net,IPPROTO_DCCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_dccp: invalid state transition " );return -NF_ACCEPT ;
@@ -590,7 +592,7 @@ static int dccp_error(struct net *net, struct sk_buff *skb,return NF_ACCEPT ; out_invalid: -if (LOG_INVALID (IPPROTO_DCCP )) +if (LOG_INVALID (net,IPPROTO_DCCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL , msg);return -NF_ACCEPT ; }
net/netfilter/nf_conntrack_proto_tcp.c +10 -8
@@ -488,6 +488,7 @@ static bool tcp_in_window(const struct nf_conn *ct,const struct tcphdr *tcph, u_int8_t pf) { + struct net *net = nf_ct_net(ct);struct ip_ct_tcp_state *sender = &state->seen[dir];struct ip_ct_tcp_state *receiver = &state->seen[!dir];const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
@@ -668,7 +669,7 @@ static bool tcp_in_window(const struct nf_conn *ct,if (sender->flags &IP_CT_TCP_FLAG_BE_LIBERAL || nf_ct_tcp_be_liberal) res = true; -if (!res &&LOG_INVALID (IPPROTO_TCP )) +if (!res &&LOG_INVALID (net,IPPROTO_TCP )) nf_log_packet(pf, 0, skb, NULL, NULL, NULL, "nf_ct_tcp: %s ", before(seq, sender->td_maxend + 1) ?
@@ -761,7 +762,7 @@ static int tcp_error(struct net *net,/* Smaller that minimal TCP header? */ th =skb_header_pointer (skb, dataoff,sizeof (_tcph), &_tcph);if (th ==NULL ) { -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: short packet " );return -NF_ACCEPT ;
@@ -769,7 +770,7 @@ static int tcp_error(struct net *net,/* Not whole TCP header or malformed packet */ if (th->doff*4 <sizeof (struct tcphdr ) || tcplen < th->doff*4 ) { -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: truncated/malformed packet " );return -NF_ACCEPT ;
@@ -782,7 +783,7 @@ static int tcp_error(struct net *net,/* FIXME: Source route IP option packets --RR */ if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum (skb, hooknum, dataoff,IPPROTO_TCP , pf)) { -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: bad TCP checksum " );return -NF_ACCEPT ;
@@ -791,7 +792,7 @@ static int tcp_error(struct net *net,/* Check TCP flags. */ tcpflags = (((u_int8_t *)th)[13 ] & ~(TH_ECE |TH_CWR |TH_PUSH ));if (!tcp_valid_flags[tcpflags]) { -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: invalid TCP flag combination " );return -NF_ACCEPT ;
@@ -808,6 +809,7 @@ static int tcp_packet(struct nf_conn *ct, u_int8_t pf, unsigned int hooknum) { +struct net *net =nf_ct_net (ct);struct nf_conntrack_tuple *tuple;enum tcp_conntrack new_state, old_state;enum ip_conntrack_dir dir;
@@ -886,7 +888,7 @@ static int tcp_packet(struct nf_conn *ct,* thus initiate a clean new session. */ write_unlock_bh (&tcp_lock); -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: killing out of sync session " );nf_ct_kill (ct);
@@ -899,7 +901,7 @@ static int tcp_packet(struct nf_conn *ct,segment_seq_plus_len (ntohl (th->seq), skb->len, dataoff, th);write_unlock_bh (&tcp_lock); -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: invalid packet ignored " );return NF_ACCEPT ;
@@ -908,7 +910,7 @@ static int tcp_packet(struct nf_conn *ct,pr_debug ("nf_ct_tcp: Invalid dir=%i index=%u ostate=%u\n" , dir,get_conntrack_index (th), old_state);write_unlock_bh (&tcp_lock); -if (LOG_INVALID (IPPROTO_TCP )) +if (LOG_INVALID (net,IPPROTO_TCP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_tcp: invalid state " );return -NF_ACCEPT ;
net/netfilter/nf_conntrack_proto_udp.c +3 -3
@@ -101,7 +101,7 @@ static int udp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,/* Header is too small? */ hdr =skb_header_pointer (skb, dataoff,sizeof (_hdr), &_hdr);if (hdr ==NULL ) { -if (LOG_INVALID (IPPROTO_UDP )) +if (LOG_INVALID (net,IPPROTO_UDP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udp: short packet " );return -NF_ACCEPT ;
@@ -109,7 +109,7 @@ static int udp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,/* Truncated/malformed packets */ if (ntohs (hdr->len) > udplen ||ntohs (hdr->len) <sizeof (*hdr)) { -if (LOG_INVALID (IPPROTO_UDP )) +if (LOG_INVALID (net,IPPROTO_UDP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udp: truncated/malformed packet " );return -NF_ACCEPT ;
@@ -125,7 +125,7 @@ static int udp_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,* FIXME: Source route IP option packets --RR */ if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum (skb, hooknum, dataoff,IPPROTO_UDP , pf)) { -if (LOG_INVALID (IPPROTO_UDP )) +if (LOG_INVALID (net,IPPROTO_UDP ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udp: bad UDP checksum " );return -NF_ACCEPT ;
net/netfilter/nf_conntrack_proto_udplite.c +4 -4
@@ -104,7 +104,7 @@ static int udplite_error(struct net *net,/* Header is too small? */ hdr =skb_header_pointer (skb, dataoff,sizeof (_hdr), &_hdr);if (hdr ==NULL ) { -if (LOG_INVALID (IPPROTO_UDPLITE )) +if (LOG_INVALID (net,IPPROTO_UDPLITE ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udplite: short packet " );return -NF_ACCEPT ;
@@ -114,7 +114,7 @@ static int udplite_error(struct net *net,if (cscov ==0 ) cscov = udplen;else if (cscov <sizeof (*hdr) || cscov > udplen) { -if (LOG_INVALID (IPPROTO_UDPLITE )) +if (LOG_INVALID (net,IPPROTO_UDPLITE ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udplite: invalid checksum coverage " );return -NF_ACCEPT ;
@@ -122,7 +122,7 @@ static int udplite_error(struct net *net,/* UDPLITE mandates checksums */ if (!hdr->check) { -if (LOG_INVALID (IPPROTO_UDPLITE )) +if (LOG_INVALID (net,IPPROTO_UDPLITE ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udplite: checksum missing " );return -NF_ACCEPT ;
@@ -132,7 +132,7 @@ static int udplite_error(struct net *net,if (net->ct.sysctl_checksum && hooknum ==NF_INET_PRE_ROUTING &&nf_checksum_partial (skb, hooknum, dataoff, cscov,IPPROTO_UDP , pf)) { -if (LOG_INVALID (IPPROTO_UDPLITE )) +if (LOG_INVALID (net,IPPROTO_UDPLITE ))nf_log_packet (pf,0 , skb,NULL ,NULL ,NULL ,"nf_ct_udplite: bad UDPLite checksum " );return -NF_ACCEPT ;
net/netfilter/nf_conntrack_standalone.c +3 -3
@@ -365,7 +365,7 @@ static ctl_table nf_ct_sysctl_table[] = { { .ctl_name = NET_NF_CONNTRACK_LOG_INVALID, .procname = "nf_conntrack_log_invalid", - .data = &nf_ct_log_invalid, + .data = &init_net.ct.sysctl_log_invalid, .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = &proc_dointvec_minmax,
@@ -403,8 +403,6 @@ static struct ctl_path nf_ct_path[] = { { } }; -EXPORT_SYMBOL_GPL (nf_ct_log_invalid); -static int nf_conntrack_standalone_init_sysctl (struct net *net) {struct ctl_table *table;
@@ -423,6 +421,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) table[1 ].data = &net->ct.count; table[3 ].data = &net->ct.sysctl_checksum; + table[4 ].data = &net->ct.sysctl_log_invalid; net->ct.sysctl_header =register_net_sysctl_table (net, nf_net_netfilter_sysctl_path, table);
@@ -473,6 +472,7 @@ static int nf_conntrack_net_init(struct net *net)if (ret <0 ) goto out_proc; net->ct.sysctl_checksum =1 ; + net->ct.sysctl_log_invalid =0 ; ret =nf_conntrack_standalone_init_sysctl (net);if (ret <0 ) goto out_sysctl;
netfilter 33/79: netns nf_conntrack: per-netns conntrack accounting
In reply to Patrick McHardycommit d716a4dfbbdf0d4731d596a96e5f4b0d892ac168
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:09 2008 +0200
netfilter: netns nf_conntrack: per-netns conntrack accounting
include/net/netfilter/nf_conntrack_acct.h +5 -5
@@ -8,6 +8,7 @@#ifndef _NF_CONNTRACK_ACCT_H#define _NF_CONNTRACK_ACCT_H +#include <net/net_namespace.h> #include <linux/netfilter/nf_conntrack_common.h> #include <linux/netfilter/nf_conntrack_tuple_common.h> #include <net/netfilter/nf_conntrack.h>
@@ -18,8 +19,6 @@ struct nf_conn_counter {u_int64_t bytes; }; -extern int nf_ct_acct; -static inline struct nf_conn_counter *nf_conn_acct_find (const struct nf_conn *ct) {
@@ -29,9 +28,10 @@ struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct)static inline struct nf_conn_counter *nf_ct_acct_ext_add (struct nf_conn *ct,gfp_t gfp) { +struct net *net =nf_ct_net (ct);struct nf_conn_counter *acct; -if (!nf_ct_acct) +if (!net->ct.sysctl_acct)return NULL ; acct =nf_ct_ext_add (ct,NF_CT_EXT_ACCT , gfp);
@@ -45,7 +45,7 @@ struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)extern unsigned int seq_print_acct (struct seq_file *s,const struct nf_conn *ct,int dir); -extern int nf_conntrack_acct_init (void ); -extern void nf_conntrack_acct_fini (void ); +extern int nf_conntrack_acct_init (struct net *net); +extern void nf_conntrack_acct_fini (struct net *net);#endif /* _NF_CONNTRACK_ACCT_H */
include/net/netns/conntrack.h +2 -0
@@ -17,10 +17,12 @@ struct netns_ct {#ifdef CONFIG_NF_CONNTRACK_EVENTS struct nf_conntrack_ecache *ecache;#endif +int sysctl_acct;int sysctl_checksum;unsigned int sysctl_log_invalid;/* Log invalid packets */ #ifdef CONFIG_SYSCTL struct ctl_table_header *sysctl_header; +struct ctl_table_header *acct_sysctl_header;#endif int hash_vmalloc;int expect_vmalloc;
net/netfilter/nf_conntrack_acct.c +72 -28
132 lines not on this page · raw message
net/netfilter/nf_conntrack_core.c +2 -2
@@ -1039,7 +1039,7 @@ void nf_conntrack_cleanup(struct net *net)nf_ct_free_hashtable (net->ct.hash, net->ct.hash_vmalloc, nf_conntrack_htable_size); -nf_conntrack_acct_fini (); +nf_conntrack_acct_fini (net);nf_conntrack_expect_fini (net);free_percpu (net->ct.stat);nf_conntrack_helper_fini ();
@@ -1191,7 +1191,7 @@ int nf_conntrack_init(struct net *net)if (ret <0 ) goto out_fini_expect; - ret =nf_conntrack_acct_init (); + ret =nf_conntrack_acct_init (net);if (ret <0 ) goto out_fini_helper;
netfilter 34/79: netns nf_conntrack: final netns tweaks
In reply to Patrick McHardycommit 08f6547d266fdba087f7fa7963fc0610be5b7cd7
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:09 2008 +0200
netfilter: netns nf_conntrack: final netns tweaks
Add init_net checks to not remove kmem_caches twice and so on.
Refactor functions to split code which should be executed only for init_net into one place.
ip_ct_attach and ip_ct_destroy assignments remain separate, because they're separate stages in setup and teardown.
NOTE: NOTRACK code is in for-every-net part. It will be made per-netns after we decidce how to do it correctly.
net/netfilter/nf_conntrack_core.c +98 -53
@@ -1010,17 +1010,15 @@ void nf_conntrack_flush(struct net *net) }EXPORT_SYMBOL_GPL (nf_conntrack_flush); -/* Mishearing the voices in his head, our hero wonders how he's -supposed to kill the mall. */ -void nf_conntrack_cleanup (struct net *net) +static void nf_conntrack_cleanup_init_net (void ) { -rcu_assign_pointer (ip_ct_attach,NULL ); - -/* This makes sure all current packets have passed through -netfilter framework. Roll on, two-stage module -delete... */ -synchronize_net (); +nf_conntrack_helper_fini (); +nf_conntrack_proto_fini (); +kmem_cache_destroy (nf_conntrack_cachep); +} +static void nf_conntrack_cleanup_net (struct net *net) +{nf_ct_event_cache_flush (net);nf_conntrack_ecache_fini (net); i_see_dead_people:
@@ -1033,17 +1031,31 @@ void nf_conntrack_cleanup(struct net *net)while (atomic_read (&nf_conntrack_untracked.ct_general.use) >1 )schedule (); -rcu_assign_pointer (nf_ct_destroy,NULL ); - -kmem_cache_destroy (nf_conntrack_cachep);nf_ct_free_hashtable (net->ct.hash, net->ct.hash_vmalloc, nf_conntrack_htable_size); -nf_conntrack_acct_fini (net);nf_conntrack_expect_fini (net);free_percpu (net->ct.stat); -nf_conntrack_helper_fini (); -nf_conntrack_proto_fini (); +} + +/* Mishearing the voices in his head, our hero wonders how he's +supposed to kill the mall. */ +void nf_conntrack_cleanup (struct net *net) +{ +if (net_eq (net, &init_net)) +rcu_assign_pointer (ip_ct_attach,NULL ); + +/* This makes sure all current packets have passed through +netfilter framework. Roll on, two-stage module +delete... */ +synchronize_net (); + +nf_conntrack_cleanup_net (net); + +if (net_eq (net, &init_net)) { +rcu_assign_pointer (nf_ct_destroy,NULL ); +nf_conntrack_cleanup_init_net (); + } }struct hlist_head *nf_ct_alloc_hashtable (unsigned int *sizep,int *vmalloced)
@@ -1128,7 +1140,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_set_hashsize);module_param_call (hashsize, nf_conntrack_set_hashsize, param_get_uint, &nf_conntrack_htable_size,0600 ); -int nf_conntrack_init (struct net *net) +static int nf_conntrack_init_init_net (void ) {int max_factor =8 ;int ret;
@@ -1150,21 +1162,6 @@ int nf_conntrack_init(struct net *net)* entries. */ max_factor =4 ; } -atomic_set (&net->ct.count,0 ); - net->ct.stat = alloc_percpu(struct ip_conntrack_stat); -if (!net->ct.stat) - goto err_stat; - ret =nf_conntrack_ecache_init (net); -if (ret <0 ) - goto err_ecache; - net->ct.hash =nf_ct_alloc_hashtable (&nf_conntrack_htable_size, - &net->ct.hash_vmalloc); -if (!net->ct.hash) { -printk (KERN_ERR "Unable to create nf_conntrack_hash\n" ); - goto err_hash; - } -INIT_HLIST_HEAD (&net->ct.unconfirmed); - nf_conntrack_max = max_factor * nf_conntrack_htable_size; printk("nf_conntrack version %s (%u buckets, %d max)\n",
@@ -1176,28 +1173,55 @@ int nf_conntrack_init(struct net *net) 0, 0, NULL);if (!nf_conntrack_cachep) {printk (KERN_ERR "Unable to create nf_conn slab cache\n" ); - goto err_free_hash; + ret = -ENOMEM ; + goto err_cache; } ret =nf_conntrack_proto_init ();if (ret <0 ) - goto err_free_conntrack_slab; - - ret =nf_conntrack_expect_init (net); -if (ret <0 ) - goto out_fini_proto; + goto err_proto; ret =nf_conntrack_helper_init ();if (ret <0 ) - goto out_fini_expect; + goto err_helper; + +return 0 ; + +err_helper: +nf_conntrack_proto_fini (); +err_proto: +kmem_cache_destroy (nf_conntrack_cachep); +err_cache: +return ret; +} + +static int nf_conntrack_init_net (struct net *net) +{ +int ret; +atomic_set (&net->ct.count,0 ); +INIT_HLIST_HEAD (&net->ct.unconfirmed); + net->ct.stat = alloc_percpu(struct ip_conntrack_stat); +if (!net->ct.stat) { + ret = -ENOMEM ; + goto err_stat; + } + ret =nf_conntrack_ecache_init (net); +if (ret <0 ) + goto err_ecache; + net->ct.hash =nf_ct_alloc_hashtable (&nf_conntrack_htable_size, + &net->ct.hash_vmalloc); +if (!net->ct.hash) { + ret = -ENOMEM ; +printk (KERN_ERR "Unable to create nf_conntrack_hash\n" ); + goto err_hash; + } + ret =nf_conntrack_expect_init (net); +if (ret <0 ) + goto err_expect; ret =nf_conntrack_acct_init (net);if (ret <0 ) - goto out_fini_helper; - -/* For use by REJECT target */ -rcu_assign_pointer (ip_ct_attach, nf_conntrack_attach); -rcu_assign_pointer (nf_ct_destroy, destroy_conntrack); + goto err_acct;/* Set up fake conntrack: - to never be deleted, not in any hashes */
@@ -1208,17 +1232,11 @@ int nf_conntrack_init(struct net *net)/* - and look it like as a confirmed connection */ set_bit (IPS_CONFIRMED_BIT , &nf_conntrack_untracked.status); -return ret; +return 0 ; -out_fini_helper: -nf_conntrack_helper_fini (); -out_fini_expect: +err_acct:nf_conntrack_expect_fini (net); -out_fini_proto: -nf_conntrack_proto_fini (); -err_free_conntrack_slab: -kmem_cache_destroy (nf_conntrack_cachep); -err_free_hash: +err_expect:nf_ct_free_hashtable (net->ct.hash, net->ct.hash_vmalloc, nf_conntrack_htable_size); err_hash:
@@ -1226,5 +1244,32 @@ err_hash: err_ecache:free_percpu (net->ct.stat); err_stat: -return -ENOMEM ; +return ret; +} + +int nf_conntrack_init (struct net *net) +{ +int ret; + +if (net_eq (net, &init_net)) { + ret =nf_conntrack_init_init_net (); +if (ret <0 ) + goto out_init_net; + } + ret =nf_conntrack_init_net (net); +if (ret <0 ) + goto out_net; + +if (net_eq (net, &init_net)) { +/* For use by REJECT target */ +rcu_assign_pointer (ip_ct_attach, nf_conntrack_attach); +rcu_assign_pointer (nf_ct_destroy, destroy_conntrack); + } +return 0 ; + +out_net: +if (net_eq (net, &init_net)) +nf_conntrack_cleanup_init_net (); +out_init_net: +return ret; }
net/netfilter/nf_conntrack_expect.c +16 -10
@@ -563,12 +563,14 @@ int nf_conntrack_expect_init(struct net *net) {int err = -ENOMEM ; -if (!nf_ct_expect_hsize) { - nf_ct_expect_hsize = nf_conntrack_htable_size /256 ; -if (!nf_ct_expect_hsize) - nf_ct_expect_hsize =1 ; +if (net_eq (net, &init_net)) { +if (!nf_ct_expect_hsize) { + nf_ct_expect_hsize = nf_conntrack_htable_size /256 ; +if (!nf_ct_expect_hsize) + nf_ct_expect_hsize =1 ; + } + nf_ct_expect_max = nf_ct_expect_hsize *4 ; } - nf_ct_expect_max = nf_ct_expect_hsize *4 ; net->ct.expect_count =0 ; net->ct.expect_hash = nf_ct_alloc_hashtable(&nf_ct_expect_hsize,
@@ -576,11 +578,13 @@ int nf_conntrack_expect_init(struct net *net)if (net->ct.expect_hash ==NULL ) goto err1; - nf_ct_expect_cachep =kmem_cache_create ("nf_conntrack_expect" , +if (net_eq (net, &init_net)) { + nf_ct_expect_cachep =kmem_cache_create ("nf_conntrack_expect" ,sizeof (struct nf_conntrack_expect ),0 ,0 ,NULL ); -if (!nf_ct_expect_cachep) - goto err2; +if (!nf_ct_expect_cachep) + goto err2; + } err =exp_proc_init (net);if (err <0 )
@@ -589,7 +593,8 @@ int nf_conntrack_expect_init(struct net *net)return 0 ; err3: -kmem_cache_destroy (nf_ct_expect_cachep); +if (net_eq (net, &init_net)) +kmem_cache_destroy (nf_ct_expect_cachep); err2:nf_ct_free_hashtable (net->ct.expect_hash, net->ct.expect_vmalloc, nf_ct_expect_hsize);
@@ -600,7 +605,8 @@ err1:void nf_conntrack_expect_fini (struct net *net) {exp_proc_remove (net); -kmem_cache_destroy (nf_ct_expect_cachep); +if (net_eq (net, &init_net)) +kmem_cache_destroy (nf_ct_expect_cachep);nf_ct_free_hashtable (net->ct.expect_hash, net->ct.expect_vmalloc, nf_ct_expect_hsize); }
netfilter 35/79: netns nf_conntrack: SIP conntracking in netns
In reply to Patrick McHardycommit a5c3a8005cb7a36ebcc5b849f6045069ce4f7ca8
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:09 2008 +0200
netfilter: netns nf_conntrack: SIP conntracking in netns
net/netfilter/nf_conntrack_sip.c +2 -1
@@ -736,6 +736,7 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb,struct nf_conntrack_expect *exp, *rtp_exp, *rtcp_exp;enum ip_conntrack_info ctinfo;struct nf_conn *ct =nf_ct_get (skb, &ctinfo); +struct net *net =nf_ct_net (ct);enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo);union nf_inet_addr *saddr;struct nf_conntrack_tuple tuple;
@@ -775,7 +776,7 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb,rcu_read_lock (); do { - exp = __nf_ct_expect_find(&init_net, &tuple); + exp = __nf_ct_expect_find(net, &tuple); if (!exp || exp->master == ct || nfct_help(exp->master)->helper != nfct_help(ct)->helper ||
netfilter 36/79: netns nf_conntrack: H323 conntracking in netns
In reply to Patrick McHardycommit 84541cc13a3bb31a58c096dde3517461e3ad91c2
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:09 2008 +0200
netfilter: netns nf_conntrack: H323 conntracking in netns
net/netfilter/nf_conntrack_h323_main.c +2 -1
@@ -1210,6 +1210,7 @@ static struct nf_conntrack_expect *find_expect(struct nf_conn *ct, union nf_inet_addr *addr, __be16 port) { +struct net *net =nf_ct_net (ct);struct nf_conntrack_expect *exp;struct nf_conntrack_tuple tuple;
@@ -1219,7 +1220,7 @@ static struct nf_conntrack_expect *find_expect(struct nf_conn *ct, tuple.dst.u.tcp.port = port; tuple.dst.protonum =IPPROTO_TCP ; - exp =__nf_ct_expect_find (&init_net, &tuple); + exp =__nf_ct_expect_find (net, &tuple);if (exp && exp->master == ct)return exp;return NULL ;
netfilter 37/79: netns nf_conntrack: GRE conntracking in netns
In reply to Patrick McHardycommit 3bb0d1c00f86b13bb184193a8f0189ddd6f0459f
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:10 2008 +0200
netfilter: netns nf_conntrack: GRE conntracking in netns
* make keymap list per-netns
* per-netns keymal lock (not strictly necessary)
* flush keymap at netns stop and module unload.
include/linux/netfilter/nf_conntrack_proto_gre.h +1 -1
@@ -87,7 +87,7 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,/* delete keymap entries */ void nf_ct_gre_keymap_destroy (struct nf_conn *ct); -extern void nf_ct_gre_keymap_flush (void ); +extern void nf_ct_gre_keymap_flush (struct net *net);extern void nf_nat_need_gre (void );#endif /* __KERNEL__ */
net/netfilter/nf_conntrack_pptp.c +1 -1
@@ -602,7 +602,7 @@ static int __init nf_conntrack_pptp_init(void) static void __exit nf_conntrack_pptp_fini(void) {nf_conntrack_helper_unregister (&pptp); -nf_ct_gre_keymap_flush (); +nf_ct_gre_keymap_flush (&init_net); }module_init (nf_conntrack_pptp_init);
net/netfilter/nf_conntrack_proto_gre.c +74 -23
196 lines not on this page · raw message
netfilter 38/79: netns nf_conntrack: PPTP conntracking in netns
In reply to Patrick McHardycommit 0e6e75af921d1f4799eeb9f83a31c86ab7cdeb8f
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:10 2008 +0200
netfilter: netns nf_conntrack: PPTP conntracking in netns
net/netfilter/nf_conntrack_pptp.c +28 -8
@@ -98,6 +98,7 @@ EXPORT_SYMBOL(pptp_msg_name);static void pptp_expectfn (struct nf_conn *ct,struct nf_conntrack_expect *exp) { +struct net *net =nf_ct_net (ct);typeof (nf_nat_pptp_hook_expectfn) nf_nat_pptp_expectfn;pr_debug ("increasing timeouts\n" );
@@ -121,7 +122,7 @@ static void pptp_expectfn(struct nf_conn *ct,pr_debug ("trying to unexpect other dir: " );nf_ct_dump_tuple (&inv_t); - exp_other =nf_ct_expect_find_get (&init_net, &inv_t); + exp_other =nf_ct_expect_find_get (net, &inv_t);if (exp_other) {/* delete other expectation. */ pr_debug ("found\n" );
@@ -134,7 +135,8 @@ static void pptp_expectfn(struct nf_conn *ct,rcu_read_unlock (); } -static int destroy_sibling_or_exp (const struct nf_conntrack_tuple *t) +static int destroy_sibling_or_exp (struct net *net, +const struct nf_conntrack_tuple *t) {const struct nf_conntrack_tuple_hash *h;struct nf_conntrack_expect *exp;
@@ -143,7 +145,7 @@ static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)pr_debug ("trying to timeout ct or exp for tuple " );nf_ct_dump_tuple (t); - h =nf_conntrack_find_get (&init_net, t); + h =nf_conntrack_find_get (net, t);if (h) { sibling =nf_ct_tuplehash_to_ctrack (h);pr_debug ("setting timeout of conntrack %p to 0\n" , sibling);
@@ -154,7 +156,7 @@ static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)nf_ct_put (sibling);return 1 ; }else { - exp =nf_ct_expect_find_get (&init_net, t); + exp =nf_ct_expect_find_get (net, t);if (exp) {pr_debug ("unexpect_related of expect %p\n" , exp);nf_ct_unexpect_related (exp);
@@ -168,6 +170,7 @@ static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)/* timeout GRE data connections */ static void pptp_destroy_siblings (struct nf_conn *ct) { +struct net *net =nf_ct_net (ct);const struct nf_conn_help *help =nfct_help (ct);struct nf_conntrack_tuple t;
@@ -178,7 +181,7 @@ static void pptp_destroy_siblings(struct nf_conn *ct) t.dst.protonum =IPPROTO_GRE ; t.src.u.gre.key = help->help.ct_pptp_info.pns_call_id; t.dst.u.gre.key = help->help.ct_pptp_info.pac_call_id; -if (!destroy_sibling_or_exp (&t)) +if (!destroy_sibling_or_exp (net, &t))pr_debug ("failed to timeout original pns->pac ct/exp\n" );/* try reply (pac->pns) tuple */
@@ -186,7 +189,7 @@ static void pptp_destroy_siblings(struct nf_conn *ct) t.dst.protonum =IPPROTO_GRE ; t.src.u.gre.key = help->help.ct_pptp_info.pac_call_id; t.dst.u.gre.key = help->help.ct_pptp_info.pns_call_id; -if (!destroy_sibling_or_exp (&t)) +if (!destroy_sibling_or_exp (net, &t))pr_debug ("failed to timeout reply pac->pns ct/exp\n" ); }
@@ -594,15 +597,32 @@ static struct nf_conntrack_helper pptp __read_mostly = { .expect_policy = &pptp_exp_policy, }; +static void nf_conntrack_pptp_net_exit (struct net *net) +{ +nf_ct_gre_keymap_flush (net); +} + +static struct pernet_operations nf_conntrack_pptp_net_ops = { + .exit = nf_conntrack_pptp_net_exit, +}; +static int __init nf_conntrack_pptp_init (void ) { -return nf_conntrack_helper_register (&pptp); +int rv; + + rv =nf_conntrack_helper_register (&pptp); +if (rv <0 ) +return rv; + rv =register_pernet_subsys (&nf_conntrack_pptp_net_ops); +if (rv <0 ) +nf_conntrack_helper_unregister (&pptp); +return rv; } static void __exit nf_conntrack_pptp_fini(void) {nf_conntrack_helper_unregister (&pptp); -nf_ct_gre_keymap_flush (&init_net); +unregister_pernet_subsys (&nf_conntrack_pptp_net_ops); }module_init (nf_conntrack_pptp_init);
netfilter 39/79: netns nat: fix ipt_MASQUERADE in netns
In reply to Patrick McHardycommit b8b8063e0d0835fb44c88d9fded2be31c9a1757e
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:10 2008 +0200
netfilter: netns nat: fix ipt_MASQUERADE in netns
First, allow entry in notifier hook.
Second, start conntrack cleanup in netns to which netdevice belongs.
net/ipv4/netfilter/ipt_MASQUERADE.c +2 -4
@@ -119,9 +119,7 @@ static int masq_device_event(struct notifier_block *this, void *ptr) {const struct net_device *dev = ptr; - -if (!net_eq (dev_net (dev), &init_net)) -return NOTIFY_DONE ; +struct net *net =dev_net (dev);if (event ==NETDEV_DOWN ) {/* Device was downed. Search entire table for
@@ -129,7 +127,7 @@ static int masq_device_event(struct notifier_block *this,and forget them. */ NF_CT_ASSERT (dev->ifindex !=0 ); -nf_ct_iterate_cleanup (&init_net, device_cmp, +nf_ct_iterate_cleanup (net, device_cmp, (void *)(long )dev->ifindex); }
netfilter 40/79: netns nat: per-netns NAT table
In reply to Patrick McHardycommit e099a173573ce1ba171092aee7bb3c72ea686e59
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:10 2008 +0200
netfilter: netns nat: per-netns NAT table
Same story as with iptable_filter, iptables_raw tables.
include/net/netns/ipv4.h +1 -0
@@ -38,6 +38,7 @@ struct netns_ipv4 {struct xt_table *iptable_raw;struct xt_table *arptable_filter;struct xt_table *iptable_security; +struct xt_table *nat_table;#endif int sysctl_icmp_echo_ignore_all;
net/ipv4/netfilter/nf_nat_rule.c +29 -11
@@ -33,7 +33,7 @@ static structstruct ipt_replace repl;struct ipt_standard entries[3 ];struct ipt_error term; -} nat_initial_table __initdata = { +} nat_initial_table __net_initdata = { .repl = { .name = "nat", .valid_hooks = NAT_VALID_HOOKS,
@@ -58,14 +58,13 @@ static struct .term = IPT_ERROR_INIT, /* ERROR */ }; -static struct xt_table __nat_table = { +static struct xt_table nat_table = { .name ="nat" , .valid_hooks =NAT_VALID_HOOKS , .lock =__RW_LOCK_UNLOCKED (__nat_table.lock), .me =THIS_MODULE , .af =AF_INET , }; -static struct xt_table *nat_table;/* Source NAT */ static unsigned int ipt_snat_target(struct sk_buff *skb,
@@ -194,9 +193,10 @@ int nf_nat_rule_find(struct sk_buff *skb,const struct net_device *out, struct nf_conn *ct) { + struct net *net = nf_ct_net(ct);int ret; - ret =ipt_do_table (skb, hooknum, in, out, nat_table); + ret =ipt_do_table (skb, hooknum, in, out, net->ipv4.nat_table);if (ret ==NF_ACCEPT ) {if (!nf_nat_initialized (ct,HOOK2MANIP (hooknum)))
@@ -226,14 +226,32 @@ static struct xt_target ipt_dnat_reg __read_mostly = { .family = AF_INET, }; +static int __net_init nf_nat_rule_net_init (struct net *net) +{ + net->ipv4.nat_table =ipt_register_table (net, &nat_table, + &nat_initial_table.repl); +if (IS_ERR (net->ipv4.nat_table)) +return PTR_ERR (net->ipv4.nat_table); +return 0 ; +} + +static void __net_exit nf_nat_rule_net_exit(struct net *net) +{ +ipt_unregister_table (net->ipv4.nat_table); +} + +static struct pernet_operations nf_nat_rule_net_ops = { + .init = nf_nat_rule_net_init, + .exit = nf_nat_rule_net_exit, +}; +int __init nf_nat_rule_init (void ) {int ret; - nat_table =ipt_register_table (&init_net, &__nat_table, - &nat_initial_table.repl); -if (IS_ERR (nat_table)) -return PTR_ERR (nat_table); + ret =register_pernet_subsys (&nf_nat_rule_net_ops); +if (ret !=0 ) + goto out; ret =xt_register_target (&ipt_snat_reg);if (ret !=0 ) goto unregister_table;
@@ -247,8 +265,8 @@ int __init nf_nat_rule_init(void) unregister_snat:xt_unregister_target (&ipt_snat_reg); unregister_table: -ipt_unregister_table (nat_table); - +unregister_pernet_subsys (&nf_nat_rule_net_ops); + out:return ret; }
@@ -256,5 +274,5 @@ void nf_nat_rule_cleanup(void) {xt_unregister_target (&ipt_dnat_reg);xt_unregister_target (&ipt_snat_reg); -ipt_unregister_table (nat_table); +unregister_pernet_subsys (&nf_nat_rule_net_ops); }
netfilter 41/79: netns nat: per-netns bysource hash
In reply to Patrick McHardycommit 0c4c9288ada0e6642d511ef872f10a4781a896ff
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:11 2008 +0200
netfilter: netns nat: per-netns bysource hash
include/net/netns/ipv4.h +2 -0
@@ -39,6 +39,8 @@ struct netns_ipv4 {struct xt_table *arptable_filter;struct xt_table *iptable_security;struct xt_table *nat_table; +struct hlist_head *nat_bysource; +int nat_vmalloced;#endif int sysctl_icmp_echo_ignore_all;
net/ipv4/netfilter/nf_nat_core.c +45 -27
135 lines not on this page · raw message
netfilter 42/79: netns nf_conntrack: fixup DNAT in netns
In reply to Patrick McHardycommit 9174c1538fffbb5dddab99563eac6b3d8b212277
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:11 2008 +0200
netfilter: netns nf_conntrack: fixup DNAT in netns
net/ipv4/netfilter/nf_nat_rule.c +3 -3
@@ -91,13 +91,13 @@ static unsigned int ipt_snat_target(struct sk_buff *skb, }/* Before 2.6.11 we did implicit source NAT if required. Warn about change. */ -static void warn_if_extra_mangle (__be32 dstip,__be32 srcip) +static void warn_if_extra_mangle (struct net *net,__be32 dstip,__be32 srcip) {static int warned =0 ;struct flowi fl = { .nl_u = { .ip4_u = { .daddr = dstip } } };struct rtable *rt; -if (ip_route_output_key (&init_net, &rt, &fl) !=0 ) +if (ip_route_output_key (net, &rt, &fl) !=0 )return ;if (rt->rt_src != srcip && !warned) {
@@ -130,7 +130,7 @@ static unsigned int ipt_dnat_target(struct sk_buff *skb,if (hooknum ==NF_INET_LOCAL_OUT && mr->range[0 ].flags &IP_NAT_RANGE_MAP_IPS ) -warn_if_extra_mangle (ip_hdr (skb)->daddr, +warn_if_extra_mangle (dev_net (out),ip_hdr (skb)->daddr, mr->range[0 ].min_ip);return nf_nat_setup_info (ct, &mr->range[0 ],IP_NAT_MANIP_DST );
netfilter 43/79: netns nat: PPTP NAT in netns
In reply to Patrick McHardycommit cfd6e3d74751b62b6d0844e24c911776e40a0135
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:11 2008 +0200
netfilter: netns nat: PPTP NAT in netns
net/ipv4/netfilter/nf_nat_pptp.c +2 -1
@@ -40,6 +40,7 @@ MODULE_ALIAS("ip_nat_pptp");static void pptp_nat_expected (struct nf_conn *ct,struct nf_conntrack_expect *exp) { +struct net *net =nf_ct_net (ct);const struct nf_conn *master = ct->master;struct nf_conntrack_expect *other_exp;struct nf_conntrack_tuple t;
@@ -73,7 +74,7 @@ static void pptp_nat_expected(struct nf_conn *ct,pr_debug ("trying to unexpect other dir: " );nf_ct_dump_tuple_ip (&t); - other_exp =nf_ct_expect_find_get (&init_net, &t); + other_exp =nf_ct_expect_find_get (net, &t);if (other_exp) {nf_ct_unexpect_related (other_exp);nf_ct_expect_put (other_exp);
netfilter 44/79: enable netfilter in netns
In reply to Patrick McHardycommit 4de6f16b9ec2422fa7ef9c22f7b1c8d5a55499b4
Author: Alexey Dobriyan <[email protected]> Date: Wed Oct 8 11:35:11 2008 +0200
netfilter: enable netfilter in netns
From kernel perspective, allow entrance in nf_hook_slow().
Stuff which uses nf_register_hook/nf_register_hooks, but otherwise not netns-ready:
DECnet netfilter
ipt_CLUSTERIP
nf_nat_standalone.c together with XFRM (?) IPVS
several individual match modules (like hashlimit) ctnetlink
NOTRACK
all sorts of queueing and reporting to userspace L3 and L4 protocol sysctls, bridge sysctls probably something else
Anyway critical mass has been achieved, there is no reason to hide netfilter any longer.
From userspace perspective, allow to manipulate all sorts of iptables/ip6tables/arptables rules.
net/netfilter/core.c +0 -8
@@ -165,14 +165,6 @@ int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,unsigned int verdict;int ret =0 ; -#ifdef CONFIG_NET_NS -struct net *net; - - net = indev ==NULL ?dev_net (outdev) :dev_net (indev); -if (net != &init_net) -return 1 ; -#endif -/* We may already have this, but read-locks nest anyway */ rcu_read_lock ();
net/netfilter/nf_sockopt.c +0 -3
@@ -65,9 +65,6 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, {struct nf_sockopt_ops *ops; -if (!net_eq (sock_net (sk), &init_net)) -return ERR_PTR (-ENOPROTOOPT ); -if (mutex_lock_interruptible (&nf_sockopt_mutex) !=0 )return ERR_PTR (-EINTR );
netfilter 45/79: split netfilter IPv4 defragmentation into a separate module
In reply to Patrick McHardycommit 73e4022f78acdbe420e8c24a7afbd90f4c8f5077
Author: KOVACS Krisztian <[email protected]> Date: Wed Oct 8 11:35:12 2008 +0200
netfilter: split netfilter IPv4 defragmentation into a separate module
Netfilter connection tracking requires all IPv4 packets to be defragmented. Both the socket match and the TPROXY target depend on this functionality, so this patch separates the Netfilter IPv4 defrag hooks into a separate module.
include/net/netfilter/ipv4/nf_defrag_ipv4.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _NF_DEFRAG_IPV4_H +#define _NF_DEFRAG_IPV4_H + +extern void nf_defrag_ipv4_enable (void ); + +#endif /* _NF_DEFRAG_IPV4_H */
net/ipv4/netfilter/Kconfig +5 -0
@@ -5,10 +5,15 @@ menu "IP: Netfilter Configuration" depends on INET && NETFILTER +config NF_DEFRAG_IPV4 + tristate + default n + config NF_CONNTRACK_IPV4 tristate "IPv4 connection tracking support (required for NAT)" depends on NF_CONNTRACK default m if NETFILTER_ADVANCED=n + select NF_DEFRAG_IPV4 ---help--- Connection tracking keeps a record of what packets have passed through your machine, in order to figure out how they are related
net/ipv4/netfilter/Makefile +3 -0
@@ -18,6 +18,9 @@ obj-$(CONFIG_NF_CONNTRACK_IPV4) += nf_conntrack_ipv4.o obj-$(CONFIG_NF_NAT) += nf_nat.o +# defrag +obj-$(CONFIG_NF_DEFRAG_IPV4) += nf_defrag_ipv4.o + # NAT helpers (nf_conntrack) obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +3 -53
95 lines not on this page · raw message
net/ipv4/netfilter/nf_defrag_ipv4.c new file +96 -0
96 lines not on this page · raw message
netfilter 46/79: iptables tproxy core
In reply to Patrick McHardycommit 9ad2d745a23853927a19789b034d9eb2e62d78ee
Author: KOVACS Krisztian <[email protected]> Date: Wed Oct 8 11:35:12 2008 +0200
netfilter: iptables tproxy core
The iptables tproxy core is a module that contains the common routines used by various tproxy related modules (TPROXY target and socket match)
include/net/netfilter/nf_tproxy_core.h new file +32 -0
@@ -0,0 +1,32 @@ +#ifndef _NF_TPROXY_CORE_H +#define _NF_TPROXY_CORE_H + +#include <linux/types.h> +#include <linux/in.h> +#include <linux/skbuff.h> +#include <net/sock.h> +#include <net/inet_sock.h> +#include <net/tcp.h> + +/* look up and get a reference to a matching socket */ +extern struct sock * +nf_tproxy_get_sock_v4 (struct net *net,const u8 protocol, +const __be32 saddr,const __be32 daddr, +const __be16 sport,const __be16 dport, +const struct net_device *in,bool listening); + +static inline void +nf_tproxy_put_sock (struct sock *sk) +{ +/* TIME_WAIT inet sockets have to be handled differently */ +if ((sk->sk_protocol ==IPPROTO_TCP ) && (sk->sk_state ==TCP_TIME_WAIT )) +inet_twsk_put (inet_twsk (sk)); +else +sock_put (sk); +} + +/* assign a socket to the skb -- consumes sk */ +int +nf_tproxy_assign_sock (struct sk_buff *skb,struct sock *sk); + +#endif
net/netfilter/Kconfig +15 -0
@@ -287,6 +287,21 @@ config NF_CT_NETLINK help This option enables support for a netlink-based userspace interface +# transparent proxy support +config NETFILTER_TPROXY + tristate "Transparent proxying support (EXPERIMENTAL)" + depends on EXPERIMENTAL + depends on IP_NF_MANGLE + depends on NETFILTER_ADVANCED + help + This option enables transparent proxying support, that is, + support for handling non-locally bound IPv4 TCP and UDP sockets. + For it to work you will have to configure certain iptables rules + and use policy routing. For more information on how to set it up + see Documentation/networking/tproxy.txt. + + To compile it as a module, choose M here. If unsure, say N. + config NETFILTER_XTABLES tristate "Netfilter Xtables support (required for ip_tables)" default m if NETFILTER_ADVANCED=n
net/netfilter/Makefile +3 -0
@@ -34,6 +34,9 @@ obj-$(CONFIG_NF_CONNTRACK_SANE) += nf_conntrack_sane.o obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o +# transparent proxy support +obj-$(CONFIG_NETFILTER_TPROXY) += nf_tproxy_core.o + # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nf_tproxy_core.c new file +96 -0
96 lines not on this page · raw message
netfilter 47/79: iptables socket match
In reply to Patrick McHardycommit 136cdc71fd54e77463e570643ac76e2b696e48a0
Author: KOVACS Krisztian <[email protected]> Date: Wed Oct 8 11:35:12 2008 +0200
netfilter: iptables socket match
Add iptables 'socket' match, which matches packets for which a TCP/UDP socket lookup succeeds.
net/netfilter/Kconfig +15 -0
@@ -778,6 +778,21 @@ config NETFILTER_XT_MATCH_SCTP If you want to compile it as a module, say M here and read <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. +config NETFILTER_XT_MATCH_SOCKET + tristate '"socket" match support (EXPERIMENTAL)' + depends on EXPERIMENTAL + depends on NETFILTER_TPROXY + depends on NETFILTER_XTABLES + depends on NETFILTER_ADVANCED + select NF_DEFRAG_IPV4 + help + This option adds a `socket' match, which can be used to match + packets for which a TCP or UDP socket lookup finds a valid socket. + It can be used in combination with the MARK target and policy + routing to implement full featured non-locally bound sockets. + + To compile it as a module, choose M here. If unsure, say N. + config NETFILTER_XT_MATCH_STATE tristate '"state" match support' depends on NETFILTER_XTABLES
net/netfilter/Makefile +1 -0
@@ -81,6 +81,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_RATEEST) += xt_rateest.o obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o obj-$(CONFIG_NETFILTER_XT_MATCH_RECENT) += xt_recent.o obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o +obj-$(CONFIG_NETFILTER_XT_MATCH_SOCKET) += xt_socket.o obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o
net/netfilter/xt_socket.c new file +192 -0
192 lines not on this page · raw message
netfilter 48/79: iptables TPROXY target
In reply to Patrick McHardycommit e84392707e10301b93121e1b74e2823db50cdf9e
Author: KOVACS Krisztian <[email protected]> Date: Wed Oct 8 11:35:12 2008 +0200
netfilter: iptables TPROXY target
The TPROXY target implements redirection of non-local TCP/UDP traffic to local sockets. Additionally, it's possible to manipulate the packet mark if and only if a socket has been found. (We need this because we cannot use multiple targets in the same iptables rule.)
include/linux/netfilter/xt_TPROXY.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _XT_TPROXY_H_target +#define _XT_TPROXY_H_target + +/* TPROXY target is capable of marking the packet to perform +* redirection. We can get rid of that whenever we get support for +* mutliple targets in the same rule. */ +struct xt_tproxy_target_info { +u_int32_t mark_mask; +u_int32_t mark_value; +__be32 laddr; +__be16 lport; +}; + +#endif /* _XT_TPROXY_H_target */
net/netfilter/Kconfig +15 -0
@@ -421,6 +421,21 @@ config NETFILTER_XT_TARGET_RATEEST To compile it as a module, choose M here. If unsure, say N. +config NETFILTER_XT_TARGET_TPROXY + tristate '"TPROXY" target support (EXPERIMENTAL)' + depends on EXPERIMENTAL + depends on NETFILTER_TPROXY + depends on NETFILTER_XTABLES + depends on NETFILTER_ADVANCED + select NF_DEFRAG_IPV4 + help + This option adds a `TPROXY' target, which is somewhat similar to + REDIRECT. It can only be used in the mangle table and is useful + to redirect traffic to a transparent proxy. It does _not_ depend + on Netfilter connection tracking and NAT, unlike REDIRECT. + + To compile it as a module, choose M here. If unsure, say N. + config NETFILTER_XT_TARGET_TRACE tristate '"TRACE" target support' depends on NETFILTER_XTABLES
net/netfilter/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o obj-$(CONFIG_NETFILTER_XT_TARGET_RATEEST) += xt_RATEEST.o obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o +obj-$(CONFIG_NETFILTER_XT_TARGET_TPROXY) += xt_TPROXY.o obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o obj-$(CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP) += xt_TCPOPTSTRIP.o obj-$(CONFIG_NETFILTER_XT_TARGET_TRACE) += xt_TRACE.o
net/netfilter/xt_TPROXY.c new file +112 -0
112 lines not on this page · raw message
netfilter 49/79: Add documentation for tproxy
In reply to Patrick McHardycommit d2f26037a38ada4a5d40d1cf0b32bc5289f50312
Author: KOVACS Krisztian <[email protected]> Date: Wed Oct 8 11:35:12 2008 +0200
netfilter: Add documentation for tproxy
Add basic usage instructions to Documentation/networking.
Documentation/networking/tproxy.txt new file +85 -0
@@ -0,0 +1,85 @@ +Transparent proxy support +========================= + +This feature adds Linux 2.2-like transparent proxy support to current kernels. +To use it, enable NETFILTER_TPROXY, the socket match and the TPROXY target in +your kernel config. You will need policy routing too, so be sure to enable that +as well. + + +1. Making non-local sockets work +================================ + +The idea is that you identify packets with destination address matching a local +socket on your box, set the packet mark to a certain value, and then match on that +value using policy routing to have those packets delivered locally: + +# iptables -t mangle -N DIVERT +# iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT +# iptables -t mangle -A DIVERT -j MARK --set-mark 1 +# iptables -t mangle -A DIVERT -j ACCEPT + +# ip rule add fwmark 1 lookup 100 +# ip route add local 0.0.0.0/0 dev lo table 100 + +Because of certain restrictions in the IPv4 routing output code you'll have to +modify your application to allow it to send datagrams _from_ non-local IP +addresses. All you have to do is enable the (SOL_IP, IP_TRANSPARENT) socket +option before calling bind: + +fd = socket(AF_INET, SOCK_STREAM, 0); +/* - 8< -*/ +int value = 1; +setsockopt(fd, SOL_IP, IP_TRANSPARENT, &value, sizeof(value)); +/* - 8< -*/ +name.sin_family = AF_INET; +name.sin_port = htons(0xCAFE); +name.sin_addr.s_addr = htonl(0xDEADBEEF); +bind(fd, &name, sizeof(name)); + +A trivial patch for netcat is available here: +http://people.netfilter.org/hidden/tproxy/netcat-ip_transparent-support.patch + + +2. Redirecting traffic +====================== + +Transparent proxying often involves "intercepting" traffic on a router. This is +usually done with the iptables REDIRECT target; however, there are serious +limitations of that method. One of the major issues is that it actually +modifies the packets to change the destination address -- which might not be +acceptable in certain situations. (Think of proxying UDP for example: you won't +be able to find out the original destination address. Even in case of TCP +getting the original destination address is racy.) + +The 'TPROXY' target provides similar functionality without relying on NAT. Simply +add rules like this to the iptables ruleset above: + +# iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY \ + --tproxy-mark 0x1/0x1 --on-port 50080 + +Note that for this to work you'll have to modify the proxy to enable (SOL_IP, +IP_TRANSPARENT) for the listening socket. + + +3. Iptables extensions +====================== + +To use tproxy you'll need to have the 'socket' and 'TPROXY' modules +compiled for iptables. A patched version of iptables is available +here: http://git.balabit.hu/?p=bazsi/iptables-tproxy.git + + +4. Application support +====================== + +4.1. Squid +---------- + +Squid 3.HEAD has support built-in. To use it, pass +'--enable-linux-netfilter' to configure and set the 'tproxy' option on +the HTTP listener you redirect traffic to with the TPROXY iptables +target. + +For more information please consult the following page on the Squid +wiki: http://wiki.squid-cache.org/Features/Tproxy4
netfilter 50/79: ebtables: do centralized size checking
In reply to Patrick McHardycommit 18219d3f7d6a5bc43825a41e0763158efbdb80d3
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:13 2008 +0200
netfilter: ebtables: do centralized size checking
include/linux/netfilter_bridge/ebtables.h +3 -0
@@ -215,6 +215,7 @@ struct ebt_matchint (*check)(const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *matchdata,unsigned int datalen);void (*destroy)(void *matchdata,unsigned int datalen); +unsigned int matchsize;struct module *me; };
@@ -229,6 +230,7 @@ struct ebt_watcherint (*check)(const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *watcherdata,unsigned int datalen);void (*destroy)(void *watcherdata,unsigned int datalen); +unsigned int targetsize;struct module *me; };
@@ -244,6 +246,7 @@ struct ebt_targetint (*check)(const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *targetdata,unsigned int datalen);void (*destroy)(void *targetdata,unsigned int datalen); +unsigned int targetsize;struct module *me; };
net/bridge/netfilter/ebt_802_3.c +3 -4
@@ -7,10 +7,10 @@* May 2003 * */ - +#include <linux/module.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_802_3.h> -#include <linux/module.h> static int ebt_filter_802_3 (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen)
@@ -42,8 +42,6 @@ static int ebt_802_3_check(const char *tablename, unsigned int hookmask, {const struct ebt_802_3_info *info = data; -if (datalen <sizeof (struct ebt_802_3_info )) -return -EINVAL ;if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK )return -EINVAL ;
@@ -54,6 +52,7 @@ static struct ebt_match filter_802_3 __read_mostly = { .name = EBT_802_3_MATCH, .match = ebt_filter_802_3, .check = ebt_802_3_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_802_3_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_among.c +1 -0
@@ -216,6 +216,7 @@ static struct ebt_match filter_among __read_mostly = { .name = EBT_AMONG_MATCH, .match = ebt_filter_among, .check = ebt_among_check, + .matchsize = -1, /* special case */ .me = THIS_MODULE, };
net/bridge/netfilter/ebt_arp.c +4 -5
@@ -8,12 +8,12 @@* April, 2002 * */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_arp.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/module.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_arp.h> static int ebt_filter_arp (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen)
@@ -105,8 +105,6 @@ static int ebt_arp_check(const char *tablename, unsigned int hookmask, {const struct ebt_arp_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_arp_info ))) -return -EINVAL ;if ((e->ethproto !=htons (ETH_P_ARP ) && e->ethproto !=htons (ETH_P_RARP )) || e->invflags &EBT_IPROTO )
@@ -120,6 +118,7 @@ static struct ebt_match filter_arp __read_mostly = { .name = EBT_ARP_MATCH, .match = ebt_filter_arp, .check = ebt_arp_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_arp_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_arpreply.c +4 -5
@@ -8,12 +8,12 @@* August, 2003 * */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_arpreply.h> #include <linux/if_arp.h> #include <net/arp.h> #include <linux/module.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_arpreply.h> static int ebt_target_reply(struct sk_buff *skb, unsigned int hooknr, const struct net_device *in, const struct net_device *out,
@@ -63,8 +63,6 @@ static int ebt_target_reply_check(const char *tablename, unsigned int hookmask, {const struct ebt_arpreply_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_arpreply_info ))) -return -EINVAL ;if (BASE_CHAIN && info->target ==EBT_RETURN )return -EINVAL ; if (e->ethproto != htons(ETH_P_ARP) ||
@@ -80,6 +78,7 @@ static struct ebt_target reply_target __read_mostly = { .name = EBT_ARPREPLY_TARGET, .target = ebt_target_reply, .check = ebt_target_reply_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_arpreply_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_dnat.c +4 -5
@@ -7,12 +7,12 @@* June, 2002 * */ - +#include <linux/module.h> +#include <net/sock.h> #include <linux/netfilter.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_nat.h> -#include <linux/module.h> -#include <net/sock.h> static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr, const struct net_device *in, const struct net_device *out,
@@ -39,8 +39,6 @@ static int ebt_target_dnat_check(const char *tablename, unsigned int hookmask, (hookmask & ~((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT)))) && (strcmp(tablename, "broute") || hookmask & ~(1 << NF_BR_BROUTING)) )return -EINVAL ; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_nat_info ))) -return -EINVAL ;if (INVALID_TARGET )return -EINVAL ;return 0 ;
@@ -50,6 +48,7 @@ static struct ebt_target dnat __read_mostly = { .name = EBT_DNAT_TARGET, .target = ebt_target_dnat, .check = ebt_target_dnat_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_nat_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_ip.c +4 -5
@@ -11,13 +11,13 @@* Innominate Security Technologies AG <[email protected]> * September, 2002 */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_ip.h> #include <linux/ip.h> #include <net/ip.h> #include <linux/in.h> #include <linux/module.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_ip.h> struct tcpudphdr {__be16 src;
@@ -83,8 +83,6 @@ static int ebt_ip_check(const char *tablename, unsigned int hookmask, {const struct ebt_ip_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_ip_info ))) -return -EINVAL ;if (e->ethproto !=htons (ETH_P_IP ) || e->invflags &EBT_IPROTO )return -EINVAL ;
@@ -111,6 +109,7 @@ static struct ebt_match filter_ip __read_mostly = { .name = EBT_IP_MATCH, .match = ebt_filter_ip, .check = ebt_ip_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_ip_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_ip6.c +4 -5
@@ -13,14 +13,14 @@* * Jan, 2008 */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_ip6.h> #include <linux/ipv6.h> #include <net/ipv6.h> #include <linux/in.h> #include <linux/module.h> #include <net/dsfield.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_ip6.h> struct tcpudphdr {__be16 src;
@@ -97,8 +97,6 @@ static int ebt_ip6_check(const char *tablename, unsigned int hookmask, {struct ebt_ip6_info *info = (struct ebt_ip6_info *)data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_ip6_info ))) -return -EINVAL ;if (e->ethproto !=htons (ETH_P_IPV6 ) || e->invflags &EBT_IPROTO )return -EINVAL ;if (info->bitmask & ~EBT_IP6_MASK || info->invflags & ~EBT_IP6_MASK )
@@ -125,6 +123,7 @@ static struct ebt_match filter_ip6 = .name = EBT_IP6_MATCH, .match = ebt_filter_ip6, .check = ebt_ip6_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_ip6_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_limit.c +4 -7
@@ -10,13 +10,12 @@* September, 2003 * */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_limit.h> #include <linux/module.h> -#include <linux/netdevice.h> #include <linux/spinlock.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_limit.h> static DEFINE_SPINLOCK (limit_lock);
@@ -71,9 +70,6 @@ static int ebt_limit_check(const char *tablename, unsigned int hookmask, {struct ebt_limit_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_limit_info ))) -return -EINVAL ; -/* Check for overflow. */ if (info->burst ==0 ||user2credits (info->avg * info->burst) <user2credits (info->avg)) {
@@ -94,6 +90,7 @@ static struct ebt_match ebt_limit_reg __read_mostly = { .name = EBT_LIMIT_MATCH, .match = ebt_limit_match, .check = ebt_limit_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_limit_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_log.c +5 -6
@@ -8,10 +8,6 @@* April, 2002 * */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_log.h> -#include <linux/netfilter.h> #include <linux/module.h> #include <linux/ip.h> #include <linux/in.h>
@@ -21,6 +17,10 @@#include <linux/ipv6.h> #include <net/ipv6.h> #include <linux/in6.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_log.h> +#include <linux/netfilter.h> static DEFINE_SPINLOCK (ebt_log_lock);
@@ -29,8 +29,6 @@ static int ebt_log_check(const char *tablename, unsigned int hookmask, {struct ebt_log_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_log_info ))) -return -EINVAL ;if (info->bitmask & ~EBT_LOG_MASK )return -EINVAL ;if (info->loglevel >=8 )
@@ -218,6 +216,7 @@ static struct ebt_watcher log = .name = EBT_LOG_WATCHER, .watcher = ebt_log, .check = ebt_log_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_log_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_mark.c +3 -3
@@ -13,9 +13,10 @@* Marking a frame doesn't really change anything in the frame anyway. */ +#include <linux/module.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_mark_t.h> -#include <linux/module.h> static int ebt_target_mark(struct sk_buff *skb, unsigned int hooknr, const struct net_device *in, const struct net_device *out,
@@ -42,8 +43,6 @@ static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,const struct ebt_mark_t_info *info = data;int tmp; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_mark_t_info ))) -return -EINVAL ; tmp = info->target | ~EBT_VERDICT_BITS ;if (BASE_CHAIN && tmp ==EBT_RETURN )return -EINVAL ;
@@ -61,6 +60,7 @@ static struct ebt_target mark_target __read_mostly = { .name = EBT_MARK_TARGET, .target = ebt_target_mark, .check = ebt_target_mark_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_mark_t_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_mark_m.c +3 -4
@@ -7,10 +7,10 @@* July, 2002 * */ - +#include <linux/module.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_mark_m.h> -#include <linux/module.h> static int ebt_filter_mark(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const void *data,
@@ -28,8 +28,6 @@ static int ebt_mark_check(const char *tablename, unsigned int hookmask, {const struct ebt_mark_m_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_mark_m_info ))) -return -EINVAL ;if (info->bitmask & ~EBT_MARK_MASK )return -EINVAL ;if ((info->bitmask &EBT_MARK_OR ) && (info->bitmask &EBT_MARK_AND ))
@@ -43,6 +41,7 @@ static struct ebt_match filter_mark __read_mostly = { .name = EBT_MARK_MATCH, .match = ebt_filter_mark, .check = ebt_mark_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_mark_m_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_nflog.c +2 -2
@@ -14,6 +14,7 @@#include <linux/module.h> #include <linux/spinlock.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_nflog.h> #include <net/netfilter/nf_log.h>
@@ -42,8 +43,6 @@ static int ebt_nflog_check(const char *tablename, {struct ebt_nflog_info *info = (struct ebt_nflog_info *)data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_nflog_info ))) -return -EINVAL ;if (info->flags & ~EBT_NFLOG_MASK )return -EINVAL ; info->prefix[EBT_NFLOG_PREFIX_SIZE -1 ] ='\0' ;
@@ -54,6 +53,7 @@ static struct ebt_watcher nflog __read_mostly = { .name = EBT_NFLOG_WATCHER, .watcher = ebt_nflog, .check = ebt_nflog_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_nflog_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_pkttype.c +3 -4
@@ -7,10 +7,10 @@* April, 2003 * */ - +#include <linux/module.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_pkttype.h> -#include <linux/module.h> static int ebt_filter_pkttype(const struct sk_buff *skb, const struct net_device *in,
@@ -28,8 +28,6 @@ static int ebt_pkttype_check(const char *tablename, unsigned int hookmask, {const struct ebt_pkttype_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_pkttype_info ))) -return -EINVAL ;if (info->invert !=0 && info->invert !=1 )return -EINVAL ;/* Allow any pkt_type value */
@@ -40,6 +38,7 @@ static struct ebt_match filter_pkttype __read_mostly = { .name = EBT_PKTTYPE_MATCH, .match = ebt_filter_pkttype, .check = ebt_pkttype_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_pkttype_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_redirect.c +5 -6
@@ -7,13 +7,13 @@* April, 2002 * */ - -#include <linux/netfilter.h> -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_redirect.h> #include <linux/module.h> #include <net/sock.h> #include "../br_private.h" +#include <linux/netfilter.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_redirect.h> static int ebt_target_redirect(struct sk_buff *skb, unsigned int hooknr, const struct net_device *in, const struct net_device *out,
@@ -38,8 +38,6 @@ static int ebt_target_redirect_check(const char *tablename, unsigned int hookmas {const struct ebt_redirect_info *info = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_redirect_info ))) -return -EINVAL ;if (BASE_CHAIN && info->target ==EBT_RETURN )return -EINVAL ;CLEAR_BASE_CHAIN_BIT ;
@@ -55,6 +53,7 @@ static struct ebt_target redirect_target __read_mostly = { .name = EBT_REDIRECT_TARGET, .target = ebt_target_redirect, .check = ebt_target_redirect_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_redirect_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_snat.c +5 -6
@@ -7,14 +7,14 @@* June, 2002 * */ - -#include <linux/netfilter.h> -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_nat.h> #include <linux/module.h> #include <net/sock.h> #include <linux/if_arp.h> #include <net/arp.h> +#include <linux/netfilter.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_nat.h> static int ebt_target_snat(struct sk_buff *skb, unsigned int hooknr, const struct net_device *in, const struct net_device *out,
@@ -49,8 +49,6 @@ static int ebt_target_snat_check(const char *tablename, unsigned int hookmask,const struct ebt_nat_info *info = data;int tmp; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_nat_info ))) -return -EINVAL ; tmp = info->target | ~EBT_VERDICT_BITS ;if (BASE_CHAIN && tmp ==EBT_RETURN )return -EINVAL ;
@@ -72,6 +70,7 @@ static struct ebt_target snat __read_mostly = { .name = EBT_SNAT_TARGET, .target = ebt_target_snat, .check = ebt_target_snat_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_nat_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_stp.c +4 -6
@@ -7,11 +7,11 @@* * July, 2003 */ - -#include <linux/netfilter_bridge/ebtables.h> -#include <linux/netfilter_bridge/ebt_stp.h> #include <linux/etherdevice.h> #include <linux/module.h> +#include <linux/netfilter/x_tables.h> +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_stp.h> #define BPDU_TYPE_CONFIG 0#define BPDU_TYPE_TCN 0x80
@@ -157,15 +157,12 @@ static int ebt_stp_check(const char *tablename, unsigned int hookmask, const struct ebt_entry *e, void *data, unsigned int datalen) { const struct ebt_stp_info *info = data; -const unsigned int len =EBT_ALIGN (sizeof (struct ebt_stp_info ));const uint8_t bridge_ula[6 ] = {0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 };const uint8_t msk[6 ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK || !(info->bitmask &EBT_STP_MASK ))return -EINVAL ; -if (datalen != len) -return -EINVAL ;/* Make sure the match only receives stp frames */ if (compare_ether_addr (e->destmac, bridge_ula) ||compare_ether_addr (e->destmsk, msk) || !(e->bitmask &EBT_DESTMAC ))
@@ -178,6 +175,7 @@ static struct ebt_match filter_stp __read_mostly = { .name = EBT_STP_MATCH, .match = ebt_filter_stp, .check = ebt_stp_check, + .matchsize = XT_ALIGN(sizeof(struct ebt_stp_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_ulog.c +3 -2
@@ -36,6 +36,7 @@#include <linux/timer.h> #include <linux/netlink.h> #include <linux/netdevice.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_ulog.h> #include <net/netfilter/nf_log.h>
@@ -260,8 +261,7 @@ static int ebt_ulog_check(const char *tablename, unsigned int hookmask, {struct ebt_ulog_info *uloginfo = data; -if (datalen !=EBT_ALIGN (sizeof (struct ebt_ulog_info )) || - uloginfo->nlgroup >31 ) +if (uloginfo->nlgroup >31 )return -EINVAL ; uloginfo->prefix[EBT_ULOG_PREFIX_LEN -1 ] ='\0' ;
@@ -276,6 +276,7 @@ static struct ebt_watcher ulog __read_mostly = { .name = EBT_ULOG_WATCHER, .watcher = ebt_ulog, .check = ebt_ulog_check, + .targetsize = XT_ALIGN(sizeof(struct ebt_ulog_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebt_vlan.c +2 -8
@@ -22,6 +22,7 @@#include <linux/if_vlan.h> #include <linux/module.h> #include <linux/moduleparam.h> +#include <linux/netfilter/x_tables.h> #include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_vlan.h>
@@ -93,14 +94,6 @@ ebt_check_vlan(const char *tablename, {struct ebt_vlan_info *info = data; -/* Parameters buffer overflow check */ -if (datalen !=EBT_ALIGN (sizeof (struct ebt_vlan_info ))) { -DEBUG_MSG - ("passed size %d is not eq to ebt_vlan_info (%Zd)\n" , - datalen,sizeof (struct ebt_vlan_info )); -return -EINVAL ; - } -/* Is it 802.1Q frame checked? */ if (e->ethproto !=htons (ETH_P_8021Q )) {DEBUG_MSG
@@ -173,6 +166,7 @@ static struct ebt_match filter_vlan __read_mostly = { .name = EBT_VLAN_MATCH, .match = ebt_filter_vlan, .check = ebt_check_vlan, + .matchsize = XT_ALIGN(sizeof(struct ebt_vlan_info)), .me = THIS_MODULE, };
net/bridge/netfilter/ebtables.c +38 -5
73 lines not on this page · raw message
netfilter 51/79: change return types of check functions for Ebtables extensions
In reply to Patrick McHardycommit 19eda879a136889110c692dec4c2ab59e0e43cef
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:13 2008 +0200
netfilter: change return types of check functions for Ebtables extensions
include/linux/netfilter_bridge/ebtables.h +3 -6
@@ -211,8 +211,7 @@ struct ebt_matchint (*match)(const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *matchdata,unsigned int datalen); -/* 0 == let it in */ -int (*check)(const char *tablename,unsigned int hookmask, +bool (*check)(const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *matchdata,unsigned int datalen);void (*destroy)(void *matchdata,unsigned int datalen);unsigned int matchsize;
@@ -226,8 +225,7 @@ struct ebt_watchervoid (*watcher)(const struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *watcherdata,unsigned int datalen); -/* 0 == let it in */ -int (*check)(const char *tablename,unsigned int hookmask, +bool (*check)(const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *watcherdata,unsigned int datalen);void (*destroy)(void *watcherdata,unsigned int datalen);unsigned int targetsize;
@@ -242,8 +240,7 @@ struct ebt_targetint (*target)(struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *targetdata,unsigned int datalen); -/* 0 == let it in */ -int (*check)(const char *tablename,unsigned int hookmask, +bool (*check)(const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *targetdata,unsigned int datalen);void (*destroy)(void *targetdata,unsigned int datalen);unsigned int targetsize;
net/bridge/netfilter/ebt_802_3.c +3 -3
@@ -37,15 +37,15 @@ static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device * }static struct ebt_match filter_802_3; -static int ebt_802_3_check (const char *tablename,unsigned int hookmask, +static bool ebt_802_3_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_802_3_info *info = data;if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK ) -return -EINVAL ; +return false; -return 0 ; +return true; }static struct ebt_match filter_802_3__read_mostly = {
net/bridge/netfilter/ebt_among.c +8 -7
@@ -177,9 +177,10 @@ static int ebt_filter_among(const struct sk_buff *skb,return EBT_MATCH ; } -static int ebt_among_check (const char *tablename,unsigned int hookmask, -const struct ebt_entry *e,void *data, -unsigned int datalen) +static bool +ebt_among_check (const char *tablename,unsigned int hookmask, +const struct ebt_entry *e,void *data, +unsigned int datalen) {const struct ebt_among_info *info = data;int expected_length =sizeof (struct ebt_among_info );
@@ -197,19 +198,19 @@ static int ebt_among_check(const char *tablename, unsigned int hookmask,"against expected %d, rounded to %Zd\n" , datalen, expected_length, EBT_ALIGN(expected_length)); -return -EINVAL ; +return false; }if (wh_dst && (err =ebt_mac_wormhash_check_integrity (wh_dst))) {printk (KERN_WARNING "ebtables: among: dst integrity fail: %x\n" , -err); -return -EINVAL ; +return false; }if (wh_src && (err =ebt_mac_wormhash_check_integrity (wh_src))) {printk (KERN_WARNING "ebtables: among: src integrity fail: %x\n" , -err); -return -EINVAL ; +return false; } -return 0 ; +return true; }static struct ebt_match filter_among__read_mostly = {
net/bridge/netfilter/ebt_arp.c +4 -4
@@ -100,7 +100,7 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *inreturn EBT_MATCH ; } -static int ebt_arp_check (const char *tablename,unsigned int hookmask, +static bool ebt_arp_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_arp_info *info = data;
@@ -108,10 +108,10 @@ static int ebt_arp_check(const char *tablename, unsigned int hookmask,if ((e->ethproto !=htons (ETH_P_ARP ) && e->ethproto !=htons (ETH_P_RARP )) || e->invflags &EBT_IPROTO ) -return -EINVAL ; +return false;if (info->bitmask & ~EBT_ARP_MASK || info->invflags & ~EBT_ARP_MASK ) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_match filter_arp__read_mostly = {
net/bridge/netfilter/ebt_arpreply.c +5 -5
@@ -58,20 +58,20 @@ static int ebt_target_reply(struct sk_buff *skb, unsigned int hooknr,return info->target; } -static int ebt_target_reply_check (const char *tablename,unsigned int hookmask, +static bool ebt_target_reply_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_arpreply_info *info = data;if (BASE_CHAIN && info->target ==EBT_RETURN ) -return -EINVAL ; +return false;if (e->ethproto !=htons (ETH_P_ARP ) || e->invflags &EBT_IPROTO ) -return -EINVAL ; +return false;CLEAR_BASE_CHAIN_BIT ;if (strcmp (tablename,"nat" ) || hookmask & ~(1 <<NF_BR_PRE_ROUTING )) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_target reply_target__read_mostly = {
net/bridge/netfilter/ebt_dnat.c +5 -5
@@ -27,21 +27,21 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr,return info->target; } -static int ebt_target_dnat_check (const char *tablename,unsigned int hookmask, +static bool ebt_target_dnat_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_nat_info *info = data;if (BASE_CHAIN && info->target ==EBT_RETURN ) -return -EINVAL ; +return false;CLEAR_BASE_CHAIN_BIT ;if ( (strcmp (tablename,"nat" ) || (hookmask & ~((1 <<NF_BR_PRE_ROUTING ) | (1 <<NF_BR_LOCAL_OUT )))) && (strcmp (tablename,"broute" ) || hookmask & ~(1 <<NF_BR_BROUTING )) ) -return -EINVAL ; +return false;if (INVALID_TARGET ) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_target dnat__read_mostly = {
net/bridge/netfilter/ebt_ip.c +8 -8
@@ -78,31 +78,31 @@ static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in,return EBT_MATCH ; } -static int ebt_ip_check (const char *tablename,unsigned int hookmask, +static bool ebt_ip_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_ip_info *info = data;if (e->ethproto !=htons (ETH_P_IP ) || e->invflags &EBT_IPROTO ) -return -EINVAL ; +return false;if (info->bitmask & ~EBT_IP_MASK || info->invflags & ~EBT_IP_MASK ) -return -EINVAL ; +return false;if (info->bitmask & (EBT_IP_DPORT |EBT_IP_SPORT )) {if (info->invflags &EBT_IP_PROTO ) -return -EINVAL ; +return false;if (info->protocol !=IPPROTO_TCP && info->protocol !=IPPROTO_UDP && info->protocol !=IPPROTO_UDPLITE && info->protocol !=IPPROTO_SCTP && info->protocol !=IPPROTO_DCCP ) -return -EINVAL ; +return false; }if (info->bitmask &EBT_IP_DPORT && info->dport[0 ] > info->dport[1 ]) -return -EINVAL ; +return false;if (info->bitmask &EBT_IP_SPORT && info->sport[0 ] > info->sport[1 ]) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_match filter_ip__read_mostly = {
net/bridge/netfilter/ebt_ip6.c +8 -8
@@ -92,30 +92,30 @@ static int ebt_filter_ip6(const struct sk_buff *skb,return EBT_MATCH ; } -static int ebt_ip6_check (const char *tablename,unsigned int hookmask, +static bool ebt_ip6_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {struct ebt_ip6_info *info = (struct ebt_ip6_info *)data;if (e->ethproto !=htons (ETH_P_IPV6 ) || e->invflags &EBT_IPROTO ) -return -EINVAL ; +return false;if (info->bitmask & ~EBT_IP6_MASK || info->invflags & ~EBT_IP6_MASK ) -return -EINVAL ; +return false;if (info->bitmask & (EBT_IP6_DPORT |EBT_IP6_SPORT )) {if (info->invflags &EBT_IP6_PROTO ) -return -EINVAL ; +return false;if (info->protocol !=IPPROTO_TCP && info->protocol !=IPPROTO_UDP && info->protocol !=IPPROTO_UDPLITE && info->protocol !=IPPROTO_SCTP && info->protocol !=IPPROTO_DCCP ) -return -EINVAL ; +return false; }if (info->bitmask &EBT_IP6_DPORT && info->dport[0 ] > info->dport[1 ]) -return -EINVAL ; +return false;if (info->bitmask &EBT_IP6_SPORT && info->sport[0 ] > info->sport[1 ]) -return -EINVAL ; -return 0 ; +return false; +return true; } static struct ebt_match filter_ip6 =
net/bridge/netfilter/ebt_limit.c +3 -3
@@ -65,7 +65,7 @@ user2credits(u_int32_t user)return (user *HZ *CREDITS_PER_JIFFY ) /EBT_LIMIT_SCALE ; } -static int ebt_limit_check (const char *tablename,unsigned int hookmask, +static bool ebt_limit_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {struct ebt_limit_info *info = data;
@@ -75,7 +75,7 @@ static int ebt_limit_check(const char *tablename, unsigned int hookmask, user2credits(info->avg * info->burst) < user2credits(info->avg)) {printk ("Overflow in ebt_limit, try lower: %u/%u\n" , info->avg, info->burst); -return -EINVAL ; +return false; }/* User avg in seconds * EBT_LIMIT_SCALE: convert to jiffies * 128. */
@@ -83,7 +83,7 @@ static int ebt_limit_check(const char *tablename, unsigned int hookmask, info->credit =user2credits (info->avg * info->burst); info->credit_cap =user2credits (info->avg * info->burst); info->cost =user2credits (info->avg); -return 0 ; +return true; }static struct ebt_match ebt_limit_reg__read_mostly = {
net/bridge/netfilter/ebt_log.c +4 -4
@@ -24,17 +24,17 @@static DEFINE_SPINLOCK (ebt_log_lock); -static int ebt_log_check (const char *tablename,unsigned int hookmask, +static bool ebt_log_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {struct ebt_log_info *info = data;if (info->bitmask & ~EBT_LOG_MASK ) -return -EINVAL ; +return false;if (info->loglevel >=8 ) -return -EINVAL ; +return false; info->prefix[EBT_LOG_PREFIX_SIZE -1 ] ='\0' ; -return 0 ; +return true; }struct tcpudphdr
net/bridge/netfilter/ebt_mark.c +5 -5
@@ -37,7 +37,7 @@ static int ebt_target_mark(struct sk_buff *skb, unsigned int hooknr,return info->target | ~EBT_VERDICT_BITS ; } -static int ebt_target_mark_check (const char *tablename,unsigned int hookmask, +static bool ebt_target_mark_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_mark_t_info *info = data;
@@ -45,15 +45,15 @@ static int ebt_target_mark_check(const char *tablename, unsigned int hookmask, tmp = info->target | ~EBT_VERDICT_BITS ;if (BASE_CHAIN && tmp ==EBT_RETURN ) -return -EINVAL ; +return false;CLEAR_BASE_CHAIN_BIT ;if (tmp < -NUM_STANDARD_TARGETS || tmp >=0 ) -return -EINVAL ; +return false; tmp = info->target & ~EBT_VERDICT_BITS ;if (tmp !=MARK_SET_VALUE && tmp !=MARK_OR_VALUE && tmp !=MARK_AND_VALUE && tmp !=MARK_XOR_VALUE ) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_target mark_target__read_mostly = {
net/bridge/netfilter/ebt_mark_m.c +5 -5
@@ -23,18 +23,18 @@ static int ebt_filter_mark(const struct sk_buff *skb,return !(((skb->mark & info->mask) == info->mark) ^ info->invert); } -static int ebt_mark_check (const char *tablename,unsigned int hookmask, +static bool ebt_mark_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_mark_m_info *info = data;if (info->bitmask & ~EBT_MARK_MASK ) -return -EINVAL ; +return false;if ((info->bitmask &EBT_MARK_OR ) && (info->bitmask &EBT_MARK_AND )) -return -EINVAL ; +return false;if (!info->bitmask) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_match filter_mark__read_mostly = {
net/bridge/netfilter/ebt_nflog.c +6 -6
@@ -36,17 +36,17 @@ static void ebt_nflog(const struct sk_buff *skb,nf_log_packet (PF_BRIDGE , hooknr, skb, in, out, &li,"%s" , info->prefix); } -static int ebt_nflog_check (const char *tablename, -unsigned int hookmask, -const struct ebt_entry *e, -void *data,unsigned int datalen) +static bool ebt_nflog_check (const char *tablename, +unsigned int hookmask, +const struct ebt_entry *e, +void *data,unsigned int datalen) {struct ebt_nflog_info *info = (struct ebt_nflog_info *)data;if (info->flags & ~EBT_NFLOG_MASK ) -return -EINVAL ; +return false; info->prefix[EBT_NFLOG_PREFIX_SIZE -1 ] ='\0' ; -return 0 ; +return true; }static struct ebt_watcher nflog__read_mostly = {
net/bridge/netfilter/ebt_pkttype.c +3 -3
@@ -23,15 +23,15 @@ static int ebt_filter_pkttype(const struct sk_buff *skb,return (skb->pkt_type != info->pkt_type) ^ info->invert; } -static int ebt_pkttype_check (const char *tablename,unsigned int hookmask, +static bool ebt_pkttype_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_pkttype_info *info = data;if (info->invert !=0 && info->invert !=1 ) -return -EINVAL ; +return false;/* Allow any pkt_type value */ -return 0 ; +return true; }static struct ebt_match filter_pkttype__read_mostly = {
net/bridge/netfilter/ebt_redirect.c +5 -5
@@ -33,20 +33,20 @@ static int ebt_target_redirect(struct sk_buff *skb, unsigned int hooknr,return info->target; } -static int ebt_target_redirect_check (const char *tablename,unsigned int hookmask, +static bool ebt_target_redirect_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_redirect_info *info = data;if (BASE_CHAIN && info->target ==EBT_RETURN ) -return -EINVAL ; +return false;CLEAR_BASE_CHAIN_BIT ;if ( (strcmp (tablename,"nat" ) || hookmask & ~(1 <<NF_BR_PRE_ROUTING )) && (strcmp (tablename,"broute" ) || hookmask & ~(1 <<NF_BR_BROUTING )) ) -return -EINVAL ; +return false;if (INVALID_TARGET ) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_target redirect_target__read_mostly = {
net/bridge/netfilter/ebt_snat.c +7 -7
@@ -43,7 +43,7 @@ out:return info->target | ~EBT_VERDICT_BITS ; } -static int ebt_target_snat_check (const char *tablename,unsigned int hookmask, +static bool ebt_target_snat_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_nat_info *info = data;
@@ -51,19 +51,19 @@ static int ebt_target_snat_check(const char *tablename, unsigned int hookmask, tmp = info->target | ~EBT_VERDICT_BITS ;if (BASE_CHAIN && tmp ==EBT_RETURN ) -return -EINVAL ; +return false;CLEAR_BASE_CHAIN_BIT ;if (strcmp (tablename,"nat" )) -return -EINVAL ; +return false;if (hookmask & ~(1 <<NF_BR_POST_ROUTING )) -return -EINVAL ; +return false;if (tmp < -NUM_STANDARD_TARGETS || tmp >=0 ) -return -EINVAL ; +return false; tmp = info->target |EBT_VERDICT_BITS ;if ((tmp & ~NAT_ARP_BIT ) != ~NAT_ARP_BIT ) -return -EINVAL ; -return 0 ; +return false; +return true; }static struct ebt_target snat__read_mostly = {
net/bridge/netfilter/ebt_stp.c +4 -4
@@ -153,7 +153,7 @@ static int ebt_filter_stp(const struct sk_buff *skb, const struct net_device *inreturn EBT_MATCH ; } -static int ebt_stp_check (const char *tablename,unsigned int hookmask, +static bool ebt_stp_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {const struct ebt_stp_info *info = data;
@@ -162,13 +162,13 @@ static int ebt_stp_check(const char *tablename, unsigned int hookmask,if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK || !(info->bitmask &EBT_STP_MASK )) -return -EINVAL ; +return false;/* Make sure the match only receives stp frames */ if (compare_ether_addr (e->destmac, bridge_ula) ||compare_ether_addr (e->destmsk, msk) || !(e->bitmask &EBT_DESTMAC )) -return -EINVAL ; +return false; -return 0 ; +return true; }static struct ebt_match filter_stp__read_mostly = {
net/bridge/netfilter/ebt_ulog.c +12 -9
@@ -255,14 +255,13 @@ static void ebt_ulog(const struct sk_buff *skb, unsigned int hooknr,ebt_ulog_packet (hooknr, skb, in, out, uloginfo,NULL ); } - -static int ebt_ulog_check (const char *tablename,unsigned int hookmask, +static bool ebt_ulog_check (const char *tablename,unsigned int hookmask,const struct ebt_entry *e,void *data,unsigned int datalen) {struct ebt_ulog_info *uloginfo = data;if (uloginfo->nlgroup >31 ) -return -EINVAL ; +return false; uloginfo->prefix[EBT_ULOG_PREFIX_LEN -1 ] ='\0' ;
@@ -288,12 +287,13 @@ static const struct nf_logger ebt_ulog_logger = {static int __init ebt_ulog_init (void ) { -int i, ret =0 ; +bool ret = true; +int i;if (nlbufsiz >=128 *1024 ) {printk (KERN_NOTICE "ebt_ulog: Netlink buffer has to be <= 128kB," " please try a smaller nlbufsiz parameter.\n" ); -return -EINVAL ; +return false; }/* initialize ulog_buffers */
@@ -305,12 +305,15 @@ static int __init ebt_ulog_init(void) ebtulognl =netlink_kernel_create (&init_net,NETLINK_NFLOG ,EBT_ULOG_MAXNLGROUPS ,NULL ,NULL ,THIS_MODULE ); -if (!ebtulognl) - ret = -ENOMEM ; -else if ((ret =ebt_register_watcher (&ulog))) +if (!ebtulognl) { + printk(KERN_WARNING KBUILD_MODNAME ": out of memory trying to " + "call netlink_kernel_create\n"); + ret = false; + }else if (ebt_register_watcher (&ulog) !=0 ) {netlink_kernel_release (ebtulognl); + } -if (ret ==0 ) +if (ret)nf_log_register (NFPROTO_BRIDGE , &ebt_ulog_logger);return ret;
net/bridge/netfilter/ebt_vlan.c +8 -8
@@ -87,7 +87,7 @@ ebt_filter_vlan(const struct sk_buff *skb,return EBT_MATCH ; } -static int +static bool ebt_check_vlan (const char *tablename,unsigned int hooknr,const struct ebt_entry *e,void *data,unsigned int datalen)
@@ -99,7 +99,7 @@ ebt_check_vlan(const char *tablename,DEBUG_MSG ("passed entry proto %2.4X is not 802.1Q (8100)\n" , (unsigned short )ntohs (e->ethproto)); -return -EINVAL ; +return false; }/* Check for bitmask range
@@ -107,14 +107,14 @@ ebt_check_vlan(const char *tablename,if (info->bitmask & ~EBT_VLAN_MASK ) {DEBUG_MSG ("bitmask %2X is out of mask (%2X)\n" , info->bitmask,EBT_VLAN_MASK ); -return -EINVAL ; +return false; }/* Check for inversion flags range */ if (info->invflags & ~EBT_VLAN_MASK ) {DEBUG_MSG ("inversion flags %2X is out of mask (%2X)\n" , info->invflags,EBT_VLAN_MASK ); -return -EINVAL ; +return false; }/* Reserved VLAN ID (VID) values
@@ -129,7 +129,7 @@ ebt_check_vlan(const char *tablename,DEBUG_MSG ("id %d is out of range (1-4096)\n" , info->id); -return -EINVAL ; +return false; }/* Note: This is valid VLAN-tagged frame point. * Any value of user_priority are acceptable,
@@ -144,7 +144,7 @@ ebt_check_vlan(const char *tablename,if ((unsigned char ) info->prio >7 ) {DEBUG_MSG ("prio %d is out of range (0-7)\n" , info->prio); -return -EINVAL ; +return false; } }/* Check for encapsulated proto range - it is possible to be
@@ -155,11 +155,11 @@ ebt_check_vlan(const char *tablename,DEBUG_MSG ("encap frame length %d is less than minimal\n" ,ntohs (info->encap)); -return -EINVAL ; +return false; } } -return 0 ; +return true; }static struct ebt_match filter_vlan__read_mostly = {
net/bridge/netfilter/ebtables.c +3 -3
@@ -365,7 +365,7 @@ ebt_check_match(struct ebt_entry_match *m, struct ebt_entry *e,return -EINVAL ; }if (match->check && - match->check (name, hookmask, e, m->data, m->match_size) !=0 ) { + !match->check (name, hookmask, e, m->data, m->match_size)) {BUGPRINT ("match->check failed\n" );module_put (match->me);return -EINVAL ;
@@ -403,7 +403,7 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct ebt_entry *e,return -EINVAL ; }if (watcher->check && - watcher->check (name, hookmask, e, w->data, w->watcher_size) !=0 ) { + !watcher->check (name, hookmask, e, w->data, w->watcher_size)) {BUGPRINT ("watcher->check failed\n" );module_put (watcher->me);return -EINVAL ;
@@ -716,7 +716,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo, ret = -EINVAL ; goto cleanup_watchers; }else if (t->u.target->check && - t->u.target->check (name, hookmask, e, t->data, t->target_size) !=0 ) { + !t->u.target->check (name, hookmask, e, t->data, t->target_size)) {module_put (t->u.target->me); ret = -EFAULT ; goto cleanup_watchers;
netfilter 52/79: change return types of match functions for ebtables extensions
In reply to Patrick McHardycommit 8cc784eec6676b58e7f60419c88179aaa97bf71c
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:13 2008 +0200
netfilter: change return types of match functions for ebtables extensions
include/linux/netfilter_bridge/ebtables.h +1 -2
@@ -207,8 +207,7 @@ struct ebt_match {struct list_head list;const char name[EBT_FUNCTION_MAXNAMELEN ]; -/* 0 == it matches */ -int (*match)(const struct sk_buff *skb,const struct net_device *in, +bool (*match)(const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *matchdata,unsigned int datalen); bool (*check)(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_802_3.c +7 -6
@@ -12,7 +12,8 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_802_3.h> -static int ebt_filter_802_3 (const struct sk_buff *skb,const struct net_device *in, +static bool ebt_filter_802_3 (const struct sk_buff *skb, +const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {const struct ebt_802_3_info *info = data;
@@ -21,19 +22,19 @@ static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *if (info->bitmask &EBT_802_3_SAP ) {if (FWINV (info->sap != hdr->llc.ui.ssap,EBT_802_3_SAP )) -return EBT_NOMATCH ; +return false;if (FWINV (info->sap != hdr->llc.ui.dsap,EBT_802_3_SAP )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_802_3_TYPE ) {if (!(hdr->llc.ui.dsap ==CHECK_TYPE && hdr->llc.ui.ssap ==CHECK_TYPE )) -return EBT_NOMATCH ; +return false;if (FWINV (info->type != type,EBT_802_3_TYPE )) -return EBT_NOMATCH ; +return false; } -return EBT_MATCH ; +return true; }static struct ebt_match filter_802_3;
net/bridge/netfilter/ebt_among.c +20 -24
95 lines not on this page · raw message
net/bridge/netfilter/ebt_arp.c +18 -17
@@ -15,7 +15,8 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_arp.h> -static int ebt_filter_arp (const struct sk_buff *skb,const struct net_device *in, +static bool ebt_filter_arp (const struct sk_buff *skb, +const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {const struct ebt_arp_info *info = data;
@@ -24,42 +25,42 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in ah =skb_header_pointer (skb,0 ,sizeof (_arph), &_arph);if (ah ==NULL ) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_OPCODE &&FWINV (info->opcode != ah->ar_op,EBT_ARP_OPCODE )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_HTYPE &&FWINV (info->htype != ah->ar_hrd,EBT_ARP_HTYPE )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_PTYPE &&FWINV (info->ptype != ah->ar_pro,EBT_ARP_PTYPE )) -return EBT_NOMATCH ; +return false;if (info->bitmask & (EBT_ARP_SRC_IP |EBT_ARP_DST_IP |EBT_ARP_GRAT )) {const __be32 *sap, *dap;__be32 saddr, daddr;if (ah->ar_pln !=sizeof (__be32) || ah->ar_pro !=htons (ETH_P_IP )) -return EBT_NOMATCH ; +return false; sap =skb_header_pointer (skb,sizeof (struct arphdr ) + ah->ar_hln,sizeof (saddr), &saddr);if (sap ==NULL ) -return EBT_NOMATCH ; +return false; dap =skb_header_pointer (skb,sizeof (struct arphdr ) +2 *ah->ar_hln+sizeof (saddr),sizeof (daddr), &daddr);if (dap ==NULL ) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_SRC_IP &&FWINV (info->saddr != (*sap & info->smsk),EBT_ARP_SRC_IP )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_DST_IP &&FWINV (info->daddr != (*dap & info->dmsk),EBT_ARP_DST_IP )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_GRAT &&FWINV (*dap != *sap,EBT_ARP_GRAT )) -return EBT_NOMATCH ; +return false; }if (info->bitmask & (EBT_ARP_SRC_MAC |EBT_ARP_DST_MAC )) {
@@ -68,18 +69,18 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *inuint8_t verdict, i;if (ah->ar_hln !=ETH_ALEN || ah->ar_hrd !=htons (ARPHRD_ETHER )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_ARP_SRC_MAC ) { mp =skb_header_pointer (skb,sizeof (struct arphdr ),sizeof (_mac), &_mac);if (mp ==NULL ) -return EBT_NOMATCH ; +return false; verdict =0 ;for (i =0 ; i <6 ; i++) verdict |= (mp[i] ^ info->smaddr[i]) & info->smmsk[i];if (FWINV (verdict !=0 ,EBT_ARP_SRC_MAC )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_ARP_DST_MAC ) {
@@ -87,17 +88,17 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in ah->ar_hln + ah->ar_pln, sizeof(_mac), &_mac);if (mp ==NULL ) -return EBT_NOMATCH ; +return false; verdict =0 ;for (i =0 ; i <6 ; i++) verdict |= (mp[i] ^ info->dmaddr[i]) & info->dmmsk[i];if (FWINV (verdict !=0 ,EBT_ARP_DST_MAC )) -return EBT_NOMATCH ; +return false; } } -return EBT_MATCH ; +return true; } static bool ebt_arp_check(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_ip.c +13 -12
@@ -24,7 +24,8 @@ struct tcpudphdr {__be16 dst; }; -static int ebt_filter_ip (const struct sk_buff *skb,const struct net_device *in, +static bool ebt_filter_ip (const struct sk_buff *skb, +const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
@@ -36,46 +37,46 @@ static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in, ih =skb_header_pointer (skb,0 ,sizeof (_iph), &_iph);if (ih ==NULL ) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP_TOS &&FWINV (info->tos != ih->tos,EBT_IP_TOS )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP_SOURCE &&FWINV ((ih->saddr & info->smsk) != info->saddr,EBT_IP_SOURCE )) -return EBT_NOMATCH ; +return false;if ((info->bitmask &EBT_IP_DEST ) &&FWINV ((ih->daddr & info->dmsk) != info->daddr,EBT_IP_DEST )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP_PROTO ) {if (FWINV (info->protocol != ih->protocol,EBT_IP_PROTO )) -return EBT_NOMATCH ; +return false;if (!(info->bitmask &EBT_IP_DPORT ) && !(info->bitmask &EBT_IP_SPORT )) -return EBT_MATCH ; +return true;if (ntohs (ih->frag_off) &IP_OFFSET ) -return EBT_NOMATCH ; +return false; pptr =skb_header_pointer (skb, ih->ihl*4 ,sizeof (_ports), &_ports);if (pptr ==NULL ) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP_DPORT ) {u32 dst =ntohs (pptr->dst);if (FWINV (dst < info->dport[0 ] || dst > info->dport[1 ],EBT_IP_DPORT )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_IP_SPORT ) {u32 src =ntohs (pptr->src);if (FWINV (src < info->sport[0 ] || src > info->sport[1 ],EBT_IP_SPORT )) -return EBT_NOMATCH ; +return false; } } -return EBT_MATCH ; +return true; } static bool ebt_ip_check(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_ip6.c +13 -13
@@ -27,7 +27,7 @@ struct tcpudphdr {__be16 dst; }; -static int ebt_filter_ip6 (const struct sk_buff *skb, +static bool ebt_filter_ip6 (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen)
@@ -42,54 +42,54 @@ static int ebt_filter_ip6(const struct sk_buff *skb, ih6 =skb_header_pointer (skb,0 ,sizeof (_ip6h), &_ip6h);if (ih6 ==NULL ) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP6_TCLASS &&FWINV (info->tclass !=ipv6_get_dsfield (ih6),EBT_IP6_TCLASS )) -return EBT_NOMATCH ; +return false;for (i =0 ; i <4 ; i++) tmp_addr.in6_u.u6_addr32[i] = ih6->saddr.in6_u.u6_addr32[i] & info->smsk.in6_u.u6_addr32[i];if (info->bitmask &EBT_IP6_SOURCE &&FWINV ((ipv6_addr_cmp (&tmp_addr, &info->saddr) !=0 ),EBT_IP6_SOURCE )) -return EBT_NOMATCH ; +return false;for (i =0 ; i <4 ; i++) tmp_addr.in6_u.u6_addr32[i] = ih6->daddr.in6_u.u6_addr32[i] & info->dmsk.in6_u.u6_addr32[i];if (info->bitmask &EBT_IP6_DEST &&FWINV ((ipv6_addr_cmp (&tmp_addr, &info->daddr) !=0 ),EBT_IP6_DEST )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP6_PROTO ) {uint8_t nexthdr = ih6->nexthdr;int offset_ph; offset_ph =ipv6_skip_exthdr (skb,sizeof (_ip6h), &nexthdr);if (offset_ph ==-1 ) -return EBT_NOMATCH ; +return false;if (FWINV (info->protocol != nexthdr,EBT_IP6_PROTO )) -return EBT_NOMATCH ; +return false;if (!(info->bitmask &EBT_IP6_DPORT ) && !(info->bitmask &EBT_IP6_SPORT )) -return EBT_MATCH ; +return true; pptr =skb_header_pointer (skb, offset_ph,sizeof (_ports), &_ports);if (pptr ==NULL ) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_IP6_DPORT ) {u32 dst =ntohs (pptr->dst);if (FWINV (dst < info->dport[0 ] || dst > info->dport[1 ],EBT_IP6_DPORT )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_IP6_SPORT ) {u32 src =ntohs (pptr->src);if (FWINV (src < info->sport[0 ] || src > info->sport[1 ],EBT_IP6_SPORT )) -return EBT_NOMATCH ; +return false; } -return EBT_MATCH ; +return true; } -return EBT_MATCH ; +return true; } static bool ebt_ip6_check(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_limit.c +3 -3
@@ -30,7 +30,7 @@ static DEFINE_SPINLOCK(limit_lock);#define CREDITS_PER_JIFFY POW2_BELOW32(MAX_CPJ) -static int ebt_limit_match (const struct sk_buff *skb, +static bool ebt_limit_match (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
@@ -46,11 +46,11 @@ static int ebt_limit_match(const struct sk_buff *skb,/* We're not limited. */ info->credit -= info->cost;spin_unlock_bh (&limit_lock); -return EBT_MATCH ; +return true; }spin_unlock_bh (&limit_lock); -return EBT_NOMATCH ; +return false; }/* Precision saver. */
net/bridge/netfilter/ebt_mark_m.c +3 -3
@@ -12,15 +12,15 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_mark_m.h> -static int ebt_filter_mark (const struct sk_buff *skb, +static bool ebt_filter_mark (const struct sk_buff *skb,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {const struct ebt_mark_m_info *info = data;if (info->bitmask &EBT_MARK_OR ) -return !(!!(skb->mark & info->mask) ^ info->invert); -return !(((skb->mark & info->mask) == info->mark) ^ info->invert); +return !!(skb->mark & info->mask) ^ info->invert; +return ((skb->mark & info->mask) == info->mark) ^ info->invert; } static bool ebt_mark_check(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_pkttype.c +2 -2
@@ -12,7 +12,7 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_pkttype.h> -static int ebt_filter_pkttype(const struct sk_buff *skb, +static bool ebt_filter_pkttype(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const void *data,
@@ -20,7 +20,7 @@ static int ebt_filter_pkttype(const struct sk_buff *skb, {const struct ebt_pkttype_info *info = data; -return (skb->pkt_type != info->pkt_type) ^ info->invert; +return (skb->pkt_type == info->pkt_type) ^ info->invert; } static bool ebt_pkttype_check(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_stp.c +20 -19
@@ -40,7 +40,7 @@ struct stp_config_pdu {#define NR16 (p) (p[0] << 8 | p[1])#define NR32 (p) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]) -static int ebt_filter_config (const struct ebt_stp_info *info, +static bool ebt_filter_config (const struct ebt_stp_info *info,const struct stp_config_pdu *stpc) {const struct ebt_stp_config_info *c;
@@ -51,12 +51,12 @@ static int ebt_filter_config(const struct ebt_stp_info *info, c = &info->config;if ((info->bitmask &EBT_STP_FLAGS ) &&FWINV (c->flags != stpc->flags,EBT_STP_FLAGS )) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_STP_ROOTPRIO ) { v16 =NR16 (stpc->root);if (FWINV (v16 < c->root_priol || v16 > c->root_priou,EBT_STP_ROOTPRIO )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_ROOTADDR ) { verdict =0 ;
@@ -64,19 +64,19 @@ static int ebt_filter_config(const struct ebt_stp_info *info, verdict |= (stpc->root[2 +i] ^ c->root_addr[i]) & c->root_addrmsk[i];if (FWINV (verdict !=0 ,EBT_STP_ROOTADDR )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_ROOTCOST ) { v32 =NR32 (stpc->root_cost);if (FWINV (v32 < c->root_costl || v32 > c->root_costu,EBT_STP_ROOTCOST )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_SENDERPRIO ) { v16 =NR16 (stpc->sender);if (FWINV (v16 < c->sender_priol || v16 > c->sender_priou,EBT_STP_SENDERPRIO )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_SENDERADDR ) { verdict =0 ;
@@ -84,42 +84,43 @@ static int ebt_filter_config(const struct ebt_stp_info *info, verdict |= (stpc->sender[2 +i] ^ c->sender_addr[i]) & c->sender_addrmsk[i];if (FWINV (verdict !=0 ,EBT_STP_SENDERADDR )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_PORT ) { v16 =NR16 (stpc->port);if (FWINV (v16 < c->portl || v16 > c->portu,EBT_STP_PORT )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_MSGAGE ) { v16 =NR16 (stpc->msg_age);if (FWINV (v16 < c->msg_agel || v16 > c->msg_ageu,EBT_STP_MSGAGE )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_MAXAGE ) { v16 =NR16 (stpc->max_age);if (FWINV (v16 < c->max_agel || v16 > c->max_ageu,EBT_STP_MAXAGE )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_HELLOTIME ) { v16 =NR16 (stpc->hello_time);if (FWINV (v16 < c->hello_timel || v16 > c->hello_timeu,EBT_STP_HELLOTIME )) -return EBT_NOMATCH ; +return false; }if (info->bitmask &EBT_STP_FWDD ) { v16 =NR16 (stpc->forward_delay);if (FWINV (v16 < c->forward_delayl || v16 > c->forward_delayu,EBT_STP_FWDD )) -return EBT_NOMATCH ; +return false; } -return EBT_MATCH ; +return true; } -static int ebt_filter_stp (const struct sk_buff *skb,const struct net_device *in, +static bool ebt_filter_stp (const struct sk_buff *skb, +const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {const struct ebt_stp_info *info = data;
@@ -129,15 +130,15 @@ static int ebt_filter_stp(const struct sk_buff *skb, const struct net_device *in sp =skb_header_pointer (skb,0 ,sizeof (_stph), &_stph);if (sp ==NULL ) -return EBT_NOMATCH ; +return false;/* The stp code only considers these */ if (memcmp (sp, header,sizeof (header))) -return EBT_NOMATCH ; +return false;if (info->bitmask &EBT_STP_TYPE &&FWINV (info->type != sp->type,EBT_STP_TYPE )) -return EBT_NOMATCH ; +return false;if (sp->type ==BPDU_TYPE_CONFIG && info->bitmask &EBT_STP_CONFIG_MASK ) {
@@ -147,10 +148,10 @@ static int ebt_filter_stp(const struct sk_buff *skb, const struct net_device *in st =skb_header_pointer (skb,sizeof (_stph),sizeof (_stpc), &_stpc);if (st ==NULL ) -return EBT_NOMATCH ; +return false;return ebt_filter_config (info, st); } -return EBT_MATCH ; +return true; } static bool ebt_stp_check(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_vlan.c +4 -4
@@ -38,9 +38,9 @@ MODULE_LICENSE("GPL"); #define DEBUG_MSG(args...) if (debug) printk (KERN_DEBUG "ebt_vlan: " args)#define GET_BITMASK (_BIT_MASK_) info->bitmask & _BIT_MASK_ -#define EXIT_ON_MISMATCH (_MATCH_,_MASK_) {if (!((info->_MATCH_ == _MATCH_)^!!(info->invflags & _MASK_))) return EBT_NOMATCH;} +#define EXIT_ON_MISMATCH (_MATCH_,_MASK_) {if (!((info->_MATCH_ == _MATCH_)^!!(info->invflags & _MASK_))) return false; } -static int +static bool ebt_filter_vlan(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out,
@@ -58,7 +58,7 @@ ebt_filter_vlan(const struct sk_buff *skb, fp =skb_header_pointer (skb,0 ,sizeof (_frame), &_frame);if (fp ==NULL ) -return EBT_NOMATCH ; +return false;/* Tag Control Information (TCI) consists of the following elements: * - User_priority. The user_priority field is three bits in length,
@@ -84,7 +84,7 @@ ebt_filter_vlan(const struct sk_buff *skb,if (GET_BITMASK (EBT_VLAN_ENCAP ))EXIT_ON_MISMATCH (encap,EBT_VLAN_ENCAP ); -return EBT_MATCH ; +return true; } static bool
netfilter 53/79: Change return types of targets/watchers for Ebtables extensions
In reply to Patrick McHardycommit 0ac6ab1f7915fc820ca0cf8f597290dbb249edcc
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:13 2008 +0200
netfilter: Change return types of targets/watchers for Ebtables extensions
include/linux/netfilter_bridge/ebtables.h +3 -3
@@ -221,7 +221,7 @@ struct ebt_watcher {struct list_head list;const char name[EBT_FUNCTION_MAXNAMELEN ]; -void (*watcher)(const struct sk_buff *skb,unsigned int hooknr, +unsigned int (*watcher)(const struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *watcherdata,unsigned int datalen); bool (*check)(const char *tablename, unsigned int hookmask,
@@ -235,8 +235,8 @@ struct ebt_target {struct list_head list;const char name[EBT_FUNCTION_MAXNAMELEN ]; -/* returns one of the standard verdicts */ -int (*target)(struct sk_buff *skb,unsigned int hooknr, +/* returns one of the standard EBT_* verdicts */ +unsigned int (*target)(struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *targetdata,unsigned int datalen); bool (*check)(const char *tablename, unsigned int hookmask,
net/bridge/netfilter/ebt_arpreply.c +1 -1
@@ -15,7 +15,7 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_arpreply.h> -static int ebt_target_reply (struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_target_reply (struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
net/bridge/netfilter/ebt_dnat.c +1 -1
@@ -14,7 +14,7 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_nat.h> -static int ebt_target_dnat (struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_target_dnat (struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
net/bridge/netfilter/ebt_log.c +2 -1
@@ -192,7 +192,7 @@ out: } -static void ebt_log (const struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_log (const struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
@@ -209,6 +209,7 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr,else ebt_log_packet (NFPROTO_BRIDGE , hooknr, skb, in, out, &li, info->prefix); +return EBT_CONTINUE ; } static struct ebt_watcher log =
net/bridge/netfilter/ebt_mark.c +1 -1
@@ -18,7 +18,7 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_mark_t.h> -static int ebt_target_mark (struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_target_mark (struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
net/bridge/netfilter/ebt_nflog.c +6 -5
@@ -19,11 +19,11 @@#include <linux/netfilter_bridge/ebt_nflog.h> #include <net/netfilter/nf_log.h> -static void ebt_nflog (const struct sk_buff *skb, -unsigned int hooknr, -const struct net_device *in, -const struct net_device *out, -const void *data,unsigned int datalen) +static unsigned int ebt_nflog (const struct sk_buff *skb, +unsigned int hooknr, +const struct net_device *in, +const struct net_device *out, +const void *data,unsigned int datalen) {struct ebt_nflog_info *info = (struct ebt_nflog_info *)data;struct nf_loginfo li;
@@ -34,6 +34,7 @@ static void ebt_nflog(const struct sk_buff *skb, li.u.ulog.qthreshold = info->threshold;nf_log_packet (PF_BRIDGE , hooknr, skb, in, out, &li,"%s" , info->prefix); +return EBT_CONTINUE ; } static bool ebt_nflog_check(const char *tablename,
net/bridge/netfilter/ebt_redirect.c +2 -1
@@ -15,7 +15,8 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_redirect.h> -static int ebt_target_redirect (struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_target_redirect (struct sk_buff *skb, +unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
net/bridge/netfilter/ebt_snat.c +1 -1
@@ -16,7 +16,7 @@#include <linux/netfilter_bridge/ebtables.h> #include <linux/netfilter_bridge/ebt_nat.h> -static int ebt_target_snat (struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_target_snat (struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {
net/bridge/netfilter/ebt_ulog.c +2 -1
@@ -246,13 +246,14 @@ static void ebt_log_packet(u_int8_t pf, unsigned int hooknum,ebt_ulog_packet (hooknum, skb, in, out, &loginfo, prefix); } -static void ebt_ulog (const struct sk_buff *skb,unsigned int hooknr, +static unsigned int ebt_ulog (const struct sk_buff *skb,unsigned int hooknr,const struct net_device *in,const struct net_device *out,const void *data,unsigned int datalen) {const struct ebt_ulog_info *uloginfo = data;ebt_ulog_packet (hooknr, skb, in, out, uloginfo,NULL ); +return EBT_CONTINUE ; } static bool ebt_ulog_check(const char *tablename, unsigned int hookmask,
netfilter 54/79: add dummy members to Ebtables code to ease transition to Xtables
In reply to Patrick McHardycommit 001a18d369f4813ed792629ff4a9a6ade2a4a031
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:14 2008 +0200
netfilter: add dummy members to Ebtables code to ease transition to Xtables
include/linux/netfilter_bridge/ebtables.h +6 -0
@@ -214,6 +214,8 @@ struct ebt_match const struct ebt_entry *e, void *matchdata, unsigned int datalen);void (*destroy)(void *matchdata,unsigned int datalen);unsigned int matchsize; +u_int8_t revision; +u_int8_t family;struct module *me; };
@@ -228,6 +230,8 @@ struct ebt_watcher const struct ebt_entry *e, void *watcherdata, unsigned int datalen);void (*destroy)(void *watcherdata,unsigned int datalen);unsigned int targetsize; +u_int8_t revision; +u_int8_t family;struct module *me; };
@@ -243,6 +247,8 @@ struct ebt_target const struct ebt_entry *e, void *targetdata, unsigned int datalen);void (*destroy)(void *targetdata,unsigned int datalen);unsigned int targetsize; +u_int8_t revision; +u_int8_t family;struct module *me; };
net/bridge/netfilter/ebt_802_3.c +2 -0
@@ -51,6 +51,8 @@ static bool ebt_802_3_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_802_3__read_mostly = { .name =EBT_802_3_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_802_3, .check = ebt_802_3_check, .matchsize =XT_ALIGN (sizeof (struct ebt_802_3_info )),
net/bridge/netfilter/ebt_among.c +2 -0
@@ -211,6 +211,8 @@ ebt_among_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_among__read_mostly = { .name =EBT_AMONG_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_among, .check = ebt_among_check, .matchsize =-1 ,/* special case */
net/bridge/netfilter/ebt_arp.c +2 -0
@@ -117,6 +117,8 @@ static bool ebt_arp_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_arp__read_mostly = { .name =EBT_ARP_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_arp, .check = ebt_arp_check, .matchsize =XT_ALIGN (sizeof (struct ebt_arp_info )),
net/bridge/netfilter/ebt_arpreply.c +2 -0
@@ -76,6 +76,8 @@ static bool ebt_target_reply_check(const char *tablename, unsigned int hookmask,static struct ebt_target reply_target__read_mostly = { .name =EBT_ARPREPLY_TARGET , + .revision =0 , + .family =NFPROTO_BRIDGE , .target = ebt_target_reply, .check = ebt_target_reply_check, .targetsize =XT_ALIGN (sizeof (struct ebt_arpreply_info )),
net/bridge/netfilter/ebt_dnat.c +2 -0
@@ -46,6 +46,8 @@ static bool ebt_target_dnat_check(const char *tablename, unsigned int hookmask,static struct ebt_target dnat__read_mostly = { .name =EBT_DNAT_TARGET , + .revision =0 , + .family =NFPROTO_BRIDGE , .target = ebt_target_dnat, .check = ebt_target_dnat_check, .targetsize =XT_ALIGN (sizeof (struct ebt_nat_info )),
net/bridge/netfilter/ebt_ip.c +2 -0
@@ -108,6 +108,8 @@ static bool ebt_ip_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_ip__read_mostly = { .name =EBT_IP_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_ip, .check = ebt_ip_check, .matchsize =XT_ALIGN (sizeof (struct ebt_ip_info )),
net/bridge/netfilter/ebt_ip6.c +2 -0
@@ -121,6 +121,8 @@ static bool ebt_ip6_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_ip6 = { .name =EBT_IP6_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_ip6, .check = ebt_ip6_check, .matchsize =XT_ALIGN (sizeof (struct ebt_ip6_info )),
net/bridge/netfilter/ebt_limit.c +2 -0
@@ -88,6 +88,8 @@ static bool ebt_limit_check(const char *tablename, unsigned int hookmask,static struct ebt_match ebt_limit_reg__read_mostly = { .name =EBT_LIMIT_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_limit_match, .check = ebt_limit_check, .matchsize =XT_ALIGN (sizeof (struct ebt_limit_info )),
net/bridge/netfilter/ebt_log.c +2 -0
@@ -215,6 +215,8 @@ static unsigned int ebt_log(const struct sk_buff *skb, unsigned int hooknr,static struct ebt_watcher log = { .name =EBT_LOG_WATCHER , + .revision =0 , + .family =NFPROTO_BRIDGE , .watcher = ebt_log, .check = ebt_log_check, .targetsize =XT_ALIGN (sizeof (struct ebt_log_info )),
net/bridge/netfilter/ebt_mark.c +2 -0
@@ -58,6 +58,8 @@ static bool ebt_target_mark_check(const char *tablename, unsigned int hookmask,static struct ebt_target mark_target__read_mostly = { .name =EBT_MARK_TARGET , + .revision =0 , + .family =NFPROTO_BRIDGE , .target = ebt_target_mark, .check = ebt_target_mark_check, .targetsize =XT_ALIGN (sizeof (struct ebt_mark_t_info )),
net/bridge/netfilter/ebt_mark_m.c +2 -0
@@ -39,6 +39,8 @@ static bool ebt_mark_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_mark__read_mostly = { .name =EBT_MARK_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_mark, .check = ebt_mark_check, .matchsize =XT_ALIGN (sizeof (struct ebt_mark_m_info )),
net/bridge/netfilter/ebt_nflog.c +2 -0
@@ -52,6 +52,8 @@ static bool ebt_nflog_check(const char *tablename,static struct ebt_watcher nflog__read_mostly = { .name =EBT_NFLOG_WATCHER , + .revision =0 , + .family =NFPROTO_BRIDGE , .watcher = ebt_nflog, .check = ebt_nflog_check, .targetsize =XT_ALIGN (sizeof (struct ebt_nflog_info )),
net/bridge/netfilter/ebt_pkttype.c +2 -0
@@ -36,6 +36,8 @@ static bool ebt_pkttype_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_pkttype__read_mostly = { .name =EBT_PKTTYPE_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_pkttype, .check = ebt_pkttype_check, .matchsize =XT_ALIGN (sizeof (struct ebt_pkttype_info )),
net/bridge/netfilter/ebt_redirect.c +2 -0
@@ -52,6 +52,8 @@ static bool ebt_target_redirect_check(const char *tablename, unsigned int hookmastatic struct ebt_target redirect_target__read_mostly = { .name =EBT_REDIRECT_TARGET , + .revision =0 , + .family =NFPROTO_BRIDGE , .target = ebt_target_redirect, .check = ebt_target_redirect_check, .targetsize =XT_ALIGN (sizeof (struct ebt_redirect_info )),
net/bridge/netfilter/ebt_snat.c +2 -0
@@ -68,6 +68,8 @@ static bool ebt_target_snat_check(const char *tablename, unsigned int hookmask,static struct ebt_target snat__read_mostly = { .name =EBT_SNAT_TARGET , + .revision =0 , + .family =NFPROTO_BRIDGE , .target = ebt_target_snat, .check = ebt_target_snat_check, .targetsize =XT_ALIGN (sizeof (struct ebt_nat_info )),
net/bridge/netfilter/ebt_stp.c +2 -0
@@ -174,6 +174,8 @@ static bool ebt_stp_check(const char *tablename, unsigned int hookmask,static struct ebt_match filter_stp__read_mostly = { .name =EBT_STP_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_stp, .check = ebt_stp_check, .matchsize =XT_ALIGN (sizeof (struct ebt_stp_info )),
net/bridge/netfilter/ebt_ulog.c +2 -0
@@ -274,6 +274,8 @@ static bool ebt_ulog_check(const char *tablename, unsigned int hookmask,static struct ebt_watcher ulog__read_mostly = { .name =EBT_ULOG_WATCHER , + .revision =0 , + .family =NFPROTO_BRIDGE , .watcher = ebt_ulog, .check = ebt_ulog_check, .targetsize =XT_ALIGN (sizeof (struct ebt_ulog_info )),
net/bridge/netfilter/ebt_vlan.c +2 -0
@@ -164,6 +164,8 @@ ebt_check_vlan(const char *tablename,static struct ebt_match filter_vlan__read_mostly = { .name =EBT_VLAN_MATCH , + .revision =0 , + .family =NFPROTO_BRIDGE , .match = ebt_filter_vlan, .check = ebt_check_vlan, .matchsize =XT_ALIGN (sizeof (struct ebt_vlan_info )),
net/bridge/netfilter/ebtables.c +49 -9
107 lines not on this page · raw message
netfilter 55/79: ebt_among: obtain match size through different means
In reply to Patrick McHardycommit 815377fe344c799228ca6278613ca3100b069ad5
Author: Jan Engelhardt <[email protected]> Date: Wed Oct 8 11:35:14 2008 +0200
netfilter: ebt_among: obtain match size through different means
The function signatures will be changed to match those of Xtables, and the datalen argument will be gone. ebt_among unfortunately relies on it, so we need to obtain it somehow.
net/bridge/netfilter/ebt_among.c +4 -2
@@ -178,6 +178,8 @@ ebt_among_check(const char *tablename, unsigned int hookmask, const struct ebt_entry *e, void *data, unsigned int datalen) { + const struct ebt_entry_match *em = + container_of(data, const struct ebt_entry_match, data);const struct ebt_among_info *info = data;int expected_length =sizeof (struct ebt_among_info );const struct ebt_mac_wormhash *wh_dst, *wh_src;
@@ -188,11 +190,11 @@ ebt_among_check(const char *tablename, unsigned int hookmask, expected_length +=ebt_mac_wormhash_size (wh_dst); expected_length +=ebt_mac_wormhash_size (wh_src); -if (datalen !=EBT_ALIGN (expected_length)) { +if (em->match_size !=EBT_ALIGN (expected_length)) {printk (KERN_WARNING "ebtables: among: wrong size: %d " "against expected %d, rounded to %Zd\n" , - datalen, expected_length, + em->match_size, expected_length,EBT_ALIGN (expected_length));return false; }