• Home
  • Raw
  • Download

Lines Matching refs:tsk

117 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope,
119 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope,
122 static int tipc_sk_insert(struct tipc_sock *tsk);
123 static void tipc_sk_remove(struct tipc_sock *tsk);
134 static u32 tsk_own_node(struct tipc_sock *tsk) in tsk_own_node() argument
136 return msg_prevnode(&tsk->phdr); in tsk_own_node()
139 static u32 tsk_peer_node(struct tipc_sock *tsk) in tsk_peer_node() argument
141 return msg_destnode(&tsk->phdr); in tsk_peer_node()
144 static u32 tsk_peer_port(struct tipc_sock *tsk) in tsk_peer_port() argument
146 return msg_destport(&tsk->phdr); in tsk_peer_port()
149 static bool tsk_unreliable(struct tipc_sock *tsk) in tsk_unreliable() argument
151 return msg_src_droppable(&tsk->phdr) != 0; in tsk_unreliable()
154 static void tsk_set_unreliable(struct tipc_sock *tsk, bool unreliable) in tsk_set_unreliable() argument
156 msg_set_src_droppable(&tsk->phdr, unreliable ? 1 : 0); in tsk_set_unreliable()
159 static bool tsk_unreturnable(struct tipc_sock *tsk) in tsk_unreturnable() argument
161 return msg_dest_droppable(&tsk->phdr) != 0; in tsk_unreturnable()
164 static void tsk_set_unreturnable(struct tipc_sock *tsk, bool unreturnable) in tsk_set_unreturnable() argument
166 msg_set_dest_droppable(&tsk->phdr, unreturnable ? 1 : 0); in tsk_set_unreturnable()
169 static int tsk_importance(struct tipc_sock *tsk) in tsk_importance() argument
171 return msg_importance(&tsk->phdr); in tsk_importance()
174 static int tsk_set_importance(struct tipc_sock *tsk, int imp) in tsk_set_importance() argument
178 msg_set_importance(&tsk->phdr, (u32)imp); in tsk_set_importance()
187 static bool tsk_conn_cong(struct tipc_sock *tsk) in tsk_conn_cong() argument
189 return tsk->snt_unacked > tsk->snd_win; in tsk_conn_cong()
205 static u16 tsk_inc(struct tipc_sock *tsk, int msglen) in tsk_inc() argument
207 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in tsk_inc()
256 static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) in tsk_peer_msg() argument
258 struct tipc_net *tn = net_generic(sock_net(&tsk->sk), tipc_net_id); in tsk_peer_msg()
259 u32 peer_port = tsk_peer_port(tsk); in tsk_peer_msg()
263 if (unlikely(!tsk->connected)) in tsk_peer_msg()
270 peer_node = tsk_peer_node(tsk); in tsk_peer_msg()
303 struct tipc_sock *tsk; in tipc_sk_create() local
333 tsk = tipc_sk(sk); in tipc_sk_create()
334 tsk->max_pkt = MAX_PKT_DEFAULT; in tipc_sk_create()
335 INIT_LIST_HEAD(&tsk->publications); in tipc_sk_create()
336 msg = &tsk->phdr; in tipc_sk_create()
343 if (tipc_sk_insert(tsk)) { in tipc_sk_create()
354 msg_set_origport(msg, tsk->portid); in tipc_sk_create()
355 setup_timer(&sk->sk_timer, tipc_sk_timeout, (unsigned long)tsk); in tipc_sk_create()
361 tsk->conn_timeout = CONN_TIMEOUT_DEFAULT; in tipc_sk_create()
362 atomic_set(&tsk->dupl_rcvcnt, 0); in tipc_sk_create()
365 tsk->snd_win = tsk_adv_blocks(RCVBUF_MIN); in tipc_sk_create()
366 tsk->rcv_win = tsk->snd_win; in tipc_sk_create()
369 tsk_set_unreturnable(tsk, true); in tipc_sk_create()
371 tsk_set_unreliable(tsk, true); in tipc_sk_create()
378 struct tipc_sock *tsk = container_of(head, struct tipc_sock, rcu); in tipc_sk_callback() local
380 sock_put(&tsk->sk); in tipc_sk_callback()
403 struct tipc_sock *tsk; in tipc_release() local
415 tsk = tipc_sk(sk); in tipc_release()
422 dnode = tsk_peer_node(tsk); in tipc_release()
433 tsk->connected = 0; in tipc_release()
434 tipc_node_remove_conn(net, dnode, tsk->portid); in tipc_release()
440 tipc_sk_withdraw(tsk, 0, NULL); in tipc_release()
442 tipc_sk_remove(tsk); in tipc_release()
443 if (tsk->connected) { in tipc_release()
446 tsk_own_node(tsk), tsk_peer_port(tsk), in tipc_release()
447 tsk->portid, TIPC_ERR_NO_PORT); in tipc_release()
449 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); in tipc_release()
450 tipc_node_remove_conn(net, dnode, tsk->portid); in tipc_release()
457 call_rcu(&tsk->rcu, tipc_sk_callback); in tipc_release()
483 struct tipc_sock *tsk = tipc_sk(sk); in tipc_bind() local
488 res = tipc_sk_withdraw(tsk, 0, NULL); in tipc_bind()
516 tipc_sk_publish(tsk, addr->scope, &addr->addr.nameseq) : in tipc_bind()
517 tipc_sk_withdraw(tsk, -addr->scope, &addr->addr.nameseq); in tipc_bind()
540 struct tipc_sock *tsk = tipc_sk(sock->sk); in tipc_getname() local
548 addr->addr.id.ref = tsk_peer_port(tsk); in tipc_getname()
549 addr->addr.id.node = tsk_peer_node(tsk); in tipc_getname()
551 addr->addr.id.ref = tsk->portid; in tipc_getname()
608 struct tipc_sock *tsk = tipc_sk(sk); in tipc_poll() local
615 if (!tsk->link_cong) in tipc_poll()
620 if (!tsk->link_cong && !tsk_conn_cong(tsk)) in tipc_poll()
651 struct tipc_sock *tsk = tipc_sk(sk); in tipc_sendmcast() local
653 struct tipc_msg *mhdr = &tsk->phdr; in tipc_sendmcast()
682 tsk->link_cong = 1; in tipc_sendmcast()
758 static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb, in tipc_sk_proto_rcv() argument
761 struct sock *sk = &tsk->sk; in tipc_sk_proto_rcv()
762 u32 onode = tsk_own_node(tsk); in tipc_sk_proto_rcv()
768 if (!tsk_peer_msg(tsk, hdr)) in tipc_sk_proto_rcv()
771 tsk->probing_state = TIPC_CONN_OK; in tipc_sk_proto_rcv()
779 conn_cong = tsk_conn_cong(tsk); in tipc_sk_proto_rcv()
780 tsk->snt_unacked -= msg_conn_ack(hdr); in tipc_sk_proto_rcv()
781 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_proto_rcv()
782 tsk->snd_win = msg_adv_win(hdr); in tipc_sk_proto_rcv()
795 struct tipc_sock *tsk = tipc_sk(sk); in tipc_wait_for_sndmsg() local
811 done = sk_wait_event(sk, timeo_p, !tsk->link_cong); in tipc_wait_for_sndmsg()
847 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_sendmsg() local
849 struct tipc_msg *mhdr = &tsk->phdr; in __tipc_sendmsg()
862 if (tsk->connected && sock->state == SS_READY) in __tipc_sendmsg()
863 dest = &tsk->remote; in __tipc_sendmsg()
875 if (tsk->published) in __tipc_sendmsg()
878 tsk->conn_type = dest->addr.name.name.type; in __tipc_sendmsg()
879 tsk->conn_instance = dest->addr.name.name.instance; in __tipc_sendmsg()
915 mtu = tipc_node_get_mtu(net, dnode, tsk->portid); in __tipc_sendmsg()
922 TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong; in __tipc_sendmsg()
923 rc = tipc_node_xmit(net, &pktchain, dnode, tsk->portid); in __tipc_sendmsg()
930 tsk->link_cong = 1; in __tipc_sendmsg()
949 struct tipc_sock *tsk = tipc_sk(sk); in tipc_wait_for_sndpkt() local
968 (!tsk->link_cong && in tipc_wait_for_sndpkt()
969 !tsk_conn_cong(tsk)) || in tipc_wait_for_sndpkt()
970 !tsk->connected); in tipc_wait_for_sndpkt()
1003 struct tipc_sock *tsk = tipc_sk(sk); in __tipc_send_stream() local
1004 struct tipc_msg *mhdr = &tsk->phdr; in __tipc_send_stream()
1007 u32 portid = tsk->portid; in __tipc_send_stream()
1020 tsk->snt_unacked = tsk_inc(tsk, dsz + hlen); in __tipc_send_stream()
1034 dnode = tsk_peer_node(tsk); in __tipc_send_stream()
1039 mtu = tsk->max_pkt; in __tipc_send_stream()
1046 if (likely(!tsk_conn_cong(tsk))) { in __tipc_send_stream()
1049 tsk->snt_unacked += tsk_inc(tsk, send + hlen); in __tipc_send_stream()
1057 tsk->max_pkt = tipc_node_get_mtu(net, dnode, in __tipc_send_stream()
1065 tsk->link_cong = 1; in __tipc_send_stream()
1094 static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, in tipc_sk_finish_conn() argument
1097 struct sock *sk = &tsk->sk; in tipc_sk_finish_conn()
1099 struct tipc_msg *msg = &tsk->phdr; in tipc_sk_finish_conn()
1107 tsk->probing_intv = CONN_PROBING_INTERVAL; in tipc_sk_finish_conn()
1108 tsk->probing_state = TIPC_CONN_OK; in tipc_sk_finish_conn()
1109 tsk->connected = 1; in tipc_sk_finish_conn()
1110 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv); in tipc_sk_finish_conn()
1111 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); in tipc_sk_finish_conn()
1112 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid); in tipc_sk_finish_conn()
1113 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); in tipc_sk_finish_conn()
1114 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) in tipc_sk_finish_conn()
1118 tsk->rcv_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1119 tsk->snd_win = FLOWCTL_MSG_WIN; in tipc_sk_finish_conn()
1156 struct tipc_sock *tsk) in tipc_sk_anc_data_recv() argument
1199 has_name = (tsk->conn_type != 0); in tipc_sk_anc_data_recv()
1200 anc_data[0] = tsk->conn_type; in tipc_sk_anc_data_recv()
1201 anc_data[1] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1202 anc_data[2] = tsk->conn_instance; in tipc_sk_anc_data_recv()
1216 static void tipc_sk_send_ack(struct tipc_sock *tsk) in tipc_sk_send_ack() argument
1218 struct net *net = sock_net(&tsk->sk); in tipc_sk_send_ack()
1221 u32 peer_port = tsk_peer_port(tsk); in tipc_sk_send_ack()
1222 u32 dnode = tsk_peer_node(tsk); in tipc_sk_send_ack()
1224 if (!tsk->connected) in tipc_sk_send_ack()
1227 dnode, tsk_own_node(tsk), peer_port, in tipc_sk_send_ack()
1228 tsk->portid, TIPC_OK); in tipc_sk_send_ack()
1232 msg_set_conn_ack(msg, tsk->rcv_unacked); in tipc_sk_send_ack()
1233 tsk->rcv_unacked = 0; in tipc_sk_send_ack()
1236 if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) { in tipc_sk_send_ack()
1237 tsk->rcv_win = tsk_adv_blocks(tsk->sk.sk_rcvbuf); in tipc_sk_send_ack()
1238 msg_set_adv_win(msg, tsk->rcv_win); in tipc_sk_send_ack()
1291 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recvmsg() local
1335 res = tipc_sk_anc_data_recv(m, msg, tsk); in tipc_recvmsg()
1361 tsk->rcv_unacked += tsk_inc(tsk, hlen + sz); in tipc_recvmsg()
1362 if (unlikely(tsk->rcv_unacked >= (tsk->rcv_win / 4))) in tipc_recvmsg()
1363 tipc_sk_send_ack(tsk); in tipc_recvmsg()
1386 struct tipc_sock *tsk = tipc_sk(sk); in tipc_recv_stream() local
1432 res = tipc_sk_anc_data_recv(m, msg, tsk); in tipc_recv_stream()
1470 tsk->rcv_unacked += tsk_inc(tsk, hlen + sz); in tipc_recv_stream()
1471 if (unlikely(tsk->rcv_unacked >= (tsk->rcv_win / 4))) in tipc_recv_stream()
1472 tipc_sk_send_ack(tsk); in tipc_recv_stream()
1532 static bool filter_connect(struct tipc_sock *tsk, struct sk_buff *skb) in filter_connect() argument
1534 struct sock *sk = &tsk->sk; in filter_connect()
1546 if (unlikely(!tsk_peer_msg(tsk, hdr))) in filter_connect()
1551 tsk->connected = 0; in filter_connect()
1553 tipc_node_remove_conn(net, tsk_peer_node(tsk), in filter_connect()
1554 tsk->portid); in filter_connect()
1576 tipc_sk_finish_conn(tsk, msg_origport(hdr), msg_orignode(hdr)); in filter_connect()
1577 msg_set_importance(&tsk->phdr, msg_importance(hdr)); in filter_connect()
1627 struct tipc_sock *tsk = tipc_sk(sk); in rcvbuf_limit() local
1633 if (likely(tsk->peer_caps & TIPC_BLOCK_FLOWCTL)) in rcvbuf_limit()
1655 struct tipc_sock *tsk = tipc_sk(sk); in filter_rcv() local
1662 tipc_sk_proto_rcv(tsk, skb, xmitq); in filter_rcv()
1668 tsk->link_cong = 0; in filter_rcv()
1685 } else if (unlikely(!filter_connect(tsk, skb))) { in filter_rcv()
1705 if (tipc_msg_reverse(tsk_own_node(tsk), &skb, err)) in filter_rcv()
1802 struct tipc_sock *tsk; in tipc_sk_rcv() local
1809 tsk = tipc_sk_lookup(net, dport); in tipc_sk_rcv()
1811 if (likely(tsk)) { in tipc_sk_rcv()
1812 sk = &tsk->sk; in tipc_sk_rcv()
1880 struct tipc_sock *tsk = tipc_sk(sk); in tipc_connect() local
1883 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; in tipc_connect()
1892 memset(&tsk->remote, 0, sizeof(struct sockaddr_tipc)); in tipc_connect()
1893 tsk->connected = 0; in tipc_connect()
1897 memcpy(&tsk->remote, dest, destlen); in tipc_connect()
1898 tsk->connected = 1; in tipc_connect()
2109 struct tipc_sock *tsk = tipc_sk(sk); in tipc_shutdown() local
2111 u32 dnode = tsk_peer_node(tsk); in tipc_shutdown()
2112 u32 dport = tsk_peer_port(tsk); in tipc_shutdown()
2114 u32 oport = tsk->portid; in tipc_shutdown()
2127 dnode = tsk_peer_node(tsk); in tipc_shutdown()
2143 tipc_node_xmit_skb(net, skb, dnode, tsk->portid); in tipc_shutdown()
2145 tsk->connected = 0; in tipc_shutdown()
2147 tipc_node_remove_conn(net, dnode, tsk->portid); in tipc_shutdown()
2170 struct tipc_sock *tsk = (struct tipc_sock *)data; in tipc_sk_timeout() local
2171 struct sock *sk = &tsk->sk; in tipc_sk_timeout()
2174 u32 own_node = tsk_own_node(tsk); in tipc_sk_timeout()
2177 if (!tsk->connected) { in tipc_sk_timeout()
2181 peer_port = tsk_peer_port(tsk); in tipc_sk_timeout()
2182 peer_node = tsk_peer_node(tsk); in tipc_sk_timeout()
2184 if (tsk->probing_state == TIPC_CONN_PROBING) { in tipc_sk_timeout()
2187 tsk->connected = 0; in tipc_sk_timeout()
2188 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), in tipc_sk_timeout()
2189 tsk_peer_port(tsk)); in tipc_sk_timeout()
2199 peer_port, tsk->portid, TIPC_OK); in tipc_sk_timeout()
2200 tsk->probing_state = TIPC_CONN_PROBING; in tipc_sk_timeout()
2201 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv); in tipc_sk_timeout()
2205 tipc_node_xmit_skb(sock_net(sk), skb, peer_node, tsk->portid); in tipc_sk_timeout()
2210 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, in tipc_sk_publish() argument
2213 struct net *net = sock_net(&tsk->sk); in tipc_sk_publish()
2217 if (tsk->connected) in tipc_sk_publish()
2219 key = tsk->portid + tsk->pub_count + 1; in tipc_sk_publish()
2220 if (key == tsk->portid) in tipc_sk_publish()
2224 scope, tsk->portid, key); in tipc_sk_publish()
2228 list_add(&publ->pport_list, &tsk->publications); in tipc_sk_publish()
2229 tsk->pub_count++; in tipc_sk_publish()
2230 tsk->published = 1; in tipc_sk_publish()
2234 static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, in tipc_sk_withdraw() argument
2237 struct net *net = sock_net(&tsk->sk); in tipc_sk_withdraw()
2242 list_for_each_entry_safe(publ, safe, &tsk->publications, pport_list) { in tipc_sk_withdraw()
2261 if (list_empty(&tsk->publications)) in tipc_sk_withdraw()
2262 tsk->published = 0; in tipc_sk_withdraw()
2273 struct tipc_sock *tsk; in tipc_sk_reinit() local
2279 tsk = ERR_PTR(rhashtable_walk_start(&iter)); in tipc_sk_reinit()
2280 if (tsk) in tipc_sk_reinit()
2283 while ((tsk = rhashtable_walk_next(&iter)) && !IS_ERR(tsk)) { in tipc_sk_reinit()
2284 spin_lock_bh(&tsk->sk.sk_lock.slock); in tipc_sk_reinit()
2285 msg = &tsk->phdr; in tipc_sk_reinit()
2288 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_sk_reinit()
2292 } while (tsk == ERR_PTR(-EAGAIN)); in tipc_sk_reinit()
2298 struct tipc_sock *tsk; in tipc_sk_lookup() local
2301 tsk = rhashtable_lookup_fast(&tn->sk_rht, &portid, tsk_rht_params); in tipc_sk_lookup()
2302 if (tsk) in tipc_sk_lookup()
2303 sock_hold(&tsk->sk); in tipc_sk_lookup()
2306 return tsk; in tipc_sk_lookup()
2309 static int tipc_sk_insert(struct tipc_sock *tsk) in tipc_sk_insert() argument
2311 struct sock *sk = &tsk->sk; in tipc_sk_insert()
2321 tsk->portid = portid; in tipc_sk_insert()
2322 sock_hold(&tsk->sk); in tipc_sk_insert()
2323 if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, in tipc_sk_insert()
2326 sock_put(&tsk->sk); in tipc_sk_insert()
2332 static void tipc_sk_remove(struct tipc_sock *tsk) in tipc_sk_remove() argument
2334 struct sock *sk = &tsk->sk; in tipc_sk_remove()
2337 if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { in tipc_sk_remove()
2387 struct tipc_sock *tsk = tipc_sk(sk); in tipc_setsockopt() local
2405 res = tsk_set_importance(tsk, value); in tipc_setsockopt()
2409 tsk_set_unreliable(tsk, value); in tipc_setsockopt()
2414 tsk_set_unreturnable(tsk, value); in tipc_setsockopt()
2446 struct tipc_sock *tsk = tipc_sk(sk); in tipc_getsockopt() local
2463 value = tsk_importance(tsk); in tipc_getsockopt()
2466 value = tsk_unreliable(tsk); in tipc_getsockopt()
2469 value = tsk_unreturnable(tsk); in tipc_getsockopt()
2472 value = tsk->conn_timeout; in tipc_getsockopt()
2635 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) in __tipc_nl_add_sk_con() argument
2641 peer_node = tsk_peer_node(tsk); in __tipc_nl_add_sk_con()
2642 peer_port = tsk_peer_port(tsk); in __tipc_nl_add_sk_con()
2651 if (tsk->conn_type != 0) { in __tipc_nl_add_sk_con()
2654 if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, tsk->conn_type)) in __tipc_nl_add_sk_con()
2656 if (nla_put_u32(skb, TIPC_NLA_CON_INST, tsk->conn_instance)) in __tipc_nl_add_sk_con()
2671 struct tipc_sock *tsk) in __tipc_nl_add_sk() argument
2687 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid)) in __tipc_nl_add_sk()
2692 if (tsk->connected) { in __tipc_nl_add_sk()
2693 err = __tipc_nl_add_sk_con(skb, tsk); in __tipc_nl_add_sk()
2696 } else if (!list_empty(&tsk->publications)) { in __tipc_nl_add_sk()
2716 struct tipc_sock *tsk; in tipc_nl_sk_dump() local
2727 rht_for_each_entry_rcu(tsk, pos, tbl, tbl_id, node) { in tipc_nl_sk_dump()
2728 spin_lock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2729 if (prev_portid && prev_portid != tsk->portid) { in tipc_nl_sk_dump()
2730 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2734 err = __tipc_nl_add_sk(skb, cb, tsk); in tipc_nl_sk_dump()
2736 prev_portid = tsk->portid; in tipc_nl_sk_dump()
2737 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2741 spin_unlock_bh(&tsk->sk.sk_lock.slock); in tipc_nl_sk_dump()
2794 struct tipc_sock *tsk, u32 *last_publ) in __tipc_nl_list_sk_publ() argument
2800 list_for_each_entry(p, &tsk->publications, pport_list) { in __tipc_nl_list_sk_publ()
2816 p = list_first_entry(&tsk->publications, struct publication, in __tipc_nl_list_sk_publ()
2820 list_for_each_entry_from(p, &tsk->publications, pport_list) { in __tipc_nl_list_sk_publ()
2839 struct tipc_sock *tsk; in tipc_nl_publ_dump() local
2867 tsk = tipc_sk_lookup(net, tsk_portid); in tipc_nl_publ_dump()
2868 if (!tsk) in tipc_nl_publ_dump()
2871 lock_sock(&tsk->sk); in tipc_nl_publ_dump()
2872 err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ); in tipc_nl_publ_dump()
2875 release_sock(&tsk->sk); in tipc_nl_publ_dump()
2876 sock_put(&tsk->sk); in tipc_nl_publ_dump()