11
11
12
12
#include <linux/atomic.h>
13
13
#include <linux/seqlock.h>
14
+ #include <net/net_namespace.h>
15
+ #include <net/netns/generic.h>
14
16
#include <net/sock.h>
15
17
#include <net/af_rxrpc.h>
16
18
#include <rxrpc/packet.h>
@@ -64,6 +66,37 @@ enum {
64
66
RXRPC_CLOSE , /* socket is being closed */
65
67
};
66
68
69
+ /*
70
+ * Per-network namespace data.
71
+ */
72
+ struct rxrpc_net {
73
+ struct proc_dir_entry * proc_net ; /* Subdir in /proc/net */
74
+ u32 epoch ; /* Local epoch for detecting local-end reset */
75
+ struct list_head calls ; /* List of calls active in this namespace */
76
+ rwlock_t call_lock ; /* Lock for ->calls */
77
+
78
+ struct list_head conn_proc_list ; /* List of conns in this namespace for proc */
79
+ struct list_head service_conns ; /* Service conns in this namespace */
80
+ rwlock_t conn_lock ; /* Lock for ->conn_proc_list, ->service_conns */
81
+ struct delayed_work service_conn_reaper ;
82
+
83
+ unsigned int nr_client_conns ;
84
+ unsigned int nr_active_client_conns ;
85
+ bool kill_all_client_conns ;
86
+ spinlock_t client_conn_cache_lock ; /* Lock for ->*_client_conns */
87
+ spinlock_t client_conn_discard_lock ; /* Prevent multiple discarders */
88
+ struct list_head waiting_client_conns ;
89
+ struct list_head active_client_conns ;
90
+ struct list_head idle_client_conns ;
91
+ struct delayed_work client_conn_reaper ;
92
+
93
+ struct list_head local_endpoints ;
94
+ struct mutex local_mutex ; /* Lock for ->local_endpoints */
95
+
96
+ spinlock_t peer_hash_lock ; /* Lock for ->peer_hash */
97
+ DECLARE_HASHTABLE (peer_hash , 10 );
98
+ };
99
+
67
100
/*
68
101
* Service backlog preallocation.
69
102
*
@@ -211,6 +244,7 @@ struct rxrpc_security {
211
244
struct rxrpc_local {
212
245
struct rcu_head rcu ;
213
246
atomic_t usage ;
247
+ struct rxrpc_net * rxnet ; /* The network ns in which this resides */
214
248
struct list_head link ;
215
249
struct socket * socket ; /* my UDP socket */
216
250
struct work_struct processor ;
@@ -601,7 +635,6 @@ struct rxrpc_ack_summary {
601
635
* af_rxrpc.c
602
636
*/
603
637
extern atomic_t rxrpc_n_tx_skbs , rxrpc_n_rx_skbs ;
604
- extern u32 rxrpc_epoch ;
605
638
extern atomic_t rxrpc_debug_id ;
606
639
extern struct workqueue_struct * rxrpc_workqueue ;
607
640
@@ -634,8 +667,6 @@ extern const char *const rxrpc_call_states[];
634
667
extern const char * const rxrpc_call_completions [];
635
668
extern unsigned int rxrpc_max_call_lifetime ;
636
669
extern struct kmem_cache * rxrpc_call_jar ;
637
- extern struct list_head rxrpc_calls ;
638
- extern rwlock_t rxrpc_call_lock ;
639
670
640
671
struct rxrpc_call * rxrpc_find_call_by_user_ID (struct rxrpc_sock * , unsigned long );
641
672
struct rxrpc_call * rxrpc_alloc_call (gfp_t );
@@ -653,7 +684,7 @@ void rxrpc_see_call(struct rxrpc_call *);
653
684
void rxrpc_get_call (struct rxrpc_call * , enum rxrpc_call_trace );
654
685
void rxrpc_put_call (struct rxrpc_call * , enum rxrpc_call_trace );
655
686
void rxrpc_cleanup_call (struct rxrpc_call * );
656
- void __exit rxrpc_destroy_all_calls (void );
687
+ void rxrpc_destroy_all_calls (struct rxrpc_net * );
657
688
658
689
static inline bool rxrpc_is_service_call (const struct rxrpc_call * call )
659
690
{
@@ -773,7 +804,8 @@ int rxrpc_connect_call(struct rxrpc_call *, struct rxrpc_conn_parameters *,
773
804
void rxrpc_expose_client_call (struct rxrpc_call * );
774
805
void rxrpc_disconnect_client_call (struct rxrpc_call * );
775
806
void rxrpc_put_client_conn (struct rxrpc_connection * );
776
- void __exit rxrpc_destroy_all_client_connections (void );
807
+ void rxrpc_discard_expired_client_conns (struct work_struct * );
808
+ void rxrpc_destroy_all_client_connections (struct rxrpc_net * );
777
809
778
810
/*
779
811
* conn_event.c
@@ -784,9 +816,6 @@ void rxrpc_process_connection(struct work_struct *);
784
816
* conn_object.c
785
817
*/
786
818
extern unsigned int rxrpc_connection_expiry ;
787
- extern struct list_head rxrpc_connections ;
788
- extern struct list_head rxrpc_connection_proc_list ;
789
- extern rwlock_t rxrpc_connection_lock ;
790
819
791
820
int rxrpc_extract_addr_from_skb (struct sockaddr_rxrpc * , struct sk_buff * );
792
821
struct rxrpc_connection * rxrpc_alloc_connection (gfp_t );
@@ -800,7 +829,8 @@ void rxrpc_see_connection(struct rxrpc_connection *);
800
829
void rxrpc_get_connection (struct rxrpc_connection * );
801
830
struct rxrpc_connection * rxrpc_get_connection_maybe (struct rxrpc_connection * );
802
831
void rxrpc_put_service_conn (struct rxrpc_connection * );
803
- void __exit rxrpc_destroy_all_connections (void );
832
+ void rxrpc_service_connection_reaper (struct work_struct * );
833
+ void rxrpc_destroy_all_connections (struct rxrpc_net * );
804
834
805
835
static inline bool rxrpc_conn_is_client (const struct rxrpc_connection * conn )
806
836
{
@@ -828,7 +858,7 @@ static inline void rxrpc_put_connection(struct rxrpc_connection *conn)
828
858
*/
829
859
struct rxrpc_connection * rxrpc_find_service_conn_rcu (struct rxrpc_peer * ,
830
860
struct sk_buff * );
831
- struct rxrpc_connection * rxrpc_prealloc_service_connection (gfp_t );
861
+ struct rxrpc_connection * rxrpc_prealloc_service_connection (struct rxrpc_net * , gfp_t );
832
862
void rxrpc_new_incoming_connection (struct rxrpc_connection * , struct sk_buff * );
833
863
void rxrpc_unpublish_service_conn (struct rxrpc_connection * );
834
864
@@ -861,9 +891,9 @@ extern void rxrpc_process_local_events(struct rxrpc_local *);
861
891
/*
862
892
* local_object.c
863
893
*/
864
- struct rxrpc_local * rxrpc_lookup_local (const struct sockaddr_rxrpc * );
894
+ struct rxrpc_local * rxrpc_lookup_local (struct net * , const struct sockaddr_rxrpc * );
865
895
void __rxrpc_put_local (struct rxrpc_local * );
866
- void __exit rxrpc_destroy_all_locals (void );
896
+ void rxrpc_destroy_all_locals (struct rxrpc_net * );
867
897
868
898
static inline void rxrpc_get_local (struct rxrpc_local * local )
869
899
{
@@ -901,6 +931,17 @@ extern unsigned int rxrpc_resend_timeout;
901
931
902
932
extern const s8 rxrpc_ack_priority [];
903
933
934
+ /*
935
+ * net_ns.c
936
+ */
937
+ extern unsigned int rxrpc_net_id ;
938
+ extern struct pernet_operations rxrpc_net_ops ;
939
+
940
+ static inline struct rxrpc_net * rxrpc_net (struct net * net )
941
+ {
942
+ return net_generic (net , rxrpc_net_id );
943
+ }
944
+
904
945
/*
905
946
* output.c
906
947
*/
0 commit comments