]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/devinet.c
serial_txx9: Use UPF_FIXED_PORT
[linux-2.6-omap-h63xx.git] / net / ipv4 / devinet.c
index e19734795a7b7cb69dbbaba7ead4f3b1a2dd303f..55d199e4ae212813dd737a9cf2706b7f9cccbe38 100644 (file)
@@ -84,7 +84,7 @@ static struct ipv4_devconf ipv4_devconf_dflt = {
 
 #define IPV4_DEVCONF_DFLT(attr) IPV4_DEVCONF(ipv4_devconf_dflt, attr)
 
-static struct nla_policy ifa_ipv4_policy[IFA_MAX+1] __read_mostly = {
+static const struct nla_policy ifa_ipv4_policy[IFA_MAX+1] = {
        [IFA_LOCAL]             = { .type = NLA_U32 },
        [IFA_ADDRESS]           = { .type = NLA_U32 },
        [IFA_BROADCAST]         = { .type = NLA_U32 },
@@ -147,7 +147,7 @@ void in_dev_finish_destroy(struct in_device *idev)
        }
 }
 
-struct in_device *inetdev_init(struct net_device *dev)
+static struct in_device *inetdev_init(struct net_device *dev)
 {
        struct in_device *in_dev;
 
@@ -203,8 +203,6 @@ static void inetdev_destroy(struct in_device *in_dev)
        ASSERT_RTNL();
 
        dev = in_dev->dev;
-       if (dev == &loopback_dev)
-               return;
 
        in_dev->dead = 1;
 
@@ -327,12 +325,8 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
                }
 
        }
-       if (destroy) {
+       if (destroy)
                inet_free_ifa(ifa1);
-
-               if (!in_dev->ifa_list)
-                       inetdev_destroy(in_dev);
-       }
 }
 
 static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
@@ -405,12 +399,10 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
        ASSERT_RTNL();
 
        if (!in_dev) {
-               in_dev = inetdev_init(dev);
-               if (!in_dev) {
-                       inet_free_ifa(ifa);
-                       return -ENOBUFS;
-               }
+               inet_free_ifa(ifa);
+               return -ENOBUFS;
        }
+       ipv4_devconf_setall(in_dev);
        if (ifa->ifa_dev != in_dev) {
                BUG_TRAP(!ifa->ifa_dev);
                in_dev_hold(in_dev);
@@ -426,7 +418,7 @@ struct in_device *inetdev_by_index(int ifindex)
        struct net_device *dev;
        struct in_device *in_dev = NULL;
        read_lock(&dev_base_lock);
-       dev = __dev_get_by_index(ifindex);
+       dev = __dev_get_by_index(&init_net, ifindex);
        if (dev)
                in_dev = in_dev_get(dev);
        read_unlock(&dev_base_lock);
@@ -512,7 +504,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
                goto errout;
        }
 
-       dev = __dev_get_by_index(ifm->ifa_index);
+       dev = __dev_get_by_index(&init_net, ifm->ifa_index);
        if (dev == NULL) {
                err = -ENODEV;
                goto errout;
@@ -520,13 +512,12 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
 
        in_dev = __in_dev_get_rtnl(dev);
        if (in_dev == NULL) {
-               in_dev = inetdev_init(dev);
-               if (in_dev == NULL) {
-                       err = -ENOBUFS;
-                       goto errout;
-               }
+               err = -ENOBUFS;
+               goto errout;
        }
 
+       ipv4_devconf_setall(in_dev);
+
        ifa = inet_alloc_ifa();
        if (ifa == NULL) {
                /*
@@ -635,7 +626,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
                *colon = 0;
 
 #ifdef CONFIG_KMOD
-       dev_load(ifr.ifr_name);
+       dev_load(&init_net, ifr.ifr_name);
 #endif
 
        switch (cmd) {
@@ -676,7 +667,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
        rtnl_lock();
 
        ret = -ENODEV;
-       if ((dev = __dev_get_by_name(ifr.ifr_name)) == NULL)
+       if ((dev = __dev_get_by_name(&init_net, ifr.ifr_name)) == NULL)
                goto done;
 
        if (colon)
@@ -916,7 +907,7 @@ no_in_dev:
         */
        read_lock(&dev_base_lock);
        rcu_read_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
                        continue;
 
@@ -995,7 +986,7 @@ __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local,
 
        read_lock(&dev_base_lock);
        rcu_read_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((in_dev = __in_dev_get_rcu(dev))) {
                        addr = confirm_addr_indev(in_dev, dst, local, scope);
                        if (addr)
@@ -1058,15 +1049,17 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
        struct net_device *dev = ptr;
        struct in_device *in_dev = __in_dev_get_rtnl(dev);
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        ASSERT_RTNL();
 
        if (!in_dev) {
                if (event == NETDEV_REGISTER) {
                        in_dev = inetdev_init(dev);
-                       if (dev == &loopback_dev) {
-                               if (!in_dev)
-                                       panic("devinet: "
-                                             "Failed to create loopback\n");
+                       if (!in_dev)
+                               return notifier_from_errno(-ENOMEM);
+                       if (dev->flags & IFF_LOOPBACK) {
                                IN_DEV_CONF_SET(in_dev, NOXFRM, 1);
                                IN_DEV_CONF_SET(in_dev, NOPOLICY, 1);
                        }
@@ -1082,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 =
@@ -1190,7 +1183,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 
        s_ip_idx = ip_idx = cb->args[1];
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < s_idx)
                        goto cont;
                if (idx > s_idx)
@@ -1201,7 +1194,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
                for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
                     ifa = ifa->ifa_next, ip_idx++) {
                        if (ip_idx < s_ip_idx)
-                               goto cont;
+                               continue;
                        if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
                                             cb->nlh->nlmsg_seq,
                                             RTM_NEWADDR, NLM_F_MULTI) <= 0)
@@ -1249,7 +1242,7 @@ static void devinet_copy_dflt_conf(int i)
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                struct in_device *in_dev;
                rcu_read_lock();
                in_dev = __in_dev_get_rcu(dev);
@@ -1338,7 +1331,7 @@ void inet_forward_change(void)
        IPV4_DEVCONF_DFLT(FORWARDING) = on;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                struct in_device *in_dev;
                rcu_read_lock();
                in_dev = __in_dev_get_rcu(dev);