^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* connection-level event handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Written by David Howells (dhowells@redhat.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/errqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <net/af_rxrpc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <net/ip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "ar-internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Retransmit terminal ACK or ABORT of the previous call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct rxrpc_skb_priv *sp = skb ? rxrpc_skb(skb) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct rxrpc_channel *chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct msghdr msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct kvec iov[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct rxrpc_wire_header whdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) __be32 abort_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct rxrpc_ackpacket ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) } __attribute__((packed)) pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct rxrpc_ackinfo ack_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int ret, ioc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) u32 serial, mtu, call_id, padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) _enter("%d", conn->debug_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) chan = &conn->channels[channel];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* If the last call got moved on whilst we were waiting to run, just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * ignore this packet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) call_id = READ_ONCE(chan->last_call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* Sync with __rxrpc_disconnect_call() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) smp_rmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) if (skb && call_id != sp->hdr.callNumber)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) msg.msg_name = &conn->params.peer->srx.transport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) msg.msg_namelen = conn->params.peer->srx.transport_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) msg.msg_control = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) msg.msg_controllen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) msg.msg_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) iov[0].iov_base = &pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) iov[0].iov_len = sizeof(pkt.whdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) iov[1].iov_base = &padding;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) iov[1].iov_len = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) iov[2].iov_base = &ack_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) iov[2].iov_len = sizeof(ack_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) pkt.whdr.epoch = htonl(conn->proto.epoch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) pkt.whdr.cid = htonl(conn->proto.cid | channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) pkt.whdr.callNumber = htonl(call_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) pkt.whdr.seq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) pkt.whdr.type = chan->last_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) pkt.whdr.flags = conn->out_clientflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) pkt.whdr.userStatus = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) pkt.whdr.securityIndex = conn->security_ix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) pkt.whdr._rsvd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) pkt.whdr.serviceId = htons(conn->service_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) len = sizeof(pkt.whdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) switch (chan->last_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) case RXRPC_PACKET_TYPE_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) pkt.abort_code = htonl(chan->last_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) iov[0].iov_len += sizeof(pkt.abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) len += sizeof(pkt.abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) ioc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) case RXRPC_PACKET_TYPE_ACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) mtu = conn->params.peer->if_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) mtu -= conn->params.peer->hdrsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) pkt.ack.bufferSpace = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) pkt.ack.maxSkew = htons(skb ? skb->priority : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) pkt.ack.firstPacket = htonl(chan->last_seq + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) pkt.ack.previousPacket = htonl(chan->last_seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) pkt.ack.serial = htonl(skb ? sp->hdr.serial : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) pkt.ack.reason = skb ? RXRPC_ACK_DUPLICATE : RXRPC_ACK_IDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) pkt.ack.nAcks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) ack_info.rxMTU = htonl(rxrpc_rx_mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) ack_info.maxMTU = htonl(mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ack_info.rwind = htonl(rxrpc_rx_window_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) ack_info.jumbo_max = htonl(rxrpc_rx_jumbo_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) pkt.whdr.flags |= RXRPC_SLOW_START_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) padding = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) iov[0].iov_len += sizeof(pkt.ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) len += sizeof(pkt.ack) + 3 + sizeof(ack_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) ioc = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* Resync with __rxrpc_disconnect_call() and check that the last call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * didn't get advanced whilst we were filling out the packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) smp_rmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (READ_ONCE(chan->last_call) != call_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) serial = atomic_inc_return(&conn->serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) pkt.whdr.serial = htonl(serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) switch (chan->last_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) case RXRPC_PACKET_TYPE_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) _proto("Tx ABORT %%%u { %d } [re]", serial, conn->abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) case RXRPC_PACKET_TYPE_ACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) trace_rxrpc_tx_ack(chan->call_debug_id, serial,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) ntohl(pkt.ack.firstPacket),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ntohl(pkt.ack.serial),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) pkt.ack.reason, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) _proto("Tx ACK %%%u [re]", serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, ioc, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) conn->params.peer->last_tx_at = ktime_get_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) trace_rxrpc_tx_fail(chan->call_debug_id, serial, ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) rxrpc_tx_point_call_final_resend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) trace_rxrpc_tx_packet(chan->call_debug_id, &pkt.whdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) rxrpc_tx_point_call_final_resend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) _leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * pass a connection-level abort onto all calls on that connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static void rxrpc_abort_calls(struct rxrpc_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) enum rxrpc_call_completion compl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) rxrpc_serial_t serial)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct rxrpc_call *call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) _enter("{%d},%x", conn->debug_id, conn->abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) spin_lock(&conn->bundle->channel_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) for (i = 0; i < RXRPC_MAXCALLS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) call = rcu_dereference_protected(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) conn->channels[i].call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) lockdep_is_held(&conn->bundle->channel_lock));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (call) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (compl == RXRPC_CALL_LOCALLY_ABORTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) trace_rxrpc_abort(call->debug_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) "CON", call->cid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) call->call_id, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) conn->abort_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) conn->error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) trace_rxrpc_rx_abort(call, serial,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) conn->abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) rxrpc_set_call_completion(call, compl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) conn->abort_code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) conn->error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) spin_unlock(&conn->bundle->channel_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) _leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * generate a connection-level abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) static int rxrpc_abort_connection(struct rxrpc_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int error, u32 abort_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct rxrpc_wire_header whdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct msghdr msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct kvec iov[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) __be32 word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u32 serial;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) _enter("%d,,%u,%u", conn->debug_id, error, abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /* generate a connection-level abort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) spin_lock_bh(&conn->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) spin_unlock_bh(&conn->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) _leave(" = 0 [already dead]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) conn->error = error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) conn->abort_code = abort_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) conn->state = RXRPC_CONN_LOCALLY_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) spin_unlock_bh(&conn->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) msg.msg_name = &conn->params.peer->srx.transport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) msg.msg_namelen = conn->params.peer->srx.transport_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) msg.msg_control = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) msg.msg_controllen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) msg.msg_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) whdr.epoch = htonl(conn->proto.epoch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) whdr.cid = htonl(conn->proto.cid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) whdr.callNumber = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) whdr.seq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) whdr.type = RXRPC_PACKET_TYPE_ABORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) whdr.flags = conn->out_clientflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) whdr.userStatus = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) whdr.securityIndex = conn->security_ix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) whdr._rsvd = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) whdr.serviceId = htons(conn->service_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) word = htonl(conn->abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) iov[0].iov_base = &whdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) iov[0].iov_len = sizeof(whdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) iov[1].iov_base = &word;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) iov[1].iov_len = sizeof(word);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) len = iov[0].iov_len + iov[1].iov_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) serial = atomic_inc_return(&conn->serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) whdr.serial = htonl(serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) _proto("Tx CONN ABORT %%%u { %d }", serial, conn->abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) trace_rxrpc_tx_fail(conn->debug_id, serial, ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) rxrpc_tx_point_conn_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) _debug("sendmsg failed: %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) trace_rxrpc_tx_packet(conn->debug_id, &whdr, rxrpc_tx_point_conn_abort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) conn->params.peer->last_tx_at = ktime_get_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) _leave(" = 0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * mark a call as being on a now-secured channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * - must be called with BH's disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static void rxrpc_call_is_secure(struct rxrpc_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) _enter("%p", call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (call) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) write_lock_bh(&call->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (call->state == RXRPC_CALL_SERVER_SECURING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) call->state = RXRPC_CALL_SERVER_RECV_REQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) rxrpc_notify_socket(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) write_unlock_bh(&call->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * connection-level Rx packet processor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static int rxrpc_process_event(struct rxrpc_connection *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u32 *_abort_code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) __be32 wtmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) u32 abort_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int loop, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) _leave(" = -ECONNABORTED [%u]", conn->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) return -ECONNABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) _enter("{%d},{%u,%%%u},", conn->debug_id, sp->hdr.type, sp->hdr.serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) switch (sp->hdr.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) case RXRPC_PACKET_TYPE_DATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) case RXRPC_PACKET_TYPE_ACK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) rxrpc_conn_retransmit_call(conn, skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) sp->hdr.cid & RXRPC_CHANNELMASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) case RXRPC_PACKET_TYPE_BUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /* Just ignore BUSY packets for now. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) case RXRPC_PACKET_TYPE_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) &wtmp, sizeof(wtmp)) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) tracepoint_string("bad_abort"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) return -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) abort_code = ntohl(wtmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) conn->error = -ECONNABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) conn->abort_code = abort_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) conn->state = RXRPC_CONN_REMOTELY_ABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED, sp->hdr.serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return -ECONNABORTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) case RXRPC_PACKET_TYPE_CHALLENGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) return conn->security->respond_to_challenge(conn, skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) _abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) case RXRPC_PACKET_TYPE_RESPONSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ret = conn->security->verify_response(conn, skb, _abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ret = conn->security->init_connection_security(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) ret = conn->security->prime_packet_security(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) spin_lock(&conn->bundle->channel_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) spin_lock_bh(&conn->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) if (conn->state == RXRPC_CONN_SERVICE_CHALLENGING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) conn->state = RXRPC_CONN_SERVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) spin_unlock_bh(&conn->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) for (loop = 0; loop < RXRPC_MAXCALLS; loop++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) rxrpc_call_is_secure(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) rcu_dereference_protected(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) conn->channels[loop].call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) lockdep_is_held(&conn->bundle->channel_lock)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) spin_unlock_bh(&conn->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) spin_unlock(&conn->bundle->channel_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) tracepoint_string("bad_conn_pkt"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * set up security and issue a challenge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) static void rxrpc_secure_connection(struct rxrpc_connection *conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) u32 abort_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) _enter("{%d}", conn->debug_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) ASSERT(conn->security_ix != 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) ASSERT(conn->server_key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if (conn->security->issue_challenge(conn) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) abort_code = RX_CALL_DEAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) goto abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) _leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) abort:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) _debug("abort %d, %d", ret, abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) rxrpc_abort_connection(conn, ret, abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) _leave(" [aborted]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * Process delayed final ACKs that we haven't subsumed into a subsequent call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) void rxrpc_process_delayed_final_acks(struct rxrpc_connection *conn, bool force)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) unsigned long j = jiffies, next_j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) unsigned int channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) bool set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) next_j = j + LONG_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) set = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) for (channel = 0; channel < RXRPC_MAXCALLS; channel++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) struct rxrpc_channel *chan = &conn->channels[channel];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) unsigned long ack_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) if (!test_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) smp_rmb(); /* vs rxrpc_disconnect_client_call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) ack_at = READ_ONCE(chan->final_ack_at);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (time_before(j, ack_at) && !force) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) if (time_before(ack_at, next_j)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) next_j = ack_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) set = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (test_and_clear_bit(RXRPC_CONN_FINAL_ACK_0 + channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) &conn->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) rxrpc_conn_retransmit_call(conn, NULL, channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) j = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) if (time_before_eq(next_j, j))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) goto again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) if (set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) rxrpc_reduce_conn_timer(conn, next_j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) * connection-level event processor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static void rxrpc_do_process_connection(struct rxrpc_connection *conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) u32 abort_code = RX_PROTOCOL_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (test_and_clear_bit(RXRPC_CONN_EV_CHALLENGE, &conn->events))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) rxrpc_secure_connection(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* Process delayed ACKs whose time has come. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) if (conn->flags & RXRPC_CONN_FINAL_ACK_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) rxrpc_process_delayed_final_acks(conn, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /* go through the conn-level event packets, releasing the ref on this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * connection that each one has when we've finished with it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) while ((skb = skb_dequeue(&conn->rx_queue))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) rxrpc_see_skb(skb, rxrpc_skb_seen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) ret = rxrpc_process_event(conn, skb, &abort_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) case -EPROTO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) case -EKEYEXPIRED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) case -EKEYREJECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) goto protocol_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) case -ENOMEM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) case -EAGAIN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) goto requeue_and_leave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) case -ECONNABORTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) rxrpc_free_skb(skb, rxrpc_skb_freed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) requeue_and_leave:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) skb_queue_head(&conn->rx_queue, skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) protocol_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) if (rxrpc_abort_connection(conn, ret, abort_code) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) goto requeue_and_leave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) rxrpc_free_skb(skb, rxrpc_skb_freed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) void rxrpc_process_connection(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) struct rxrpc_connection *conn =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) container_of(work, struct rxrpc_connection, processor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) rxrpc_see_connection(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) if (__rxrpc_use_local(conn->params.local)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) rxrpc_do_process_connection(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) rxrpc_unuse_local(conn->params.local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) rxrpc_put_connection(conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) _leave("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) }