tcp.c (1e2b44e78eead7bcadfbf96f70d95773191541c9) tcp.c (b7ff8b1036f0b0df1390ba6b5e9bc7ec458e857a)
1/*
2 * Copyright (c) 2006, 2018 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:

--- 259 unchanged lines hidden (view full) ---

268
269out:
270 lens->nr = rds_tcp_tc_count;
271 lens->each = sizeof(tsinfo);
272
273 spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
274}
275
1/*
2 * Copyright (c) 2006, 2018 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:

--- 259 unchanged lines hidden (view full) ---

268
269out:
270 lens->nr = rds_tcp_tc_count;
271 lens->each = sizeof(tsinfo);
272
273 spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
274}
275
276/* Handle RDS6_INFO_TCP_SOCKETS socket option. It returns both IPv4 and
277 * IPv6 connections. IPv4 connection address is returned in an IPv4 mapped
278 * address.
279 */
280static void rds6_tcp_tc_info(struct socket *sock, unsigned int len,
281 struct rds_info_iterator *iter,
282 struct rds_info_lengths *lens)
283{
284 struct rds6_info_tcp_socket tsinfo6;
285 struct rds_tcp_connection *tc;
286 unsigned long flags;
287
288 spin_lock_irqsave(&rds_tcp_tc_list_lock, flags);
289
290 if (len / sizeof(tsinfo6) < rds6_tcp_tc_count)
291 goto out;
292
293 list_for_each_entry(tc, &rds_tcp_tc_list, t_list_item) {
294 struct sock *sk = tc->t_sock->sk;
295 struct inet_sock *inet = inet_sk(sk);
296
297 tsinfo6.local_addr = sk->sk_v6_rcv_saddr;
298 tsinfo6.local_port = inet->inet_sport;
299 tsinfo6.peer_addr = sk->sk_v6_daddr;
300 tsinfo6.peer_port = inet->inet_dport;
301
302 tsinfo6.hdr_rem = tc->t_tinc_hdr_rem;
303 tsinfo6.data_rem = tc->t_tinc_data_rem;
304 tsinfo6.last_sent_nxt = tc->t_last_sent_nxt;
305 tsinfo6.last_expected_una = tc->t_last_expected_una;
306 tsinfo6.last_seen_una = tc->t_last_seen_una;
307
308 rds_info_copy(iter, &tsinfo6, sizeof(tsinfo6));
309 }
310
311out:
312 lens->nr = rds6_tcp_tc_count;
313 lens->each = sizeof(tsinfo6);
314
315 spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
316}
317
276static int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr,
277 __u32 scope_id)
278{
279 struct net_device *dev = NULL;
280 int ret;
281
282 if (ipv6_addr_v4mapped(addr)) {
283 if (inet_addr_type(net, addr->s6_addr32[3]) == RTN_LOCAL)

--- 339 unchanged lines hidden (view full) ---

623 return 0;
624}
625
626static void rds_tcp_exit(void)
627{
628 rds_tcp_set_unloading();
629 synchronize_rcu();
630 rds_info_deregister_func(RDS_INFO_TCP_SOCKETS, rds_tcp_tc_info);
318static int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr,
319 __u32 scope_id)
320{
321 struct net_device *dev = NULL;
322 int ret;
323
324 if (ipv6_addr_v4mapped(addr)) {
325 if (inet_addr_type(net, addr->s6_addr32[3]) == RTN_LOCAL)

--- 339 unchanged lines hidden (view full) ---

665 return 0;
666}
667
668static void rds_tcp_exit(void)
669{
670 rds_tcp_set_unloading();
671 synchronize_rcu();
672 rds_info_deregister_func(RDS_INFO_TCP_SOCKETS, rds_tcp_tc_info);
673 rds_info_deregister_func(RDS6_INFO_TCP_SOCKETS, rds6_tcp_tc_info);
631 unregister_pernet_device(&rds_tcp_net_ops);
632 rds_tcp_destroy_conns();
633 rds_trans_unregister(&rds_tcp_transport);
634 rds_tcp_recv_exit();
635 kmem_cache_destroy(rds_tcp_conn_slab);
636}
637module_exit(rds_tcp_exit);
638

--- 15 unchanged lines hidden (view full) ---

654
655 ret = register_pernet_device(&rds_tcp_net_ops);
656 if (ret)
657 goto out_recv;
658
659 rds_trans_register(&rds_tcp_transport);
660
661 rds_info_register_func(RDS_INFO_TCP_SOCKETS, rds_tcp_tc_info);
674 unregister_pernet_device(&rds_tcp_net_ops);
675 rds_tcp_destroy_conns();
676 rds_trans_unregister(&rds_tcp_transport);
677 rds_tcp_recv_exit();
678 kmem_cache_destroy(rds_tcp_conn_slab);
679}
680module_exit(rds_tcp_exit);
681

--- 15 unchanged lines hidden (view full) ---

697
698 ret = register_pernet_device(&rds_tcp_net_ops);
699 if (ret)
700 goto out_recv;
701
702 rds_trans_register(&rds_tcp_transport);
703
704 rds_info_register_func(RDS_INFO_TCP_SOCKETS, rds_tcp_tc_info);
705 rds_info_register_func(RDS6_INFO_TCP_SOCKETS, rds6_tcp_tc_info);
662
663 goto out;
664out_recv:
665 rds_tcp_recv_exit();
666out_slab:
667 kmem_cache_destroy(rds_tcp_conn_slab);
668out:
669 return ret;
670}
671module_init(rds_tcp_init);
672
673MODULE_AUTHOR("Oracle Corporation <rds-devel@oss.oracle.com>");
674MODULE_DESCRIPTION("RDS: TCP transport");
675MODULE_LICENSE("Dual BSD/GPL");
676
706
707 goto out;
708out_recv:
709 rds_tcp_recv_exit();
710out_slab:
711 kmem_cache_destroy(rds_tcp_conn_slab);
712out:
713 return ret;
714}
715module_init(rds_tcp_init);
716
717MODULE_AUTHOR("Oracle Corporation <rds-devel@oss.oracle.com>");
718MODULE_DESCRIPTION("RDS: TCP transport");
719MODULE_LICENSE("Dual BSD/GPL");
720