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

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

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ 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.75 ] ~ [ 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  *      SNMP service broadcast connection tracking helper
  3  *
  4  *      (c) 2011 Jiri Olsa <jolsa@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 License
  8  *      as published by the Free Software Foundation; either version
  9  *      2 of the License, or (at your option) any later version.
 10  */
 11 #include <linux/kernel.h>
 12 #include <linux/module.h>
 13 #include <linux/init.h>
 14 #include <linux/in.h>
 15 
 16 #include <net/netfilter/nf_conntrack.h>
 17 #include <net/netfilter/nf_conntrack_helper.h>
 18 #include <net/netfilter/nf_conntrack_expect.h>
 19 #include <linux/netfilter/nf_conntrack_snmp.h>
 20 
 21 #define SNMP_PORT       161
 22 
 23 MODULE_AUTHOR("Jiri Olsa <jolsa@redhat.com>");
 24 MODULE_DESCRIPTION("SNMP service broadcast connection tracking helper");
 25 MODULE_LICENSE("GPL");
 26 MODULE_ALIAS_NFCT_HELPER("snmp");
 27 
 28 static unsigned int timeout __read_mostly = 30;
 29 module_param(timeout, uint, S_IRUSR);
 30 MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds");
 31 
 32 int (*nf_nat_snmp_hook)(struct sk_buff *skb,
 33                         unsigned int protoff,
 34                         struct nf_conn *ct,
 35                         enum ip_conntrack_info ctinfo);
 36 EXPORT_SYMBOL_GPL(nf_nat_snmp_hook);
 37 
 38 static int snmp_conntrack_help(struct sk_buff *skb, unsigned int protoff,
 39                 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
 40 {
 41         typeof(nf_nat_snmp_hook) nf_nat_snmp;
 42 
 43         nf_conntrack_broadcast_help(skb, protoff, ct, ctinfo, timeout);
 44 
 45         nf_nat_snmp = rcu_dereference(nf_nat_snmp_hook);
 46         if (nf_nat_snmp && ct->status & IPS_NAT_MASK)
 47                 return nf_nat_snmp(skb, protoff, ct, ctinfo);
 48 
 49         return NF_ACCEPT;
 50 }
 51 
 52 static struct nf_conntrack_expect_policy exp_policy = {
 53         .max_expected   = 1,
 54 };
 55 
 56 static struct nf_conntrack_helper helper __read_mostly = {
 57         .name                   = "snmp",
 58         .tuple.src.l3num        = NFPROTO_IPV4,
 59         .tuple.src.u.udp.port   = cpu_to_be16(SNMP_PORT),
 60         .tuple.dst.protonum     = IPPROTO_UDP,
 61         .me                     = THIS_MODULE,
 62         .help                   = snmp_conntrack_help,
 63         .expect_policy          = &exp_policy,
 64 };
 65 
 66 static int __init nf_conntrack_snmp_init(void)
 67 {
 68         exp_policy.timeout = timeout;
 69         return nf_conntrack_helper_register(&helper);
 70 }
 71 
 72 static void __exit nf_conntrack_snmp_fini(void)
 73 {
 74         nf_conntrack_helper_unregister(&helper);
 75 }
 76 
 77 module_init(nf_conntrack_snmp_init);
 78 module_exit(nf_conntrack_snmp_fini);
 79 

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