net/ipv4: queue work on power efficient wq
[cascardo/linux.git] / net / ipv4 / devinet.c
index 84956f5..ac2dff3 100644 (file)
@@ -464,7 +464,7 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh,
        }
 
        if (!(ifa->ifa_flags & IFA_F_SECONDARY)) {
-               net_srandom(ifa->ifa_local);
+               prandom_seed((__force u32) ifa->ifa_local);
                ifap = last_primary;
        }
 
@@ -474,7 +474,7 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh,
        inet_hash_insert(dev_net(in_dev->dev), ifa);
 
        cancel_delayed_work(&check_lifetime_work);
-       schedule_delayed_work(&check_lifetime_work, 0);
+       queue_delayed_work(system_power_efficient_wq, &check_lifetime_work, 0);
 
        /* Send message first, then call notifier.
           Notifier will trigger FIB update, so that
@@ -684,7 +684,8 @@ static void check_lifetime(struct work_struct *work)
        if (time_before(next_sched, now + ADDRCONF_TIMER_FUZZ_MAX))
                next_sched = now + ADDRCONF_TIMER_FUZZ_MAX;
 
-       schedule_delayed_work(&check_lifetime_work, next_sched - now);
+       queue_delayed_work(system_power_efficient_wq, &check_lifetime_work,
+                       next_sched - now);
 }
 
 static void set_ifa_lifetime(struct in_ifaddr *ifa, __u32 valid_lft,
@@ -842,7 +843,8 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
                ifa = ifa_existing;
                set_ifa_lifetime(ifa, valid_lft, prefered_lft);
                cancel_delayed_work(&check_lifetime_work);
-               schedule_delayed_work(&check_lifetime_work, 0);
+               queue_delayed_work(system_power_efficient_wq,
+                               &check_lifetime_work, 0);
                rtmsg_ifa(RTM_NEWADDR, ifa, nlh, NETLINK_CB(skb).portid);
                blocking_notifier_call_chain(&inetaddr_chain, NETDEV_UP, ifa);
        }
@@ -1385,6 +1387,8 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
                                memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
                                set_ifa_lifetime(ifa, INFINITY_LIFE_TIME,
                                                 INFINITY_LIFE_TIME);
+                               ipv4_devconf_setall(in_dev);
+                               neigh_parms_data_state_setall(in_dev->arp_parms);
                                inet_insert_ifa(ifa);
                        }
                }
@@ -1696,6 +1700,8 @@ static int inet_netconf_msgsize_devconf(int type)
                size += nla_total_size(4);
        if (type == -1 || type == NETCONFA_MC_FORWARDING)
                size += nla_total_size(4);
+       if (type == -1 || type == NETCONFA_PROXY_NEIGH)
+               size += nla_total_size(4);
 
        return size;
 }
@@ -1732,6 +1738,10 @@ static int inet_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
            nla_put_s32(skb, NETCONFA_MC_FORWARDING,
                        IPV4_DEVCONF(*devconf, MC_FORWARDING)) < 0)
                goto nla_put_failure;
+       if ((type == -1 || type == NETCONFA_PROXY_NEIGH) &&
+           nla_put_s32(skb, NETCONFA_PROXY_NEIGH,
+                       IPV4_DEVCONF(*devconf, PROXY_ARP)) < 0)
+               goto nla_put_failure;
 
        return nlmsg_end(skb, nlh);
 
@@ -1769,6 +1779,7 @@ static const struct nla_policy devconf_ipv4_policy[NETCONFA_MAX+1] = {
        [NETCONFA_IFINDEX]      = { .len = sizeof(int) },
        [NETCONFA_FORWARDING]   = { .len = sizeof(int) },
        [NETCONFA_RP_FILTER]    = { .len = sizeof(int) },
+       [NETCONFA_PROXY_NEIGH]  = { .len = sizeof(int) },
 };
 
 static int inet_netconf_get_devconf(struct sk_buff *in_skb,
@@ -1950,6 +1961,19 @@ static void inet_forward_change(struct net *net)
        }
 }
 
+static int devinet_conf_ifindex(struct net *net, struct ipv4_devconf *cnf)
+{
+       if (cnf == net->ipv4.devconf_dflt)
+               return NETCONFA_IFINDEX_DEFAULT;
+       else if (cnf == net->ipv4.devconf_all)
+               return NETCONFA_IFINDEX_ALL;
+       else {
+               struct in_device *idev
+                       = container_of(cnf, struct in_device, cnf);
+               return idev->dev->ifindex;
+       }
+}
+
 static int devinet_conf_proc(struct ctl_table *ctl, int write,
                             void __user *buffer,
                             size_t *lenp, loff_t *ppos)
@@ -1962,6 +1986,7 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,
                struct ipv4_devconf *cnf = ctl->extra1;
                struct net *net = ctl->extra2;
                int i = (int *)ctl->data - cnf->data;
+               int ifindex;
 
                set_bit(i, cnf->state);
 
@@ -1971,23 +1996,19 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,
                    i == IPV4_DEVCONF_ROUTE_LOCALNET - 1)
                        if ((new_value == 0) && (old_value != 0))
                                rt_cache_flush(net);
+
                if (i == IPV4_DEVCONF_RP_FILTER - 1 &&
                    new_value != old_value) {
-                       int ifindex;
-
-                       if (cnf == net->ipv4.devconf_dflt)
-                               ifindex = NETCONFA_IFINDEX_DEFAULT;
-                       else if (cnf == net->ipv4.devconf_all)
-                               ifindex = NETCONFA_IFINDEX_ALL;
-                       else {
-                               struct in_device *idev =
-                                       container_of(cnf, struct in_device,
-                                                    cnf);
-                               ifindex = idev->dev->ifindex;
-                       }
+                       ifindex = devinet_conf_ifindex(net, cnf);
                        inet_netconf_notify_devconf(net, NETCONFA_RP_FILTER,
                                                    ifindex, cnf);
                }
+               if (i == IPV4_DEVCONF_PROXY_ARP - 1 &&
+                   new_value != old_value) {
+                       ifindex = devinet_conf_ifindex(net, cnf);
+                       inet_netconf_notify_devconf(net, NETCONFA_PROXY_NEIGH,
+                                                   ifindex, cnf);
+               }
        }
 
        return ret;
@@ -2303,7 +2324,7 @@ void __init devinet_init(void)
        register_gifconf(PF_INET, inet_gifconf);
        register_netdevice_notifier(&ip_netdev_notifier);
 
-       schedule_delayed_work(&check_lifetime_work, 0);
+       queue_delayed_work(system_power_efficient_wq, &check_lifetime_work, 0);
 
        rtnl_af_register(&inet_af_ops);