From: Patrick McHardy <kaber@trash.net>
To: Yasuyuki KOZAKAI <yasuyuki.kozakai@toshiba.co.jp>
Cc: rusty@rustcorp.com.au, netfilter-devel@lists.netfilter.org,
pablo@netfilter.org, kadlec@blackhole.kfki.hu
Subject: Re: [PATCH 05/10] nf_nat: Use extension infrastructure
Date: Mon, 25 Jun 2007 12:08:35 +0200 [thread overview]
Message-ID: <467F9423.3050503@trash.net> (raw)
In-Reply-To: <200706250315.l5P3F5vI009154@toshiba.co.jp>
Yasuyuki KOZAKAI wrote:
> diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
> index ac7e8ab..1ce4969 100644
> --- a/net/ipv4/netfilter/nf_nat_core.c
> +++ b/net/ipv4/netfilter/nf_nat_core.c
> @@ -297,11 +297,22 @@ nf_nat_setup_info(struct nf_conn *ct,
> unsigned int hooknum)
> {
> struct nf_conntrack_tuple curr_tuple, new_tuple;
> - struct nf_conn_nat *nat = nfct_nat(ct);
> - struct nf_nat_info *info = &nat->info;
> + struct nf_conn_nat *nat;
> + struct nf_nat_info *info;
> int have_to_hash = !(ct->status & IPS_NAT_DONE_MASK);
> enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
>
> + /* nat helper or nfctnetlink also setup binding */
> + nat = nfct_nat(ct);
> + if (!nat) {
> + nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC);
> + if (unlikely(nat == NULL)) {
gcc assumes unlikely for ptr == NULL by default.
> + DEBUGP("failed to add NAT extension\n");
> + return NF_ACCEPT;
> + }
> + }
> + info = &nat->info;
> +
> NF_CT_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
> hooknum == NF_IP_POST_ROUTING ||
> hooknum == NF_IP_LOCAL_IN ||
> @@ -592,17 +603,53 @@ nf_nat_port_nfattr_to_range(struct nfattr *tb[], struct nf_nat_range *range)
> EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nfattr);
> #endif
>
> +static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
> +{
> + struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT);
> + struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old;
> + struct nf_conn *ct = old_nat->info.ct;
> + unsigned int srchash;
> +
> + if (!ct || !(ct->status & IPS_NAT_DONE_MASK))
> + return;
Is !ct really possible? Looks like something that should be catched
on a higher level if it really is.
> +
> + srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
> +
> + write_lock_bh(&nf_nat_lock);
> + list_del(&old_nat->info.bysource);
> + new_nat->info.ct = ct;
> + list_add(&new_nat->info.bysource, &bysource[srchash]);
list_replace maybe?
next prev parent reply other threads:[~2007-06-25 10:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-25 3:15 [PATCH 05/10] nf_nat: Use extension infrastructure Yasuyuki KOZAKAI
2007-06-25 10:08 ` Patrick McHardy [this message]
2007-06-25 15:48 ` Yasuyuki KOZAKAI
-- strict thread matches above, loose matches on Subject: below --
2007-06-25 17:21 Yasuyuki KOZAKAI
[not found] <200706251721.l5PHLwlX004434@toshiba.co.jp>
2007-06-25 18:20 ` Patrick McHardy
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=467F9423.3050503@trash.net \
--to=kaber@trash.net \
--cc=kadlec@blackhole.kfki.hu \
--cc=netfilter-devel@lists.netfilter.org \
--cc=pablo@netfilter.org \
--cc=rusty@rustcorp.com.au \
--cc=yasuyuki.kozakai@toshiba.co.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.