[PATCH 05/10] nf_nat: Use extension infrastructure
Yasuyuki KOZAKAI
yasuyuki.kozakai at toshiba.co.jp
Mon Jun 25 17:48:38 CEST 2007
From: Patrick McHardy <kaber at trash.net>
Date: Mon, 25 Jun 2007 12:08:35 +0200
> Yasuyuki KOZAKAI wrote:
> > + /* 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.
I didn't know that, thanks.
> > +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.
No, I've removed it.
> > +
> > + 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?
It's useful, thanks.
-- Yasuyuki Kozakai
More information about the netfilter-devel
mailing list