提交 74c51a14 编写于 作者: A Alexey Dobriyan 提交者: Patrick McHardy

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.
Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: NPatrick McHardy <kaber@trash.net>
上级 a702a65f
...@@ -50,7 +50,7 @@ struct nf_conntrack_l4proto ...@@ -50,7 +50,7 @@ struct nf_conntrack_l4proto
/* Called when a conntrack entry is destroyed */ /* Called when a conntrack entry is destroyed */
void (*destroy)(struct nf_conn *ct); 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, enum ip_conntrack_info *ctinfo,
u_int8_t pf, unsigned int hooknum); u_int8_t pf, unsigned int hooknum);
......
...@@ -123,7 +123,7 @@ static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb, ...@@ -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 */ /* Returns conntrack if it dealt with ICMP, and filled in skb fields */
static int static int
icmp_error_message(struct sk_buff *skb, icmp_error_message(struct net *net, struct sk_buff *skb,
enum ip_conntrack_info *ctinfo, enum ip_conntrack_info *ctinfo,
unsigned int hooknum) unsigned int hooknum)
{ {
...@@ -155,7 +155,7 @@ icmp_error_message(struct sk_buff *skb, ...@@ -155,7 +155,7 @@ icmp_error_message(struct sk_buff *skb,
*ctinfo = IP_CT_RELATED; *ctinfo = IP_CT_RELATED;
h = nf_conntrack_find_get(&init_net, &innertuple); h = nf_conntrack_find_get(net, &innertuple);
if (!h) { if (!h) {
pr_debug("icmp_error_message: no match\n"); pr_debug("icmp_error_message: no match\n");
return -NF_ACCEPT; return -NF_ACCEPT;
...@@ -172,7 +172,7 @@ icmp_error_message(struct sk_buff *skb, ...@@ -172,7 +172,7 @@ icmp_error_message(struct sk_buff *skb,
/* Small and modified version of icmp_rcv */ /* Small and modified version of icmp_rcv */
static int 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) enum ip_conntrack_info *ctinfo, u_int8_t pf, unsigned int hooknum)
{ {
const struct icmphdr *icmph; const struct icmphdr *icmph;
...@@ -217,7 +217,7 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff, ...@@ -217,7 +217,7 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff,
&& icmph->type != ICMP_REDIRECT) && icmph->type != ICMP_REDIRECT)
return NF_ACCEPT; 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) #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
......
...@@ -122,7 +122,8 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb, ...@@ -122,7 +122,8 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb,
} }
static int static int
icmpv6_error_message(struct sk_buff *skb, icmpv6_error_message(struct net *net,
struct sk_buff *skb,
unsigned int icmp6off, unsigned int icmp6off,
enum ip_conntrack_info *ctinfo, enum ip_conntrack_info *ctinfo,
unsigned int hooknum) unsigned int hooknum)
...@@ -156,7 +157,7 @@ icmpv6_error_message(struct sk_buff *skb, ...@@ -156,7 +157,7 @@ icmpv6_error_message(struct sk_buff *skb,
*ctinfo = IP_CT_RELATED; *ctinfo = IP_CT_RELATED;
h = nf_conntrack_find_get(&init_net, &intuple); h = nf_conntrack_find_get(net, &intuple);
if (!h) { if (!h) {
pr_debug("icmpv6_error: no match\n"); pr_debug("icmpv6_error: no match\n");
return -NF_ACCEPT; return -NF_ACCEPT;
...@@ -172,7 +173,7 @@ icmpv6_error_message(struct sk_buff *skb, ...@@ -172,7 +173,7 @@ icmpv6_error_message(struct sk_buff *skb,
} }
static int 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) enum ip_conntrack_info *ctinfo, u_int8_t pf, unsigned int hooknum)
{ {
const struct icmp6hdr *icmp6h; const struct icmp6hdr *icmp6h;
...@@ -197,7 +198,7 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff, ...@@ -197,7 +198,7 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff,
if (icmp6h->icmp6_type >= 128) if (icmp6h->icmp6_type >= 128)
return NF_ACCEPT; 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) #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
......
...@@ -703,12 +703,14 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, ...@@ -703,12 +703,14 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
/* It may be an special packet, error, unclean... /* It may be an special packet, error, unclean...
* inverse of the return code tells to the netfilter * inverse of the return code tells to the netfilter
* core what to do with the packet. */ * core what to do with the packet. */
if (l4proto->error != NULL && if (l4proto->error != NULL) {
(ret = l4proto->error(skb, dataoff, &ctinfo, pf, hooknum)) <= 0) { ret = l4proto->error(net, skb, dataoff, &ctinfo, pf, hooknum);
if (ret <= 0) {
NF_CT_STAT_INC_ATOMIC(error); NF_CT_STAT_INC_ATOMIC(error);
NF_CT_STAT_INC_ATOMIC(invalid); NF_CT_STAT_INC_ATOMIC(invalid);
return -ret; return -ret;
} }
}
ct = resolve_normal_ct(net, skb, dataoff, pf, protonum, ct = resolve_normal_ct(net, skb, dataoff, pf, protonum,
l3proto, l4proto, &set_reply, &ctinfo); l3proto, l4proto, &set_reply, &ctinfo);
......
...@@ -545,9 +545,9 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb, ...@@ -545,9 +545,9 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
return NF_ACCEPT; return NF_ACCEPT;
} }
static int dccp_error(struct sk_buff *skb, unsigned int dataoff, static int dccp_error(struct net *net, struct sk_buff *skb,
enum ip_conntrack_info *ctinfo, u_int8_t pf, unsigned int dataoff, enum ip_conntrack_info *ctinfo,
unsigned int hooknum) u_int8_t pf, unsigned int hooknum)
{ {
struct dccp_hdr _dh, *dh; struct dccp_hdr _dh, *dh;
unsigned int dccp_len = skb->len - dataoff; unsigned int dccp_len = skb->len - dataoff;
......
...@@ -746,7 +746,8 @@ static const u8 tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG) + 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. */ /* 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, unsigned int dataoff,
enum ip_conntrack_info *ctinfo, enum ip_conntrack_info *ctinfo,
u_int8_t pf, u_int8_t pf,
......
...@@ -89,7 +89,7 @@ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb, ...@@ -89,7 +89,7 @@ static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,
return true; 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, enum ip_conntrack_info *ctinfo,
u_int8_t pf, u_int8_t pf,
unsigned int hooknum) unsigned int hooknum)
......
...@@ -89,7 +89,9 @@ static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb, ...@@ -89,7 +89,9 @@ static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb,
return true; 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, enum ip_conntrack_info *ctinfo,
u_int8_t pf, u_int8_t pf,
unsigned int hooknum) unsigned int hooknum)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册