]> err.no Git - linux-2.6/commitdiff
[IPV4]: When possible test for IFF_LOOPBACK and not dev == loopback_dev
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 27 Sep 2007 05:10:06 +0000 (22:10 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:52:48 +0000 (16:52 -0700)
Now that multiple loopback devices are becoming possible it makes
the code a little cleaner and more maintainable to test if a deivice
is th a loopback device by testing dev->flags & IFF_LOOPBACK instead
of dev == loopback_dev.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/devinet.c
net/ipv4/ipconfig.c
net/ipv4/ipvs/ip_vs_core.c

index e7f2b022316e4f3ae1e37b631d7bdfa6845dcb6c..55d199e4ae212813dd737a9cf2706b7f9cccbe38 100644 (file)
@@ -1059,7 +1059,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
                        in_dev = inetdev_init(dev);
                        if (!in_dev)
                                return notifier_from_errno(-ENOMEM);
-                       if (dev == loopback_dev) {
+                       if (dev->flags & IFF_LOOPBACK) {
                                IN_DEV_CONF_SET(in_dev, NOXFRM, 1);
                                IN_DEV_CONF_SET(in_dev, NOPOLICY, 1);
                        }
@@ -1075,7 +1075,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
        case NETDEV_UP:
                if (dev->mtu < 68)
                        break;
-               if (dev == loopback_dev) {
+               if (dev->flags & IFF_LOOPBACK) {
                        struct in_ifaddr *ifa;
                        if ((ifa = inet_alloc_ifa()) != NULL) {
                                ifa->ifa_local =
index 2d2e0cda04700c906044c550304eb4e81a975980..af5d5b39fc139d9f4c4fc673a755a4bda521e32c 100644 (file)
@@ -190,11 +190,15 @@ static int __init ic_open_devs(void)
        rtnl_lock();
 
        /* bring loopback device up first */
-       if (dev_change_flags(loopback_dev, loopback_dev->flags | IFF_UP) < 0)
-               printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev->name);
+       for_each_netdev(&init_net, dev) {
+               if (!(dev->flags & IFF_LOOPBACK))
+                       continue;
+               if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
+                       printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name);
+       }
 
        for_each_netdev(&init_net, dev) {
-               if (dev == loopback_dev)
+               if (dev->flags & IFF_LOOPBACK)
                        continue;
                if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
                    (!(dev->flags & IFF_LOOPBACK) &&
index 74503267e5d48e026f595fbcf0981c7277299157..fbca2a2ff29fa5c5435f9023b8da89b36641833d 100644 (file)
@@ -961,7 +961,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff **pskb,
         *      ... don't know why 1st test DOES NOT include 2nd (?)
         */
        if (unlikely(skb->pkt_type != PACKET_HOST
-                    || skb->dev == loopback_dev || skb->sk)) {
+                    || skb->dev->flags & IFF_LOOPBACK || skb->sk)) {
                IP_VS_DBG(12, "packet type=%d proto=%d daddr=%d.%d.%d.%d ignored\n",
                          skb->pkt_type,
                          ip_hdr(skb)->protocol,