Lines Matching refs:sk
30 struct sock *sk = sock->sk; in pn_socket_release() local
32 if (sk) { in pn_socket_release()
33 sock->sk = NULL; in pn_socket_release()
34 sk->sk_prot->close(sk, 0); in pn_socket_release()
132 int pn_sock_hash(struct sock *sk) in pn_sock_hash() argument
134 struct hlist_head *hlist = pn_hash_list(pn_sk(sk)->sobject); in pn_sock_hash()
137 sk_add_node_rcu(sk, hlist); in pn_sock_hash()
144 void pn_sock_unhash(struct sock *sk) in pn_sock_unhash() argument
147 sk_del_node_init_rcu(sk); in pn_sock_unhash()
149 pn_sock_unbind_all_res(sk); in pn_sock_unhash()
158 struct sock *sk = sock->sk; in pn_socket_bind() local
159 struct pn_sock *pn = pn_sk(sk); in pn_socket_bind()
165 if (sk->sk_prot->bind) in pn_socket_bind()
166 return sk->sk_prot->bind(sk, addr, len); in pn_socket_bind()
175 if (saddr && phonet_address_lookup(sock_net(sk), saddr)) in pn_socket_bind()
178 lock_sock(sk); in pn_socket_bind()
179 if (sk->sk_state != TCP_CLOSE || pn_port(pn->sobject)) { in pn_socket_bind()
183 WARN_ON(sk_hashed(sk)); in pn_socket_bind()
185 err = sk->sk_prot->get_port(sk, pn_port(handle)); in pn_socket_bind()
194 err = sk->sk_prot->hash(sk); in pn_socket_bind()
198 release_sock(sk); in pn_socket_bind()
213 BUG_ON(!pn_port(pn_sk(sock->sk)->sobject)); in pn_socket_autobind()
220 struct sock *sk = sock->sk; in pn_socket_connect() local
221 struct pn_sock *pn = pn_sk(sk); in pn_socket_connect()
224 long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); in pn_socket_connect()
234 lock_sock(sk); in pn_socket_connect()
238 if (sk->sk_state != TCP_CLOSE) { in pn_socket_connect()
255 err = sk->sk_prot->connect(sk, addr, len); in pn_socket_connect()
262 while (sk->sk_state == TCP_SYN_SENT) { in pn_socket_connect()
274 prepare_to_wait_exclusive(sk_sleep(sk), &wait, in pn_socket_connect()
276 release_sock(sk); in pn_socket_connect()
278 lock_sock(sk); in pn_socket_connect()
279 finish_wait(sk_sleep(sk), &wait); in pn_socket_connect()
282 if ((1 << sk->sk_state) & (TCPF_SYN_RECV|TCPF_ESTABLISHED)) in pn_socket_connect()
284 else if (sk->sk_state == TCP_CLOSE_WAIT) in pn_socket_connect()
290 release_sock(sk); in pn_socket_connect()
297 struct sock *sk = sock->sk; in pn_socket_accept() local
301 if (unlikely(sk->sk_state != TCP_LISTEN)) in pn_socket_accept()
304 newsk = sk->sk_prot->accept(sk, flags, &err, kern); in pn_socket_accept()
318 struct sock *sk = sock->sk; in pn_socket_getname() local
319 struct pn_sock *pn = pn_sk(sk); in pn_socket_getname()
333 struct sock *sk = sock->sk; in pn_socket_poll() local
334 struct pep_sock *pn = pep_sk(sk); in pn_socket_poll()
337 poll_wait(file, sk_sleep(sk), wait); in pn_socket_poll()
339 if (sk->sk_state == TCP_CLOSE) in pn_socket_poll()
341 if (!skb_queue_empty_lockless(&sk->sk_receive_queue)) in pn_socket_poll()
345 if (!mask && sk->sk_state == TCP_CLOSE_WAIT) in pn_socket_poll()
348 if (sk->sk_state == TCP_ESTABLISHED && in pn_socket_poll()
349 refcount_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf && in pn_socket_poll()
359 struct sock *sk = sock->sk; in pn_socket_ioctl() local
360 struct pn_sock *pn = pn_sk(sk); in pn_socket_ioctl()
370 lock_sock(sk); in pn_socket_ioctl()
371 if (sk->sk_bound_dev_if) in pn_socket_ioctl()
372 dev = dev_get_by_index(sock_net(sk), in pn_socket_ioctl()
373 sk->sk_bound_dev_if); in pn_socket_ioctl()
375 dev = phonet_device_get(sock_net(sk)); in pn_socket_ioctl()
380 release_sock(sk); in pn_socket_ioctl()
390 return sk->sk_prot->ioctl(sk, cmd, arg); in pn_socket_ioctl()
395 struct sock *sk = sock->sk; in pn_socket_listen() local
401 lock_sock(sk); in pn_socket_listen()
407 if (sk->sk_state != TCP_LISTEN) { in pn_socket_listen()
408 sk->sk_state = TCP_LISTEN; in pn_socket_listen()
409 sk->sk_ack_backlog = 0; in pn_socket_listen()
411 sk->sk_max_ack_backlog = backlog; in pn_socket_listen()
413 release_sock(sk); in pn_socket_listen()
420 struct sock *sk = sock->sk; in pn_socket_sendmsg() local
425 return sk->sk_prot->sendmsg(sk, m, total_len); in pn_socket_sendmsg()
470 int pn_sock_get_port(struct sock *sk, unsigned short sport) in pn_sock_get_port() argument
473 struct net *net = sock_net(sk); in pn_sock_get_port()
474 struct pn_sock *pn = pn_sk(sk); in pn_sock_get_port()
539 static struct sock *pn_sock_get_next(struct seq_file *seq, struct sock *sk) in pn_sock_get_next() argument
544 sk = sk_next(sk); in pn_sock_get_next()
545 while (sk && !net_eq(net, sock_net(sk))); in pn_sock_get_next()
547 return sk; in pn_sock_get_next()
559 struct sock *sk; in pn_sock_seq_next() local
562 sk = pn_sock_get_idx(seq, 0); in pn_sock_seq_next()
564 sk = pn_sock_get_next(seq, v); in pn_sock_seq_next()
566 return sk; in pn_sock_seq_next()
582 struct sock *sk = v; in pn_sock_seq_show() local
583 struct pn_sock *pn = pn_sk(sk); in pn_sock_seq_show()
587 sk->sk_protocol, pn->sobject, pn->dobject, in pn_sock_seq_show()
588 pn->resource, sk->sk_state, in pn_sock_seq_show()
589 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk), in pn_sock_seq_show()
590 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)), in pn_sock_seq_show()
591 sock_i_ino(sk), in pn_sock_seq_show()
592 refcount_read(&sk->sk_refcnt), sk, in pn_sock_seq_show()
593 atomic_read(&sk->sk_drops)); in pn_sock_seq_show()
608 struct sock *sk[256]; member
616 struct sock *sk; in pn_find_sock_by_res() local
622 sk = rcu_dereference(pnres.sk[res]); in pn_find_sock_by_res()
623 if (sk) in pn_find_sock_by_res()
624 sock_hold(sk); in pn_find_sock_by_res()
626 return sk; in pn_find_sock_by_res()
631 int pn_sock_bind_res(struct sock *sk, u8 res) in pn_sock_bind_res() argument
635 if (!net_eq(sock_net(sk), &init_net)) in pn_sock_bind_res()
639 if (pn_socket_autobind(sk->sk_socket)) in pn_sock_bind_res()
643 if (pnres.sk[res] == NULL) { in pn_sock_bind_res()
644 sock_hold(sk); in pn_sock_bind_res()
645 rcu_assign_pointer(pnres.sk[res], sk); in pn_sock_bind_res()
652 int pn_sock_unbind_res(struct sock *sk, u8 res) in pn_sock_unbind_res() argument
660 if (pnres.sk[res] == sk) { in pn_sock_unbind_res()
661 RCU_INIT_POINTER(pnres.sk[res], NULL); in pn_sock_unbind_res()
668 sock_put(sk); in pn_sock_unbind_res()
673 void pn_sock_unbind_all_res(struct sock *sk) in pn_sock_unbind_all_res() argument
679 if (pnres.sk[res] == sk) { in pn_sock_unbind_all_res()
680 RCU_INIT_POINTER(pnres.sk[res], NULL); in pn_sock_unbind_all_res()
687 __sock_put(sk); in pn_sock_unbind_all_res()
703 if (pnres.sk[i] == NULL) in pn_res_get_idx()
706 return pnres.sk + i; in pn_res_get_idx()
712 static struct sock **pn_res_get_next(struct seq_file *seq, struct sock **sk) in pn_res_get_next() argument
719 for (i = (sk - pnres.sk) + 1; i < 256; i++) in pn_res_get_next()
720 if (pnres.sk[i]) in pn_res_get_next()
721 return pnres.sk + i; in pn_res_get_next()
734 struct sock **sk; in pn_res_seq_next() local
737 sk = pn_res_get_idx(seq, 0); in pn_res_seq_next()
739 sk = pn_res_get_next(seq, v); in pn_res_seq_next()
741 return sk; in pn_res_seq_next()
757 struct sock *sk = *psk; in pn_res_seq_show() local
760 (int) (psk - pnres.sk), in pn_res_seq_show()
761 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)), in pn_res_seq_show()
762 sock_i_ino(sk)); in pn_res_seq_show()