Skip to content

Commit bfacaf7

Browse files
Marc Dionnebrauner
authored andcommitted
afs: Fix ignored callbacks over ipv4
When searching for a matching peer, all addresses need to be searched, not just the ipv6 ones in the fs_addresses6 list. Given that the lists no longer contain addresses, there is little reason to splitting things between separate lists, so unify them into a single list. When processing an incoming callback from an ipv4 address, this would lead to a failure to set call->server, resulting in the callback being ignored and the client seeing stale contents. Fixes: 72904d7 ("rxrpc, afs: Allow afs to pin rxrpc_peer objects") Reported-by: Markus Suvanto <[email protected]> Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008035.html Signed-off-by: Marc Dionne <[email protected]> Signed-off-by: David Howells <[email protected]> Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008037.html # v1 Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008066.html # v2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent e21a2f1 commit bfacaf7

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

fs/afs/internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ struct afs_net {
321321
struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */
322322
struct hlist_head fs_proc; /* procfs servers list */
323323

324-
struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */
325-
struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */
324+
struct hlist_head fs_addresses; /* afs_server (by lowest IPv6 addr) */
326325
seqlock_t fs_addr_lock; /* For fs_addresses[46] */
327326

328327
struct work_struct fs_manager;
@@ -561,8 +560,7 @@ struct afs_server {
561560
struct afs_server __rcu *uuid_next; /* Next server with same UUID */
562561
struct afs_server *uuid_prev; /* Previous server with same UUID */
563562
struct list_head probe_link; /* Link in net->fs_probe_list */
564-
struct hlist_node addr4_link; /* Link in net->fs_addresses4 */
565-
struct hlist_node addr6_link; /* Link in net->fs_addresses6 */
563+
struct hlist_node addr_link; /* Link in net->fs_addresses6 */
566564
struct hlist_node proc_link; /* Link in net->fs_proc */
567565
struct list_head volumes; /* RCU list of afs_server_entry objects */
568566
struct afs_server *gc_next; /* Next server in manager's list */

fs/afs/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ static int __net_init afs_net_init(struct net *net_ns)
9090
INIT_LIST_HEAD(&net->fs_probe_slow);
9191
INIT_HLIST_HEAD(&net->fs_proc);
9292

93-
INIT_HLIST_HEAD(&net->fs_addresses4);
94-
INIT_HLIST_HEAD(&net->fs_addresses6);
93+
INIT_HLIST_HEAD(&net->fs_addresses);
9594
seqlock_init(&net->fs_addr_lock);
9695

9796
INIT_WORK(&net->fs_manager, afs_manage_servers);

fs/afs/server.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct afs_server *afs_find_server(struct afs_net *net, const struct rxrpc_peer
3838
seq++; /* 2 on the 1st/lockless path, otherwise odd */
3939
read_seqbegin_or_lock(&net->fs_addr_lock, &seq);
4040

41-
hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) {
41+
hlist_for_each_entry_rcu(server, &net->fs_addresses, addr_link) {
4242
estate = rcu_dereference(server->endpoint_state);
4343
alist = estate->addresses;
4444
for (i = 0; i < alist->nr_addrs; i++)
@@ -177,10 +177,8 @@ static struct afs_server *afs_install_server(struct afs_cell *cell,
177177
* bit, but anything we might want to do gets messy and memory
178178
* intensive.
179179
*/
180-
if (alist->nr_ipv4 > 0)
181-
hlist_add_head_rcu(&server->addr4_link, &net->fs_addresses4);
182-
if (alist->nr_addrs > alist->nr_ipv4)
183-
hlist_add_head_rcu(&server->addr6_link, &net->fs_addresses6);
180+
if (alist->nr_addrs > 0)
181+
hlist_add_head_rcu(&server->addr_link, &net->fs_addresses);
184182

185183
write_sequnlock(&net->fs_addr_lock);
186184

@@ -511,10 +509,8 @@ static void afs_gc_servers(struct afs_net *net, struct afs_server *gc_list)
511509

512510
list_del(&server->probe_link);
513511
hlist_del_rcu(&server->proc_link);
514-
if (!hlist_unhashed(&server->addr4_link))
515-
hlist_del_rcu(&server->addr4_link);
516-
if (!hlist_unhashed(&server->addr6_link))
517-
hlist_del_rcu(&server->addr6_link);
512+
if (!hlist_unhashed(&server->addr_link))
513+
hlist_del_rcu(&server->addr_link);
518514
}
519515
write_sequnlock(&net->fs_lock);
520516

0 commit comments

Comments
 (0)