Skip to content

Commit f3a123b

Browse files
committed
rxrpc: Allow the app to store private data on peer structs
Provide a way for the application (e.g. the afs filesystem) to store private data on the rxrpc_peer structs for later retrieval via the call object. This will allow afs to store a pointer to the afs_server object on the rxrpc_peer struct, thereby obviating the need for afs to keep lookup tables by which it can associate an incoming call with server that transmitted it. Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Jakub Kicinski <[email protected]> cc: "David S. Miller" <[email protected]> cc: Eric Dumazet <[email protected]> cc: Paolo Abeni <[email protected]> cc: Simon Horman <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ # v1 Link: https://lore.kernel.org/r/[email protected]/ # v4
1 parent 469c82b commit f3a123b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

include/net/af_rxrpc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ struct rxrpc_peer *rxrpc_kernel_get_peer(struct rxrpc_peer *peer);
6969
struct rxrpc_peer *rxrpc_kernel_get_call_peer(struct socket *sock, struct rxrpc_call *call);
7070
const struct sockaddr_rxrpc *rxrpc_kernel_remote_srx(const struct rxrpc_peer *peer);
7171
const struct sockaddr *rxrpc_kernel_remote_addr(const struct rxrpc_peer *peer);
72+
unsigned long rxrpc_kernel_set_peer_data(struct rxrpc_peer *peer, unsigned long app_data);
73+
unsigned long rxrpc_kernel_get_peer_data(const struct rxrpc_peer *peer);
7274
unsigned int rxrpc_kernel_get_srtt(const struct rxrpc_peer *);
7375
int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
7476
rxrpc_user_attach_call_t, unsigned long, gfp_t,

net/rxrpc/ar-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ struct rxrpc_peer {
344344
struct hlist_head error_targets; /* targets for net error distribution */
345345
struct rb_root service_conns; /* Service connections */
346346
struct list_head keepalive_link; /* Link in net->peer_keepalive[] */
347+
unsigned long app_data; /* Application data (e.g. afs_server) */
347348
time64_t last_tx_at; /* Last time packet sent here */
348349
seqlock_t service_conn_lock;
349350
spinlock_t lock; /* access lock */

net/rxrpc/peer_object.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,29 @@ const struct sockaddr *rxrpc_kernel_remote_addr(const struct rxrpc_peer *peer)
520520
(peer ? &peer->srx.transport : &rxrpc_null_addr.transport);
521521
}
522522
EXPORT_SYMBOL(rxrpc_kernel_remote_addr);
523+
524+
/**
525+
* rxrpc_kernel_set_peer_data - Set app-specific data on a peer.
526+
* @peer: The peer to alter
527+
* @app_data: The data to set
528+
*
529+
* Set the app-specific data on a peer. AF_RXRPC makes no effort to retain
530+
* anything the data might refer to. The previous app_data is returned.
531+
*/
532+
unsigned long rxrpc_kernel_set_peer_data(struct rxrpc_peer *peer, unsigned long app_data)
533+
{
534+
return xchg(&peer->app_data, app_data);
535+
}
536+
EXPORT_SYMBOL(rxrpc_kernel_set_peer_data);
537+
538+
/**
539+
* rxrpc_kernel_get_peer_data - Get app-specific data from a peer.
540+
* @peer: The peer to query
541+
*
542+
* Retrieve the app-specific data from a peer.
543+
*/
544+
unsigned long rxrpc_kernel_get_peer_data(const struct rxrpc_peer *peer)
545+
{
546+
return peer->app_data;
547+
}
548+
EXPORT_SYMBOL(rxrpc_kernel_get_peer_data);

0 commit comments

Comments
 (0)