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

« back to all changes in this revision

Viewing changes to net/bridge/netfilter/ebt_ulog.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 *   flushed even if it is not full yet.
28
28
 *
29
29
 */
30
 
 
 
30
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
31
#include <linux/module.h>
 
32
#include <linux/slab.h>
32
33
#include <linux/spinlock.h>
33
34
#include <linux/socket.h>
34
35
#include <linux/skbuff.h>
43
44
#include <net/sock.h>
44
45
#include "../br_private.h"
45
46
 
46
 
#define PRINTR(format, args...) do { if (net_ratelimit()) \
47
 
                                printk(format , ## args); } while (0)
48
 
 
49
47
static unsigned int nlbufsiz = NLMSG_GOODSIZE;
50
48
module_param(nlbufsiz, uint, 0600);
51
49
MODULE_PARM_DESC(nlbufsiz, "netlink buffer size (number of bytes) "
106
104
        n = max(size, nlbufsiz);
107
105
        skb = alloc_skb(n, GFP_ATOMIC);
108
106
        if (!skb) {
109
 
                PRINTR(KERN_ERR "ebt_ulog: can't alloc whole buffer "
110
 
                       "of size %ub!\n", n);
 
107
                pr_debug("cannot alloc whole buffer of size %ub!\n", n);
111
108
                if (n > size) {
112
109
                        /* try to allocate only as much as we need for
113
110
                         * current packet */
114
111
                        skb = alloc_skb(size, GFP_ATOMIC);
115
112
                        if (!skb)
116
 
                                PRINTR(KERN_ERR "ebt_ulog: can't even allocate "
117
 
                                       "buffer of size %ub\n", size);
 
113
                                pr_debug("cannot even allocate "
 
114
                                         "buffer of size %ub\n", size);
118
115
                }
119
116
        }
120
117
 
141
138
 
142
139
        size = NLMSG_SPACE(sizeof(*pm) + copy_len);
143
140
        if (size > nlbufsiz) {
144
 
                PRINTR("ebt_ulog: Size %Zd needed, but nlbufsiz=%d\n",
145
 
                       size, nlbufsiz);
 
141
                pr_debug("Size %Zd needed, but nlbufsiz=%d\n", size, nlbufsiz);
146
142
                return;
147
143
        }
148
144
 
181
177
        if (in) {
182
178
                strcpy(pm->physindev, in->name);
183
179
                /* If in isn't a bridge, then physindev==indev */
184
 
                if (in->br_port)
185
 
                        strcpy(pm->indev, in->br_port->br->dev->name);
 
180
                if (br_port_exists(in))
 
181
                        /* rcu_read_lock()ed by nf_hook_slow */
 
182
                        strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
186
183
                else
187
184
                        strcpy(pm->indev, in->name);
188
185
        } else
191
188
        if (out) {
192
189
                /* If out exists, then out is a bridge port */
193
190
                strcpy(pm->physoutdev, out->name);
194
 
                strcpy(pm->outdev, out->br_port->br->dev->name);
 
191
                /* rcu_read_lock()ed by nf_hook_slow */
 
192
                strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
195
193
        } else
196
194
                pm->outdev[0] = pm->physoutdev[0] = '\0';
197
195
 
216
214
        return;
217
215
 
218
216
nlmsg_failure:
219
 
        printk(KERN_CRIT "ebt_ulog: error during NLMSG_PUT. This should "
220
 
               "not happen, please report to author.\n");
 
217
        pr_debug("error during NLMSG_PUT. This should "
 
218
                 "not happen, please report to author.\n");
221
219
        goto unlock;
222
220
alloc_failure:
223
221
        goto unlock;
247
245
}
248
246
 
249
247
static unsigned int
250
 
ebt_ulog_tg(struct sk_buff *skb, const struct xt_target_param *par)
 
248
ebt_ulog_tg(struct sk_buff *skb, const struct xt_action_param *par)
251
249
{
252
250
        ebt_ulog_packet(par->hooknum, skb, par->in, par->out,
253
251
                        par->targinfo, NULL);
254
252
        return EBT_CONTINUE;
255
253
}
256
254
 
257
 
static bool ebt_ulog_tg_check(const struct xt_tgchk_param *par)
 
255
static int ebt_ulog_tg_check(const struct xt_tgchk_param *par)
258
256
{
259
257
        struct ebt_ulog_info *uloginfo = par->targinfo;
260
258
 
261
259
        if (uloginfo->nlgroup > 31)
262
 
                return false;
 
260
                return -EINVAL;
263
261
 
264
262
        uloginfo->prefix[EBT_ULOG_PREFIX_LEN - 1] = '\0';
265
263
 
266
264
        if (uloginfo->qthreshold > EBT_ULOG_MAX_QLEN)
267
265
                uloginfo->qthreshold = EBT_ULOG_MAX_QLEN;
268
266
 
269
 
        return true;
 
267
        return 0;
270
268
}
271
269
 
272
270
static struct xt_target ebt_ulog_tg_reg __read_mostly = {
275
273
        .family         = NFPROTO_BRIDGE,
276
274
        .target         = ebt_ulog_tg,
277
275
        .checkentry     = ebt_ulog_tg_check,
278
 
        .targetsize     = XT_ALIGN(sizeof(struct ebt_ulog_info)),
 
276
        .targetsize     = sizeof(struct ebt_ulog_info),
279
277
        .me             = THIS_MODULE,
280
278
};
281
279
 
291
289
        int i;
292
290
 
293
291
        if (nlbufsiz >= 128*1024) {
294
 
                printk(KERN_NOTICE "ebt_ulog: Netlink buffer has to be <= 128kB,"
295
 
                       " please try a smaller nlbufsiz parameter.\n");
 
292
                pr_warning("Netlink buffer has to be <= 128kB,"
 
293
                           " please try a smaller nlbufsiz parameter.\n");
296
294
                return -EINVAL;
297
295
        }
298
296
 
305
303
        ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG,
306
304
                                          EBT_ULOG_MAXNLGROUPS, NULL, NULL,
307
305
                                          THIS_MODULE);
308
 
        if (!ebtulognl) {
309
 
                printk(KERN_WARNING KBUILD_MODNAME ": out of memory trying to "
310
 
                       "call netlink_kernel_create\n");
 
306
        if (!ebtulognl)
311
307
                ret = -ENOMEM;
312
 
        } else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0) {
 
308
        else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0)
313
309
                netlink_kernel_release(ebtulognl);
314
 
        }
315
310
 
316
311
        if (ret == 0)
317
312
                nf_log_register(NFPROTO_BRIDGE, &ebt_ulog_logger);