~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to net/netfilter/nf_conntrack_snmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
20
#define SNMP_PORT       161
 
21
 
 
22
MODULE_AUTHOR("Jiri Olsa <jolsa@redhat.com>");
 
23
MODULE_DESCRIPTION("SNMP service broadcast connection tracking helper");
 
24
MODULE_LICENSE("GPL");
 
25
MODULE_ALIAS_NFCT_HELPER("snmp");
 
26
 
 
27
static unsigned int timeout __read_mostly = 30;
 
28
module_param(timeout, uint, S_IRUSR);
 
29
MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds");
 
30
 
 
31
int (*nf_nat_snmp_hook)(struct sk_buff *skb,
 
32
                        unsigned int protoff,
 
33
                        struct nf_conn *ct,
 
34
                        enum ip_conntrack_info ctinfo);
 
35
EXPORT_SYMBOL_GPL(nf_nat_snmp_hook);
 
36
 
 
37
static int snmp_conntrack_help(struct sk_buff *skb, unsigned int protoff,
 
38
                struct nf_conn *ct, enum ip_conntrack_info ctinfo)
 
39
{
 
40
        typeof(nf_nat_snmp_hook) nf_nat_snmp;
 
41
 
 
42
        nf_conntrack_broadcast_help(skb, protoff, ct, ctinfo, timeout);
 
43
 
 
44
        nf_nat_snmp = rcu_dereference(nf_nat_snmp_hook);
 
45
        if (nf_nat_snmp && ct->status & IPS_NAT_MASK)
 
46
                return nf_nat_snmp(skb, protoff, ct, ctinfo);
 
47
 
 
48
        return NF_ACCEPT;
 
49
}
 
50
 
 
51
static struct nf_conntrack_expect_policy exp_policy = {
 
52
        .max_expected   = 1,
 
53
};
 
54
 
 
55
static struct nf_conntrack_helper helper __read_mostly = {
 
56
        .name                   = "snmp",
 
57
        .tuple.src.l3num        = NFPROTO_IPV4,
 
58
        .tuple.src.u.udp.port   = cpu_to_be16(SNMP_PORT),
 
59
        .tuple.dst.protonum     = IPPROTO_UDP,
 
60
        .me                     = THIS_MODULE,
 
61
        .help                   = snmp_conntrack_help,
 
62
        .expect_policy          = &exp_policy,
 
63
};
 
64
 
 
65
static int __init nf_conntrack_snmp_init(void)
 
66
{
 
67
        exp_policy.timeout = timeout;
 
68
        return nf_conntrack_helper_register(&helper);
 
69
}
 
70
 
 
71
static void __exit nf_conntrack_snmp_fini(void)
 
72
{
 
73
        nf_conntrack_helper_unregister(&helper);
 
74
}
 
75
 
 
76
module_init(nf_conntrack_snmp_init);
 
77
module_exit(nf_conntrack_snmp_fini);