From: Alexey Dobriyan <adobriyan@gmail.com>
To: kaber@trash.net
Cc: netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
containers@lists.linux-foundation.org
Subject: [PATCH 08/33] netns ct: pass netns pointer to L4 protocol's ->error hook
Date: Mon, 8 Sep 2008 07:02:45 +0400 [thread overview]
Message-ID: <1220842990-30500-8-git-send-email-adobriyan@gmail.com> (raw)
In-Reply-To: <48C01046.2070704@trash.net>
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.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index d4376e9..97723d3 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -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);
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index daf3463..8c7ed5b 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -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)
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 548cf4f..aabddfe 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -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)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 5c96d97..251f020 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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,
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index edc3035..6ead8da 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -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;
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 539a820..4e71de2 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -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,
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 2a965c4..8a245be 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -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)
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
index 4fb6c8d..9817019 100644
--- a/net/netfilter/nf_conntrack_proto_udplite.c
+++ b/net/netfilter/nf_conntrack_proto_udplite.c
@@ -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)
next prev parent reply other threads:[~2008-09-08 3:02 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-21 22:00 [PATCH 10/38] netns ct: per-netns expectations adobriyan
2008-09-04 16:43 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 01/33] nf_conntrack_sip: de-static helper pointers Alexey Dobriyan
2008-09-08 3:02 ` [PATCH 02/33] nf_conntrack_gre: more locking around keymap list Alexey Dobriyan
2008-09-08 3:02 ` [PATCH 03/33] nf_conntrack_gre: nf_ct_gre_keymap_flush() fixlet Alexey Dobriyan
2008-09-09 5:39 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 04/33] Fix {ip,6}_route_me_harder() in netns Alexey Dobriyan
2008-09-09 5:44 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 05/33] netns ct: per-netns expectations Alexey Dobriyan
2008-09-09 5:49 ` Patrick McHardy
2008-09-09 7:07 ` Alexey Dobriyan
2008-09-09 7:10 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 06/33] netns ct: per-netns unconfirmed list Alexey Dobriyan
2008-09-09 5:50 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 07/33] netns ct: pass netns pointer to nf_conntrack_in() Alexey Dobriyan
2008-09-09 5:52 ` Patrick McHardy
2008-09-08 3:02 ` Alexey Dobriyan [this message]
2008-09-09 5:54 ` [PATCH 08/33] netns ct: pass netns pointer to L4 protocol's ->error hook Patrick McHardy
2008-09-08 3:02 ` [PATCH 09/33] netns ct: per-netns /proc/net/nf_conntrack, /proc/net/stat/nf_conntrack Alexey Dobriyan
2008-09-09 5:56 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 10/33] netns ct: per-netns /proc/net/nf_conntrack_expect Alexey Dobriyan
2008-09-09 5:57 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 11/33] netns ct: per-netns /proc/net/ip_conntrack, /proc/net/stat/ip_conntrack, /proc/net/ip_conntrack_expect Alexey Dobriyan
2008-09-09 5:59 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 12/33] netns ct: export netns list Alexey Dobriyan
2008-09-09 5:59 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 13/33] netns ct: unregister helper in every netns Alexey Dobriyan
2008-09-09 6:01 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 14/33] netns ct: cleanup after L3 and L4 proto unregister " Alexey Dobriyan
2008-09-09 6:03 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 15/33] netns ct: pass conntrack to nf_conntrack_event_cache() not skb Alexey Dobriyan
2008-09-09 6:04 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 16/33] netns ct: per-netns event cache Alexey Dobriyan
[not found] ` <1220842990-30500-16-git-send-email-adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-09-09 6:12 ` Patrick McHardy
2008-09-09 7:07 ` Alexey Dobriyan
2008-09-09 7:07 ` Patrick McHardy
2008-09-09 7:16 ` Patrick McHardy
2008-09-08 3:02 ` [PATCH 17/33] netns ct: final init_net tweaks Alexey Dobriyan
2008-09-09 7:20 ` Patrick McHardy
2008-09-09 7:32 ` Alexey Dobriyan
2008-09-09 7:51 ` Patrick McHardy
2008-09-13 10:45 ` Alexey Dobriyan
2008-09-27 0:00 ` Alexey Dobriyan
2008-09-28 10:31 ` Patrick McHardy
2008-09-13 10:48 ` [PATCH v2 1/6] netns ct: per-netns statistics Alexey Dobriyan
2008-10-02 7:58 ` Patrick McHardy
2008-09-13 10:49 ` [PATCH v2 2/6] netns ct: per-netns /proc/net/stat/nf_conntrack , /proc/net/stat/ip_conntrack Alexey Dobriyan
2008-10-02 7:59 ` Patrick McHardy
2008-09-13 10:51 ` [PATCH v2 3/6] netns ct: per-netns net.netfilter.nf_conntrack_count sysctl Alexey Dobriyan
2008-10-02 8:00 ` Patrick McHardy
2008-09-13 10:52 ` [PATCH v2 4/6] netns ct: per-netns net.netfilter.nf_conntrack_checksum sysctl Alexey Dobriyan
2008-10-02 8:02 ` Patrick McHardy
2008-09-13 10:53 ` [PATCH v2 5/6] netns ct: per-netns net.netfilter.nf_conntrack_log_invalid sysctl Alexey Dobriyan
2008-10-02 8:04 ` Patrick McHardy
2008-09-13 10:55 ` [PATCH v2 6/6] netns ct: per-netns conntrack accounting Alexey Dobriyan
2008-09-26 23:59 ` [PATCH v2 7/6] netns ct: final netns tweaks Alexey Dobriyan
2008-10-02 8:11 ` Patrick McHardy
2008-10-02 8:06 ` [PATCH v2 6/6] netns ct: per-netns conntrack accounting Patrick McHardy
2008-09-08 3:02 ` [PATCH 17/33] netns ct: final init_net tweaks Alexey Dobriyan
2008-09-08 3:02 ` [PATCH 19/33] netns ct: per-netns /proc/net/stat/nf_conntrack, /proc/net/stat/ip_conntrack Alexey Dobriyan
2008-09-08 3:02 ` [PATCH 20/33] netns ct: per-netns net.netfilter.nf_conntrack_count sysctl Alexey Dobriyan
2008-09-08 3:02 ` [PATCH 21/33] netns ct: per-netns net.netfilter.nf_conntrack_checksum sysctl Alexey Dobriyan
2008-09-08 3:02 ` [PATCH 22/33] netns ct: per-netns net.netfilter.nf_conntrack_log_invalid sysctl Alexey Dobriyan
2008-09-08 3:03 ` Alexey Dobriyan
2008-09-08 3:03 ` [PATCH 24/33] netns ct: SIP conntracking in netns Alexey Dobriyan
2008-10-02 8:52 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 25/33] netns ct: H323 " Alexey Dobriyan
2008-10-02 8:52 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 26/33] netns ct: GRE " Alexey Dobriyan
2008-10-02 8:53 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 27/33] netns ct: PPTP " Alexey Dobriyan
2008-10-02 8:54 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 28/33] netns nat: fix ipt_MASQUERADE " Alexey Dobriyan
2008-10-02 9:06 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 29/33] netns nat: per-netns NAT table Alexey Dobriyan
2008-10-02 9:08 ` Patrick McHardy
2008-10-02 9:09 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 30/33] netns nat: per-netns bysource hash Alexey Dobriyan
2008-10-02 9:09 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 31/33] netns ct: fixup DNAT in netns Alexey Dobriyan
2008-10-02 9:10 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 32/33] netns nat: PPTP NAT " Alexey Dobriyan
2008-10-02 9:11 ` Patrick McHardy
2008-09-08 3:03 ` [PATCH 33/33] Enable netfilter " Alexey Dobriyan
2008-10-02 9:12 ` Patrick McHardy
2008-10-02 9:51 ` Alexey Dobriyan
2008-10-02 10:00 ` Patrick McHardy
2008-10-02 9:53 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220842990-30500-8-git-send-email-adobriyan@gmail.com \
--to=adobriyan@gmail.com \
--cc=containers@lists.linux-foundation.org \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).