~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to net/ipv4/netfilter/ip_tables.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
}
69
69
EXPORT_SYMBOL_GPL(ipt_alloc_initial_table);
70
70
 
71
 
/*
72
 
   We keep a set of rules for each CPU, so we can avoid write-locking
73
 
   them in the softirq when updating the counters and therefore
74
 
   only need to read-lock in the softirq; doing a write_lock_bh() in user
75
 
   context stops packets coming through and allows user context to read
76
 
   the counters or update the rules.
77
 
 
78
 
   Hence the start of any table is given by get_table() below.  */
79
 
 
80
71
/* Returns whether matches rule or not. */
81
72
/* Performance critical - called for every packet */
82
73
static inline bool
311
302
        unsigned int *stackptr, origptr, cpu;
312
303
        const struct xt_table_info *private;
313
304
        struct xt_action_param acpar;
 
305
        unsigned int addend;
314
306
 
315
307
        /* Initialization */
316
308
        ip = ip_hdr(skb);
331
323
        acpar.hooknum = hook;
332
324
 
333
325
        IP_NF_ASSERT(table->valid_hooks & (1 << hook));
334
 
        xt_info_rdlock_bh();
 
326
        local_bh_disable();
 
327
        addend = xt_write_recseq_begin();
335
328
        private = table->private;
336
329
        cpu        = smp_processor_id();
337
330
        table_base = private->entries[cpu];
430
423
        pr_debug("Exiting %s; resetting sp from %u to %u\n",
431
424
                 __func__, *stackptr, origptr);
432
425
        *stackptr = origptr;
433
 
        xt_info_rdunlock_bh();
 
426
        xt_write_recseq_end(addend);
 
427
        local_bh_enable();
 
428
 
434
429
#ifdef DEBUG_ALLOW_ALL
435
430
        return NF_ACCEPT;
436
431
#else
571
566
        const struct xt_entry_target *t;
572
567
 
573
568
        if (!ip_checkentry(&e->ip)) {
574
 
                duprintf("ip check failed %p %s.\n", e, par->match->name);
 
569
                duprintf("ip check failed %p %s.\n", e, name);
575
570
                return -EINVAL;
576
571
        }
577
572
 
886
881
        unsigned int i;
887
882
 
888
883
        for_each_possible_cpu(cpu) {
889
 
                seqlock_t *lock = &per_cpu(xt_info_locks, cpu).lock;
 
884
                seqcount_t *s = &per_cpu(xt_recseq, cpu);
890
885
 
891
886
                i = 0;
892
887
                xt_entry_foreach(iter, t->entries[cpu], t->size) {
894
889
                        unsigned int start;
895
890
 
896
891
                        do {
897
 
                                start = read_seqbegin(lock);
 
892
                                start = read_seqcount_begin(s);
898
893
                                bcnt = iter->counters.bcnt;
899
894
                                pcnt = iter->counters.pcnt;
900
 
                        } while (read_seqretry(lock, start));
 
895
                        } while (read_seqcount_retry(s, start));
901
896
 
902
897
                        ADD_COUNTER(counters[i], bcnt, pcnt);
903
898
                        ++i; /* macro does multi eval of i */
1063
1058
        memcpy(newinfo, info, offsetof(struct xt_table_info, entries));
1064
1059
        newinfo->initial_entries = 0;
1065
1060
        loc_cpu_entry = info->entries[raw_smp_processor_id()];
 
1061
        xt_compat_init_offsets(AF_INET, info->number);
1066
1062
        xt_entry_foreach(iter, loc_cpu_entry, info->size) {
1067
1063
                ret = compat_calc_entry(iter, info, loc_cpu_entry, newinfo);
1068
1064
                if (ret != 0)
1311
1307
        int ret = 0;
1312
1308
        void *loc_cpu_entry;
1313
1309
        struct ipt_entry *iter;
 
1310
        unsigned int addend;
1314
1311
#ifdef CONFIG_COMPAT
1315
1312
        struct compat_xt_counters_info compat_tmp;
1316
1313
 
1367
1364
        /* Choose the copy that is on our node */
1368
1365
        curcpu = smp_processor_id();
1369
1366
        loc_cpu_entry = private->entries[curcpu];
1370
 
        xt_info_wrlock(curcpu);
 
1367
        addend = xt_write_recseq_begin();
1371
1368
        xt_entry_foreach(iter, loc_cpu_entry, private->size) {
1372
1369
                ADD_COUNTER(iter->counters, paddc[i].bcnt, paddc[i].pcnt);
1373
1370
                ++i;
1374
1371
        }
1375
 
        xt_info_wrunlock(curcpu);
 
1372
        xt_write_recseq_end(addend);
1376
1373
 unlock_up_free:
1377
1374
        local_bh_enable();
1378
1375
        xt_table_unlock(t);
1665
1662
        duprintf("translate_compat_table: size %u\n", info->size);
1666
1663
        j = 0;
1667
1664
        xt_compat_lock(AF_INET);
 
1665
        xt_compat_init_offsets(AF_INET, number);
1668
1666
        /* Walk through entries, checking offsets. */
1669
1667
        xt_entry_foreach(iter0, entry0, total_size) {
1670
1668
                ret = check_compat_entry_size_and_hooks(iter0, info, &size,
2231
2229
        if (ret < 0)
2232
2230
                goto err1;
2233
2231
 
2234
 
        /* Noone else will be downing sem now, so we won't sleep */
 
2232
        /* No one else will be downing sem now, so we won't sleep */
2235
2233
        ret = xt_register_targets(ipt_builtin_tg, ARRAY_SIZE(ipt_builtin_tg));
2236
2234
        if (ret < 0)
2237
2235
                goto err2;