]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/netfilter/ipt_MASQUERADE.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[linux-2.6-omap-h63xx.git] / net / ipv4 / netfilter / ipt_MASQUERADE.c
index d4f2d777533080e01dfa6f43de64588e349f1b32..3e0b562b2db704571b044b928e6bea712b9167b7 100644 (file)
@@ -27,17 +27,11 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
 MODULE_DESCRIPTION("iptables MASQUERADE target module");
 
-#if 0
-#define DEBUGP printk
-#else
-#define DEBUGP(format, args...)
-#endif
-
 /* Lock protects masq region inside conntrack */
 static DEFINE_RWLOCK(masq_lock);
 
 /* FIXME: Multiple targets. --RR */
-static int
+static bool
 masquerade_check(const char *tablename,
                 const void *e,
                 const struct xt_target *target,
@@ -47,14 +41,14 @@ masquerade_check(const char *tablename,
        const struct nf_nat_multi_range_compat *mr = targinfo;
 
        if (mr->range[0].flags & IP_NAT_RANGE_MAP_IPS) {
-               DEBUGP("masquerade_check: bad MAP_IPS.\n");
-               return 0;
+               pr_debug("masquerade_check: bad MAP_IPS.\n");
+               return false;
        }
        if (mr->rangesize != 1) {
-               DEBUGP("masquerade_check: bad rangesize %u.\n", mr->rangesize);
-               return 0;
+               pr_debug("masquerade_check: bad rangesize %u\n", mr->rangesize);
+               return false;
        }
-       return 1;
+       return true;
 }
 
 static unsigned int
@@ -70,7 +64,7 @@ masquerade_target(struct sk_buff **pskb,
        enum ip_conntrack_info ctinfo;
        struct nf_nat_range newrange;
        const struct nf_nat_multi_range_compat *mr;
-       struct rtable *rt;
+       const struct rtable *rt;
        __be32 newsrc;
 
        NF_CT_ASSERT(hooknum == NF_IP_POST_ROUTING);
@@ -109,10 +103,10 @@ masquerade_target(struct sk_buff **pskb,
        return nf_nat_setup_info(ct, &newrange, hooknum);
 }
 
-static inline int
+static int
 device_cmp(struct nf_conn *i, void *ifindex)
 {
-       struct nf_conn_nat *nat = nfct_nat(i);
+       const struct nf_conn_nat *nat = nfct_nat(i);
        int ret;
 
        if (!nat)
@@ -129,7 +123,10 @@ static int masq_device_event(struct notifier_block *this,
                             unsigned long event,
                             void *ptr)
 {
-       struct net_device *dev = ptr;
+       const struct net_device *dev = ptr;
+
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
 
        if (event == NETDEV_DOWN) {
                /* Device was downed.  Search entire table for
@@ -147,7 +144,7 @@ static int masq_inet_event(struct notifier_block *this,
                           unsigned long event,
                           void *ptr)
 {
-       struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;
+       const struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;
 
        if (event == NETDEV_DOWN) {
                /* IP address was deleted.  Search entire table for
@@ -169,7 +166,7 @@ static struct notifier_block masq_inet_notifier = {
        .notifier_call  = masq_inet_event,
 };
 
-static struct xt_target masquerade = {
+static struct xt_target masquerade __read_mostly = {
        .name           = "MASQUERADE",
        .family         = AF_INET,
        .target         = masquerade_target,