transport.c (0337966d121ebebf73a1c346123e8112796e684e) | transport.c (eee2fa6ab3225192d6d894c54a6fb02ac9efdff6) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2006 Oracle. All rights reserved. | 2 * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved. |
3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or --- 17 unchanged lines hidden (view full) --- 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * SOFTWARE. 31 * 32 */ 33#include <linux/kernel.h> 34#include <linux/module.h> 35#include <linux/in.h> | 3 * 4 * This software is available to you under a choice of one of two 5 * licenses. You may choose to be licensed under the terms of the GNU 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or --- 17 unchanged lines hidden (view full) --- 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * SOFTWARE. 31 * 32 */ 33#include <linux/kernel.h> 34#include <linux/module.h> 35#include <linux/in.h> |
36#include <linux/ipv6.h> |
|
36 37#include "rds.h" 38#include "loop.h" 39 40static struct rds_transport *transports[RDS_TRANS_COUNT]; 41static DECLARE_RWSEM(rds_trans_sem); 42 43void rds_trans_register(struct rds_transport *trans) --- 26 unchanged lines hidden (view full) --- 70EXPORT_SYMBOL_GPL(rds_trans_unregister); 71 72void rds_trans_put(struct rds_transport *trans) 73{ 74 if (trans) 75 module_put(trans->t_owner); 76} 77 | 37 38#include "rds.h" 39#include "loop.h" 40 41static struct rds_transport *transports[RDS_TRANS_COUNT]; 42static DECLARE_RWSEM(rds_trans_sem); 43 44void rds_trans_register(struct rds_transport *trans) --- 26 unchanged lines hidden (view full) --- 71EXPORT_SYMBOL_GPL(rds_trans_unregister); 72 73void rds_trans_put(struct rds_transport *trans) 74{ 75 if (trans) 76 module_put(trans->t_owner); 77} 78 |
78struct rds_transport *rds_trans_get_preferred(struct net *net, __be32 addr) | 79struct rds_transport *rds_trans_get_preferred(struct net *net, 80 const struct in6_addr *addr, 81 __u32 scope_id) |
79{ 80 struct rds_transport *ret = NULL; 81 struct rds_transport *trans; 82 unsigned int i; 83 | 82{ 83 struct rds_transport *ret = NULL; 84 struct rds_transport *trans; 85 unsigned int i; 86 |
84 if (IN_LOOPBACK(ntohl(addr))) | 87 if (ipv6_addr_v4mapped(addr)) { 88 if (*(u_int8_t *)&addr->s6_addr32[3] == IN_LOOPBACKNET) 89 return &rds_loop_transport; 90 } else if (ipv6_addr_loopback(addr)) { |
85 return &rds_loop_transport; | 91 return &rds_loop_transport; |
92 } |
|
86 87 down_read(&rds_trans_sem); 88 for (i = 0; i < RDS_TRANS_COUNT; i++) { 89 trans = transports[i]; 90 | 93 94 down_read(&rds_trans_sem); 95 for (i = 0; i < RDS_TRANS_COUNT; i++) { 96 trans = transports[i]; 97 |
91 if (trans && (trans->laddr_check(net, addr) == 0) && | 98 if (trans && (trans->laddr_check(net, addr, scope_id) == 0) && |
92 (!trans->t_owner || try_module_get(trans->t_owner))) { 93 ret = trans; 94 break; 95 } 96 } 97 up_read(&rds_trans_sem); 98 99 return ret; --- 56 unchanged lines hidden --- | 99 (!trans->t_owner || try_module_get(trans->t_owner))) { 100 ret = trans; 101 break; 102 } 103 } 104 up_read(&rds_trans_sem); 105 106 return ret; --- 56 unchanged lines hidden --- |