Lines Matching +full:2 +full:- +full:wire

1 // SPDX-License-Identifier: GPL-2.0-or-later
17 #include "ar-internal.h"
23 struct sockaddr *sa = msg->msg_name; in do_udp_sendmsg()
24 struct sock *sk = socket->sk; in do_udp_sendmsg()
27 if (sa->sa_family == AF_INET6) { in do_udp_sendmsg()
28 if (sk->sk_family != AF_INET6) { in do_udp_sendmsg()
30 return -ENOPROTOOPT; in do_udp_sendmsg()
51 u16 tx_backoff = READ_ONCE(call->tx_backoff); in rxrpc_tx_backoff()
54 WRITE_ONCE(call->tx_backoff, tx_backoff + 1); in rxrpc_tx_backoff()
56 WRITE_ONCE(call->tx_backoff, 0); in rxrpc_tx_backoff()
65 * Receiving a response to the ping will prevent the ->expect_rx_by timer from
70 unsigned long now = jiffies, keepalive_at = call->next_rx_timo / 6; in rxrpc_set_keepalive()
73 WRITE_ONCE(call->keepalive_at, keepalive_at); in rxrpc_set_keepalive()
91 u8 *ackp = txb->acks; in rxrpc_fill_out_ack()
93 call->ackr_nr_unacked = 0; in rxrpc_fill_out_ack()
94 atomic_set(&call->ackr_nr_consumed, 0); in rxrpc_fill_out_ack()
95 rxrpc_inc_stat(call->rxnet, stat_tx_ack_fill); in rxrpc_fill_out_ack()
96 clear_bit(RXRPC_CALL_RX_IS_IDLE, &call->flags); in rxrpc_fill_out_ack()
98 window = call->ackr_window; in rxrpc_fill_out_ack()
99 wtop = call->ackr_wtop; in rxrpc_fill_out_ack()
100 sack = call->ackr_sack_base % RXRPC_SACK_SIZE; in rxrpc_fill_out_ack()
101 txb->ack.firstPacket = htonl(window); in rxrpc_fill_out_ack()
102 txb->ack.nAcks = wtop - window; in rxrpc_fill_out_ack()
105 wrap = RXRPC_SACK_SIZE - sack; in rxrpc_fill_out_ack()
106 to = min_t(unsigned int, txb->ack.nAcks, RXRPC_SACK_SIZE); in rxrpc_fill_out_ack()
108 if (sack + txb->ack.nAcks <= RXRPC_SACK_SIZE) { in rxrpc_fill_out_ack()
109 memcpy(txb->acks, call->ackr_sack_table + sack, txb->ack.nAcks); in rxrpc_fill_out_ack()
111 memcpy(txb->acks, call->ackr_sack_table + sack, wrap); in rxrpc_fill_out_ack()
112 memcpy(txb->acks + wrap, call->ackr_sack_table, in rxrpc_fill_out_ack()
113 to - wrap); in rxrpc_fill_out_ack()
119 } else if (txb->ack.reason == RXRPC_ACK_DELAY) { in rxrpc_fill_out_ack()
120 txb->ack.reason = RXRPC_ACK_IDLE; in rxrpc_fill_out_ack()
123 mtu = conn->peer->if_mtu; in rxrpc_fill_out_ack()
124 mtu -= conn->peer->hdrsize; in rxrpc_fill_out_ack()
126 qsize = (window - 1) - call->rx_consumed; in rxrpc_fill_out_ack()
127 rsize = max_t(int, call->rx_winsize - qsize, 0); in rxrpc_fill_out_ack()
138 return txb->ack.nAcks + 3 + sizeof(trailer); in rxrpc_fill_out_ack()
147 unsigned long avail = call->rtt_avail; in rxrpc_begin_rtt_probe()
154 if (!test_and_clear_bit(rtt_slot, &call->rtt_avail)) in rxrpc_begin_rtt_probe()
157 call->rtt_serial[rtt_slot] = serial; in rxrpc_begin_rtt_probe()
158 call->rtt_sent_at[rtt_slot] = ktime_get_real(); in rxrpc_begin_rtt_probe()
160 set_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail); in rxrpc_begin_rtt_probe()
167 return -1; in rxrpc_begin_rtt_probe()
176 if (rtt_slot != -1) { in rxrpc_cancel_rtt_probe()
177 clear_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail); in rxrpc_cancel_rtt_probe()
179 set_bit(rtt_slot, &call->rtt_avail); in rxrpc_cancel_rtt_probe()
194 int ret, rtt_slot = -1; in rxrpc_send_ack_packet()
197 if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) in rxrpc_send_ack_packet()
198 return -ECONNRESET; in rxrpc_send_ack_packet()
200 conn = call->conn; in rxrpc_send_ack_packet()
202 msg.msg_name = &call->peer->srx.transport; in rxrpc_send_ack_packet()
203 msg.msg_namelen = call->peer->srx.transport_len; in rxrpc_send_ack_packet()
208 if (txb->ack.reason == RXRPC_ACK_PING) in rxrpc_send_ack_packet()
209 txb->wire.flags |= RXRPC_REQUEST_ACK; in rxrpc_send_ack_packet()
215 iov[0].iov_base = &txb->wire; in rxrpc_send_ack_packet()
216 iov[0].iov_len = sizeof(txb->wire) + sizeof(txb->ack) + n; in rxrpc_send_ack_packet()
220 txb->wire.serial = htonl(serial); in rxrpc_send_ack_packet()
221 trace_rxrpc_tx_ack(call->debug_id, serial, in rxrpc_send_ack_packet()
222 ntohl(txb->ack.firstPacket), in rxrpc_send_ack_packet()
223 ntohl(txb->ack.serial), txb->ack.reason, txb->ack.nAcks, in rxrpc_send_ack_packet()
226 if (txb->ack.reason == RXRPC_ACK_PING) in rxrpc_send_ack_packet()
229 rxrpc_inc_stat(call->rxnet, stat_tx_ack_send); in rxrpc_send_ack_packet()
232 txb->ack.previousPacket = htonl(call->rx_highest_seq); in rxrpc_send_ack_packet()
235 ret = do_udp_sendmsg(conn->local->socket, &msg, len); in rxrpc_send_ack_packet()
236 call->peer->last_tx_at = ktime_get_seconds(); in rxrpc_send_ack_packet()
238 trace_rxrpc_tx_fail(call->debug_id, serial, ret, in rxrpc_send_ack_packet()
241 trace_rxrpc_tx_packet(call->debug_id, &txb->wire, in rxrpc_send_ack_packet()
243 if (txb->wire.flags & RXRPC_REQUEST_ACK) in rxrpc_send_ack_packet()
244 call->peer->rtt_last_req = ktime_get_real(); in rxrpc_send_ack_packet()
270 * hard-ACK'd all of its request data. After that point, we're not in rxrpc_send_abort_packet()
276 test_bit(RXRPC_CALL_TX_ALL_ACKED, &call->flags)) in rxrpc_send_abort_packet()
279 if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) in rxrpc_send_abort_packet()
280 return -ECONNRESET; in rxrpc_send_abort_packet()
282 conn = call->conn; in rxrpc_send_abort_packet()
284 msg.msg_name = &call->peer->srx.transport; in rxrpc_send_abort_packet()
285 msg.msg_namelen = call->peer->srx.transport_len; in rxrpc_send_abort_packet()
290 pkt.whdr.epoch = htonl(conn->proto.epoch); in rxrpc_send_abort_packet()
291 pkt.whdr.cid = htonl(call->cid); in rxrpc_send_abort_packet()
292 pkt.whdr.callNumber = htonl(call->call_id); in rxrpc_send_abort_packet()
295 pkt.whdr.flags = conn->out_clientflag; in rxrpc_send_abort_packet()
297 pkt.whdr.securityIndex = call->security_ix; in rxrpc_send_abort_packet()
299 pkt.whdr.serviceId = htons(call->dest_srx.srx_service); in rxrpc_send_abort_packet()
300 pkt.abort_code = htonl(call->abort_code); in rxrpc_send_abort_packet()
309 ret = do_udp_sendmsg(conn->local->socket, &msg, sizeof(pkt)); in rxrpc_send_abort_packet()
310 conn->peer->last_tx_at = ktime_get_seconds(); in rxrpc_send_abort_packet()
312 trace_rxrpc_tx_fail(call->debug_id, serial, ret, in rxrpc_send_abort_packet()
315 trace_rxrpc_tx_packet(call->debug_id, &pkt.whdr, in rxrpc_send_abort_packet()
327 struct rxrpc_connection *conn = call->conn; in rxrpc_send_data_packet()
332 int ret, rtt_slot = -1; in rxrpc_send_data_packet()
334 _enter("%x,{%d}", txb->seq, txb->len); in rxrpc_send_data_packet()
338 txb->wire.serial = htonl(serial); in rxrpc_send_data_packet()
340 if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags) && in rxrpc_send_data_packet()
341 txb->seq == 1) in rxrpc_send_data_packet()
342 txb->wire.userStatus = RXRPC_USERSTATUS_SERVICE_UPGRADE; in rxrpc_send_data_packet()
344 iov[0].iov_base = &txb->wire; in rxrpc_send_data_packet()
345 iov[0].iov_len = sizeof(txb->wire) + txb->len; in rxrpc_send_data_packet()
349 msg.msg_name = &call->peer->srx.transport; in rxrpc_send_data_packet()
350 msg.msg_namelen = call->peer->srx.transport_len; in rxrpc_send_data_packet()
360 * soft-ACKs in it and then never follow up with a proper hard ACK. in rxrpc_send_data_packet()
362 if (txb->wire.flags & RXRPC_REQUEST_ACK) in rxrpc_send_data_packet()
364 else if (test_bit(RXRPC_TXBUF_LAST, &txb->flags) && rxrpc_sending_to_client(txb)) in rxrpc_send_data_packet()
366 else if (test_and_clear_bit(RXRPC_CALL_EV_ACK_LOST, &call->events)) in rxrpc_send_data_packet()
368 else if (test_bit(RXRPC_TXBUF_RESENT, &txb->flags)) in rxrpc_send_data_packet()
370 else if (call->cong_mode == RXRPC_CALL_SLOW_START && call->cong_cwnd <= 2) in rxrpc_send_data_packet()
372 else if (call->tx_winsize <= 2) in rxrpc_send_data_packet()
374 else if (call->peer->rtt_count < 3 && txb->seq & 1) in rxrpc_send_data_packet()
376 else if (ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), ktime_get_real())) in rxrpc_send_data_packet()
381 rxrpc_inc_stat(call->rxnet, stat_why_req_ack[why]); in rxrpc_send_data_packet()
382 trace_rxrpc_req_ack(call->debug_id, txb->seq, why); in rxrpc_send_data_packet()
384 txb->wire.flags |= RXRPC_REQUEST_ACK; in rxrpc_send_data_packet()
391 trace_rxrpc_tx_data(call, txb->seq, serial, in rxrpc_send_data_packet()
392 txb->wire.flags, in rxrpc_send_data_packet()
393 test_bit(RXRPC_TXBUF_RESENT, &txb->flags), in rxrpc_send_data_packet()
399 trace_rxrpc_tx_data(call, txb->seq, serial, txb->wire.flags, in rxrpc_send_data_packet()
400 test_bit(RXRPC_TXBUF_RESENT, &txb->flags), false); in rxrpc_send_data_packet()
409 cmpxchg(&call->tx_transmitted, txb->seq - 1, txb->seq); in rxrpc_send_data_packet()
413 if (txb->len >= call->peer->maxdata) in rxrpc_send_data_packet()
416 txb->last_sent = ktime_get_real(); in rxrpc_send_data_packet()
417 if (txb->wire.flags & RXRPC_REQUEST_ACK) in rxrpc_send_data_packet()
421 * - returns -EMSGSIZE if UDP would have to fragment the packet in rxrpc_send_data_packet()
423 * - in which case, we'll have processed the ICMP error in rxrpc_send_data_packet()
426 rxrpc_inc_stat(call->rxnet, stat_tx_data_send); in rxrpc_send_data_packet()
427 ret = do_udp_sendmsg(conn->local->socket, &msg, len); in rxrpc_send_data_packet()
428 conn->peer->last_tx_at = ktime_get_seconds(); in rxrpc_send_data_packet()
431 rxrpc_inc_stat(call->rxnet, stat_tx_data_send_fail); in rxrpc_send_data_packet()
433 trace_rxrpc_tx_fail(call->debug_id, serial, ret, in rxrpc_send_data_packet()
436 trace_rxrpc_tx_packet(call->debug_id, &txb->wire, in rxrpc_send_data_packet()
441 if (ret == -EMSGSIZE) in rxrpc_send_data_packet()
446 call->tx_last_sent = txb->last_sent; in rxrpc_send_data_packet()
447 if (txb->wire.flags & RXRPC_REQUEST_ACK) { in rxrpc_send_data_packet()
448 call->peer->rtt_last_req = txb->last_sent; in rxrpc_send_data_packet()
449 if (call->peer->rtt_count > 1) { in rxrpc_send_data_packet()
452 ack_lost_at = rxrpc_get_rto_backoff(call->peer, false); in rxrpc_send_data_packet()
454 WRITE_ONCE(call->ack_lost_at, ack_lost_at); in rxrpc_send_data_packet()
460 if (txb->seq == 1 && in rxrpc_send_data_packet()
462 &call->flags)) { in rxrpc_send_data_packet()
465 expect_rx_by = nowj + call->next_rx_timo; in rxrpc_send_data_packet()
466 WRITE_ONCE(call->expect_rx_by, expect_rx_by); in rxrpc_send_data_packet()
478 if (!test_and_set_bit(RXRPC_CALL_BEGAN_RX_TIMER, &call->flags)) in rxrpc_send_data_packet()
483 _leave(" = %d [%u]", ret, call->peer->maxdata); in rxrpc_send_data_packet()
490 txb->last_sent = ktime_get_real(); in rxrpc_send_data_packet()
491 if (txb->wire.flags & RXRPC_REQUEST_ACK) in rxrpc_send_data_packet()
494 switch (conn->local->srx.transport.family) { in rxrpc_send_data_packet()
497 rxrpc_local_dont_fragment(conn->local, false); in rxrpc_send_data_packet()
498 rxrpc_inc_stat(call->rxnet, stat_tx_data_send_frag); in rxrpc_send_data_packet()
499 ret = do_udp_sendmsg(conn->local->socket, &msg, len); in rxrpc_send_data_packet()
500 conn->peer->last_tx_at = ktime_get_seconds(); in rxrpc_send_data_packet()
502 rxrpc_local_dont_fragment(conn->local, true); in rxrpc_send_data_packet()
510 rxrpc_inc_stat(call->rxnet, stat_tx_data_send_fail); in rxrpc_send_data_packet()
512 trace_rxrpc_tx_fail(call->debug_id, serial, ret, in rxrpc_send_data_packet()
515 trace_rxrpc_tx_packet(call->debug_id, &txb->wire, in rxrpc_send_data_packet()
523 * Transmit a connection-level abort.
529 struct kvec iov[2]; in rxrpc_send_conn_abort()
535 msg.msg_name = &conn->peer->srx.transport; in rxrpc_send_conn_abort()
536 msg.msg_namelen = conn->peer->srx.transport_len; in rxrpc_send_conn_abort()
541 whdr.epoch = htonl(conn->proto.epoch); in rxrpc_send_conn_abort()
542 whdr.cid = htonl(conn->proto.cid); in rxrpc_send_conn_abort()
546 whdr.flags = conn->out_clientflag; in rxrpc_send_conn_abort()
548 whdr.securityIndex = conn->security_ix; in rxrpc_send_conn_abort()
550 whdr.serviceId = htons(conn->service_id); in rxrpc_send_conn_abort()
552 word = htonl(conn->abort_code); in rxrpc_send_conn_abort()
564 iov_iter_kvec(&msg.msg_iter, WRITE, iov, 2, len); in rxrpc_send_conn_abort()
565 ret = do_udp_sendmsg(conn->local->socket, &msg, len); in rxrpc_send_conn_abort()
567 trace_rxrpc_tx_fail(conn->debug_id, serial, ret, in rxrpc_send_conn_abort()
573 trace_rxrpc_tx_packet(conn->debug_id, &whdr, rxrpc_tx_point_conn_abort); in rxrpc_send_conn_abort()
575 conn->peer->last_tx_at = ktime_get_seconds(); in rxrpc_send_conn_abort()
587 struct kvec iov[2]; in rxrpc_reject_packet()
606 switch (skb->mark) { in rxrpc_reject_packet()
614 code = htonl(skb->priority); in rxrpc_reject_packet()
616 ioc = 2; in rxrpc_reject_packet()
625 whdr.epoch = htonl(sp->hdr.epoch); in rxrpc_reject_packet()
626 whdr.cid = htonl(sp->hdr.cid); in rxrpc_reject_packet()
627 whdr.callNumber = htonl(sp->hdr.callNumber); in rxrpc_reject_packet()
628 whdr.serviceId = htons(sp->hdr.serviceId); in rxrpc_reject_packet()
629 whdr.flags = sp->hdr.flags; in rxrpc_reject_packet()
634 ret = do_udp_sendmsg(local->socket, &msg, size); in rxrpc_reject_packet()
636 trace_rxrpc_tx_fail(local->debug_id, 0, ret, in rxrpc_reject_packet()
639 trace_rxrpc_tx_packet(local->debug_id, &whdr, in rxrpc_reject_packet()
651 struct kvec iov[2]; in rxrpc_send_keepalive()
657 msg.msg_name = &peer->srx.transport; in rxrpc_send_keepalive()
658 msg.msg_namelen = peer->srx.transport_len; in rxrpc_send_keepalive()
663 whdr.epoch = htonl(peer->local->rxnet->epoch); in rxrpc_send_keepalive()
668 whdr.type = RXRPC_PACKET_TYPE_VERSION; /* Not client-initiated */ in rxrpc_send_keepalive()
682 iov_iter_kvec(&msg.msg_iter, WRITE, iov, 2, len); in rxrpc_send_keepalive()
683 ret = do_udp_sendmsg(peer->local->socket, &msg, len); in rxrpc_send_keepalive()
685 trace_rxrpc_tx_fail(peer->debug_id, 0, ret, in rxrpc_send_keepalive()
688 trace_rxrpc_tx_packet(peer->debug_id, &whdr, in rxrpc_send_keepalive()
691 peer->last_tx_at = ktime_get_seconds(); in rxrpc_send_keepalive()
715 case -ENETUNREACH: in rxrpc_transmit_one()
716 case -EHOSTUNREACH: in rxrpc_transmit_one()
717 case -ECONNREFUSED: in rxrpc_transmit_one()
727 unsigned long resend_at = now + call->peer->rto_j; in rxrpc_transmit_one()
729 WRITE_ONCE(call->resend_at, resend_at); in rxrpc_transmit_one()