ARM64: dts: rockchip: add USB2.0 host nodes for rk3399
[firefly-linux-kernel-4.4.55.git] / net / decnet / dn_dev.c
index b5e52100a89a1ab3ea24b5e697339e7db478218c..b2c26b081134a0c5b3697bfbad0148a029a5b95e 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/sysctl.h>
 #include <linux/notifier.h>
 #include <linux/slab.h>
+#include <linux/jiffies.h>
 #include <asm/uaccess.h>
 #include <net/net_namespace.h>
 #include <net/neighbour.h>
@@ -158,11 +159,11 @@ static int max_t3[] = { 8191 }; /* Must fit in 16 bits when multiplied by BCT3MU
 static int min_priority[1];
 static int max_priority[] = { 127 }; /* From DECnet spec */
 
-static int dn_forwarding_proc(ctl_table *, int,
+static int dn_forwarding_proc(struct ctl_table *, int,
                        void __user *, size_t *, loff_t *);
 static struct dn_dev_sysctl_table {
        struct ctl_table_header *sysctl_header;
-       ctl_table dn_dev_vars[5];
+       struct ctl_table dn_dev_vars[5];
 } dn_dev_sysctl = {
        NULL,
        {
@@ -242,7 +243,7 @@ static void dn_dev_sysctl_unregister(struct dn_dev_parms *parms)
        }
 }
 
-static int dn_forwarding_proc(ctl_table *table, int write,
+static int dn_forwarding_proc(struct ctl_table *table, int write,
                                void __user *buffer,
                                size_t *lenp, loff_t *ppos)
 {
@@ -561,6 +562,7 @@ static const struct nla_policy dn_ifa_policy[IFA_MAX+1] = {
        [IFA_LOCAL]             = { .type = NLA_U16 },
        [IFA_LABEL]             = { .type = NLA_STRING,
                                    .len = IFNAMSIZ - 1 },
+       [IFA_FLAGS]             = { .type = NLA_U32 },
 };
 
 static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
@@ -648,7 +650,8 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
 
        ifa->ifa_local = nla_get_le16(tb[IFA_LOCAL]);
        ifa->ifa_address = nla_get_le16(tb[IFA_ADDRESS]);
-       ifa->ifa_flags = ifm->ifa_flags;
+       ifa->ifa_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) :
+                                        ifm->ifa_flags;
        ifa->ifa_scope = ifm->ifa_scope;
        ifa->ifa_dev = dn_db;
 
@@ -669,7 +672,8 @@ static inline size_t dn_ifaddr_nlmsg_size(void)
        return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
               + nla_total_size(IFNAMSIZ) /* IFA_LABEL */
               + nla_total_size(2) /* IFA_ADDRESS */
-              + nla_total_size(2); /* IFA_LOCAL */
+              + nla_total_size(2) /* IFA_LOCAL */
+              + nla_total_size(4); /* IFA_FLAGS */
 }
 
 static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
@@ -677,6 +681,7 @@ static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
 {
        struct ifaddrmsg *ifm;
        struct nlmsghdr *nlh;
+       u32 ifa_flags = ifa->ifa_flags | IFA_F_PERMANENT;
 
        nlh = nlmsg_put(skb, portid, seq, event, sizeof(*ifm), flags);
        if (nlh == NULL)
@@ -685,7 +690,7 @@ static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
        ifm = nlmsg_data(nlh);
        ifm->ifa_family = AF_DECnet;
        ifm->ifa_prefixlen = 16;
-       ifm->ifa_flags = ifa->ifa_flags | IFA_F_PERMANENT;
+       ifm->ifa_flags = ifa_flags;
        ifm->ifa_scope = ifa->ifa_scope;
        ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
 
@@ -694,9 +699,11 @@ static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
            (ifa->ifa_local &&
             nla_put_le16(skb, IFA_LOCAL, ifa->ifa_local)) ||
            (ifa->ifa_label[0] &&
-            nla_put_string(skb, IFA_LABEL, ifa->ifa_label)))
+            nla_put_string(skb, IFA_LABEL, ifa->ifa_label)) ||
+            nla_put_u32(skb, IFA_FLAGS, ifa_flags))
                goto nla_put_failure;
-       return nlmsg_end(skb, nlh);
+       nlmsg_end(skb, nlh);
+       return 0;
 
 nla_put_failure:
        nlmsg_cancel(skb, nlh);
@@ -870,7 +877,7 @@ static void dn_send_endnode_hello(struct net_device *dev, struct dn_ifaddr *ifa)
 static int dn_am_i_a_router(struct dn_neigh *dn, struct dn_dev *dn_db, struct dn_ifaddr *ifa)
 {
        /* First check time since device went up */
-       if ((jiffies - dn_db->uptime) < DRDELAY)
+       if (time_before(jiffies, dn_db->uptime + DRDELAY))
                return 0;
 
        /* If there is no router, then yes... */