linux/net/netfilter/nf_conntrack_acct.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/* Accounting handling for netfilter. */
   3
   4/*
   5 * (C) 2008 Krzysztof Piotr Oledzki <ole@ans.pl>
   6 */
   7
   8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
   9
  10#include <linux/netfilter.h>
  11#include <linux/slab.h>
  12#include <linux/kernel.h>
  13#include <linux/moduleparam.h>
  14#include <linux/export.h>
  15
  16#include <net/netfilter/nf_conntrack.h>
  17#include <net/netfilter/nf_conntrack_extend.h>
  18#include <net/netfilter/nf_conntrack_acct.h>
  19
  20static bool nf_ct_acct __read_mostly;
  21
  22module_param_named(acct, nf_ct_acct, bool, 0644);
  23MODULE_PARM_DESC(acct, "Enable connection tracking flow accounting.");
  24
  25static const struct nf_ct_ext_type acct_extend = {
  26        .len    = sizeof(struct nf_conn_acct),
  27        .align  = __alignof__(struct nf_conn_acct),
  28        .id     = NF_CT_EXT_ACCT,
  29};
  30
  31void nf_conntrack_acct_pernet_init(struct net *net)
  32{
  33        net->ct.sysctl_acct = nf_ct_acct;
  34}
  35
  36int nf_conntrack_acct_init(void)
  37{
  38        int ret = nf_ct_extend_register(&acct_extend);
  39        if (ret < 0)
  40                pr_err("Unable to register extension\n");
  41        return ret;
  42}
  43
  44void nf_conntrack_acct_fini(void)
  45{
  46        nf_ct_extend_unregister(&acct_extend);
  47}
  48