const struct net_device *out,
                            struct nf_conn *ct);
 
-extern unsigned int
-alloc_null_binding(struct nf_conn *ct, unsigned int hooknum);
 #endif /* _NF_NAT_RULE_H */
 
 
        NF_CT_ASSERT(par->hooknum == NF_INET_PRE_ROUTING ||
                     par->hooknum == NF_INET_POST_ROUTING ||
-                    par->hooknum == NF_INET_LOCAL_OUT);
+                    par->hooknum == NF_INET_LOCAL_OUT ||
+                    par->hooknum == NF_INET_LOCAL_IN);
        ct = nf_ct_get(skb, &ctinfo);
 
        netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip);
        .table          = "nat",
        .hooks          = (1 << NF_INET_PRE_ROUTING) |
                          (1 << NF_INET_POST_ROUTING) |
-                         (1 << NF_INET_LOCAL_OUT),
+                         (1 << NF_INET_LOCAL_OUT) |
+                         (1 << NF_INET_LOCAL_IN),
        .checkentry     = netmap_tg_check,
        .me             = THIS_MODULE
 };
 
 
 #define NAT_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | \
                         (1 << NF_INET_POST_ROUTING) | \
-                        (1 << NF_INET_LOCAL_OUT))
+                        (1 << NF_INET_LOCAL_OUT) | \
+                        (1 << NF_INET_LOCAL_IN))
 
 static const struct xt_table nat_table = {
        .name           = "nat",
        enum ip_conntrack_info ctinfo;
        const struct nf_nat_multi_range_compat *mr = par->targinfo;
 
-       NF_CT_ASSERT(par->hooknum == NF_INET_POST_ROUTING);
+       NF_CT_ASSERT(par->hooknum == NF_INET_POST_ROUTING ||
+                    par->hooknum == NF_INET_LOCAL_IN);
 
        ct = nf_ct_get(skb, &ctinfo);
 
        return 0;
 }
 
-unsigned int
+static unsigned int
 alloc_null_binding(struct nf_conn *ct, unsigned int hooknum)
 {
        /* Force range to this IP; let proto decide mapping for
        .target         = ipt_snat_target,
        .targetsize     = sizeof(struct nf_nat_multi_range_compat),
        .table          = "nat",
-       .hooks          = 1 << NF_INET_POST_ROUTING,
+       .hooks          = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_LOCAL_IN),
        .checkentry     = ipt_snat_checkentry,
        .family         = AF_INET,
 };
 
                if (!nf_nat_initialized(ct, maniptype)) {
                        unsigned int ret;
 
-                       if (hooknum == NF_INET_LOCAL_IN)
-                               /* LOCAL_IN hook doesn't have a chain!  */
-                               ret = alloc_null_binding(ct, hooknum);
-                       else
-                               ret = nf_nat_rule_find(skb, hooknum, in, out,
-                                                      ct);
-
+                       ret = nf_nat_rule_find(skb, hooknum, in, out, ct);
                        if (ret != NF_ACCEPT)
                                return ret;
                } else