1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun====================== 4*4882a593SmuzhiyunRxRPC Network Protocol 5*4882a593Smuzhiyun====================== 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThe RxRPC protocol driver provides a reliable two-phase transport on top of UDP 8*4882a593Smuzhiyunthat can be used to perform RxRPC remote operations. This is done over sockets 9*4882a593Smuzhiyunof AF_RXRPC family, using sendmsg() and recvmsg() with control data to send and 10*4882a593Smuzhiyunreceive data, aborts and errors. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunContents of this document: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun (#) Overview. 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun (#) RxRPC protocol summary. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun (#) AF_RXRPC driver model. 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun (#) Control messages. 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun (#) Socket options. 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun (#) Security. 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun (#) Example client usage. 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun (#) Example server usage. 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun (#) AF_RXRPC kernel interface. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun (#) Configurable parameters. 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunOverview 36*4882a593Smuzhiyun======== 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunRxRPC is a two-layer protocol. There is a session layer which provides 39*4882a593Smuzhiyunreliable virtual connections using UDP over IPv4 (or IPv6) as the transport 40*4882a593Smuzhiyunlayer, but implements a real network protocol; and there's the presentation 41*4882a593Smuzhiyunlayer which renders structured data to binary blobs and back again using XDR 42*4882a593Smuzhiyun(as does SunRPC):: 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun +-------------+ 45*4882a593Smuzhiyun | Application | 46*4882a593Smuzhiyun +-------------+ 47*4882a593Smuzhiyun | XDR | Presentation 48*4882a593Smuzhiyun +-------------+ 49*4882a593Smuzhiyun | RxRPC | Session 50*4882a593Smuzhiyun +-------------+ 51*4882a593Smuzhiyun | UDP | Transport 52*4882a593Smuzhiyun +-------------+ 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunAF_RXRPC provides: 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun (1) Part of an RxRPC facility for both kernel and userspace applications by 58*4882a593Smuzhiyun making the session part of it a Linux network protocol (AF_RXRPC). 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun (2) A two-phase protocol. The client transmits a blob (the request) and then 61*4882a593Smuzhiyun receives a blob (the reply), and the server receives the request and then 62*4882a593Smuzhiyun transmits the reply. 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun (3) Retention of the reusable bits of the transport system set up for one call 65*4882a593Smuzhiyun to speed up subsequent calls. 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun (4) A secure protocol, using the Linux kernel's key retention facility to 68*4882a593Smuzhiyun manage security on the client end. The server end must of necessity be 69*4882a593Smuzhiyun more active in security negotiations. 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunAF_RXRPC does not provide XDR marshalling/presentation facilities. That is 72*4882a593Smuzhiyunleft to the application. AF_RXRPC only deals in blobs. Even the operation ID 73*4882a593Smuzhiyunis just the first four bytes of the request blob, and as such is beyond the 74*4882a593Smuzhiyunkernel's interest. 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunSockets of AF_RXRPC family are: 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun (1) created as type SOCK_DGRAM; 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun (2) provided with a protocol of the type of underlying transport they're going 82*4882a593Smuzhiyun to use - currently only PF_INET is supported. 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun 85*4882a593SmuzhiyunThe Andrew File System (AFS) is an example of an application that uses this and 86*4882a593Smuzhiyunthat has both kernel (filesystem) and userspace (utility) components. 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun 89*4882a593SmuzhiyunRxRPC Protocol Summary 90*4882a593Smuzhiyun====================== 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunAn overview of the RxRPC protocol: 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun (#) RxRPC sits on top of another networking protocol (UDP is the only option 95*4882a593Smuzhiyun currently), and uses this to provide network transport. UDP ports, for 96*4882a593Smuzhiyun example, provide transport endpoints. 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun (#) RxRPC supports multiple virtual "connections" from any given transport 99*4882a593Smuzhiyun endpoint, thus allowing the endpoints to be shared, even to the same 100*4882a593Smuzhiyun remote endpoint. 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun (#) Each connection goes to a particular "service". A connection may not go 103*4882a593Smuzhiyun to multiple services. A service may be considered the RxRPC equivalent of 104*4882a593Smuzhiyun a port number. AF_RXRPC permits multiple services to share an endpoint. 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun (#) Client-originating packets are marked, thus a transport endpoint can be 107*4882a593Smuzhiyun shared between client and server connections (connections have a 108*4882a593Smuzhiyun direction). 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun (#) Up to a billion connections may be supported concurrently between one 111*4882a593Smuzhiyun local transport endpoint and one service on one remote endpoint. An RxRPC 112*4882a593Smuzhiyun connection is described by seven numbers:: 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun Local address } 115*4882a593Smuzhiyun Local port } Transport (UDP) address 116*4882a593Smuzhiyun Remote address } 117*4882a593Smuzhiyun Remote port } 118*4882a593Smuzhiyun Direction 119*4882a593Smuzhiyun Connection ID 120*4882a593Smuzhiyun Service ID 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun (#) Each RxRPC operation is a "call". A connection may make up to four 123*4882a593Smuzhiyun billion calls, but only up to four calls may be in progress on a 124*4882a593Smuzhiyun connection at any one time. 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun (#) Calls are two-phase and asymmetric: the client sends its request data, 127*4882a593Smuzhiyun which the service receives; then the service transmits the reply data 128*4882a593Smuzhiyun which the client receives. 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun (#) The data blobs are of indefinite size, the end of a phase is marked with a 131*4882a593Smuzhiyun flag in the packet. The number of packets of data making up one blob may 132*4882a593Smuzhiyun not exceed 4 billion, however, as this would cause the sequence number to 133*4882a593Smuzhiyun wrap. 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun (#) The first four bytes of the request data are the service operation ID. 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun (#) Security is negotiated on a per-connection basis. The connection is 138*4882a593Smuzhiyun initiated by the first data packet on it arriving. If security is 139*4882a593Smuzhiyun requested, the server then issues a "challenge" and then the client 140*4882a593Smuzhiyun replies with a "response". If the response is successful, the security is 141*4882a593Smuzhiyun set for the lifetime of that connection, and all subsequent calls made 142*4882a593Smuzhiyun upon it use that same security. In the event that the server lets a 143*4882a593Smuzhiyun connection lapse before the client, the security will be renegotiated if 144*4882a593Smuzhiyun the client uses the connection again. 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun (#) Calls use ACK packets to handle reliability. Data packets are also 147*4882a593Smuzhiyun explicitly sequenced per call. 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun (#) There are two types of positive acknowledgment: hard-ACKs and soft-ACKs. 150*4882a593Smuzhiyun A hard-ACK indicates to the far side that all the data received to a point 151*4882a593Smuzhiyun has been received and processed; a soft-ACK indicates that the data has 152*4882a593Smuzhiyun been received but may yet be discarded and re-requested. The sender may 153*4882a593Smuzhiyun not discard any transmittable packets until they've been hard-ACK'd. 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun (#) Reception of a reply data packet implicitly hard-ACK's all the data 156*4882a593Smuzhiyun packets that make up the request. 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun (#) An call is complete when the request has been sent, the reply has been 159*4882a593Smuzhiyun received and the final hard-ACK on the last packet of the reply has 160*4882a593Smuzhiyun reached the server. 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun (#) An call may be aborted by either end at any time up to its completion. 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun 165*4882a593SmuzhiyunAF_RXRPC Driver Model 166*4882a593Smuzhiyun===================== 167*4882a593Smuzhiyun 168*4882a593SmuzhiyunAbout the AF_RXRPC driver: 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun (#) The AF_RXRPC protocol transparently uses internal sockets of the transport 171*4882a593Smuzhiyun protocol to represent transport endpoints. 172*4882a593Smuzhiyun 173*4882a593Smuzhiyun (#) AF_RXRPC sockets map onto RxRPC connection bundles. Actual RxRPC 174*4882a593Smuzhiyun connections are handled transparently. One client socket may be used to 175*4882a593Smuzhiyun make multiple simultaneous calls to the same service. One server socket 176*4882a593Smuzhiyun may handle calls from many clients. 177*4882a593Smuzhiyun 178*4882a593Smuzhiyun (#) Additional parallel client connections will be initiated to support extra 179*4882a593Smuzhiyun concurrent calls, up to a tunable limit. 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun (#) Each connection is retained for a certain amount of time [tunable] after 182*4882a593Smuzhiyun the last call currently using it has completed in case a new call is made 183*4882a593Smuzhiyun that could reuse it. 184*4882a593Smuzhiyun 185*4882a593Smuzhiyun (#) Each internal UDP socket is retained [tunable] for a certain amount of 186*4882a593Smuzhiyun time [tunable] after the last connection using it discarded, in case a new 187*4882a593Smuzhiyun connection is made that could use it. 188*4882a593Smuzhiyun 189*4882a593Smuzhiyun (#) A client-side connection is only shared between calls if they have 190*4882a593Smuzhiyun the same key struct describing their security (and assuming the calls 191*4882a593Smuzhiyun would otherwise share the connection). Non-secured calls would also be 192*4882a593Smuzhiyun able to share connections with each other. 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun (#) A server-side connection is shared if the client says it is. 195*4882a593Smuzhiyun 196*4882a593Smuzhiyun (#) ACK'ing is handled by the protocol driver automatically, including ping 197*4882a593Smuzhiyun replying. 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun (#) SO_KEEPALIVE automatically pings the other side to keep the connection 200*4882a593Smuzhiyun alive [TODO]. 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun (#) If an ICMP error is received, all calls affected by that error will be 203*4882a593Smuzhiyun aborted with an appropriate network error passed through recvmsg(). 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun 206*4882a593SmuzhiyunInteraction with the user of the RxRPC socket: 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun (#) A socket is made into a server socket by binding an address with a 209*4882a593Smuzhiyun non-zero service ID. 210*4882a593Smuzhiyun 211*4882a593Smuzhiyun (#) In the client, sending a request is achieved with one or more sendmsgs, 212*4882a593Smuzhiyun followed by the reply being received with one or more recvmsgs. 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun (#) The first sendmsg for a request to be sent from a client contains a tag to 215*4882a593Smuzhiyun be used in all other sendmsgs or recvmsgs associated with that call. The 216*4882a593Smuzhiyun tag is carried in the control data. 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun (#) connect() is used to supply a default destination address for a client 219*4882a593Smuzhiyun socket. This may be overridden by supplying an alternate address to the 220*4882a593Smuzhiyun first sendmsg() of a call (struct msghdr::msg_name). 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun (#) If connect() is called on an unbound client, a random local port will 223*4882a593Smuzhiyun bound before the operation takes place. 224*4882a593Smuzhiyun 225*4882a593Smuzhiyun (#) A server socket may also be used to make client calls. To do this, the 226*4882a593Smuzhiyun first sendmsg() of the call must specify the target address. The server's 227*4882a593Smuzhiyun transport endpoint is used to send the packets. 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun (#) Once the application has received the last message associated with a call, 230*4882a593Smuzhiyun the tag is guaranteed not to be seen again, and so it can be used to pin 231*4882a593Smuzhiyun client resources. A new call can then be initiated with the same tag 232*4882a593Smuzhiyun without fear of interference. 233*4882a593Smuzhiyun 234*4882a593Smuzhiyun (#) In the server, a request is received with one or more recvmsgs, then the 235*4882a593Smuzhiyun the reply is transmitted with one or more sendmsgs, and then the final ACK 236*4882a593Smuzhiyun is received with a last recvmsg. 237*4882a593Smuzhiyun 238*4882a593Smuzhiyun (#) When sending data for a call, sendmsg is given MSG_MORE if there's more 239*4882a593Smuzhiyun data to come on that call. 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun (#) When receiving data for a call, recvmsg flags MSG_MORE if there's more 242*4882a593Smuzhiyun data to come for that call. 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun (#) When receiving data or messages for a call, MSG_EOR is flagged by recvmsg 245*4882a593Smuzhiyun to indicate the terminal message for that call. 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun (#) A call may be aborted by adding an abort control message to the control 248*4882a593Smuzhiyun data. Issuing an abort terminates the kernel's use of that call's tag. 249*4882a593Smuzhiyun Any messages waiting in the receive queue for that call will be discarded. 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun (#) Aborts, busy notifications and challenge packets are delivered by recvmsg, 252*4882a593Smuzhiyun and control data messages will be set to indicate the context. Receiving 253*4882a593Smuzhiyun an abort or a busy message terminates the kernel's use of that call's tag. 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun (#) The control data part of the msghdr struct is used for a number of things: 256*4882a593Smuzhiyun 257*4882a593Smuzhiyun (#) The tag of the intended or affected call. 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun (#) Sending or receiving errors, aborts and busy notifications. 260*4882a593Smuzhiyun 261*4882a593Smuzhiyun (#) Notifications of incoming calls. 262*4882a593Smuzhiyun 263*4882a593Smuzhiyun (#) Sending debug requests and receiving debug replies [TODO]. 264*4882a593Smuzhiyun 265*4882a593Smuzhiyun (#) When the kernel has received and set up an incoming call, it sends a 266*4882a593Smuzhiyun message to server application to let it know there's a new call awaiting 267*4882a593Smuzhiyun its acceptance [recvmsg reports a special control message]. The server 268*4882a593Smuzhiyun application then uses sendmsg to assign a tag to the new call. Once that 269*4882a593Smuzhiyun is done, the first part of the request data will be delivered by recvmsg. 270*4882a593Smuzhiyun 271*4882a593Smuzhiyun (#) The server application has to provide the server socket with a keyring of 272*4882a593Smuzhiyun secret keys corresponding to the security types it permits. When a secure 273*4882a593Smuzhiyun connection is being set up, the kernel looks up the appropriate secret key 274*4882a593Smuzhiyun in the keyring and then sends a challenge packet to the client and 275*4882a593Smuzhiyun receives a response packet. The kernel then checks the authorisation of 276*4882a593Smuzhiyun the packet and either aborts the connection or sets up the security. 277*4882a593Smuzhiyun 278*4882a593Smuzhiyun (#) The name of the key a client will use to secure its communications is 279*4882a593Smuzhiyun nominated by a socket option. 280*4882a593Smuzhiyun 281*4882a593Smuzhiyun 282*4882a593SmuzhiyunNotes on sendmsg: 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun (#) MSG_WAITALL can be set to tell sendmsg to ignore signals if the peer is 285*4882a593Smuzhiyun making progress at accepting packets within a reasonable time such that we 286*4882a593Smuzhiyun manage to queue up all the data for transmission. This requires the 287*4882a593Smuzhiyun client to accept at least one packet per 2*RTT time period. 288*4882a593Smuzhiyun 289*4882a593Smuzhiyun If this isn't set, sendmsg() will return immediately, either returning 290*4882a593Smuzhiyun EINTR/ERESTARTSYS if nothing was consumed or returning the amount of data 291*4882a593Smuzhiyun consumed. 292*4882a593Smuzhiyun 293*4882a593Smuzhiyun 294*4882a593SmuzhiyunNotes on recvmsg: 295*4882a593Smuzhiyun 296*4882a593Smuzhiyun (#) If there's a sequence of data messages belonging to a particular call on 297*4882a593Smuzhiyun the receive queue, then recvmsg will keep working through them until: 298*4882a593Smuzhiyun 299*4882a593Smuzhiyun (a) it meets the end of that call's received data, 300*4882a593Smuzhiyun 301*4882a593Smuzhiyun (b) it meets a non-data message, 302*4882a593Smuzhiyun 303*4882a593Smuzhiyun (c) it meets a message belonging to a different call, or 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun (d) it fills the user buffer. 306*4882a593Smuzhiyun 307*4882a593Smuzhiyun If recvmsg is called in blocking mode, it will keep sleeping, awaiting the 308*4882a593Smuzhiyun reception of further data, until one of the above four conditions is met. 309*4882a593Smuzhiyun 310*4882a593Smuzhiyun (2) MSG_PEEK operates similarly, but will return immediately if it has put any 311*4882a593Smuzhiyun data in the buffer rather than sleeping until it can fill the buffer. 312*4882a593Smuzhiyun 313*4882a593Smuzhiyun (3) If a data message is only partially consumed in filling a user buffer, 314*4882a593Smuzhiyun then the remainder of that message will be left on the front of the queue 315*4882a593Smuzhiyun for the next taker. MSG_TRUNC will never be flagged. 316*4882a593Smuzhiyun 317*4882a593Smuzhiyun (4) If there is more data to be had on a call (it hasn't copied the last byte 318*4882a593Smuzhiyun of the last data message in that phase yet), then MSG_MORE will be 319*4882a593Smuzhiyun flagged. 320*4882a593Smuzhiyun 321*4882a593Smuzhiyun 322*4882a593SmuzhiyunControl Messages 323*4882a593Smuzhiyun================ 324*4882a593Smuzhiyun 325*4882a593SmuzhiyunAF_RXRPC makes use of control messages in sendmsg() and recvmsg() to multiplex 326*4882a593Smuzhiyuncalls, to invoke certain actions and to report certain conditions. These are: 327*4882a593Smuzhiyun 328*4882a593Smuzhiyun ======================= === =========== =============================== 329*4882a593Smuzhiyun MESSAGE ID SRT DATA MEANING 330*4882a593Smuzhiyun ======================= === =========== =============================== 331*4882a593Smuzhiyun RXRPC_USER_CALL_ID sr- User ID App's call specifier 332*4882a593Smuzhiyun RXRPC_ABORT srt Abort code Abort code to issue/received 333*4882a593Smuzhiyun RXRPC_ACK -rt n/a Final ACK received 334*4882a593Smuzhiyun RXRPC_NET_ERROR -rt error num Network error on call 335*4882a593Smuzhiyun RXRPC_BUSY -rt n/a Call rejected (server busy) 336*4882a593Smuzhiyun RXRPC_LOCAL_ERROR -rt error num Local error encountered 337*4882a593Smuzhiyun RXRPC_NEW_CALL -r- n/a New call received 338*4882a593Smuzhiyun RXRPC_ACCEPT s-- n/a Accept new call 339*4882a593Smuzhiyun RXRPC_EXCLUSIVE_CALL s-- n/a Make an exclusive client call 340*4882a593Smuzhiyun RXRPC_UPGRADE_SERVICE s-- n/a Client call can be upgraded 341*4882a593Smuzhiyun RXRPC_TX_LENGTH s-- data len Total length of Tx data 342*4882a593Smuzhiyun ======================= === =========== =============================== 343*4882a593Smuzhiyun 344*4882a593Smuzhiyun (SRT = usable in Sendmsg / delivered by Recvmsg / Terminal message) 345*4882a593Smuzhiyun 346*4882a593Smuzhiyun (#) RXRPC_USER_CALL_ID 347*4882a593Smuzhiyun 348*4882a593Smuzhiyun This is used to indicate the application's call ID. It's an unsigned long 349*4882a593Smuzhiyun that the app specifies in the client by attaching it to the first data 350*4882a593Smuzhiyun message or in the server by passing it in association with an RXRPC_ACCEPT 351*4882a593Smuzhiyun message. recvmsg() passes it in conjunction with all messages except 352*4882a593Smuzhiyun those of the RXRPC_NEW_CALL message. 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun (#) RXRPC_ABORT 355*4882a593Smuzhiyun 356*4882a593Smuzhiyun This is can be used by an application to abort a call by passing it to 357*4882a593Smuzhiyun sendmsg, or it can be delivered by recvmsg to indicate a remote abort was 358*4882a593Smuzhiyun received. Either way, it must be associated with an RXRPC_USER_CALL_ID to 359*4882a593Smuzhiyun specify the call affected. If an abort is being sent, then error EBADSLT 360*4882a593Smuzhiyun will be returned if there is no call with that user ID. 361*4882a593Smuzhiyun 362*4882a593Smuzhiyun (#) RXRPC_ACK 363*4882a593Smuzhiyun 364*4882a593Smuzhiyun This is delivered to a server application to indicate that the final ACK 365*4882a593Smuzhiyun of a call was received from the client. It will be associated with an 366*4882a593Smuzhiyun RXRPC_USER_CALL_ID to indicate the call that's now complete. 367*4882a593Smuzhiyun 368*4882a593Smuzhiyun (#) RXRPC_NET_ERROR 369*4882a593Smuzhiyun 370*4882a593Smuzhiyun This is delivered to an application to indicate that an ICMP error message 371*4882a593Smuzhiyun was encountered in the process of trying to talk to the peer. An 372*4882a593Smuzhiyun errno-class integer value will be included in the control message data 373*4882a593Smuzhiyun indicating the problem, and an RXRPC_USER_CALL_ID will indicate the call 374*4882a593Smuzhiyun affected. 375*4882a593Smuzhiyun 376*4882a593Smuzhiyun (#) RXRPC_BUSY 377*4882a593Smuzhiyun 378*4882a593Smuzhiyun This is delivered to a client application to indicate that a call was 379*4882a593Smuzhiyun rejected by the server due to the server being busy. It will be 380*4882a593Smuzhiyun associated with an RXRPC_USER_CALL_ID to indicate the rejected call. 381*4882a593Smuzhiyun 382*4882a593Smuzhiyun (#) RXRPC_LOCAL_ERROR 383*4882a593Smuzhiyun 384*4882a593Smuzhiyun This is delivered to an application to indicate that a local error was 385*4882a593Smuzhiyun encountered and that a call has been aborted because of it. An 386*4882a593Smuzhiyun errno-class integer value will be included in the control message data 387*4882a593Smuzhiyun indicating the problem, and an RXRPC_USER_CALL_ID will indicate the call 388*4882a593Smuzhiyun affected. 389*4882a593Smuzhiyun 390*4882a593Smuzhiyun (#) RXRPC_NEW_CALL 391*4882a593Smuzhiyun 392*4882a593Smuzhiyun This is delivered to indicate to a server application that a new call has 393*4882a593Smuzhiyun arrived and is awaiting acceptance. No user ID is associated with this, 394*4882a593Smuzhiyun as a user ID must subsequently be assigned by doing an RXRPC_ACCEPT. 395*4882a593Smuzhiyun 396*4882a593Smuzhiyun (#) RXRPC_ACCEPT 397*4882a593Smuzhiyun 398*4882a593Smuzhiyun This is used by a server application to attempt to accept a call and 399*4882a593Smuzhiyun assign it a user ID. It should be associated with an RXRPC_USER_CALL_ID 400*4882a593Smuzhiyun to indicate the user ID to be assigned. If there is no call to be 401*4882a593Smuzhiyun accepted (it may have timed out, been aborted, etc.), then sendmsg will 402*4882a593Smuzhiyun return error ENODATA. If the user ID is already in use by another call, 403*4882a593Smuzhiyun then error EBADSLT will be returned. 404*4882a593Smuzhiyun 405*4882a593Smuzhiyun (#) RXRPC_EXCLUSIVE_CALL 406*4882a593Smuzhiyun 407*4882a593Smuzhiyun This is used to indicate that a client call should be made on a one-off 408*4882a593Smuzhiyun connection. The connection is discarded once the call has terminated. 409*4882a593Smuzhiyun 410*4882a593Smuzhiyun (#) RXRPC_UPGRADE_SERVICE 411*4882a593Smuzhiyun 412*4882a593Smuzhiyun This is used to make a client call to probe if the specified service ID 413*4882a593Smuzhiyun may be upgraded by the server. The caller must check msg_name returned to 414*4882a593Smuzhiyun recvmsg() for the service ID actually in use. The operation probed must 415*4882a593Smuzhiyun be one that takes the same arguments in both services. 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun Once this has been used to establish the upgrade capability (or lack 418*4882a593Smuzhiyun thereof) of the server, the service ID returned should be used for all 419*4882a593Smuzhiyun future communication to that server and RXRPC_UPGRADE_SERVICE should no 420*4882a593Smuzhiyun longer be set. 421*4882a593Smuzhiyun 422*4882a593Smuzhiyun (#) RXRPC_TX_LENGTH 423*4882a593Smuzhiyun 424*4882a593Smuzhiyun This is used to inform the kernel of the total amount of data that is 425*4882a593Smuzhiyun going to be transmitted by a call (whether in a client request or a 426*4882a593Smuzhiyun service response). If given, it allows the kernel to encrypt from the 427*4882a593Smuzhiyun userspace buffer directly to the packet buffers, rather than copying into 428*4882a593Smuzhiyun the buffer and then encrypting in place. This may only be given with the 429*4882a593Smuzhiyun first sendmsg() providing data for a call. EMSGSIZE will be generated if 430*4882a593Smuzhiyun the amount of data actually given is different. 431*4882a593Smuzhiyun 432*4882a593Smuzhiyun This takes a parameter of __s64 type that indicates how much will be 433*4882a593Smuzhiyun transmitted. This may not be less than zero. 434*4882a593Smuzhiyun 435*4882a593SmuzhiyunThe symbol RXRPC__SUPPORTED is defined as one more than the highest control 436*4882a593Smuzhiyunmessage type supported. At run time this can be queried by means of the 437*4882a593SmuzhiyunRXRPC_SUPPORTED_CMSG socket option (see below). 438*4882a593Smuzhiyun 439*4882a593Smuzhiyun 440*4882a593Smuzhiyun============== 441*4882a593SmuzhiyunSOCKET OPTIONS 442*4882a593Smuzhiyun============== 443*4882a593Smuzhiyun 444*4882a593SmuzhiyunAF_RXRPC sockets support a few socket options at the SOL_RXRPC level: 445*4882a593Smuzhiyun 446*4882a593Smuzhiyun (#) RXRPC_SECURITY_KEY 447*4882a593Smuzhiyun 448*4882a593Smuzhiyun This is used to specify the description of the key to be used. The key is 449*4882a593Smuzhiyun extracted from the calling process's keyrings with request_key() and 450*4882a593Smuzhiyun should be of "rxrpc" type. 451*4882a593Smuzhiyun 452*4882a593Smuzhiyun The optval pointer points to the description string, and optlen indicates 453*4882a593Smuzhiyun how long the string is, without the NUL terminator. 454*4882a593Smuzhiyun 455*4882a593Smuzhiyun (#) RXRPC_SECURITY_KEYRING 456*4882a593Smuzhiyun 457*4882a593Smuzhiyun Similar to above but specifies a keyring of server secret keys to use (key 458*4882a593Smuzhiyun type "keyring"). See the "Security" section. 459*4882a593Smuzhiyun 460*4882a593Smuzhiyun (#) RXRPC_EXCLUSIVE_CONNECTION 461*4882a593Smuzhiyun 462*4882a593Smuzhiyun This is used to request that new connections should be used for each call 463*4882a593Smuzhiyun made subsequently on this socket. optval should be NULL and optlen 0. 464*4882a593Smuzhiyun 465*4882a593Smuzhiyun (#) RXRPC_MIN_SECURITY_LEVEL 466*4882a593Smuzhiyun 467*4882a593Smuzhiyun This is used to specify the minimum security level required for calls on 468*4882a593Smuzhiyun this socket. optval must point to an int containing one of the following 469*4882a593Smuzhiyun values: 470*4882a593Smuzhiyun 471*4882a593Smuzhiyun (a) RXRPC_SECURITY_PLAIN 472*4882a593Smuzhiyun 473*4882a593Smuzhiyun Encrypted checksum only. 474*4882a593Smuzhiyun 475*4882a593Smuzhiyun (b) RXRPC_SECURITY_AUTH 476*4882a593Smuzhiyun 477*4882a593Smuzhiyun Encrypted checksum plus packet padded and first eight bytes of packet 478*4882a593Smuzhiyun encrypted - which includes the actual packet length. 479*4882a593Smuzhiyun 480*4882a593Smuzhiyun (c) RXRPC_SECURITY_ENCRYPT 481*4882a593Smuzhiyun 482*4882a593Smuzhiyun Encrypted checksum plus entire packet padded and encrypted, including 483*4882a593Smuzhiyun actual packet length. 484*4882a593Smuzhiyun 485*4882a593Smuzhiyun (#) RXRPC_UPGRADEABLE_SERVICE 486*4882a593Smuzhiyun 487*4882a593Smuzhiyun This is used to indicate that a service socket with two bindings may 488*4882a593Smuzhiyun upgrade one bound service to the other if requested by the client. optval 489*4882a593Smuzhiyun must point to an array of two unsigned short ints. The first is the 490*4882a593Smuzhiyun service ID to upgrade from and the second the service ID to upgrade to. 491*4882a593Smuzhiyun 492*4882a593Smuzhiyun (#) RXRPC_SUPPORTED_CMSG 493*4882a593Smuzhiyun 494*4882a593Smuzhiyun This is a read-only option that writes an int into the buffer indicating 495*4882a593Smuzhiyun the highest control message type supported. 496*4882a593Smuzhiyun 497*4882a593Smuzhiyun 498*4882a593Smuzhiyun======== 499*4882a593SmuzhiyunSECURITY 500*4882a593Smuzhiyun======== 501*4882a593Smuzhiyun 502*4882a593SmuzhiyunCurrently, only the kerberos 4 equivalent protocol has been implemented 503*4882a593Smuzhiyun(security index 2 - rxkad). This requires the rxkad module to be loaded and, 504*4882a593Smuzhiyunon the client, tickets of the appropriate type to be obtained from the AFS 505*4882a593Smuzhiyunkaserver or the kerberos server and installed as "rxrpc" type keys. This is 506*4882a593Smuzhiyunnormally done using the klog program. An example simple klog program can be 507*4882a593Smuzhiyunfound at: 508*4882a593Smuzhiyun 509*4882a593Smuzhiyun http://people.redhat.com/~dhowells/rxrpc/klog.c 510*4882a593Smuzhiyun 511*4882a593SmuzhiyunThe payload provided to add_key() on the client should be of the following 512*4882a593Smuzhiyunform:: 513*4882a593Smuzhiyun 514*4882a593Smuzhiyun struct rxrpc_key_sec2_v1 { 515*4882a593Smuzhiyun uint16_t security_index; /* 2 */ 516*4882a593Smuzhiyun uint16_t ticket_length; /* length of ticket[] */ 517*4882a593Smuzhiyun uint32_t expiry; /* time at which expires */ 518*4882a593Smuzhiyun uint8_t kvno; /* key version number */ 519*4882a593Smuzhiyun uint8_t __pad[3]; 520*4882a593Smuzhiyun uint8_t session_key[8]; /* DES session key */ 521*4882a593Smuzhiyun uint8_t ticket[0]; /* the encrypted ticket */ 522*4882a593Smuzhiyun }; 523*4882a593Smuzhiyun 524*4882a593SmuzhiyunWhere the ticket blob is just appended to the above structure. 525*4882a593Smuzhiyun 526*4882a593Smuzhiyun 527*4882a593SmuzhiyunFor the server, keys of type "rxrpc_s" must be made available to the server. 528*4882a593SmuzhiyunThey have a description of "<serviceID>:<securityIndex>" (eg: "52:2" for an 529*4882a593Smuzhiyunrxkad key for the AFS VL service). When such a key is created, it should be 530*4882a593Smuzhiyungiven the server's secret key as the instantiation data (see the example 531*4882a593Smuzhiyunbelow). 532*4882a593Smuzhiyun 533*4882a593Smuzhiyun add_key("rxrpc_s", "52:2", secret_key, 8, keyring); 534*4882a593Smuzhiyun 535*4882a593SmuzhiyunA keyring is passed to the server socket by naming it in a sockopt. The server 536*4882a593Smuzhiyunsocket then looks the server secret keys up in this keyring when secure 537*4882a593Smuzhiyunincoming connections are made. This can be seen in an example program that can 538*4882a593Smuzhiyunbe found at: 539*4882a593Smuzhiyun 540*4882a593Smuzhiyun http://people.redhat.com/~dhowells/rxrpc/listen.c 541*4882a593Smuzhiyun 542*4882a593Smuzhiyun 543*4882a593Smuzhiyun==================== 544*4882a593SmuzhiyunEXAMPLE CLIENT USAGE 545*4882a593Smuzhiyun==================== 546*4882a593Smuzhiyun 547*4882a593SmuzhiyunA client would issue an operation by: 548*4882a593Smuzhiyun 549*4882a593Smuzhiyun (1) An RxRPC socket is set up by:: 550*4882a593Smuzhiyun 551*4882a593Smuzhiyun client = socket(AF_RXRPC, SOCK_DGRAM, PF_INET); 552*4882a593Smuzhiyun 553*4882a593Smuzhiyun Where the third parameter indicates the protocol family of the transport 554*4882a593Smuzhiyun socket used - usually IPv4 but it can also be IPv6 [TODO]. 555*4882a593Smuzhiyun 556*4882a593Smuzhiyun (2) A local address can optionally be bound:: 557*4882a593Smuzhiyun 558*4882a593Smuzhiyun struct sockaddr_rxrpc srx = { 559*4882a593Smuzhiyun .srx_family = AF_RXRPC, 560*4882a593Smuzhiyun .srx_service = 0, /* we're a client */ 561*4882a593Smuzhiyun .transport_type = SOCK_DGRAM, /* type of transport socket */ 562*4882a593Smuzhiyun .transport.sin_family = AF_INET, 563*4882a593Smuzhiyun .transport.sin_port = htons(7000), /* AFS callback */ 564*4882a593Smuzhiyun .transport.sin_address = 0, /* all local interfaces */ 565*4882a593Smuzhiyun }; 566*4882a593Smuzhiyun bind(client, &srx, sizeof(srx)); 567*4882a593Smuzhiyun 568*4882a593Smuzhiyun This specifies the local UDP port to be used. If not given, a random 569*4882a593Smuzhiyun non-privileged port will be used. A UDP port may be shared between 570*4882a593Smuzhiyun several unrelated RxRPC sockets. Security is handled on a basis of 571*4882a593Smuzhiyun per-RxRPC virtual connection. 572*4882a593Smuzhiyun 573*4882a593Smuzhiyun (3) The security is set:: 574*4882a593Smuzhiyun 575*4882a593Smuzhiyun const char *key = "AFS:cambridge.redhat.com"; 576*4882a593Smuzhiyun setsockopt(client, SOL_RXRPC, RXRPC_SECURITY_KEY, key, strlen(key)); 577*4882a593Smuzhiyun 578*4882a593Smuzhiyun This issues a request_key() to get the key representing the security 579*4882a593Smuzhiyun context. The minimum security level can be set:: 580*4882a593Smuzhiyun 581*4882a593Smuzhiyun unsigned int sec = RXRPC_SECURITY_ENCRYPT; 582*4882a593Smuzhiyun setsockopt(client, SOL_RXRPC, RXRPC_MIN_SECURITY_LEVEL, 583*4882a593Smuzhiyun &sec, sizeof(sec)); 584*4882a593Smuzhiyun 585*4882a593Smuzhiyun (4) The server to be contacted can then be specified (alternatively this can 586*4882a593Smuzhiyun be done through sendmsg):: 587*4882a593Smuzhiyun 588*4882a593Smuzhiyun struct sockaddr_rxrpc srx = { 589*4882a593Smuzhiyun .srx_family = AF_RXRPC, 590*4882a593Smuzhiyun .srx_service = VL_SERVICE_ID, 591*4882a593Smuzhiyun .transport_type = SOCK_DGRAM, /* type of transport socket */ 592*4882a593Smuzhiyun .transport.sin_family = AF_INET, 593*4882a593Smuzhiyun .transport.sin_port = htons(7005), /* AFS volume manager */ 594*4882a593Smuzhiyun .transport.sin_address = ..., 595*4882a593Smuzhiyun }; 596*4882a593Smuzhiyun connect(client, &srx, sizeof(srx)); 597*4882a593Smuzhiyun 598*4882a593Smuzhiyun (5) The request data should then be posted to the server socket using a series 599*4882a593Smuzhiyun of sendmsg() calls, each with the following control message attached: 600*4882a593Smuzhiyun 601*4882a593Smuzhiyun ================== =================================== 602*4882a593Smuzhiyun RXRPC_USER_CALL_ID specifies the user ID for this call 603*4882a593Smuzhiyun ================== =================================== 604*4882a593Smuzhiyun 605*4882a593Smuzhiyun MSG_MORE should be set in msghdr::msg_flags on all but the last part of 606*4882a593Smuzhiyun the request. Multiple requests may be made simultaneously. 607*4882a593Smuzhiyun 608*4882a593Smuzhiyun An RXRPC_TX_LENGTH control message can also be specified on the first 609*4882a593Smuzhiyun sendmsg() call. 610*4882a593Smuzhiyun 611*4882a593Smuzhiyun If a call is intended to go to a destination other than the default 612*4882a593Smuzhiyun specified through connect(), then msghdr::msg_name should be set on the 613*4882a593Smuzhiyun first request message of that call. 614*4882a593Smuzhiyun 615*4882a593Smuzhiyun (6) The reply data will then be posted to the server socket for recvmsg() to 616*4882a593Smuzhiyun pick up. MSG_MORE will be flagged by recvmsg() if there's more reply data 617*4882a593Smuzhiyun for a particular call to be read. MSG_EOR will be set on the terminal 618*4882a593Smuzhiyun read for a call. 619*4882a593Smuzhiyun 620*4882a593Smuzhiyun All data will be delivered with the following control message attached: 621*4882a593Smuzhiyun 622*4882a593Smuzhiyun RXRPC_USER_CALL_ID - specifies the user ID for this call 623*4882a593Smuzhiyun 624*4882a593Smuzhiyun If an abort or error occurred, this will be returned in the control data 625*4882a593Smuzhiyun buffer instead, and MSG_EOR will be flagged to indicate the end of that 626*4882a593Smuzhiyun call. 627*4882a593Smuzhiyun 628*4882a593SmuzhiyunA client may ask for a service ID it knows and ask that this be upgraded to a 629*4882a593Smuzhiyunbetter service if one is available by supplying RXRPC_UPGRADE_SERVICE on the 630*4882a593Smuzhiyunfirst sendmsg() of a call. The client should then check srx_service in the 631*4882a593Smuzhiyunmsg_name filled in by recvmsg() when collecting the result. srx_service will 632*4882a593Smuzhiyunhold the same value as given to sendmsg() if the upgrade request was ignored by 633*4882a593Smuzhiyunthe service - otherwise it will be altered to indicate the service ID the 634*4882a593Smuzhiyunserver upgraded to. Note that the upgraded service ID is chosen by the server. 635*4882a593SmuzhiyunThe caller has to wait until it sees the service ID in the reply before sending 636*4882a593Smuzhiyunany more calls (further calls to the same destination will be blocked until the 637*4882a593Smuzhiyunprobe is concluded). 638*4882a593Smuzhiyun 639*4882a593Smuzhiyun 640*4882a593SmuzhiyunExample Server Usage 641*4882a593Smuzhiyun==================== 642*4882a593Smuzhiyun 643*4882a593SmuzhiyunA server would be set up to accept operations in the following manner: 644*4882a593Smuzhiyun 645*4882a593Smuzhiyun (1) An RxRPC socket is created by:: 646*4882a593Smuzhiyun 647*4882a593Smuzhiyun server = socket(AF_RXRPC, SOCK_DGRAM, PF_INET); 648*4882a593Smuzhiyun 649*4882a593Smuzhiyun Where the third parameter indicates the address type of the transport 650*4882a593Smuzhiyun socket used - usually IPv4. 651*4882a593Smuzhiyun 652*4882a593Smuzhiyun (2) Security is set up if desired by giving the socket a keyring with server 653*4882a593Smuzhiyun secret keys in it:: 654*4882a593Smuzhiyun 655*4882a593Smuzhiyun keyring = add_key("keyring", "AFSkeys", NULL, 0, 656*4882a593Smuzhiyun KEY_SPEC_PROCESS_KEYRING); 657*4882a593Smuzhiyun 658*4882a593Smuzhiyun const char secret_key[8] = { 659*4882a593Smuzhiyun 0xa7, 0x83, 0x8a, 0xcb, 0xc7, 0x83, 0xec, 0x94 }; 660*4882a593Smuzhiyun add_key("rxrpc_s", "52:2", secret_key, 8, keyring); 661*4882a593Smuzhiyun 662*4882a593Smuzhiyun setsockopt(server, SOL_RXRPC, RXRPC_SECURITY_KEYRING, "AFSkeys", 7); 663*4882a593Smuzhiyun 664*4882a593Smuzhiyun The keyring can be manipulated after it has been given to the socket. This 665*4882a593Smuzhiyun permits the server to add more keys, replace keys, etc. while it is live. 666*4882a593Smuzhiyun 667*4882a593Smuzhiyun (3) A local address must then be bound:: 668*4882a593Smuzhiyun 669*4882a593Smuzhiyun struct sockaddr_rxrpc srx = { 670*4882a593Smuzhiyun .srx_family = AF_RXRPC, 671*4882a593Smuzhiyun .srx_service = VL_SERVICE_ID, /* RxRPC service ID */ 672*4882a593Smuzhiyun .transport_type = SOCK_DGRAM, /* type of transport socket */ 673*4882a593Smuzhiyun .transport.sin_family = AF_INET, 674*4882a593Smuzhiyun .transport.sin_port = htons(7000), /* AFS callback */ 675*4882a593Smuzhiyun .transport.sin_address = 0, /* all local interfaces */ 676*4882a593Smuzhiyun }; 677*4882a593Smuzhiyun bind(server, &srx, sizeof(srx)); 678*4882a593Smuzhiyun 679*4882a593Smuzhiyun More than one service ID may be bound to a socket, provided the transport 680*4882a593Smuzhiyun parameters are the same. The limit is currently two. To do this, bind() 681*4882a593Smuzhiyun should be called twice. 682*4882a593Smuzhiyun 683*4882a593Smuzhiyun (4) If service upgrading is required, first two service IDs must have been 684*4882a593Smuzhiyun bound and then the following option must be set:: 685*4882a593Smuzhiyun 686*4882a593Smuzhiyun unsigned short service_ids[2] = { from_ID, to_ID }; 687*4882a593Smuzhiyun setsockopt(server, SOL_RXRPC, RXRPC_UPGRADEABLE_SERVICE, 688*4882a593Smuzhiyun service_ids, sizeof(service_ids)); 689*4882a593Smuzhiyun 690*4882a593Smuzhiyun This will automatically upgrade connections on service from_ID to service 691*4882a593Smuzhiyun to_ID if they request it. This will be reflected in msg_name obtained 692*4882a593Smuzhiyun through recvmsg() when the request data is delivered to userspace. 693*4882a593Smuzhiyun 694*4882a593Smuzhiyun (5) The server is then set to listen out for incoming calls:: 695*4882a593Smuzhiyun 696*4882a593Smuzhiyun listen(server, 100); 697*4882a593Smuzhiyun 698*4882a593Smuzhiyun (6) The kernel notifies the server of pending incoming connections by sending 699*4882a593Smuzhiyun it a message for each. This is received with recvmsg() on the server 700*4882a593Smuzhiyun socket. It has no data, and has a single dataless control message 701*4882a593Smuzhiyun attached:: 702*4882a593Smuzhiyun 703*4882a593Smuzhiyun RXRPC_NEW_CALL 704*4882a593Smuzhiyun 705*4882a593Smuzhiyun The address that can be passed back by recvmsg() at this point should be 706*4882a593Smuzhiyun ignored since the call for which the message was posted may have gone by 707*4882a593Smuzhiyun the time it is accepted - in which case the first call still on the queue 708*4882a593Smuzhiyun will be accepted. 709*4882a593Smuzhiyun 710*4882a593Smuzhiyun (7) The server then accepts the new call by issuing a sendmsg() with two 711*4882a593Smuzhiyun pieces of control data and no actual data: 712*4882a593Smuzhiyun 713*4882a593Smuzhiyun ================== ============================== 714*4882a593Smuzhiyun RXRPC_ACCEPT indicate connection acceptance 715*4882a593Smuzhiyun RXRPC_USER_CALL_ID specify user ID for this call 716*4882a593Smuzhiyun ================== ============================== 717*4882a593Smuzhiyun 718*4882a593Smuzhiyun (8) The first request data packet will then be posted to the server socket for 719*4882a593Smuzhiyun recvmsg() to pick up. At that point, the RxRPC address for the call can 720*4882a593Smuzhiyun be read from the address fields in the msghdr struct. 721*4882a593Smuzhiyun 722*4882a593Smuzhiyun Subsequent request data will be posted to the server socket for recvmsg() 723*4882a593Smuzhiyun to collect as it arrives. All but the last piece of the request data will 724*4882a593Smuzhiyun be delivered with MSG_MORE flagged. 725*4882a593Smuzhiyun 726*4882a593Smuzhiyun All data will be delivered with the following control message attached: 727*4882a593Smuzhiyun 728*4882a593Smuzhiyun 729*4882a593Smuzhiyun ================== =================================== 730*4882a593Smuzhiyun RXRPC_USER_CALL_ID specifies the user ID for this call 731*4882a593Smuzhiyun ================== =================================== 732*4882a593Smuzhiyun 733*4882a593Smuzhiyun (9) The reply data should then be posted to the server socket using a series 734*4882a593Smuzhiyun of sendmsg() calls, each with the following control messages attached: 735*4882a593Smuzhiyun 736*4882a593Smuzhiyun ================== =================================== 737*4882a593Smuzhiyun RXRPC_USER_CALL_ID specifies the user ID for this call 738*4882a593Smuzhiyun ================== =================================== 739*4882a593Smuzhiyun 740*4882a593Smuzhiyun MSG_MORE should be set in msghdr::msg_flags on all but the last message 741*4882a593Smuzhiyun for a particular call. 742*4882a593Smuzhiyun 743*4882a593Smuzhiyun(10) The final ACK from the client will be posted for retrieval by recvmsg() 744*4882a593Smuzhiyun when it is received. It will take the form of a dataless message with two 745*4882a593Smuzhiyun control messages attached: 746*4882a593Smuzhiyun 747*4882a593Smuzhiyun ================== =================================== 748*4882a593Smuzhiyun RXRPC_USER_CALL_ID specifies the user ID for this call 749*4882a593Smuzhiyun RXRPC_ACK indicates final ACK (no data) 750*4882a593Smuzhiyun ================== =================================== 751*4882a593Smuzhiyun 752*4882a593Smuzhiyun MSG_EOR will be flagged to indicate that this is the final message for 753*4882a593Smuzhiyun this call. 754*4882a593Smuzhiyun 755*4882a593Smuzhiyun(11) Up to the point the final packet of reply data is sent, the call can be 756*4882a593Smuzhiyun aborted by calling sendmsg() with a dataless message with the following 757*4882a593Smuzhiyun control messages attached: 758*4882a593Smuzhiyun 759*4882a593Smuzhiyun ================== =================================== 760*4882a593Smuzhiyun RXRPC_USER_CALL_ID specifies the user ID for this call 761*4882a593Smuzhiyun RXRPC_ABORT indicates abort code (4 byte data) 762*4882a593Smuzhiyun ================== =================================== 763*4882a593Smuzhiyun 764*4882a593Smuzhiyun Any packets waiting in the socket's receive queue will be discarded if 765*4882a593Smuzhiyun this is issued. 766*4882a593Smuzhiyun 767*4882a593SmuzhiyunNote that all the communications for a particular service take place through 768*4882a593Smuzhiyunthe one server socket, using control messages on sendmsg() and recvmsg() to 769*4882a593Smuzhiyundetermine the call affected. 770*4882a593Smuzhiyun 771*4882a593Smuzhiyun 772*4882a593SmuzhiyunAF_RXRPC Kernel Interface 773*4882a593Smuzhiyun========================= 774*4882a593Smuzhiyun 775*4882a593SmuzhiyunThe AF_RXRPC module also provides an interface for use by in-kernel utilities 776*4882a593Smuzhiyunsuch as the AFS filesystem. This permits such a utility to: 777*4882a593Smuzhiyun 778*4882a593Smuzhiyun (1) Use different keys directly on individual client calls on one socket 779*4882a593Smuzhiyun rather than having to open a whole slew of sockets, one for each key it 780*4882a593Smuzhiyun might want to use. 781*4882a593Smuzhiyun 782*4882a593Smuzhiyun (2) Avoid having RxRPC call request_key() at the point of issue of a call or 783*4882a593Smuzhiyun opening of a socket. Instead the utility is responsible for requesting a 784*4882a593Smuzhiyun key at the appropriate point. AFS, for instance, would do this during VFS 785*4882a593Smuzhiyun operations such as open() or unlink(). The key is then handed through 786*4882a593Smuzhiyun when the call is initiated. 787*4882a593Smuzhiyun 788*4882a593Smuzhiyun (3) Request the use of something other than GFP_KERNEL to allocate memory. 789*4882a593Smuzhiyun 790*4882a593Smuzhiyun (4) Avoid the overhead of using the recvmsg() call. RxRPC messages can be 791*4882a593Smuzhiyun intercepted before they get put into the socket Rx queue and the socket 792*4882a593Smuzhiyun buffers manipulated directly. 793*4882a593Smuzhiyun 794*4882a593SmuzhiyunTo use the RxRPC facility, a kernel utility must still open an AF_RXRPC socket, 795*4882a593Smuzhiyunbind an address as appropriate and listen if it's to be a server socket, but 796*4882a593Smuzhiyunthen it passes this to the kernel interface functions. 797*4882a593Smuzhiyun 798*4882a593SmuzhiyunThe kernel interface functions are as follows: 799*4882a593Smuzhiyun 800*4882a593Smuzhiyun (#) Begin a new client call:: 801*4882a593Smuzhiyun 802*4882a593Smuzhiyun struct rxrpc_call * 803*4882a593Smuzhiyun rxrpc_kernel_begin_call(struct socket *sock, 804*4882a593Smuzhiyun struct sockaddr_rxrpc *srx, 805*4882a593Smuzhiyun struct key *key, 806*4882a593Smuzhiyun unsigned long user_call_ID, 807*4882a593Smuzhiyun s64 tx_total_len, 808*4882a593Smuzhiyun gfp_t gfp, 809*4882a593Smuzhiyun rxrpc_notify_rx_t notify_rx, 810*4882a593Smuzhiyun bool upgrade, 811*4882a593Smuzhiyun bool intr, 812*4882a593Smuzhiyun unsigned int debug_id); 813*4882a593Smuzhiyun 814*4882a593Smuzhiyun This allocates the infrastructure to make a new RxRPC call and assigns 815*4882a593Smuzhiyun call and connection numbers. The call will be made on the UDP port that 816*4882a593Smuzhiyun the socket is bound to. The call will go to the destination address of a 817*4882a593Smuzhiyun connected client socket unless an alternative is supplied (srx is 818*4882a593Smuzhiyun non-NULL). 819*4882a593Smuzhiyun 820*4882a593Smuzhiyun If a key is supplied then this will be used to secure the call instead of 821*4882a593Smuzhiyun the key bound to the socket with the RXRPC_SECURITY_KEY sockopt. Calls 822*4882a593Smuzhiyun secured in this way will still share connections if at all possible. 823*4882a593Smuzhiyun 824*4882a593Smuzhiyun The user_call_ID is equivalent to that supplied to sendmsg() in the 825*4882a593Smuzhiyun control data buffer. It is entirely feasible to use this to point to a 826*4882a593Smuzhiyun kernel data structure. 827*4882a593Smuzhiyun 828*4882a593Smuzhiyun tx_total_len is the amount of data the caller is intending to transmit 829*4882a593Smuzhiyun with this call (or -1 if unknown at this point). Setting the data size 830*4882a593Smuzhiyun allows the kernel to encrypt directly to the packet buffers, thereby 831*4882a593Smuzhiyun saving a copy. The value may not be less than -1. 832*4882a593Smuzhiyun 833*4882a593Smuzhiyun notify_rx is a pointer to a function to be called when events such as 834*4882a593Smuzhiyun incoming data packets or remote aborts happen. 835*4882a593Smuzhiyun 836*4882a593Smuzhiyun upgrade should be set to true if a client operation should request that 837*4882a593Smuzhiyun the server upgrade the service to a better one. The resultant service ID 838*4882a593Smuzhiyun is returned by rxrpc_kernel_recv_data(). 839*4882a593Smuzhiyun 840*4882a593Smuzhiyun intr should be set to true if the call should be interruptible. If this 841*4882a593Smuzhiyun is not set, this function may not return until a channel has been 842*4882a593Smuzhiyun allocated; if it is set, the function may return -ERESTARTSYS. 843*4882a593Smuzhiyun 844*4882a593Smuzhiyun debug_id is the call debugging ID to be used for tracing. This can be 845*4882a593Smuzhiyun obtained by atomically incrementing rxrpc_debug_id. 846*4882a593Smuzhiyun 847*4882a593Smuzhiyun If this function is successful, an opaque reference to the RxRPC call is 848*4882a593Smuzhiyun returned. The caller now holds a reference on this and it must be 849*4882a593Smuzhiyun properly ended. 850*4882a593Smuzhiyun 851*4882a593Smuzhiyun (#) End a client call:: 852*4882a593Smuzhiyun 853*4882a593Smuzhiyun void rxrpc_kernel_end_call(struct socket *sock, 854*4882a593Smuzhiyun struct rxrpc_call *call); 855*4882a593Smuzhiyun 856*4882a593Smuzhiyun This is used to end a previously begun call. The user_call_ID is expunged 857*4882a593Smuzhiyun from AF_RXRPC's knowledge and will not be seen again in association with 858*4882a593Smuzhiyun the specified call. 859*4882a593Smuzhiyun 860*4882a593Smuzhiyun (#) Send data through a call:: 861*4882a593Smuzhiyun 862*4882a593Smuzhiyun typedef void (*rxrpc_notify_end_tx_t)(struct sock *sk, 863*4882a593Smuzhiyun unsigned long user_call_ID, 864*4882a593Smuzhiyun struct sk_buff *skb); 865*4882a593Smuzhiyun 866*4882a593Smuzhiyun int rxrpc_kernel_send_data(struct socket *sock, 867*4882a593Smuzhiyun struct rxrpc_call *call, 868*4882a593Smuzhiyun struct msghdr *msg, 869*4882a593Smuzhiyun size_t len, 870*4882a593Smuzhiyun rxrpc_notify_end_tx_t notify_end_rx); 871*4882a593Smuzhiyun 872*4882a593Smuzhiyun This is used to supply either the request part of a client call or the 873*4882a593Smuzhiyun reply part of a server call. msg.msg_iovlen and msg.msg_iov specify the 874*4882a593Smuzhiyun data buffers to be used. msg_iov may not be NULL and must point 875*4882a593Smuzhiyun exclusively to in-kernel virtual addresses. msg.msg_flags may be given 876*4882a593Smuzhiyun MSG_MORE if there will be subsequent data sends for this call. 877*4882a593Smuzhiyun 878*4882a593Smuzhiyun The msg must not specify a destination address, control data or any flags 879*4882a593Smuzhiyun other than MSG_MORE. len is the total amount of data to transmit. 880*4882a593Smuzhiyun 881*4882a593Smuzhiyun notify_end_rx can be NULL or it can be used to specify a function to be 882*4882a593Smuzhiyun called when the call changes state to end the Tx phase. This function is 883*4882a593Smuzhiyun called with the call-state spinlock held to prevent any reply or final ACK 884*4882a593Smuzhiyun from being delivered first. 885*4882a593Smuzhiyun 886*4882a593Smuzhiyun (#) Receive data from a call:: 887*4882a593Smuzhiyun 888*4882a593Smuzhiyun int rxrpc_kernel_recv_data(struct socket *sock, 889*4882a593Smuzhiyun struct rxrpc_call *call, 890*4882a593Smuzhiyun void *buf, 891*4882a593Smuzhiyun size_t size, 892*4882a593Smuzhiyun size_t *_offset, 893*4882a593Smuzhiyun bool want_more, 894*4882a593Smuzhiyun u32 *_abort, 895*4882a593Smuzhiyun u16 *_service) 896*4882a593Smuzhiyun 897*4882a593Smuzhiyun This is used to receive data from either the reply part of a client call 898*4882a593Smuzhiyun or the request part of a service call. buf and size specify how much 899*4882a593Smuzhiyun data is desired and where to store it. *_offset is added on to buf and 900*4882a593Smuzhiyun subtracted from size internally; the amount copied into the buffer is 901*4882a593Smuzhiyun added to *_offset before returning. 902*4882a593Smuzhiyun 903*4882a593Smuzhiyun want_more should be true if further data will be required after this is 904*4882a593Smuzhiyun satisfied and false if this is the last item of the receive phase. 905*4882a593Smuzhiyun 906*4882a593Smuzhiyun There are three normal returns: 0 if the buffer was filled and want_more 907*4882a593Smuzhiyun was true; 1 if the buffer was filled, the last DATA packet has been 908*4882a593Smuzhiyun emptied and want_more was false; and -EAGAIN if the function needs to be 909*4882a593Smuzhiyun called again. 910*4882a593Smuzhiyun 911*4882a593Smuzhiyun If the last DATA packet is processed but the buffer contains less than 912*4882a593Smuzhiyun the amount requested, EBADMSG is returned. If want_more wasn't set, but 913*4882a593Smuzhiyun more data was available, EMSGSIZE is returned. 914*4882a593Smuzhiyun 915*4882a593Smuzhiyun If a remote ABORT is detected, the abort code received will be stored in 916*4882a593Smuzhiyun ``*_abort`` and ECONNABORTED will be returned. 917*4882a593Smuzhiyun 918*4882a593Smuzhiyun The service ID that the call ended up with is returned into *_service. 919*4882a593Smuzhiyun This can be used to see if a call got a service upgrade. 920*4882a593Smuzhiyun 921*4882a593Smuzhiyun (#) Abort a call?? 922*4882a593Smuzhiyun 923*4882a593Smuzhiyun :: 924*4882a593Smuzhiyun 925*4882a593Smuzhiyun void rxrpc_kernel_abort_call(struct socket *sock, 926*4882a593Smuzhiyun struct rxrpc_call *call, 927*4882a593Smuzhiyun u32 abort_code); 928*4882a593Smuzhiyun 929*4882a593Smuzhiyun This is used to abort a call if it's still in an abortable state. The 930*4882a593Smuzhiyun abort code specified will be placed in the ABORT message sent. 931*4882a593Smuzhiyun 932*4882a593Smuzhiyun (#) Intercept received RxRPC messages:: 933*4882a593Smuzhiyun 934*4882a593Smuzhiyun typedef void (*rxrpc_interceptor_t)(struct sock *sk, 935*4882a593Smuzhiyun unsigned long user_call_ID, 936*4882a593Smuzhiyun struct sk_buff *skb); 937*4882a593Smuzhiyun 938*4882a593Smuzhiyun void 939*4882a593Smuzhiyun rxrpc_kernel_intercept_rx_messages(struct socket *sock, 940*4882a593Smuzhiyun rxrpc_interceptor_t interceptor); 941*4882a593Smuzhiyun 942*4882a593Smuzhiyun This installs an interceptor function on the specified AF_RXRPC socket. 943*4882a593Smuzhiyun All messages that would otherwise wind up in the socket's Rx queue are 944*4882a593Smuzhiyun then diverted to this function. Note that care must be taken to process 945*4882a593Smuzhiyun the messages in the right order to maintain DATA message sequentiality. 946*4882a593Smuzhiyun 947*4882a593Smuzhiyun The interceptor function itself is provided with the address of the socket 948*4882a593Smuzhiyun and handling the incoming message, the ID assigned by the kernel utility 949*4882a593Smuzhiyun to the call and the socket buffer containing the message. 950*4882a593Smuzhiyun 951*4882a593Smuzhiyun The skb->mark field indicates the type of message: 952*4882a593Smuzhiyun 953*4882a593Smuzhiyun =============================== ======================================= 954*4882a593Smuzhiyun Mark Meaning 955*4882a593Smuzhiyun =============================== ======================================= 956*4882a593Smuzhiyun RXRPC_SKB_MARK_DATA Data message 957*4882a593Smuzhiyun RXRPC_SKB_MARK_FINAL_ACK Final ACK received for an incoming call 958*4882a593Smuzhiyun RXRPC_SKB_MARK_BUSY Client call rejected as server busy 959*4882a593Smuzhiyun RXRPC_SKB_MARK_REMOTE_ABORT Call aborted by peer 960*4882a593Smuzhiyun RXRPC_SKB_MARK_NET_ERROR Network error detected 961*4882a593Smuzhiyun RXRPC_SKB_MARK_LOCAL_ERROR Local error encountered 962*4882a593Smuzhiyun RXRPC_SKB_MARK_NEW_CALL New incoming call awaiting acceptance 963*4882a593Smuzhiyun =============================== ======================================= 964*4882a593Smuzhiyun 965*4882a593Smuzhiyun The remote abort message can be probed with rxrpc_kernel_get_abort_code(). 966*4882a593Smuzhiyun The two error messages can be probed with rxrpc_kernel_get_error_number(). 967*4882a593Smuzhiyun A new call can be accepted with rxrpc_kernel_accept_call(). 968*4882a593Smuzhiyun 969*4882a593Smuzhiyun Data messages can have their contents extracted with the usual bunch of 970*4882a593Smuzhiyun socket buffer manipulation functions. A data message can be determined to 971*4882a593Smuzhiyun be the last one in a sequence with rxrpc_kernel_is_data_last(). When a 972*4882a593Smuzhiyun data message has been used up, rxrpc_kernel_data_consumed() should be 973*4882a593Smuzhiyun called on it. 974*4882a593Smuzhiyun 975*4882a593Smuzhiyun Messages should be handled to rxrpc_kernel_free_skb() to dispose of. It 976*4882a593Smuzhiyun is possible to get extra refs on all types of message for later freeing, 977*4882a593Smuzhiyun but this may pin the state of a call until the message is finally freed. 978*4882a593Smuzhiyun 979*4882a593Smuzhiyun (#) Accept an incoming call:: 980*4882a593Smuzhiyun 981*4882a593Smuzhiyun struct rxrpc_call * 982*4882a593Smuzhiyun rxrpc_kernel_accept_call(struct socket *sock, 983*4882a593Smuzhiyun unsigned long user_call_ID); 984*4882a593Smuzhiyun 985*4882a593Smuzhiyun This is used to accept an incoming call and to assign it a call ID. This 986*4882a593Smuzhiyun function is similar to rxrpc_kernel_begin_call() and calls accepted must 987*4882a593Smuzhiyun be ended in the same way. 988*4882a593Smuzhiyun 989*4882a593Smuzhiyun If this function is successful, an opaque reference to the RxRPC call is 990*4882a593Smuzhiyun returned. The caller now holds a reference on this and it must be 991*4882a593Smuzhiyun properly ended. 992*4882a593Smuzhiyun 993*4882a593Smuzhiyun (#) Reject an incoming call:: 994*4882a593Smuzhiyun 995*4882a593Smuzhiyun int rxrpc_kernel_reject_call(struct socket *sock); 996*4882a593Smuzhiyun 997*4882a593Smuzhiyun This is used to reject the first incoming call on the socket's queue with 998*4882a593Smuzhiyun a BUSY message. -ENODATA is returned if there were no incoming calls. 999*4882a593Smuzhiyun Other errors may be returned if the call had been aborted (-ECONNABORTED) 1000*4882a593Smuzhiyun or had timed out (-ETIME). 1001*4882a593Smuzhiyun 1002*4882a593Smuzhiyun (#) Allocate a null key for doing anonymous security:: 1003*4882a593Smuzhiyun 1004*4882a593Smuzhiyun struct key *rxrpc_get_null_key(const char *keyname); 1005*4882a593Smuzhiyun 1006*4882a593Smuzhiyun This is used to allocate a null RxRPC key that can be used to indicate 1007*4882a593Smuzhiyun anonymous security for a particular domain. 1008*4882a593Smuzhiyun 1009*4882a593Smuzhiyun (#) Get the peer address of a call:: 1010*4882a593Smuzhiyun 1011*4882a593Smuzhiyun void rxrpc_kernel_get_peer(struct socket *sock, struct rxrpc_call *call, 1012*4882a593Smuzhiyun struct sockaddr_rxrpc *_srx); 1013*4882a593Smuzhiyun 1014*4882a593Smuzhiyun This is used to find the remote peer address of a call. 1015*4882a593Smuzhiyun 1016*4882a593Smuzhiyun (#) Set the total transmit data size on a call:: 1017*4882a593Smuzhiyun 1018*4882a593Smuzhiyun void rxrpc_kernel_set_tx_length(struct socket *sock, 1019*4882a593Smuzhiyun struct rxrpc_call *call, 1020*4882a593Smuzhiyun s64 tx_total_len); 1021*4882a593Smuzhiyun 1022*4882a593Smuzhiyun This sets the amount of data that the caller is intending to transmit on a 1023*4882a593Smuzhiyun call. It's intended to be used for setting the reply size as the request 1024*4882a593Smuzhiyun size should be set when the call is begun. tx_total_len may not be less 1025*4882a593Smuzhiyun than zero. 1026*4882a593Smuzhiyun 1027*4882a593Smuzhiyun (#) Get call RTT:: 1028*4882a593Smuzhiyun 1029*4882a593Smuzhiyun u64 rxrpc_kernel_get_rtt(struct socket *sock, struct rxrpc_call *call); 1030*4882a593Smuzhiyun 1031*4882a593Smuzhiyun Get the RTT time to the peer in use by a call. The value returned is in 1032*4882a593Smuzhiyun nanoseconds. 1033*4882a593Smuzhiyun 1034*4882a593Smuzhiyun (#) Check call still alive:: 1035*4882a593Smuzhiyun 1036*4882a593Smuzhiyun bool rxrpc_kernel_check_life(struct socket *sock, 1037*4882a593Smuzhiyun struct rxrpc_call *call, 1038*4882a593Smuzhiyun u32 *_life); 1039*4882a593Smuzhiyun void rxrpc_kernel_probe_life(struct socket *sock, 1040*4882a593Smuzhiyun struct rxrpc_call *call); 1041*4882a593Smuzhiyun 1042*4882a593Smuzhiyun The first function passes back in ``*_life`` a number that is updated when 1043*4882a593Smuzhiyun ACKs are received from the peer (notably including PING RESPONSE ACKs 1044*4882a593Smuzhiyun which we can elicit by sending PING ACKs to see if the call still exists 1045*4882a593Smuzhiyun on the server). The caller should compare the numbers of two calls to see 1046*4882a593Smuzhiyun if the call is still alive after waiting for a suitable interval. It also 1047*4882a593Smuzhiyun returns true as long as the call hasn't yet reached the completed state. 1048*4882a593Smuzhiyun 1049*4882a593Smuzhiyun This allows the caller to work out if the server is still contactable and 1050*4882a593Smuzhiyun if the call is still alive on the server while waiting for the server to 1051*4882a593Smuzhiyun process a client operation. 1052*4882a593Smuzhiyun 1053*4882a593Smuzhiyun The second function causes a ping ACK to be transmitted to try to provoke 1054*4882a593Smuzhiyun the peer into responding, which would then cause the value returned by the 1055*4882a593Smuzhiyun first function to change. Note that this must be called in TASK_RUNNING 1056*4882a593Smuzhiyun state. 1057*4882a593Smuzhiyun 1058*4882a593Smuzhiyun (#) Get reply timestamp:: 1059*4882a593Smuzhiyun 1060*4882a593Smuzhiyun bool rxrpc_kernel_get_reply_time(struct socket *sock, 1061*4882a593Smuzhiyun struct rxrpc_call *call, 1062*4882a593Smuzhiyun ktime_t *_ts) 1063*4882a593Smuzhiyun 1064*4882a593Smuzhiyun This allows the timestamp on the first DATA packet of the reply of a 1065*4882a593Smuzhiyun client call to be queried, provided that it is still in the Rx ring. If 1066*4882a593Smuzhiyun successful, the timestamp will be stored into ``*_ts`` and true will be 1067*4882a593Smuzhiyun returned; false will be returned otherwise. 1068*4882a593Smuzhiyun 1069*4882a593Smuzhiyun (#) Get remote client epoch:: 1070*4882a593Smuzhiyun 1071*4882a593Smuzhiyun u32 rxrpc_kernel_get_epoch(struct socket *sock, 1072*4882a593Smuzhiyun struct rxrpc_call *call) 1073*4882a593Smuzhiyun 1074*4882a593Smuzhiyun This allows the epoch that's contained in packets of an incoming client 1075*4882a593Smuzhiyun call to be queried. This value is returned. The function always 1076*4882a593Smuzhiyun successful if the call is still in progress. It shouldn't be called once 1077*4882a593Smuzhiyun the call has expired. Note that calling this on a local client call only 1078*4882a593Smuzhiyun returns the local epoch. 1079*4882a593Smuzhiyun 1080*4882a593Smuzhiyun This value can be used to determine if the remote client has been 1081*4882a593Smuzhiyun restarted as it shouldn't change otherwise. 1082*4882a593Smuzhiyun 1083*4882a593Smuzhiyun (#) Set the maxmimum lifespan on a call:: 1084*4882a593Smuzhiyun 1085*4882a593Smuzhiyun void rxrpc_kernel_set_max_life(struct socket *sock, 1086*4882a593Smuzhiyun struct rxrpc_call *call, 1087*4882a593Smuzhiyun unsigned long hard_timeout) 1088*4882a593Smuzhiyun 1089*4882a593Smuzhiyun This sets the maximum lifespan on a call to hard_timeout (which is in 1090*4882a593Smuzhiyun jiffies). In the event of the timeout occurring, the call will be 1091*4882a593Smuzhiyun aborted and -ETIME or -ETIMEDOUT will be returned. 1092*4882a593Smuzhiyun 1093*4882a593Smuzhiyun (#) Apply the RXRPC_MIN_SECURITY_LEVEL sockopt to a socket from within in the 1094*4882a593Smuzhiyun kernel:: 1095*4882a593Smuzhiyun 1096*4882a593Smuzhiyun int rxrpc_sock_set_min_security_level(struct sock *sk, 1097*4882a593Smuzhiyun unsigned int val); 1098*4882a593Smuzhiyun 1099*4882a593Smuzhiyun This specifies the minimum security level required for calls on this 1100*4882a593Smuzhiyun socket. 1101*4882a593Smuzhiyun 1102*4882a593Smuzhiyun 1103*4882a593SmuzhiyunConfigurable Parameters 1104*4882a593Smuzhiyun======================= 1105*4882a593Smuzhiyun 1106*4882a593SmuzhiyunThe RxRPC protocol driver has a number of configurable parameters that can be 1107*4882a593Smuzhiyunadjusted through sysctls in /proc/net/rxrpc/: 1108*4882a593Smuzhiyun 1109*4882a593Smuzhiyun (#) req_ack_delay 1110*4882a593Smuzhiyun 1111*4882a593Smuzhiyun The amount of time in milliseconds after receiving a packet with the 1112*4882a593Smuzhiyun request-ack flag set before we honour the flag and actually send the 1113*4882a593Smuzhiyun requested ack. 1114*4882a593Smuzhiyun 1115*4882a593Smuzhiyun Usually the other side won't stop sending packets until the advertised 1116*4882a593Smuzhiyun reception window is full (to a maximum of 255 packets), so delaying the 1117*4882a593Smuzhiyun ACK permits several packets to be ACK'd in one go. 1118*4882a593Smuzhiyun 1119*4882a593Smuzhiyun (#) soft_ack_delay 1120*4882a593Smuzhiyun 1121*4882a593Smuzhiyun The amount of time in milliseconds after receiving a new packet before we 1122*4882a593Smuzhiyun generate a soft-ACK to tell the sender that it doesn't need to resend. 1123*4882a593Smuzhiyun 1124*4882a593Smuzhiyun (#) idle_ack_delay 1125*4882a593Smuzhiyun 1126*4882a593Smuzhiyun The amount of time in milliseconds after all the packets currently in the 1127*4882a593Smuzhiyun received queue have been consumed before we generate a hard-ACK to tell 1128*4882a593Smuzhiyun the sender it can free its buffers, assuming no other reason occurs that 1129*4882a593Smuzhiyun we would send an ACK. 1130*4882a593Smuzhiyun 1131*4882a593Smuzhiyun (#) resend_timeout 1132*4882a593Smuzhiyun 1133*4882a593Smuzhiyun The amount of time in milliseconds after transmitting a packet before we 1134*4882a593Smuzhiyun transmit it again, assuming no ACK is received from the receiver telling 1135*4882a593Smuzhiyun us they got it. 1136*4882a593Smuzhiyun 1137*4882a593Smuzhiyun (#) max_call_lifetime 1138*4882a593Smuzhiyun 1139*4882a593Smuzhiyun The maximum amount of time in seconds that a call may be in progress 1140*4882a593Smuzhiyun before we preemptively kill it. 1141*4882a593Smuzhiyun 1142*4882a593Smuzhiyun (#) dead_call_expiry 1143*4882a593Smuzhiyun 1144*4882a593Smuzhiyun The amount of time in seconds before we remove a dead call from the call 1145*4882a593Smuzhiyun list. Dead calls are kept around for a little while for the purpose of 1146*4882a593Smuzhiyun repeating ACK and ABORT packets. 1147*4882a593Smuzhiyun 1148*4882a593Smuzhiyun (#) connection_expiry 1149*4882a593Smuzhiyun 1150*4882a593Smuzhiyun The amount of time in seconds after a connection was last used before we 1151*4882a593Smuzhiyun remove it from the connection list. While a connection is in existence, 1152*4882a593Smuzhiyun it serves as a placeholder for negotiated security; when it is deleted, 1153*4882a593Smuzhiyun the security must be renegotiated. 1154*4882a593Smuzhiyun 1155*4882a593Smuzhiyun (#) transport_expiry 1156*4882a593Smuzhiyun 1157*4882a593Smuzhiyun The amount of time in seconds after a transport was last used before we 1158*4882a593Smuzhiyun remove it from the transport list. While a transport is in existence, it 1159*4882a593Smuzhiyun serves to anchor the peer data and keeps the connection ID counter. 1160*4882a593Smuzhiyun 1161*4882a593Smuzhiyun (#) rxrpc_rx_window_size 1162*4882a593Smuzhiyun 1163*4882a593Smuzhiyun The size of the receive window in packets. This is the maximum number of 1164*4882a593Smuzhiyun unconsumed received packets we're willing to hold in memory for any 1165*4882a593Smuzhiyun particular call. 1166*4882a593Smuzhiyun 1167*4882a593Smuzhiyun (#) rxrpc_rx_mtu 1168*4882a593Smuzhiyun 1169*4882a593Smuzhiyun The maximum packet MTU size that we're willing to receive in bytes. This 1170*4882a593Smuzhiyun indicates to the peer whether we're willing to accept jumbo packets. 1171*4882a593Smuzhiyun 1172*4882a593Smuzhiyun (#) rxrpc_rx_jumbo_max 1173*4882a593Smuzhiyun 1174*4882a593Smuzhiyun The maximum number of packets that we're willing to accept in a jumbo 1175*4882a593Smuzhiyun packet. Non-terminal packets in a jumbo packet must contain a four byte 1176*4882a593Smuzhiyun header plus exactly 1412 bytes of data. The terminal packet must contain 1177*4882a593Smuzhiyun a four byte header plus any amount of data. In any event, a jumbo packet 1178*4882a593Smuzhiyun may not exceed rxrpc_rx_mtu in size. 1179