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

« back to all changes in this revision

Viewing changes to net/netfilter/nf_conntrack_netlink.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:
42
42
#include <net/netfilter/nf_conntrack_tuple.h>
43
43
#include <net/netfilter/nf_conntrack_acct.h>
44
44
#include <net/netfilter/nf_conntrack_zones.h>
 
45
#include <net/netfilter/nf_conntrack_timestamp.h>
45
46
#ifdef CONFIG_NF_NAT_NEEDED
46
47
#include <net/netfilter/nf_nat_core.h>
47
48
#include <net/netfilter/nf_nat_protocol.h>
230
231
        return -1;
231
232
}
232
233
 
 
234
static int
 
235
ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)
 
236
{
 
237
        struct nlattr *nest_count;
 
238
        const struct nf_conn_tstamp *tstamp;
 
239
 
 
240
        tstamp = nf_conn_tstamp_find(ct);
 
241
        if (!tstamp)
 
242
                return 0;
 
243
 
 
244
        nest_count = nla_nest_start(skb, CTA_TIMESTAMP | NLA_F_NESTED);
 
245
        if (!nest_count)
 
246
                goto nla_put_failure;
 
247
 
 
248
        NLA_PUT_BE64(skb, CTA_TIMESTAMP_START, cpu_to_be64(tstamp->start));
 
249
        if (tstamp->stop != 0) {
 
250
                NLA_PUT_BE64(skb, CTA_TIMESTAMP_STOP,
 
251
                             cpu_to_be64(tstamp->stop));
 
252
        }
 
253
        nla_nest_end(skb, nest_count);
 
254
 
 
255
        return 0;
 
256
 
 
257
nla_put_failure:
 
258
        return -1;
 
259
}
 
260
 
233
261
#ifdef CONFIG_NF_CONNTRACK_MARK
234
262
static inline int
235
263
ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
404
432
            ctnetlink_dump_timeout(skb, ct) < 0 ||
405
433
            ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
406
434
            ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0 ||
 
435
            ctnetlink_dump_timestamp(skb, ct) < 0 ||
407
436
            ctnetlink_dump_protoinfo(skb, ct) < 0 ||
408
437
            ctnetlink_dump_helpinfo(skb, ct) < 0 ||
409
438
            ctnetlink_dump_mark(skb, ct) < 0 ||
471
500
}
472
501
 
473
502
static inline size_t
 
503
ctnetlink_timestamp_size(const struct nf_conn *ct)
 
504
{
 
505
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
 
506
        if (!nf_ct_ext_exist(ct, NF_CT_EXT_TSTAMP))
 
507
                return 0;
 
508
        return nla_total_size(0) + 2 * nla_total_size(sizeof(uint64_t));
 
509
#else
 
510
        return 0;
 
511
#endif
 
512
}
 
513
 
 
514
static inline size_t
474
515
ctnetlink_nlmsg_size(const struct nf_conn *ct)
475
516
{
476
517
        return NLMSG_ALIGN(sizeof(struct nfgenmsg))
481
522
               + nla_total_size(sizeof(u_int32_t)) /* CTA_ID */
482
523
               + nla_total_size(sizeof(u_int32_t)) /* CTA_STATUS */
483
524
               + ctnetlink_counters_size(ct)
 
525
               + ctnetlink_timestamp_size(ct)
484
526
               + nla_total_size(sizeof(u_int32_t)) /* CTA_TIMEOUT */
485
527
               + nla_total_size(0) /* CTA_PROTOINFO */
486
528
               + nla_total_size(0) /* CTA_HELP */
571
613
 
572
614
        if (events & (1 << IPCT_DESTROY)) {
573
615
                if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
574
 
                    ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0)
 
616
                    ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0 ||
 
617
                    ctnetlink_dump_timestamp(skb, ct) < 0)
575
618
                        goto nla_put_failure;
576
619
        } else {
577
620
                if (ctnetlink_dump_timeout(skb, ct) < 0)
761
804
static int
762
805
ctnetlink_parse_tuple(const struct nlattr * const cda[],
763
806
                      struct nf_conntrack_tuple *tuple,
764
 
                      enum ctattr_tuple type, u_int8_t l3num)
 
807
                      enum ctattr_type type, u_int8_t l3num)
765
808
{
766
809
        struct nlattr *tb[CTA_TUPLE_MAX+1];
767
810
        int err;
1291
1334
        struct nf_conn *ct;
1292
1335
        int err = -EINVAL;
1293
1336
        struct nf_conntrack_helper *helper;
 
1337
        struct nf_conn_tstamp *tstamp;
1294
1338
 
1295
1339
        ct = nf_conntrack_alloc(net, zone, otuple, rtuple, GFP_ATOMIC);
1296
1340
        if (IS_ERR(ct))
1358
1402
        }
1359
1403
 
1360
1404
        nf_ct_acct_ext_add(ct, GFP_ATOMIC);
 
1405
        nf_ct_tstamp_ext_add(ct, GFP_ATOMIC);
1361
1406
        nf_ct_ecache_ext_add(ct, 0, 0, GFP_ATOMIC);
1362
1407
        /* we must add conntrack extensions before confirmation. */
1363
1408
        ct->status |= IPS_CONFIRMED;
1376
1421
        }
1377
1422
#endif
1378
1423
 
 
1424
        memset(&ct->proto, 0, sizeof(ct->proto));
1379
1425
        if (cda[CTA_PROTOINFO]) {
1380
1426
                err = ctnetlink_change_protoinfo(ct, cda);
1381
1427
                if (err < 0)
1406
1452
                __set_bit(IPS_EXPECTED_BIT, &ct->status);
1407
1453
                ct->master = master_ct;
1408
1454
        }
 
1455
        tstamp = nf_conn_tstamp_find(ct);
 
1456
        if (tstamp)
 
1457
                tstamp->start = ktime_to_ns(ktime_get_real());
1409
1458
 
1410
1459
        add_timer(&ct->timeout);
1411
1460
        nf_conntrack_hash_insert(ct);