rxrpc: Make the I/O thread take over the call and local processor work
[linux-block.git] / net / rxrpc / local_event.c
CommitLineData
2874c5fd 1// SPDX-License-Identifier: GPL-2.0-or-later
87563616
DH
2/* AF_RXRPC local endpoint management
3 *
4 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
87563616
DH
6 */
7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
10#include <linux/module.h>
11#include <linux/net.h>
12#include <linux/skbuff.h>
13#include <linux/slab.h>
87563616
DH
14#include <net/sock.h>
15#include <net/af_rxrpc.h>
16#include <generated/utsrelease.h>
17#include "ar-internal.h"
18
19static const char rxrpc_version_string[65] = "linux-" UTS_RELEASE " AF_RXRPC";
20
21/*
22 * Reply to a version request
23 */
5e6ef4f1
DH
24void rxrpc_send_version_request(struct rxrpc_local *local,
25 struct rxrpc_host_header *hdr,
26 struct sk_buff *skb)
87563616
DH
27{
28 struct rxrpc_wire_header whdr;
29 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
1c2bc7b9 30 struct sockaddr_rxrpc srx;
87563616
DH
31 struct msghdr msg;
32 struct kvec iov[2];
33 size_t len;
34 int ret;
35
36 _enter("");
37
5a790b73 38 if (rxrpc_extract_addr_from_skb(&srx, skb) < 0)
1c2bc7b9 39 return;
87563616 40
1c2bc7b9
DH
41 msg.msg_name = &srx.transport;
42 msg.msg_namelen = srx.transport_len;
87563616
DH
43 msg.msg_control = NULL;
44 msg.msg_controllen = 0;
45 msg.msg_flags = 0;
46
47 whdr.epoch = htonl(sp->hdr.epoch);
48 whdr.cid = htonl(sp->hdr.cid);
49 whdr.callNumber = htonl(sp->hdr.callNumber);
50 whdr.seq = 0;
51 whdr.serial = 0;
52 whdr.type = RXRPC_PACKET_TYPE_VERSION;
53 whdr.flags = RXRPC_LAST_PACKET | (~hdr->flags & RXRPC_CLIENT_INITIATED);
54 whdr.userStatus = 0;
55 whdr.securityIndex = 0;
56 whdr._rsvd = 0;
57 whdr.serviceId = htons(sp->hdr.serviceId);
58
59 iov[0].iov_base = &whdr;
60 iov[0].iov_len = sizeof(whdr);
61 iov[1].iov_base = (char *)rxrpc_version_string;
62 iov[1].iov_len = sizeof(rxrpc_version_string);
63
64 len = iov[0].iov_len + iov[1].iov_len;
65
87563616
DH
66 ret = kernel_sendmsg(local->socket, &msg, iov, 2, len);
67 if (ret < 0)
6b47fe1d 68 trace_rxrpc_tx_fail(local->debug_id, 0, ret,
4764c0da
DH
69 rxrpc_tx_point_version_reply);
70 else
71 trace_rxrpc_tx_packet(local->debug_id, &whdr,
72 rxrpc_tx_point_version_reply);
87563616
DH
73
74 _leave("");
75}