]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/devinet.c
[TCP]: Bound TSO defer time
[linux-2.6-omap-h63xx.git] / net / ipv4 / devinet.c
index 398e7b9ca66b462279cd4bf766560cad4cc799e5..7602c79a389bece923dc5dfd8b00b524690d8d85 100644 (file)
@@ -85,10 +85,10 @@ static struct nla_policy ifa_ipv4_policy[IFA_MAX+1] __read_mostly = {
        [IFA_ADDRESS]           = { .type = NLA_U32 },
        [IFA_BROADCAST]         = { .type = NLA_U32 },
        [IFA_ANYCAST]           = { .type = NLA_U32 },
-       [IFA_LABEL]             = { .type = NLA_STRING },
+       [IFA_LABEL]             = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
 };
 
-static void rtmsg_ifa(int event, struct in_ifaddr *);
+static void rtmsg_ifa(int event, struct in_ifaddr *, struct nlmsghdr *, u32);
 
 static BLOCKING_NOTIFIER_HEAD(inetaddr_chain);
 static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
@@ -224,7 +224,7 @@ static void inetdev_destroy(struct in_device *in_dev)
        call_rcu(&in_dev->rcu_head, in_dev_rcu_put);
 }
 
-int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b)
+int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b)
 {
        rcu_read_lock();
        for_primary_ifa(in_dev) {
@@ -239,8 +239,8 @@ int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b)
        return 0;
 }
 
-static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
-                        int destroy)
+static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
+                        int destroy, struct nlmsghdr *nlh, u32 pid)
 {
        struct in_ifaddr *promote = NULL;
        struct in_ifaddr *ifa, *ifa1 = *ifap;
@@ -273,7 +273,7 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
                        if (!do_promote) {
                                *ifap1 = ifa->ifa_next;
 
-                               rtmsg_ifa(RTM_DELADDR, ifa);
+                               rtmsg_ifa(RTM_DELADDR, ifa, nlh, pid);
                                blocking_notifier_call_chain(&inetaddr_chain,
                                                NETDEV_DOWN, ifa);
                                inet_free_ifa(ifa);
@@ -298,7 +298,7 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
           is valid, it will try to restore deleted routes... Grr.
           So that, this order is correct.
         */
-       rtmsg_ifa(RTM_DELADDR, ifa1);
+       rtmsg_ifa(RTM_DELADDR, ifa1, nlh, pid);
        blocking_notifier_call_chain(&inetaddr_chain, NETDEV_DOWN, ifa1);
 
        if (promote) {
@@ -310,7 +310,7 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
                }
 
                promote->ifa_flags &= ~IFA_F_SECONDARY;
-               rtmsg_ifa(RTM_NEWADDR, promote);
+               rtmsg_ifa(RTM_NEWADDR, promote, nlh, pid);
                blocking_notifier_call_chain(&inetaddr_chain,
                                NETDEV_UP, promote);
                for (ifa = promote->ifa_next; ifa; ifa = ifa->ifa_next) {
@@ -329,7 +329,14 @@ static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
        }
 }
 
-static int inet_insert_ifa(struct in_ifaddr *ifa)
+static void inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
+                        int destroy)
+{
+       __inet_del_ifa(in_dev, ifap, destroy, NULL, 0);
+}
+
+static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh,
+                            u32 pid)
 {
        struct in_device *in_dev = ifa->ifa_dev;
        struct in_ifaddr *ifa1, **ifap, **last_primary;
@@ -374,12 +381,17 @@ static int inet_insert_ifa(struct in_ifaddr *ifa)
        /* Send message first, then call notifier.
           Notifier will trigger FIB update, so that
           listeners of netlink will know about new ifaddr */
-       rtmsg_ifa(RTM_NEWADDR, ifa);
+       rtmsg_ifa(RTM_NEWADDR, ifa, nlh, pid);
        blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa);
 
        return 0;
 }
 
+static int inet_insert_ifa(struct in_ifaddr *ifa)
+{
+       return __inet_insert_ifa(ifa, NULL, 0);
+}
+
 static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
 {
        struct in_device *in_dev = __in_dev_get_rtnl(dev);
@@ -417,8 +429,8 @@ struct in_device *inetdev_by_index(int ifindex)
 
 /* Called only from RTNL semaphored context. No locks. */
 
-struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix,
-                                   u32 mask)
+struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
+                                   __be32 mask)
 {
        ASSERT_RTNL();
 
@@ -455,7 +467,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
        for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
             ifap = &ifa->ifa_next) {
                if (tb[IFA_LOCAL] &&
-                   ifa->ifa_local != nla_get_u32(tb[IFA_LOCAL]))
+                   ifa->ifa_local != nla_get_be32(tb[IFA_LOCAL]))
                        continue;
 
                if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label))
@@ -463,10 +475,10 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
 
                if (tb[IFA_ADDRESS] &&
                    (ifm->ifa_prefixlen != ifa->ifa_prefixlen ||
-                   !inet_ifa_match(nla_get_u32(tb[IFA_ADDRESS]), ifa)))
+                   !inet_ifa_match(nla_get_be32(tb[IFA_ADDRESS]), ifa)))
                        continue;
 
