diff options
Diffstat (limited to 'net/rxrpc/peer_object.c')
| -rw-r--r-- | net/rxrpc/peer_object.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c index 01a9febfa367..5691b7d266ca 100644 --- a/net/rxrpc/peer_object.c +++ b/net/rxrpc/peer_object.c | |||
| @@ -153,8 +153,10 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *local, | |||
| 153 | * assess the MTU size for the network interface through which this peer is | 153 | * assess the MTU size for the network interface through which this peer is |
| 154 | * reached | 154 | * reached |
| 155 | */ | 155 | */ |
| 156 | static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) | 156 | static void rxrpc_assess_MTU_size(struct rxrpc_sock *rx, |
| 157 | struct rxrpc_peer *peer) | ||
| 157 | { | 158 | { |
| 159 | struct net *net = sock_net(&rx->sk); | ||
| 158 | struct dst_entry *dst; | 160 | struct dst_entry *dst; |
| 159 | struct rtable *rt; | 161 | struct rtable *rt; |
| 160 | struct flowi fl; | 162 | struct flowi fl; |
| @@ -169,7 +171,7 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) | |||
| 169 | switch (peer->srx.transport.family) { | 171 | switch (peer->srx.transport.family) { |
| 170 | case AF_INET: | 172 | case AF_INET: |
| 171 | rt = ip_route_output_ports( | 173 | rt = ip_route_output_ports( |
| 172 | &init_net, fl4, NULL, | 174 | net, fl4, NULL, |
| 173 | peer->srx.transport.sin.sin_addr.s_addr, 0, | 175 | peer->srx.transport.sin.sin_addr.s_addr, 0, |
| 174 | htons(7000), htons(7001), IPPROTO_UDP, 0, 0); | 176 | htons(7000), htons(7001), IPPROTO_UDP, 0, 0); |
| 175 | if (IS_ERR(rt)) { | 177 | if (IS_ERR(rt)) { |
| @@ -188,7 +190,7 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) | |||
| 188 | sizeof(struct in6_addr)); | 190 | sizeof(struct in6_addr)); |
| 189 | fl6->fl6_dport = htons(7001); | 191 | fl6->fl6_dport = htons(7001); |
| 190 | fl6->fl6_sport = htons(7000); | 192 | fl6->fl6_sport = htons(7000); |
| 191 | dst = ip6_route_output(&init_net, NULL, fl6); | 193 | dst = ip6_route_output(net, NULL, fl6); |
| 192 | if (dst->error) { | 194 | if (dst->error) { |
| 193 | _leave(" [route err %d]", dst->error); | 195 | _leave(" [route err %d]", dst->error); |
| 194 | return; | 196 | return; |
| @@ -223,6 +225,7 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp) | |||
| 223 | peer->service_conns = RB_ROOT; | 225 | peer->service_conns = RB_ROOT; |
| 224 | seqlock_init(&peer->service_conn_lock); | 226 | seqlock_init(&peer->service_conn_lock); |
| 225 | spin_lock_init(&peer->lock); | 227 | spin_lock_init(&peer->lock); |
| 228 | spin_lock_init(&peer->rtt_input_lock); | ||
| 226 | peer->debug_id = atomic_inc_return(&rxrpc_debug_id); | 229 | peer->debug_id = atomic_inc_return(&rxrpc_debug_id); |
| 227 | 230 | ||
| 228 | if (RXRPC_TX_SMSS > 2190) | 231 | if (RXRPC_TX_SMSS > 2190) |
| @@ -240,10 +243,11 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp) | |||
| 240 | /* | 243 | /* |
| 241 | * Initialise peer record. | 244 | * Initialise peer record. |
| 242 | */ | 245 | */ |
| 243 | static void rxrpc_init_peer(struct rxrpc_peer *peer, unsigned long hash_key) | 246 | static void rxrpc_init_peer(struct rxrpc_sock *rx, struct rxrpc_peer *peer, |
| 247 | unsigned long hash_key) | ||
| 244 | { | 248 | { |
| 245 | peer->hash_key = hash_key; | 249 | peer->hash_key = hash_key; |
| 246 | rxrpc_assess_MTU_size(peer); | 250 | rxrpc_assess_MTU_size(rx, peer); |
| 247 | peer->mtu = peer->if_mtu; | 251 | peer->mtu = peer->if_mtu; |
| 248 | peer->rtt_last_req = ktime_get_real(); | 252 | peer->rtt_last_req = ktime_get_real(); |
| 249 | 253 | ||
| @@ -275,7 +279,8 @@ static void rxrpc_init_peer(struct rxrpc_peer *peer, unsigned long hash_key) | |||
| 275 | /* | 279 | /* |
| 276 | * Set up a new peer. | 280 | * Set up a new peer. |
| 277 | */ | 281 | */ |
| 278 | static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local, | 282 | static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_sock *rx, |
| 283 | struct rxrpc_local *local, | ||
| 279 | struct sockaddr_rxrpc *srx, | 284 | struct sockaddr_rxrpc *srx, |
| 280 | unsigned long hash_key, | 285 | unsigned long hash_key, |
| 281 | gfp_t gfp) | 286 | gfp_t gfp) |
| @@ -287,7 +292,7 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local, | |||
| 287 | peer = rxrpc_alloc_peer(local, gfp); | 292 | peer = rxrpc_alloc_peer(local, gfp); |
| 288 | if (peer) { | 293 | if (peer) { |
| 289 | memcpy(&peer->srx, srx, sizeof(*srx)); | 294 | memcpy(&peer->srx, srx, sizeof(*srx)); |
| 290 | rxrpc_init_peer(peer, hash_key); | 295 | rxrpc_init_peer(rx, peer, hash_key); |
| 291 | } | 296 | } |
| 292 | 297 | ||
| 293 | _leave(" = %p", peer); | 298 | _leave(" = %p", peer); |
| @@ -299,14 +304,15 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local, | |||
| 299 | * since we've already done a search in the list from the non-reentrant context | 304 | * since we've already done a search in the list from the non-reentrant context |
| 300 | * (the data_ready handler) that is the only place we can add new peers. | 305 | * (the data_ready handler) that is the only place we can add new peers. |
| 301 | */ | 306 | */ |
| 302 | void rxrpc_new_incoming_peer(struct rxrpc_local *local, struct rxrpc_peer *peer) | 307 | void rxrpc_new_incoming_peer(struct rxrpc_sock *rx, struct rxrpc_local *local, |
| 308 | struct rxrpc_peer *peer) | ||
| 303 | { | 309 | { |
| 304 | struct rxrpc_net *rxnet = local->rxnet; | 310 | struct rxrpc_net *rxnet = local->rxnet; |
| 305 | unsigned long hash_key; | 311 | unsigned long hash_key; |
| 306 | 312 | ||
| 307 | hash_key = rxrpc_peer_hash_key(local, &peer->srx); | 313 | hash_key = rxrpc_peer_hash_key(local, &peer->srx); |
| 308 | peer->local = local; | 314 | peer->local = local; |
| 309 | rxrpc_init_peer(peer, hash_key); | 315 | rxrpc_init_peer(rx, peer, hash_key); |
| 310 | 316 | ||
| 311 | spin_lock(&rxnet->peer_hash_lock); | 317 | spin_lock(&rxnet->peer_hash_lock); |
| 312 | hash_add_rcu(rxnet->peer_hash, &peer->hash_link, hash_key); | 318 | hash_add_rcu(rxnet->peer_hash, &peer->hash_link, hash_key); |
| @@ -317,7 +323,8 @@ void rxrpc_new_incoming_peer(struct rxrpc_local *local, struct rxrpc_peer *peer) | |||
| 317 | /* | 323 | /* |
| 318 | * obtain a remote transport endpoint for the specified address | 324 | * obtain a remote transport endpoint for the specified address |
| 319 | */ | 325 | */ |
| 320 | struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local, | 326 | struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_sock *rx, |
| 327 | struct rxrpc_local *local, | ||
| 321 | struct sockaddr_rxrpc *srx, gfp_t gfp) | 328 | struct sockaddr_rxrpc *srx, gfp_t gfp) |
| 322 | { | 329 | { |
| 323 | struct rxrpc_peer *peer, *candidate; | 330 | struct rxrpc_peer *peer, *candidate; |
| @@ -337,7 +344,7 @@ struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local, | |||
| 337 | /* The peer is not yet present in hash - create a candidate | 344 | /* The peer is not yet present in hash - create a candidate |
| 338 | * for a new record and then redo the search. | 345 | * for a new record and then redo the search. |
| 339 | */ | 346 | */ |
| 340 | candidate = rxrpc_create_peer(local, srx, hash_key, gfp); | 347 | candidate = rxrpc_create_peer(rx, local, srx, hash_key, gfp); |
| 341 | if (!candidate) { | 348 | if (!candidate) { |
| 342 | _leave(" = NULL [nomem]"); | 349 | _leave(" = NULL [nomem]"); |
| 343 | return NULL; | 350 | return NULL; |
