Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rxrpc: Stash the network namespace pointer in rxrpc_local

Stash the network namespace pointer in the rxrpc_local struct in addition
to a pointer to the rxrpc-specific net namespace info. Use this to remove
some places where the socket is passed as a parameter.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org

+21 -23
+5 -5
net/rxrpc/ar-internal.h
··· 283 283 struct rcu_head rcu; 284 284 atomic_t active_users; /* Number of users of the local endpoint */ 285 285 refcount_t ref; /* Number of references to the structure */ 286 - struct rxrpc_net *rxnet; /* The network ns in which this resides */ 286 + struct net *net; /* The network namespace */ 287 + struct rxrpc_net *rxnet; /* Our bits in the network namespace */ 287 288 struct hlist_node link; 288 289 struct socket *socket; /* my UDP socket */ 289 290 struct task_struct *io_thread; ··· 1064 1063 */ 1065 1064 struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *, 1066 1065 const struct sockaddr_rxrpc *); 1067 - struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_sock *, struct rxrpc_local *, 1068 - struct sockaddr_rxrpc *, gfp_t); 1066 + struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local, 1067 + struct sockaddr_rxrpc *srx, gfp_t gfp); 1069 1068 struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *, gfp_t, 1070 1069 enum rxrpc_peer_trace); 1071 - void rxrpc_new_incoming_peer(struct rxrpc_sock *, struct rxrpc_local *, 1072 - struct rxrpc_peer *); 1070 + void rxrpc_new_incoming_peer(struct rxrpc_local *local, struct rxrpc_peer *peer); 1073 1071 void rxrpc_destroy_all_peers(struct rxrpc_net *); 1074 1072 struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *, enum rxrpc_peer_trace); 1075 1073 struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *, enum rxrpc_peer_trace);
+1 -1
net/rxrpc/call_accept.c
··· 280 280 (peer_tail + 1) & 281 281 (RXRPC_BACKLOG_MAX - 1)); 282 282 283 - rxrpc_new_incoming_peer(rx, local, peer); 283 + rxrpc_new_incoming_peer(local, peer); 284 284 } 285 285 286 286 /* Now allocate and set up the connection */
+1 -1
net/rxrpc/conn_client.c
··· 378 378 379 379 _enter("{%d,%lx},", call->debug_id, call->user_call_ID); 380 380 381 - cp->peer = rxrpc_lookup_peer(rx, cp->local, srx, gfp); 381 + cp->peer = rxrpc_lookup_peer(cp->local, srx, gfp); 382 382 if (!cp->peer) 383 383 goto error; 384 384
+4 -3
net/rxrpc/local_object.c
··· 85 85 /* 86 86 * Allocate a new local endpoint. 87 87 */ 88 - static struct rxrpc_local *rxrpc_alloc_local(struct rxrpc_net *rxnet, 88 + static struct rxrpc_local *rxrpc_alloc_local(struct net *net, 89 89 const struct sockaddr_rxrpc *srx) 90 90 { 91 91 struct rxrpc_local *local; ··· 94 94 if (local) { 95 95 refcount_set(&local->ref, 1); 96 96 atomic_set(&local->active_users, 1); 97 - local->rxnet = rxnet; 97 + local->net = net; 98 + local->rxnet = rxrpc_net(net); 98 99 INIT_HLIST_NODE(&local->link); 99 100 init_rwsem(&local->defrag_sem); 100 101 init_completion(&local->io_thread_ready); ··· 249 248 goto found; 250 249 } 251 250 252 - local = rxrpc_alloc_local(rxnet, srx); 251 + local = rxrpc_alloc_local(net, srx); 253 252 if (!local) 254 253 goto nomem; 255 254
+10 -13
net/rxrpc/peer_object.c
··· 147 147 * assess the MTU size for the network interface through which this peer is 148 148 * reached 149 149 */ 150 - static void rxrpc_assess_MTU_size(struct rxrpc_sock *rx, 150 + static void rxrpc_assess_MTU_size(struct rxrpc_local *local, 151 151 struct rxrpc_peer *peer) 152 152 { 153 - struct net *net = sock_net(&rx->sk); 153 + struct net *net = local->net; 154 154 struct dst_entry *dst; 155 155 struct rtable *rt; 156 156 struct flowi fl; ··· 236 236 /* 237 237 * Initialise peer record. 238 238 */ 239 - static void rxrpc_init_peer(struct rxrpc_sock *rx, struct rxrpc_peer *peer, 239 + static void rxrpc_init_peer(struct rxrpc_local *local, struct rxrpc_peer *peer, 240 240 unsigned long hash_key) 241 241 { 242 242 peer->hash_key = hash_key; 243 - rxrpc_assess_MTU_size(rx, peer); 243 + rxrpc_assess_MTU_size(local, peer); 244 244 peer->mtu = peer->if_mtu; 245 245 peer->rtt_last_req = ktime_get_real(); 246 246 ··· 272 272 /* 273 273 * Set up a new peer. 274 274 */ 275 - static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_sock *rx, 276 - struct rxrpc_local *local, 275 + static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local, 277 276 struct sockaddr_rxrpc *srx, 278 277 unsigned long hash_key, 279 278 gfp_t gfp) ··· 284 285 peer = rxrpc_alloc_peer(local, gfp, rxrpc_peer_new_client); 285 286 if (peer) { 286 287 memcpy(&peer->srx, srx, sizeof(*srx)); 287 - rxrpc_init_peer(rx, peer, hash_key); 288 + rxrpc_init_peer(local, peer, hash_key); 288 289 } 289 290 290 291 _leave(" = %p", peer); ··· 303 304 * since we've already done a search in the list from the non-reentrant context 304 305 * (the data_ready handler) that is the only place we can add new peers. 305 306 */ 306 - void rxrpc_new_incoming_peer(struct rxrpc_sock *rx, struct rxrpc_local *local, 307 - struct rxrpc_peer *peer) 307 + void rxrpc_new_incoming_peer(struct rxrpc_local *local, struct rxrpc_peer *peer) 308 308 { 309 309 struct rxrpc_net *rxnet = local->rxnet; 310 310 unsigned long hash_key; 311 311 312 312 hash_key = rxrpc_peer_hash_key(local, &peer->srx); 313 - rxrpc_init_peer(rx, peer, hash_key); 313 + rxrpc_init_peer(local, peer, hash_key); 314 314 315 315 spin_lock(&rxnet->peer_hash_lock); 316 316 hash_add_rcu(rxnet->peer_hash, &peer->hash_link, hash_key); ··· 320 322 /* 321 323 * obtain a remote transport endpoint for the specified address 322 324 */ 323 - struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_sock *rx, 324 - struct rxrpc_local *local, 325 + struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local, 325 326 struct sockaddr_rxrpc *srx, gfp_t gfp) 326 327 { 327 328 struct rxrpc_peer *peer, *candidate; ··· 340 343 /* The peer is not yet present in hash - create a candidate 341 344 * for a new record and then redo the search. 342 345 */ 343 - candidate = rxrpc_create_peer(rx, local, srx, hash_key, gfp); 346 + candidate = rxrpc_create_peer(local, srx, hash_key, gfp); 344 347 if (!candidate) { 345 348 _leave(" = NULL [nomem]"); 346 349 return NULL;