diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-09-27 01:10:06 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:48 -0400 |
commit | 0cc217e16cb8ca8ef2544363571fce94259900e0 (patch) | |
tree | 05d7ef10fd9971fffa3f3870a4c3e66077bb1dc2 /net/ipv4 | |
parent | 5967789dbc8aafdba5813fa8e8cfce3c90516f83 (diff) |
[IPV4]: When possible test for IFF_LOOPBACK and not dev == loopback_dev
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>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/devinet.c | 4 | ||||
-rw-r--r-- | net/ipv4/ipconfig.c | 10 | ||||
-rw-r--r-- | net/ipv4/ipvs/ip_vs_core.c | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index e7f2b022316e..55d199e4ae21 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -1059,7 +1059,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1059 | in_dev = inetdev_init(dev); | 1059 | in_dev = inetdev_init(dev); |
1060 | if (!in_dev) | 1060 | if (!in_dev) |
1061 | return notifier_from_errno(-ENOMEM); | 1061 | return notifier_from_errno(-ENOMEM); |
1062 | if (dev == loopback_dev) { | 1062 | if (dev->flags & IFF_LOOPBACK) { |
1063 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); | 1063 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); |
1064 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); | 1064 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); |
1065 | } | 1065 | } |
@@ -1075,7 +1075,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1075 | case NETDEV_UP: | 1075 | case NETDEV_UP: |
1076 | if (dev->mtu < 68) | 1076 | if (dev->mtu < 68) |
1077 | break; | 1077 | break; |
1078 | if (dev == loopback_dev) { | 1078 | if (dev->flags & IFF_LOOPBACK) { |
1079 | struct in_ifaddr *ifa; | 1079 | struct in_ifaddr *ifa; |
1080 | if ((ifa = inet_alloc_ifa()) != NULL) { | 1080 | if ((ifa = inet_alloc_ifa()) != NULL) { |
1081 | ifa->ifa_local = | 1081 | ifa->ifa_local = |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 2d2e0cda0470..af5d5b39fc13 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -190,11 +190,15 @@ static int __init ic_open_devs(void) | |||
190 | rtnl_lock(); | 190 | rtnl_lock(); |
191 | 191 | ||
192 | /* bring loopback device up first */ | 192 | /* bring loopback device up first */ |
193 | if (dev_change_flags(loopback_dev, loopback_dev->flags | IFF_UP) < 0) | 193 | for_each_netdev(&init_net, dev) { |
194 | printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev->name); | 194 | if (!(dev->flags & IFF_LOOPBACK)) |
195 | continue; | ||
196 | if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) | ||
197 | printk(KERN_ERR "IP-Config: Failed to open %s\n", dev->name); | ||
198 | } | ||
195 | 199 | ||
196 | for_each_netdev(&init_net, dev) { | 200 | for_each_netdev(&init_net, dev) { |
197 | if (dev == loopback_dev) | 201 | if (dev->flags & IFF_LOOPBACK) |
198 | continue; | 202 | continue; |
199 | if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : | 203 | if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : |
200 | (!(dev->flags & IFF_LOOPBACK) && | 204 | (!(dev->flags & IFF_LOOPBACK) && |
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index 74503267e5d4..fbca2a2ff29f 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c | |||
@@ -961,7 +961,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff **pskb, | |||
961 | * ... don't know why 1st test DOES NOT include 2nd (?) | 961 | * ... don't know why 1st test DOES NOT include 2nd (?) |
962 | */ | 962 | */ |
963 | if (unlikely(skb->pkt_type != PACKET_HOST | 963 | if (unlikely(skb->pkt_type != PACKET_HOST |
964 | || skb->dev == loopback_dev || skb->sk)) { | 964 | || skb->dev->flags & IFF_LOOPBACK || skb->sk)) { |
965 | IP_VS_DBG(12, "packet type=%d proto=%d daddr=%d.%d.%d.%d ignored\n", | 965 | IP_VS_DBG(12, "packet type=%d proto=%d daddr=%d.%d.%d.%d ignored\n", |
966 | skb->pkt_type, | 966 | skb->pkt_type, |
967 | ip_hdr(skb)->protocol, | 967 | ip_hdr(skb)->protocol, |