rtnetlink: Remove passing of attributes into rtnl_doit functions
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / ipv6 / addrconf.c
index 4dc0d44a5d31cb54788b7d2df076617b46b4e2f5..15794fdaf028079ba0fab468784e81f6bc093c6a 100644 (file)
@@ -544,8 +544,7 @@ static const struct nla_policy devconf_ipv6_policy[NETCONFA_MAX+1] = {
 };
 
 static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
-                                    struct nlmsghdr *nlh,
-                                    void *arg)
+                                    struct nlmsghdr *nlh)
 {
        struct net *net = sock_net(in_skb->sk);
        struct nlattr *tb[NETCONFA_MAX+1];
@@ -605,6 +604,74 @@ errout:
        return err;
 }
 
+static int inet6_netconf_dump_devconf(struct sk_buff *skb,
+                                     struct netlink_callback *cb)
+{
+       struct net *net = sock_net(skb->sk);
+       int h, s_h;
+       int idx, s_idx;
+       struct net_device *dev;
+       struct inet6_dev *idev;
+       struct hlist_head *head;
+
+       s_h = cb->args[0];
+       s_idx = idx = cb->args[1];
+
+       for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
+               idx = 0;
+               head = &net->dev_index_head[h];
+               rcu_read_lock();
+               hlist_for_each_entry_rcu(dev, head, index_hlist) {
+                       if (idx < s_idx)
+                               goto cont;
+                       idev = __in6_dev_get(dev);
+                       if (!idev)
+                               goto cont;
+
+                       if (inet6_netconf_fill_devconf(skb, dev->ifindex,
+                                                      &idev->cnf,
+                                                      NETLINK_CB(cb->skb).portid,
+                                                      cb->nlh->nlmsg_seq,
+                                                      RTM_NEWNETCONF,
+                                                      NLM_F_MULTI,
+                                                      -1) <= 0) {
+                               rcu_read_unlock();
+                               goto done;
+                       }
+cont:
+                       idx++;
+               }
+               rcu_read_unlock();
+       }
+       if (h == NETDEV_HASHENTRIES) {
+               if (inet6_netconf_fill_devconf(skb, NETCONFA_IFINDEX_ALL,
+                                              net->ipv6.devconf_all,
+                                              NETLINK_CB(cb->skb).portid,
+                                              cb->nlh->nlmsg_seq,
+                                              RTM_NEWNETCONF, NLM_F_MULTI,
+                                              -1) <= 0)
+                       goto done;
+               else
+                       h++;
+       }
+       if (h == NETDEV_HASHENTRIES + 1) {
+               if (inet6_netconf_fill_devconf(skb, NETCONFA_IFINDEX_DEFAULT,
+                                              net->ipv6.devconf_dflt,
+                                              NETLINK_CB(cb->skb).portid,
+                                              cb->nlh->nlmsg_seq,
+                                              RTM_NEWNETCONF, NLM_F_MULTI,
+                                              -1) <= 0)
+                       goto done;
+               else
+                       h++;
+       }
+done:
+       cb->args[0] = h;
+       cb->args[1] = idx;
+
+       return skb->len;
+}
+
 #ifdef CONFIG_SYSCTL
 static void dev_forward_change(struct inet6_dev *idev)
 {
@@ -1419,11 +1486,10 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
                  struct net_device *dev, int strict)
 {
        struct inet6_ifaddr *ifp;
-       struct hlist_node *node;
        unsigned int hash = inet6_addr_hash(addr);
 
        rcu_read_lock_bh();
-       hlist_for_each_entry_rcu(ifp, node, &inet6_addr_lst[hash], addr_lst) {
+       hlist_for_each_entry_rcu(ifp, &inet6_addr_lst[hash], addr_lst) {
                if (!net_eq(dev_net(ifp->idev->dev), net))
                        continue;
                if (ipv6_addr_equal(&ifp->addr, addr) &&
@@ -1445,9 +1511,8 @@ static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
 {
        unsigned int hash = inet6_addr_hash(addr);
        struct inet6_ifaddr *ifp;
-       struct hlist_node *node;
 
-       hlist_for_each_entry(ifp, node, &inet6_addr_lst[hash], addr_lst) {
+       hlist_for_each_entry(ifp, &inet6_addr_lst[hash], addr_lst) {
                if (!net_eq(dev_net(ifp->idev->dev), net))
                        continue;
                if (ipv6_addr_equal(&ifp->addr, addr)) {
@@ -1487,10 +1552,9 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add
 {
        struct inet6_ifaddr *ifp, *result = NULL;
        unsigned int hash = inet6_addr_hash(addr);
-       struct hlist_node *node;
 
        rcu_read_lock_bh();
-       hlist_for_each_entry_rcu_bh(ifp, node, &inet6_addr_lst[hash], addr_lst) {
+       hlist_for_each_entry_rcu_bh(ifp, &inet6_addr_lst[hash], addr_lst) {
                if (!net_eq(dev_net(ifp->idev->dev), net))
                        continue;
                if (ipv6_addr_equal(&ifp->addr, addr)) {
@@ -2907,11 +2971,10 @@ static int addrconf_ifdown(struct net_device *dev, int how)
        /* Step 2: clear hash table */
        for (i = 0; i < IN6_ADDR_HSIZE; i++) {
                struct hlist_head *h = &inet6_addr_lst[i];
-               struct hlist_node *n;
 
                spin_lock_bh(&addrconf_hash_lock);
        restart:
-               hlist_for_each_entry_rcu(ifa, n, h, addr_lst) {
+               hlist_for_each_entry_rcu(ifa, h, addr_lst) {
                        if (ifa->idev == idev) {
                                hlist_del_init_rcu(&ifa->addr_lst);
                                addrconf_del_timer(ifa);
@@ -3218,8 +3281,7 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos)
        }
 
        for (; state->bucket < IN6_ADDR_HSIZE; ++state->bucket) {
-               struct hlist_node *n;
-               hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
+               hlist_for_each_entry_rcu_bh(ifa, &inet6_addr_lst[state->bucket],
                                         addr_lst) {
                        if (!net_eq(dev_net(ifa->idev->dev), net))
                                continue;
@@ -3244,9 +3306,8 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
 {
        struct if6_iter_state *state = seq->private;
        struct net *net = seq_file_net(seq);
-       struct hlist_node *n = &ifa->addr_lst;
 
-       hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) {
+       hlist_for_each_entry_continue_rcu_bh(ifa, addr_lst) {
                if (!net_eq(dev_net(ifa->idev->dev), net))
                        continue;
                state->offset++;
@@ -3255,7 +3316,7 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
 
        while (++state->bucket < IN6_ADDR_HSIZE) {
                state->offset = 0;
-               hlist_for_each_entry_rcu_bh(ifa, n,
+               hlist_for_each_entry_rcu_bh(ifa,
                                     &inet6_addr_lst[state->bucket], addr_lst) {
                        if (!net_eq(dev_net(ifa->idev->dev), net))
                                continue;
@@ -3357,11 +3418,10 @@ int ipv6_chk_home_addr(struct net *net, const struct in6_addr *addr)
 {
        int ret = 0;
        struct inet6_ifaddr *ifp = NULL;
-       struct hlist_node *n;
        unsigned int hash = inet6_addr_hash(addr);
 
        rcu_read_lock_bh();
-       hlist_for_each_entry_rcu_bh(ifp, n, &inet6_addr_lst[hash], addr_lst) {
+       hlist_for_each_entry_rcu_bh(ifp, &inet6_addr_lst[hash], addr_lst) {
                if (!net_eq(dev_net(ifp->idev->dev), net))
                        continue;
                if (ipv6_addr_equal(&ifp->addr, addr) &&
@@ -3383,7 +3443,6 @@ static void addrconf_verify(unsigned long foo)
 {
        unsigned long now, next, next_sec, next_sched;
        struct inet6_ifaddr *ifp;
-       struct hlist_node *node;
        int i;
 
        rcu_read_lock_bh();
@@ -3395,7 +3454,7 @@ static void addrconf_verify(unsigned long foo)
 
        for (i = 0; i < IN6_ADDR_HSIZE; i++) {
 restart:
-               hlist_for_each_entry_rcu_bh(ifp, node,
+               hlist_for_each_entry_rcu_bh(ifp,
                                         &inet6_addr_lst[i], addr_lst) {
                        unsigned long age;
 
@@ -3518,7 +3577,7 @@ static const struct nla_policy ifa_ipv6_policy[IFA_MAX+1] = {
 };
 
 static int
-inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
        struct net *net = sock_net(skb->sk);
        struct ifaddrmsg *ifm;
@@ -3584,7 +3643,7 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u8 ifa_flags,
 }
 
 static int
-inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
+inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
        struct net *net = sock_net(skb->sk);
        struct ifaddrmsg *ifm;
@@ -3866,7 +3925,6 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
        struct net_device *dev;
        struct inet6_dev *idev;
        struct hlist_head *head;
-       struct hlist_node *node;
 
        s_h = cb->args[0];
        s_idx = idx = cb->args[1];
@@ -3876,7 +3934,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
        for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
                idx = 0;
                head = &net->dev_index_head[h];
-               hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
+               hlist_for_each_entry_rcu(dev, head, index_hlist) {
                        if (idx < s_idx)
                                goto cont;
                        if (h > s_h || idx > s_idx)
@@ -3924,8 +3982,7 @@ static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb)
        return inet6_dump_addr(skb, cb, type);
 }
 
-static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh,
-                            void *arg)
+static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh)
 {
        struct net *net = sock_net(in_skb->sk);
        struct ifaddrmsg *ifm;
@@ -4222,7 +4279,6 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
        struct net_device *dev;
        struct inet6_dev *idev;
        struct hlist_head *head;
-       struct hlist_node *node;
 
        s_h = cb->args[0];
        s_idx = cb->args[1];
@@ -4231,7 +4287,7 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
        for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
                idx = 0;
                head = &net->dev_index_head[h];
-               hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
+               hlist_for_each_entry_rcu(dev, head, index_hlist) {
                        if (idx < s_idx)
                                goto cont;
                        idev = __in6_dev_get(dev);
@@ -4950,7 +5006,7 @@ int __init addrconf_init(void)
        __rtnl_register(PF_INET6, RTM_GETANYCAST, NULL,
                        inet6_dump_ifacaddr, NULL);
        __rtnl_register(PF_INET6, RTM_GETNETCONF, inet6_netconf_get_devconf,
-                       NULL, NULL);
+                       inet6_netconf_dump_devconf, NULL);
 
        ipv6_addr_label_rtnl_register();