Changes:   Initialize loopback's inetdev for VE during register loopback as well.
------------------

Don't clean in_device for VE's loopback during delete ifaddr

2.6.9 VZ kernel doesn't automatically setups IP address 127.0.0.1 during
            "ip link set lo up"
for VEs.
RHEL-5's and latest kernels auto add 127.0.0.01 to "lo" on device UP

However older kernels (older than 2.6.12)  have third type of
behaviour: add 127.0.0.1 to "lo" during up only if "lo" has other IP
addresses.

Luckily for us, almost of all initscripts have the next code:

    if ! LC_ALL=C ip addr ls ${REALDEVICE} | grep -q "${IPADDR}/${PREFIX}" ; then
         if ! ip addr add ${IPADDR}/${PREFIX} \
            brd ${BROADCAST:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then
            echo $"Error adding address ${IPADDR} for ${DEVICE}."
         fi
    fi

Bug https://bugzilla.sw.ru/show_bug.cgi?id=465470

Signed-off-by: Vitaliy Gusev <vgusev@openvz.org>

--
diff -up linux-2.6.9_/net/ipv4/devinet.c~fc12~2 linux-2.6.9_/net/ipv4/devinet.c
--- linux-2.6.9_/net/ipv4/devinet.c~fc12~2	2010-02-05 12:32:30.000000000 +0300
+++ linux-2.6.9_/net/ipv4/devinet.c	2010-02-09 13:06:59.000000000 +0300
@@ -190,7 +190,7 @@ static void in_dev_rcu_put(struct rcu_he
 	in_dev_put(idev);
 }
 
-static void inetdev_destroy(struct in_device *in_dev)
+static void inetdev_destroy(struct in_device *in_dev, int force)
 {
 	struct in_ifaddr *ifa;
 	struct net_device *dev;
@@ -198,7 +198,7 @@ static void inetdev_destroy(struct in_de
 	ASSERT_RTNL();
 
 	dev = in_dev->dev;
-	if (dev == &loopback_dev)
+ 	if (!force && dev == &visible_loopback_dev)
 		return;
 
 	in_dev->dead = 1;
@@ -289,7 +289,7 @@ void inet_del_ifa(struct in_device *in_d
 		inet_free_ifa(ifa1);
 
 		if (!in_dev->ifa_list)
-			inetdev_destroy(in_dev);
+			inetdev_destroy(in_dev, 0);
 	}
 }
 
@@ -958,7 +958,7 @@ static int inetdev_event(struct notifier
 	ASSERT_RTNL();
 
 	if (!in_dev) {
-		if (event == NETDEV_REGISTER && dev == &loopback_dev) {
+		if (event == NETDEV_REGISTER && dev == &visible_loopback_dev) {
 			in_dev = inetdev_init(dev);
 			if (!in_dev)
 				panic("devinet: Failed to create loopback\n");
@@ -996,11 +996,12 @@ static int inetdev_event(struct notifier
 		ip_mc_down(in_dev);
 		break;
 	case NETDEV_CHANGEMTU:
-		if (dev->mtu >= 68)
-			break;
-		/* MTU falled under 68, disable IP */
+		if (dev->mtu < 68)
+			/* MTU falled under 68, disable IP */
+			inetdev_destroy(in_dev, 0);
+		break;
 	case NETDEV_UNREGISTER:
-		inetdev_destroy(in_dev);
+		inetdev_destroy(in_dev, 1);
 		break;
 	case NETDEV_CHANGENAME:
 		/* Do not notify about label change, this event is

