blob: 225f8d11e173f2ccba2b861ff5a2f5e6dc841c1d [file] [log] [blame]
Jan Engelhardte0a812a2008-01-14 23:38:52 -08001/*
2 * xt_MARK - Netfilter module to modify the NFMARK field of an skb
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Jan Engelhardte0a812a2008-01-14 23:38:52 -08004 * (C) 1999-2001 Marc Boucher <marc@mbsi.ca>
5 * Copyright © CC Computer Consultants GmbH, 2007 - 2008
6 * Jan Engelhardt <jengelh@computergmbh.de>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 */
12
13#include <linux/module.h>
14#include <linux/skbuff.h>
15#include <linux/ip.h>
16#include <net/checksum.h>
17
Harald Welte2e4e6a12006-01-12 13:30:04 -080018#include <linux/netfilter/x_tables.h>
19#include <linux/netfilter/xt_MARK.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21MODULE_LICENSE("GPL");
22MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
Jan Engelhardt2ae15b62008-01-14 23:42:28 -080023MODULE_DESCRIPTION("Xtables: packet mark modification");
Harald Welte2e4e6a12006-01-12 13:30:04 -080024MODULE_ALIAS("ipt_MARK");
25MODULE_ALIAS("ip6t_MARK");
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27static unsigned int
Jan Engelhardt7eb35582008-10-08 11:35:19 +020028mark_tg(struct sk_buff *skb, const struct xt_target_param *par)
Jan Engelhardte0a812a2008-01-14 23:38:52 -080029{
Jan Engelhardt7eb35582008-10-08 11:35:19 +020030 const struct xt_mark_tginfo2 *info = par->targinfo;
Jan Engelhardte0a812a2008-01-14 23:38:52 -080031
32 skb->mark = (skb->mark & ~info->mask) ^ info->mark;
33 return XT_CONTINUE;
34}
35
Jan Engelhardtc8001f72009-06-12 18:47:32 +020036static struct xt_target mark_tg_reg __read_mostly = {
37 .name = "MARK",
38 .revision = 2,
39 .family = NFPROTO_UNSPEC,
40 .target = mark_tg,
41 .targetsize = sizeof(struct xt_mark_tginfo2),
42 .me = THIS_MODULE,
Harald Welte2e4e6a12006-01-12 13:30:04 -080043};
44
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080045static int __init mark_tg_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070046{
Jan Engelhardtc8001f72009-06-12 18:47:32 +020047 return xt_register_target(&mark_tg_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080050static void __exit mark_tg_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051{
Jan Engelhardtc8001f72009-06-12 18:47:32 +020052 xt_unregister_target(&mark_tg_reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080055module_init(mark_tg_init);
56module_exit(mark_tg_exit);