Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 314571
b: refs/heads/master
c: d584a61
h: refs/heads/master
i:
  314569: 4455772
  314567: 6b30ce4
v: v3
  • Loading branch information
Pablo Neira Ayuso committed Jun 22, 2012
1 parent 0090da4 commit b6036d2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5a05fae5ca7cd5279567747fc34d60413b504cd6
refs/heads/master: d584a61a931e6cbfef0dd811c4ae0250ec5987f4
6 changes: 5 additions & 1 deletion trunk/include/linux/netfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,14 @@ struct nfq_ct_hook {
size_t (*build_size)(const struct nf_conn *ct);
int (*build)(struct sk_buff *skb, struct nf_conn *ct);
int (*parse)(const struct nlattr *attr, struct nf_conn *ct);
};
extern struct nfq_ct_hook __rcu *nfq_ct_hook;

struct nfq_ct_nat_hook {
void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
u32 ctinfo, int off);
};
extern struct nfq_ct_hook __rcu *nfq_ct_hook;
extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook;
#else
static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
#endif
Expand Down
6 changes: 6 additions & 0 deletions trunk/net/ipv4/netfilter/nf_nat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ static struct nf_ct_helper_expectfn follow_master_nat = {
.expectfn = nf_nat_follow_master,
};

static struct nfq_ct_nat_hook nfq_ct_nat = {
.seq_adjust = nf_nat_tcp_seq_adjust,
};

static int __init nf_nat_init(void)
{
size_t i;
Expand Down Expand Up @@ -731,6 +735,7 @@ static int __init nf_nat_init(void)
nfnetlink_parse_nat_setup);
BUG_ON(nf_ct_nat_offset != NULL);
RCU_INIT_POINTER(nf_ct_nat_offset, nf_nat_get_offset);
RCU_INIT_POINTER(nfq_ct_nat_hook, &nfq_ct_nat);
return 0;

cleanup_extend:
Expand All @@ -747,6 +752,7 @@ static void __exit nf_nat_cleanup(void)
RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL);
RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL);
RCU_INIT_POINTER(nf_ct_nat_offset, NULL);
RCU_INIT_POINTER(nfq_ct_nat_hook, NULL);
synchronize_net();
}

Expand Down
3 changes: 3 additions & 0 deletions trunk/net/netfilter/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ EXPORT_SYMBOL(nf_conntrack_destroy);
struct nfq_ct_hook __rcu *nfq_ct_hook __read_mostly;
EXPORT_SYMBOL_GPL(nfq_ct_hook);

struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook __read_mostly;
EXPORT_SYMBOL_GPL(nfq_ct_nat_hook);

#endif /* CONFIG_NF_CONNTRACK */

#ifdef CONFIG_PROC_FS
Expand Down
3 changes: 0 additions & 3 deletions trunk/net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,9 +1757,6 @@ static struct nfq_ct_hook ctnetlink_nfqueue_hook = {
.build_size = ctnetlink_nfqueue_build_size,
.build = ctnetlink_nfqueue_build,
.parse = ctnetlink_nfqueue_parse,
#ifdef CONFIG_NF_NAT_NEEDED
.seq_adjust = nf_nat_tcp_seq_adjust,
#endif
};
#endif /* CONFIG_NETFILTER_NETLINK_QUEUE_CT */

Expand Down
8 changes: 4 additions & 4 deletions trunk/net/netfilter/nfnetlink_queue_ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ int nfqnl_ct_put(struct sk_buff *skb, struct nf_conn *ct,
void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
enum ip_conntrack_info ctinfo, int diff)
{
struct nfq_ct_hook *nfq_ct;
struct nfq_ct_nat_hook *nfq_nat_ct;

nfq_ct = rcu_dereference(nfq_ct_hook);
if (nfq_ct == NULL)
nfq_nat_ct = rcu_dereference(nfq_ct_nat_hook);
if (nfq_nat_ct == NULL)
return;

if ((ct->status & IPS_NAT_MASK) && diff)
nfq_ct->seq_adjust(skb, ct, ctinfo, diff);
nfq_nat_ct->seq_adjust(skb, ct, ctinfo, diff);
}

0 comments on commit b6036d2

Please sign in to comment.