Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux...
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / udp_diag.c
index 7927db0a927951a20b4502d38fca0bba9e94862c..6116604bf6e8fd64d82b5d9496197cb7e4accef7 100644 (file)
@@ -18,8 +18,9 @@
 #include <linux/sock_diag.h>
 
 static int sk_diag_dump(struct sock *sk, struct sk_buff *skb,
-               struct netlink_callback *cb, struct inet_diag_req_v2 *req,
-               struct nlattr *bc)
+                       struct netlink_callback *cb,
+                       const struct inet_diag_req_v2 *req,
+                       struct nlattr *bc)
 {
        if (!inet_diag_bc_sk(bc, sk))
                return 0;
@@ -31,7 +32,8 @@ static int sk_diag_dump(struct sock *sk, struct sk_buff *skb,
 }
 
 static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
-               const struct nlmsghdr *nlh, struct inet_diag_req_v2 *req)
+                       const struct nlmsghdr *nlh,
+                       const struct inet_diag_req_v2 *req)
 {
        int err = -EINVAL;
        struct sock *sk;
@@ -56,7 +58,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
                goto out_nosk;
 
        err = -ENOENT;
-       if (sk == NULL)
+       if (!sk)
                goto out_nosk;
 
        err = sock_diag_check_cookie(sk, req->id.idiag_cookie);
@@ -90,8 +92,9 @@ out_nosk:
        return err;
 }
 
-static void udp_dump(struct udp_table *table, struct sk_buff *skb, struct netlink_callback *cb,
-               struct inet_diag_req_v2 *r, struct nlattr *bc)
+static void udp_dump(struct udp_table *table, struct sk_buff *skb,
+                    struct netlink_callback *cb,
+                    const struct inet_diag_req_v2 *r, struct nlattr *bc)
 {
        int num, s_num, slot, s_slot;
        struct net *net = sock_net(skb->sk);
@@ -99,11 +102,13 @@ static void udp_dump(struct udp_table *table, struct sk_buff *skb, struct netlin
        s_slot = cb->args[0];
        num = s_num = cb->args[1];
 
-       for (slot = s_slot; slot <= table->mask; num = s_num = 0, slot++) {
+       for (slot = s_slot; slot <= table->mask; s_num = 0, slot++) {
                struct sock *sk;
                struct hlist_nulls_node *node;
                struct udp_hslot *hslot = &table->hash[slot];
 
+               num = 0;
+
                if (hlist_nulls_empty(&hslot->head))
                        continue;
 
@@ -142,13 +147,13 @@ done:
 }
 
 static void udp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
-               struct inet_diag_req_v2 *r, struct nlattr *bc)
+                         const struct inet_diag_req_v2 *r, struct nlattr *bc)
 {
        udp_dump(&udp_table, skb, cb, r, bc);
 }
 
 static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
-               struct inet_diag_req_v2 *req)
+                            const struct inet_diag_req_v2 *req)
 {
        return udp_dump_one(&udp_table, in_skb, nlh, req);
 }
@@ -165,16 +170,18 @@ static const struct inet_diag_handler udp_diag_handler = {
        .dump_one        = udp_diag_dump_one,
        .idiag_get_info  = udp_diag_get_info,
        .idiag_type      = IPPROTO_UDP,
+       .idiag_info_size = 0,
 };
 
 static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
-               struct inet_diag_req_v2 *r, struct nlattr *bc)
+                             const struct inet_diag_req_v2 *r,
+                             struct nlattr *bc)
 {
        udp_dump(&udplite_table, skb, cb, r, bc);
 }
 
 static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
-               struct inet_diag_req_v2 *req)
+                                const struct inet_diag_req_v2 *req)
 {
        return udp_dump_one(&udplite_table, in_skb, nlh, req);
 }
@@ -184,6 +191,7 @@ static const struct inet_diag_handler udplite_diag_handler = {
        .dump_one        = udplite_diag_dump_one,
        .idiag_get_info  = udp_diag_get_info,
        .idiag_type      = IPPROTO_UDPLITE,
+       .idiag_info_size = 0,
 };
 
 static int __init udp_diag_init(void)