[NETFILTER]: nf_nat: fix MASQUERADE crash on device down
authorMartin Josefsson <gandalf@wlug.westbo.se>
Thu, 4 Jan 2007 20:16:54 +0000 (12:16 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jan 2007 20:16:54 +0000 (12:16 -0800)
Check the return value of nfct_nat() in device_cmp(), we might very well
have non NAT conntrack entries as well (Netfilter bugzilla #528).

Signed-off-by: Martin Josefsson <gandalf@wlug.westbo.se>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/netfilter/ipt_MASQUERADE.c

index 28b9233956b57c1f6ab30931e3752f8be05f47d1..d669685afd04dac843529c8171bd4994af8b8813 100644 (file)
@@ -127,10 +127,13 @@ masquerade_target(struct sk_buff **pskb,
 static inline int
 device_cmp(struct ip_conntrack *i, void *ifindex)
 {
+       int ret;
 #ifdef CONFIG_NF_NAT_NEEDED
        struct nf_conn_nat *nat = nfct_nat(i);
+
+       if (!nat)
+               return 0;
 #endif
-       int ret;
 
        read_lock_bh(&masq_lock);
 #ifdef CONFIG_NF_NAT_NEEDED