NFC: llcp: Reset RW, LTO, and MIU remote parameters when link goes down
authorThierry Escande <thierry.escande@linux.intel.com>
Tue, 2 Apr 2013 08:25:15 +0000 (10:25 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 11 Apr 2013 14:28:59 +0000 (16:28 +0200)
This resets remote parameters in both local and socket llcp structures when the
link goes down. That way, nfc_llcp_getsockopt won't return values corresponding
to the previous link parameters.

Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/llcp/llcp.c
net/nfc/llcp/llcp.h
net/nfc/llcp/sock.c

index 79de8bafd42649dd807d9fb58e1e49c95abb1a83..83e788e840a06f47228e6b16255127b4c6e70aed 100644 (file)
@@ -47,6 +47,12 @@ void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *sk)
        write_unlock(&l->lock);
 }
 
+void nfc_llcp_socket_remote_param_init(struct nfc_llcp_sock *sock)
+{
+       sock->remote_rw = LLCP_DEFAULT_RW;
+       sock->remote_miu = LLCP_MAX_MIU + 1;
+}
+
 static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock)
 {
        struct nfc_llcp_local *local = sock->local;
@@ -112,6 +118,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen,
                        }
 
                        if (listen == true) {
+                               nfc_llcp_socket_remote_param_init(llcp_sock);
                                bh_unlock_sock(sk);
                                continue;
                        }
@@ -123,6 +130,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen,
                 */
                if (sk->sk_state == LLCP_BOUND && sk->sk_type == SOCK_DGRAM &&
                    listen == true) {
+                       nfc_llcp_socket_remote_param_init(llcp_sock);
                        bh_unlock_sock(sk);
                        continue;
                }
@@ -1522,6 +1530,9 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev)
        if (local == NULL)
                return;
 
+       local->remote_miu = LLCP_DEFAULT_MIU;
+       local->remote_lto = LLCP_DEFAULT_LTO;
+
        /* Close and purge all existing sockets */
        nfc_llcp_socket_release(local, true, 0);
 }
index 3b2c67eb8efb778660416196ec5a6e55bed5a379..ff8c434f7df89d5df8fd37281c06c315f35a6b18 100644 (file)
@@ -212,6 +212,7 @@ struct nfc_llcp_ui_cb {
 
 void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s);
 void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *s);
+void nfc_llcp_socket_remote_param_init(struct nfc_llcp_sock *sock);
 struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);
 struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local);
 int nfc_llcp_local_put(struct nfc_llcp_local *local);
index dc94e397d22af66b638c2634ce48574ce469b9bf..641c535be3d4f73b3a11b5c802be5e7584f08d8e 100644 (file)
@@ -933,12 +933,11 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp)
        llcp_sock->dsap = LLCP_SAP_SDP;
        llcp_sock->rw = LLCP_MAX_RW + 1;
        llcp_sock->miux = cpu_to_be16(LLCP_MAX_MIUX + 1);
-       llcp_sock->remote_rw = LLCP_DEFAULT_RW;
-       llcp_sock->remote_miu = LLCP_MAX_MIU + 1;
        llcp_sock->send_n = llcp_sock->send_ack_n = 0;
        llcp_sock->recv_n = llcp_sock->recv_ack_n = 0;
        llcp_sock->remote_ready = 1;
        llcp_sock->reserved_ssap = LLCP_SAP_MAX;
+       nfc_llcp_socket_remote_param_init(llcp_sock);
        skb_queue_head_init(&llcp_sock->tx_queue);
        skb_queue_head_init(&llcp_sock->tx_pending_queue);
        INIT_LIST_HEAD(&llcp_sock->accept_queue);