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

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

Version: ~ [ linux-5.6-rc7 ] ~ [ linux-5.5.11 ] ~ [ linux-5.4.27 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.112 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ 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.82 ] ~ [ 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 /*
  2  * (C) 2011 Pablo Neira Ayuso <pablo@netfilter.org>
  3  * (C) 2011 Intra2net AG <http://www.intra2net.com>
  4  *
  5  * This program is free software; you can redistribute it and/or modify
  6  * it under the terms of the GNU General Public License version 2 (or any
  7  * later at your option) as published by the Free Software Foundation.
  8  */
  9 #include <linux/module.h>
 10 #include <linux/skbuff.h>
 11 
 12 #include <linux/netfilter/x_tables.h>
 13 #include <linux/netfilter/nfnetlink_acct.h>
 14 #include <linux/netfilter/xt_nfacct.h>
 15 
 16 MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
 17 MODULE_DESCRIPTION("Xtables: match for the extended accounting infrastructure");
 18 MODULE_LICENSE("GPL");
 19 MODULE_ALIAS("ipt_nfacct");
 20 MODULE_ALIAS("ip6t_nfacct");
 21 
 22 static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par)
 23 {
 24         const struct xt_nfacct_match_info *info = par->targinfo;
 25 
 26         nfnl_acct_update(skb, info->nfacct);
 27 
 28         return true;
 29 }
 30 
 31 static int
 32 nfacct_mt_checkentry(const struct xt_mtchk_param *par)
 33 {
 34         struct xt_nfacct_match_info *info = par->matchinfo;
 35         struct nf_acct *nfacct;
 36 
 37         nfacct = nfnl_acct_find_get(info->name);
 38         if (nfacct == NULL) {
 39                 pr_info("xt_nfacct: accounting object with name `%s' "
 40                         "does not exists\n", info->name);
 41                 return -ENOENT;
 42         }
 43         info->nfacct = nfacct;
 44         return 0;
 45 }
 46 
 47 static void
 48 nfacct_mt_destroy(const struct xt_mtdtor_param *par)
 49 {
 50         const struct xt_nfacct_match_info *info = par->matchinfo;
 51 
 52         nfnl_acct_put(info->nfacct);
 53 }
 54 
 55 static struct xt_match nfacct_mt_reg __read_mostly = {
 56         .name       = "nfacct",
 57         .family     = NFPROTO_UNSPEC,
 58         .checkentry = nfacct_mt_checkentry,
 59         .match      = nfacct_mt,
 60         .destroy    = nfacct_mt_destroy,
 61         .matchsize  = sizeof(struct xt_nfacct_match_info),
 62         .me         = THIS_MODULE,
 63 };
 64 
 65 static int __init nfacct_mt_init(void)
 66 {
 67         return xt_register_match(&nfacct_mt_reg);
 68 }
 69 
 70 static void __exit nfacct_mt_exit(void)
 71 {
 72         xt_unregister_match(&nfacct_mt_reg);
 73 }
 74 
 75 module_init(nfacct_mt_init);
 76 module_exit(nfacct_mt_exit);
 77 

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