-               inet_del_ifa(in_dev, ifap, 1);
+               __inet_del_ifa(in_dev, ifap, 1, nlh, NETLINK_CB(skb).pid);
                return 0;
        }
 
@@ -528,14 +540,14 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
        ifa->ifa_scope = ifm->ifa_scope;
        ifa->ifa_dev = in_dev;
 
-       ifa->ifa_local = nla_get_u32(tb[IFA_LOCAL]);
-       ifa->ifa_address = nla_get_u32(tb[IFA_ADDRESS]);
+       ifa->ifa_local = nla_get_be32(tb[IFA_LOCAL]);
+       ifa->ifa_address = nla_get_be32(tb[IFA_ADDRESS]);
 
        if (tb[IFA_BROADCAST])
-               ifa->ifa_broadcast = nla_get_u32(tb[IFA_BROADCAST]);
+               ifa->ifa_broadcast = nla_get_be32(tb[IFA_BROADCAST]);
 
        if (tb[IFA_ANYCAST])
-               ifa->ifa_anycast = nla_get_u32(tb[IFA_ANYCAST]);
+               ifa->ifa_anycast = nla_get_be32(tb[IFA_ANYCAST]);
 
        if (tb[IFA_LABEL])
                nla_strlcpy(ifa->ifa_label, tb[IFA_LABEL], IFNAMSIZ);
@@ -558,7 +570,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
        if (IS_ERR(ifa))
                return PTR_ERR(ifa);
 
-       return inet_insert_ifa(ifa);
+       return __inet_insert_ifa(ifa, nlh, NETLINK_CB(skb).pid);
 }
 
 /*
@@ -793,7 +805,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
                        break;
                ret = 0;
                if (ifa->ifa_mask != sin->sin_addr.s_addr) {
-                       u32 old_mask = ifa->ifa_mask;
+                       __be32 old_mask = ifa->ifa_mask;
                        inet_del_ifa(in_dev, ifap, 0);
                        ifa->ifa_mask = sin->sin_addr.s_addr;
                        ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
@@ -864,9 +876,9 @@ out:
        return done;
 }
 
-u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope)
+__be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope)
 {
-       u32 addr = 0;
+       __be32 addr = 0;
        struct in_device *in_dev;
 
        rcu_read_lock();
@@ -915,11 +927,11 @@ out:
        return addr;
 }
 
-static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst,
-                             u32 local, int scope)
+static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst,
+                             __be32 local, int scope)
 {
        int same = 0;
-       u32 addr = 0;
+       __be32 addr = 0;
 
        for_ifa(in_dev) {
                if (!addr &&
@@ -959,9 +971,9 @@ static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst,
  * - local: address, 0=autoselect the local address
  * - scope: maximum allowed scope value for the local address
  */
-u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scope)
+__be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local, int scope)
 {
-       u32 addr = 0;
+       __be32 addr = 0;
        struct in_device *in_dev;
 
        if (dev) {
@@ -1126,16 +1138,16 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
        ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
 
        if (ifa->ifa_address)
-               NLA_PUT_U32(skb, IFA_ADDRESS, ifa->ifa_address);
+               NLA_PUT_BE32(skb, IFA_ADDRESS, ifa->ifa_address);
 
        if (ifa->ifa_local)
-               NLA_PUT_U32(skb, IFA_LOCAL, ifa->ifa_local);
+               NLA_PUT_BE32(skb, IFA_LOCAL, ifa->ifa_local);
 
        if (ifa->ifa_broadcast)
-               NLA_PUT_U32(skb, IFA_BROADCAST, ifa->ifa_broadcast);
+               NLA_PUT_BE32(skb, IFA_BROADCAST, ifa->ifa_broadcast);
 
        if (ifa->ifa_anycast)
-               NLA_PUT_U32(skb, IFA_ANYCAST, ifa->ifa_anycast);
+               NLA_PUT_BE32(skb, IFA_ANYCAST, ifa->ifa_anycast);
 
        if (ifa->ifa_label[0])
                NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
@@ -1189,18 +1201,27 @@ done:
        return skb->len;
 }
 
-static void rtmsg_ifa(int event, struct in_ifaddr* ifa)
+static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh,
+                     u32 pid)
 {
        struct sk_buff *skb;
+       u32 seq = nlh ? nlh->nlmsg_seq : 0;
+       int err = -ENOBUFS;
 
        skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
        if (skb == NULL)
-               netlink_set_err(rtnl, 0, RTNLGRP_IPV4_IFADDR, ENOBUFS);
-       else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
+               goto errout;
+
+       err = inet_fill_ifaddr(skb, ifa, pid, seq, event, 0);
+       if (err < 0) {
                kfree_skb(skb);
-               netlink_set_err(rtnl, 0, RTNLGRP_IPV4_IFADDR, EINVAL);
-       } else
-               netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV4_IFADDR, GFP_KERNEL);
+               goto errout;
+       }
+
+       err = rtnl_notify(skb, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL);
+errout:
+       if (err < 0)
+               rtnl_set_sk_err(RTNLGRP_IPV4_IFADDR, err);
 }
 
 static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = {