aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@linux.intel.com>2013-04-02 04:25:15 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-11 10:28:59 -0400
commitabd18d43302ae0e214d020c842b34e706cc3778e (patch)
tree8f60cefae483e5ef1b006c79d2922dce7dcdda4b /net/nfc
parent66cbfa10f3bdbc86222598ac700c352da90e588f (diff)
NFC: llcp: Reset RW, LTO, and MIU remote parameters when link goes down
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>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/llcp/llcp.c11
-rw-r--r--net/nfc/llcp/llcp.h1
-rw-r--r--net/nfc/llcp/sock.c3
3 files changed, 13 insertions, 2 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 79de8bafd426..83e788e840a0 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -47,6 +47,12 @@ void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *sk)
47 write_unlock(&l->lock); 47 write_unlock(&l->lock);
48} 48}
49 49
50void nfc_llcp_socket_remote_param_init(struct nfc_llcp_sock *sock)
51{
52 sock->remote_rw = LLCP_DEFAULT_RW;
53 sock->remote_miu = LLCP_MAX_MIU + 1;
54}
55
50static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock) 56static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock)
51{ 57{
52 struct nfc_llcp_local *local = sock->local; 58 struct nfc_llcp_local *local = sock->local;
@@ -112,6 +118,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen,
112 } 118 }
113 119
114 if (listen == true) { 120 if (listen == true) {
121 nfc_llcp_socket_remote_param_init(llcp_sock);
115 bh_unlock_sock(sk); 122 bh_unlock_sock(sk);
116 continue; 123 continue;
117 } 124 }
@@ -123,6 +130,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen,
123 */ 130 */
124 if (sk->sk_state == LLCP_BOUND && sk->sk_type == SOCK_DGRAM && 131 if (sk->sk_state == LLCP_BOUND && sk->sk_type == SOCK_DGRAM &&
125 listen == true) { 132 listen == true) {
133 nfc_llcp_socket_remote_param_init(llcp_sock);
126 bh_unlock_sock(sk); 134 bh_unlock_sock(sk);
127 continue; 135 continue;
128 } 136 }
@@ -1522,6 +1530,9 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev)
1522 if (local == NULL) 1530 if (local == NULL)
1523 return; 1531 return;
1524 1532
1533 local->remote_miu = LLCP_DEFAULT_MIU;
1534 local->remote_lto = LLCP_DEFAULT_LTO;
1535
1525 /* Close and purge all existing sockets */ 1536 /* Close and purge all existing sockets */
1526 nfc_llcp_socket_release(local, true, 0); 1537 nfc_llcp_socket_release(local, true, 0);
1527} 1538}
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h
index 3b2c67eb8efb..ff8c434f7df8 100644
--- a/net/nfc/llcp/llcp.h
+++ b/net/nfc/llcp/llcp.h
@@ -212,6 +212,7 @@ struct nfc_llcp_ui_cb {
212 212
213void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s); 213void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s);
214void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *s); 214void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *s);
215void nfc_llcp_socket_remote_param_init(struct nfc_llcp_sock *sock);
215struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); 216struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);
216struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local); 217struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local);
217int nfc_llcp_local_put(struct nfc_llcp_local *local); 218int nfc_llcp_local_put(struct nfc_llcp_local *local);
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index dc94e397d22a..641c535be3d4 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -933,12 +933,11 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp)
933 llcp_sock->dsap = LLCP_SAP_SDP; 933 llcp_sock->dsap = LLCP_SAP_SDP;
934 llcp_sock->rw = LLCP_MAX_RW + 1; 934 llcp_sock->rw = LLCP_MAX_RW + 1;
935 llcp_sock->miux = cpu_to_be16(LLCP_MAX_MIUX + 1); 935 llcp_sock->miux = cpu_to_be16(LLCP_MAX_MIUX + 1);
936 llcp_sock->remote_rw = LLCP_DEFAULT_RW;
937 llcp_sock->remote_miu = LLCP_MAX_MIU + 1;
938 llcp_sock->send_n = llcp_sock->send_ack_n = 0; 936 llcp_sock->send_n = llcp_sock->send_ack_n = 0;
939 llcp_sock->recv_n = llcp_sock->recv_ack_n = 0; 937 llcp_sock->recv_n = llcp_sock->recv_ack_n = 0;
940 llcp_sock->remote_ready = 1; 938 llcp_sock->remote_ready = 1;
941 llcp_sock->reserved_ssap = LLCP_SAP_MAX; 939 llcp_sock->reserved_ssap = LLCP_SAP_MAX;
940 nfc_llcp_socket_remote_param_init(llcp_sock);
942 skb_queue_head_init(&llcp_sock->tx_queue); 941 skb_queue_head_init(&llcp_sock->tx_queue);
943 skb_queue_head_init(&llcp_sock->tx_pending_queue); 942 skb_queue_head_init(&llcp_sock->tx_pending_queue);
944 INIT_LIST_HEAD(&llcp_sock->accept_queue); 943 INIT_LIST_HEAD(&llcp_sock->accept_queue);