public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: netdev@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	Marc Dionne <marc.dionne@auristor.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Christian Brauner <brauner@kernel.org>,
	linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
	Simon Horman <horms@kernel.org>
Subject: [PATCH net-next 12/15] rxrpc: Allow the app to store private data on peer structs
Date: Mon, 24 Feb 2025 23:41:49 +0000	[thread overview]
Message-ID: <20250224234154.2014840-13-dhowells@redhat.com> (raw)
In-Reply-To: <20250224234154.2014840-1-dhowells@redhat.com>

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 <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Paolo Abeni <pabeni@redhat.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
---
 include/net/af_rxrpc.h  |  2 ++
 net/rxrpc/ar-internal.h |  1 +
 net/rxrpc/peer_object.c | 26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/include/net/af_rxrpc.h b/include/net/af_rxrpc.h
index 0754c463224a..cf793d18e5df 100644
--- a/include/net/af_rxrpc.h
+++ b/include/net/af_rxrpc.h
@@ -69,6 +69,8 @@ struct rxrpc_peer *rxrpc_kernel_get_peer(struct rxrpc_peer *peer);
 struct rxrpc_peer *rxrpc_kernel_get_call_peer(struct socket *sock, struct rxrpc_call *call);
 const struct sockaddr_rxrpc *rxrpc_kernel_remote_srx(const struct rxrpc_peer *peer);
 const struct sockaddr *rxrpc_kernel_remote_addr(const struct rxrpc_peer *peer);
+unsigned long rxrpc_kernel_set_peer_data(struct rxrpc_peer *peer, unsigned long app_data);
+unsigned long rxrpc_kernel_get_peer_data(const struct rxrpc_peer *peer);
 unsigned int rxrpc_kernel_get_srtt(const struct rxrpc_peer *);
 int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
 			       rxrpc_user_attach_call_t, unsigned long, gfp_t,
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index a64a0cab1bf7..3cc3af15086f 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -344,6 +344,7 @@ struct rxrpc_peer {
 	struct hlist_head	error_targets;	/* targets for net error distribution */
 	struct rb_root		service_conns;	/* Service connections */
 	struct list_head	keepalive_link;	/* Link in net->peer_keepalive[] */
+	unsigned long		app_data;	/* Application data (e.g. afs_server) */
 	time64_t		last_tx_at;	/* Last time packet sent here */
 	seqlock_t		service_conn_lock;
 	spinlock_t		lock;		/* access lock */
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index 56e09d161a97..a0c0e4d590f5 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -520,3 +520,29 @@ const struct sockaddr *rxrpc_kernel_remote_addr(const struct rxrpc_peer *peer)
 		(peer ? &peer->srx.transport : &rxrpc_null_addr.transport);
 }
 EXPORT_SYMBOL(rxrpc_kernel_remote_addr);
+
+/**
+ * rxrpc_kernel_set_peer_data - Set app-specific data on a peer.
+ * @peer: The peer to alter
+ * @app_data: The data to set
+ *
+ * Set the app-specific data on a peer.  AF_RXRPC makes no effort to retain
+ * anything the data might refer to.  The previous app_data is returned.
+ */
+unsigned long rxrpc_kernel_set_peer_data(struct rxrpc_peer *peer, unsigned long app_data)
+{
+	return xchg(&peer->app_data, app_data);
+}
+EXPORT_SYMBOL(rxrpc_kernel_set_peer_data);
+
+/**
+ * rxrpc_kernel_get_peer_data - Get app-specific data from a peer.
+ * @peer: The peer to query
+ *
+ * Retrieve the app-specific data from a peer.
+ */
+unsigned long rxrpc_kernel_get_peer_data(const struct rxrpc_peer *peer)
+{
+	return peer->app_data;
+}
+EXPORT_SYMBOL(rxrpc_kernel_get_peer_data);


  parent reply	other threads:[~2025-02-24 23:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 23:41 [PATCH net-next 00/15] afs, rxrpc: Clean up refcounting on afs_cell and afs_server records David Howells
2025-02-24 23:41 ` [PATCH net-next 01/15] rxrpc: rxperf: Fix missing decoding of terminal magic cookie David Howells
2025-02-24 23:41 ` [PATCH net-next 02/15] rxrpc: peer->mtu_lock is redundant David Howells
2025-02-24 23:41 ` [PATCH net-next 03/15] rxrpc: Fix locking issues with the peer record hash David Howells
2025-02-24 23:41 ` [PATCH net-next 04/15] afs: Fix the server_list to unuse a displaced server rather than putting it David Howells
2025-02-24 23:41 ` [PATCH net-next 05/15] afs: Give an afs_server object a ref on the afs_cell object it points to David Howells
2025-02-24 23:41 ` [PATCH net-next 06/15] afs: Remove the "autocell" mount option David Howells
2025-02-24 23:41 ` [PATCH net-next 07/15] afs: Change dynroot to create contents on demand David Howells
2025-02-24 23:41 ` [PATCH net-next 08/15] afs: Improve afs_volume tracing to display a debug ID David Howells
2025-02-24 23:41 ` [PATCH net-next 09/15] afs: Improve server refcount/active count tracing David Howells
2025-02-24 23:41 ` [PATCH net-next 10/15] afs: Make afs_lookup_cell() take a trace note David Howells
2025-02-24 23:41 ` [PATCH net-next 11/15] afs: Drop the net parameter from afs_unuse_cell() David Howells
2025-02-24 23:41 ` David Howells [this message]
2025-02-24 23:41 ` [PATCH net-next 13/15] afs: Use the per-peer app data provided by rxrpc David Howells
2025-02-24 23:41 ` [PATCH net-next 14/15] afs: Fix afs_server ref accounting David Howells
2025-02-24 23:41 ` [PATCH net-next 15/15] afs: Simplify cell record handling David Howells
2025-02-27 11:27 ` [PATCH net-next 00/15] afs, rxrpc: Clean up refcounting on afs_cell and afs_server records Paolo Abeni
2025-02-27 13:10   ` David Howells
2025-02-27 14:43     ` Paolo Abeni
2025-02-27 15:36       ` Which tree to push afs + crypto + rxrpc spanning patches through? David Howells
2025-02-28  8:08         ` Herbert Xu
2025-02-27 19:20 ` [PATCH net-next 00/15] afs, rxrpc: Clean up refcounting on afs_cell and afs_server records patchwork-bot+netdevbpf
2025-02-28  0:49   ` Jakub Kicinski
2025-02-28  6:52     ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250224234154.2014840-13-dhowells@redhat.com \
    --to=dhowells@redhat.com \
    --cc=brauner@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox