Lines Matching +full:rs +full:-
14 * - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
70 * marked this socket and don't return a rs ref to the rx path.
76 struct rds_sock *rs; in rds_find_bound() local
80 rs = rhashtable_lookup(&bind_hash_table, key, ht_parms); in rds_find_bound()
81 if (rs && (sock_flag(rds_rs_to_sk(rs), SOCK_DEAD) || in rds_find_bound()
82 !refcount_inc_not_zero(&rds_rs_to_sk(rs)->sk_refcnt))) in rds_find_bound()
83 rs = NULL; in rds_find_bound()
87 rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr, in rds_find_bound()
90 return rs; in rds_find_bound()
93 /* returns -ve errno or +ve port */
94 static int rds_add_bound(struct rds_sock *rs, const struct in6_addr *addr, in rds_add_bound() argument
97 int ret = -EADDRINUSE; in rds_add_bound()
104 return -EINVAL; in rds_add_bound()
108 last = rover - 1; in rds_add_bound()
122 memcpy(rs->rs_bound_key, key, sizeof(rs->rs_bound_key)); in rds_add_bound()
123 rs->rs_bound_addr = *addr; in rds_add_bound()
124 net_get_random_once(&rs->rs_hash_initval, in rds_add_bound()
125 sizeof(rs->rs_hash_initval)); in rds_add_bound()
126 rs->rs_bound_port = cpu_to_be16(rover); in rds_add_bound()
127 rs->rs_bound_node.next = NULL; in rds_add_bound()
128 rds_sock_addref(rs); in rds_add_bound()
130 &rs->rs_bound_node, ht_parms)) { in rds_add_bound()
131 *port = rs->rs_bound_port; in rds_add_bound()
132 rs->rs_bound_scope_id = scope_id; in rds_add_bound()
134 rdsdebug("rs %p binding to %pI6c:%d\n", in rds_add_bound()
135 rs, addr, (int)ntohs(*port)); in rds_add_bound()
138 rs->rs_bound_addr = in6addr_any; in rds_add_bound()
139 rds_sock_put(rs); in rds_add_bound()
140 ret = -ENOMEM; in rds_add_bound()
148 void rds_remove_bound(struct rds_sock *rs) in rds_remove_bound() argument
151 if (ipv6_addr_any(&rs->rs_bound_addr)) in rds_remove_bound()
154 rdsdebug("rs %p unbinding from %pI6c:%d\n", in rds_remove_bound()
155 rs, &rs->rs_bound_addr, in rds_remove_bound()
156 ntohs(rs->rs_bound_port)); in rds_remove_bound()
158 rhashtable_remove_fast(&bind_hash_table, &rs->rs_bound_node, ht_parms); in rds_remove_bound()
159 rds_sock_put(rs); in rds_remove_bound()
160 rs->rs_bound_addr = in6addr_any; in rds_remove_bound()
165 struct sock *sk = sock->sk; in rds_bind()
166 struct rds_sock *rs = rds_sk_to_rs(sk); in rds_bind() local
177 return -EINVAL; in rds_bind()
178 if (uaddr->sa_family == AF_INET) { in rds_bind()
182 sin->sin_addr.s_addr == htonl(INADDR_ANY) || in rds_bind()
183 sin->sin_addr.s_addr == htonl(INADDR_BROADCAST) || in rds_bind()
184 ipv4_is_multicast(sin->sin_addr.s_addr)) in rds_bind()
185 return -EINVAL; in rds_bind()
186 ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &v6addr); in rds_bind()
188 port = sin->sin_port; in rds_bind()
190 } else if (uaddr->sa_family == AF_INET6) { in rds_bind()
195 return -EINVAL; in rds_bind()
196 addr_type = ipv6_addr_type(&sin6->sin6_addr); in rds_bind()
201 return -EINVAL; in rds_bind()
206 addr4 = sin6->sin6_addr.s6_addr32[3]; in rds_bind()
210 return -EINVAL; in rds_bind()
214 if (sin6->sin6_scope_id == 0) in rds_bind()
215 return -EINVAL; in rds_bind()
216 scope_id = sin6->sin6_scope_id; in rds_bind()
218 binding_addr = &sin6->sin6_addr; in rds_bind()
219 port = sin6->sin6_port; in rds_bind()
222 return -EINVAL; in rds_bind()
226 /* RDS socket does not allow re-binding. */ in rds_bind()
227 if (!ipv6_addr_any(&rs->rs_bound_addr)) { in rds_bind()
228 ret = -EINVAL; in rds_bind()
233 * non-link local address (scope_id is 0). in rds_bind()
235 if (!ipv6_addr_any(&rs->rs_conn_addr) && scope_id && in rds_bind()
236 rs->rs_bound_scope_id && in rds_bind()
237 scope_id != rs->rs_bound_scope_id) { in rds_bind()
238 ret = -EINVAL; in rds_bind()
245 if (rs->rs_transport) { in rds_bind()
246 trans = rs->rs_transport; in rds_bind()
247 if (!trans->laddr_check || in rds_bind()
248 trans->laddr_check(sock_net(sock->sk), in rds_bind()
250 ret = -ENOPROTOOPT; in rds_bind()
254 trans = rds_trans_get_preferred(sock_net(sock->sk), in rds_bind()
257 ret = -EADDRNOTAVAIL; in rds_bind()
262 rs->rs_transport = trans; in rds_bind()
266 ret = rds_add_bound(rs, binding_addr, &port, scope_id); in rds_bind()
268 rs->rs_transport = NULL; in rds_bind()