~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/rxrpc/net_ns.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* rxrpc network namespace handling.
  2  *
  3  * Copyright (C) 2017 Red Hat, Inc. All Rights Reserved.
  4  * Written by David Howells (dhowells@redhat.com)
  5  *
  6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU General Public Licence
  8  * as published by the Free Software Foundation; either version
  9  * 2 of the Licence, or (at your option) any later version.
 10  */
 11 
 12 #include <linux/proc_fs.h>
 13 #include "ar-internal.h"
 14 
 15 unsigned int rxrpc_net_id;
 16 
 17 /*
 18  * Initialise a per-network namespace record.
 19  */
 20 static __net_init int rxrpc_init_net(struct net *net)
 21 {
 22         struct rxrpc_net *rxnet = rxrpc_net(net);
 23         int ret;
 24 
 25         get_random_bytes(&rxnet->epoch, sizeof(rxnet->epoch));
 26         rxnet->epoch |= RXRPC_RANDOM_EPOCH;
 27 
 28         INIT_LIST_HEAD(&rxnet->calls);
 29         rwlock_init(&rxnet->call_lock);
 30 
 31         INIT_LIST_HEAD(&rxnet->conn_proc_list);
 32         INIT_LIST_HEAD(&rxnet->service_conns);
 33         rwlock_init(&rxnet->conn_lock);
 34         INIT_DELAYED_WORK(&rxnet->service_conn_reaper,
 35                           rxrpc_service_connection_reaper);
 36 
 37         rxnet->nr_client_conns = 0;
 38         rxnet->nr_active_client_conns = 0;
 39         rxnet->kill_all_client_conns = false;
 40         spin_lock_init(&rxnet->client_conn_cache_lock);
 41         spin_lock_init(&rxnet->client_conn_discard_lock);
 42         INIT_LIST_HEAD(&rxnet->waiting_client_conns);
 43         INIT_LIST_HEAD(&rxnet->active_client_conns);
 44         INIT_LIST_HEAD(&rxnet->idle_client_conns);
 45         INIT_DELAYED_WORK(&rxnet->client_conn_reaper,
 46                           rxrpc_discard_expired_client_conns);
 47 
 48         INIT_LIST_HEAD(&rxnet->local_endpoints);
 49         mutex_init(&rxnet->local_mutex);
 50         hash_init(rxnet->peer_hash);
 51         spin_lock_init(&rxnet->peer_hash_lock);
 52 
 53         ret = -ENOMEM;
 54         rxnet->proc_net = proc_net_mkdir(net, "rxrpc", net->proc_net);
 55         if (!rxnet->proc_net)
 56                 goto err_proc;
 57 
 58         proc_create("calls", 0444, rxnet->proc_net, &rxrpc_call_seq_fops);
 59         proc_create("conns", 0444, rxnet->proc_net, &rxrpc_connection_seq_fops);
 60         return 0;
 61 
 62 err_proc:
 63         return ret;
 64 }
 65 
 66 /*
 67  * Clean up a per-network namespace record.
 68  */
 69 static __net_exit void rxrpc_exit_net(struct net *net)
 70 {
 71         struct rxrpc_net *rxnet = rxrpc_net(net);
 72 
 73         rxrpc_destroy_all_calls(rxnet);
 74         rxrpc_destroy_all_connections(rxnet);
 75         rxrpc_destroy_all_locals(rxnet);
 76         proc_remove(rxnet->proc_net);
 77 }
 78 
 79 struct pernet_operations rxrpc_net_ops = {
 80         .init   = rxrpc_init_net,
 81         .exit   = rxrpc_exit_net,
 82         .id     = &rxrpc_net_id,
 83         .size   = sizeof(struct rxrpc_net),
 84 };
 85 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp