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

TOMOYO Linux Cross Reference
Linux/net/netfilter/nf_conntrack_timestamp.c

Version: ~ [ linux-5.8-rc4 ] ~ [ linux-5.7.7 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.50 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.131 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.187 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.229 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.229 ] ~ [ 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.85 ] ~ [ 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-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 /*
  2  * (C) 2010 Pablo Neira Ayuso <pablo@netfilter.org>
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License version 2 as
  6  * published by the Free Software Foundation (or any later at your option).
  7  */
  8 
  9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 10 
 11 #include <linux/netfilter.h>
 12 #include <linux/slab.h>
 13 #include <linux/kernel.h>
 14 #include <linux/moduleparam.h>
 15 
 16 #include <net/netfilter/nf_conntrack.h>
 17 #include <net/netfilter/nf_conntrack_extend.h>
 18 #include <net/netfilter/nf_conntrack_timestamp.h>
 19 
 20 static bool nf_ct_tstamp __read_mostly;
 21 
 22 module_param_named(tstamp, nf_ct_tstamp, bool, 0644);
 23 MODULE_PARM_DESC(tstamp, "Enable connection tracking flow timestamping.");
 24 
 25 #ifdef CONFIG_SYSCTL
 26 static struct ctl_table tstamp_sysctl_table[] = {
 27         {
 28                 .procname       = "nf_conntrack_timestamp",
 29                 .data           = &init_net.ct.sysctl_tstamp,
 30                 .maxlen         = sizeof(unsigned int),
 31                 .mode           = 0644,
 32                 .proc_handler   = proc_dointvec,
 33         },
 34         {}
 35 };
 36 #endif /* CONFIG_SYSCTL */
 37 
 38 static const struct nf_ct_ext_type tstamp_extend = {
 39         .len    = sizeof(struct nf_conn_tstamp),
 40         .align  = __alignof__(struct nf_conn_tstamp),
 41         .id     = NF_CT_EXT_TSTAMP,
 42 };
 43 
 44 #ifdef CONFIG_SYSCTL
 45 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
 46 {
 47         struct ctl_table *table;
 48 
 49         table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
 50                         GFP_KERNEL);
 51         if (!table)
 52                 goto out;
 53 
 54         table[0].data = &net->ct.sysctl_tstamp;
 55 
 56         /* Don't export sysctls to unprivileged users */
 57         if (net->user_ns != &init_user_ns)
 58                 table[0].procname = NULL;
 59 
 60         net->ct.tstamp_sysctl_header = register_net_sysctl(net, "net/netfilter",
 61                                                            table);
 62         if (!net->ct.tstamp_sysctl_header) {
 63                 pr_err("can't register to sysctl\n");
 64                 goto out_register;
 65         }
 66         return 0;
 67 
 68 out_register:
 69         kfree(table);
 70 out:
 71         return -ENOMEM;
 72 }
 73 
 74 static void nf_conntrack_tstamp_fini_sysctl(struct net *net)
 75 {
 76         struct ctl_table *table;
 77 
 78         table = net->ct.tstamp_sysctl_header->ctl_table_arg;
 79         unregister_net_sysctl_table(net->ct.tstamp_sysctl_header);
 80         kfree(table);
 81 }
 82 #else
 83 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
 84 {
 85         return 0;
 86 }
 87 
 88 static void nf_conntrack_tstamp_fini_sysctl(struct net *net)
 89 {
 90 }
 91 #endif
 92 
 93 int nf_conntrack_tstamp_pernet_init(struct net *net)
 94 {
 95         net->ct.sysctl_tstamp = nf_ct_tstamp;
 96         return nf_conntrack_tstamp_init_sysctl(net);
 97 }
 98 
 99 void nf_conntrack_tstamp_pernet_fini(struct net *net)
100 {
101         nf_conntrack_tstamp_fini_sysctl(net);
102 }
103 
104 int nf_conntrack_tstamp_init(void)
105 {
106         int ret;
107         ret = nf_ct_extend_register(&tstamp_extend);
108         if (ret < 0)
109                 pr_err("Unable to register extension\n");
110         return ret;
111 }
112 
113 void nf_conntrack_tstamp_fini(void)
114 {
115         nf_ct_extend_unregister(&tstamp_extend);
116 }
117 

~ [ 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