Release 4.11 net/netfilter/xt_dscp.c
/* IP tables module for matching the value of the IPv4/IPv6 DSCP field
*
* (C) 2002 by Harald Welte <laforge@netfilter.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <net/dsfield.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter/xt_dscp.h>
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("Xtables: DSCP/TOS field match");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_dscp");
MODULE_ALIAS("ip6t_dscp");
MODULE_ALIAS("ipt_tos");
MODULE_ALIAS("ip6t_tos");
static bool
dscp_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
const struct xt_dscp_info *info = par->matchinfo;
u_int8_t dscp = ipv4_get_dsfield(ip_hdr(skb)) >> XT_DSCP_SHIFT;
return (dscp == info->dscp) ^ !!info->invert;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 46 | 83.64% | 1 | 16.67% |
Jan Engelhardt | 6 | 10.91% | 4 | 66.67% |
Arnaldo Carvalho de Melo | 3 | 5.45% | 1 | 16.67% |
Total | 55 | 100.00% | 6 | 100.00% |
static bool
dscp_mt6(const struct sk_buff *skb, struct xt_action_param *par)
{
const struct xt_dscp_info *info = par->matchinfo;
u_int8_t dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> XT_DSCP_SHIFT;
return (dscp == info->dscp) ^ !!info->invert;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 46 | 83.64% | 1 | 16.67% |
Jan Engelhardt | 6 | 10.91% | 4 | 66.67% |
Arnaldo Carvalho de Melo | 3 | 5.45% | 1 | 16.67% |
Total | 55 | 100.00% | 6 | 100.00% |
static int dscp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_dscp_info *info = par->matchinfo;
if (info->dscp > XT_DSCP_MAX) {
pr_info("dscp %x out of range\n", info->dscp);
return -EDOM;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 29 | 60.42% | 1 | 14.29% |
Jan Engelhardt | 19 | 39.58% | 6 | 85.71% |
Total | 48 | 100.00% | 7 | 100.00% |
static bool tos_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
const struct xt_tos_match_info *info = par->matchinfo;
if (xt_family(par) == NFPROTO_IPV4)
return ((ip_hdr(skb)->tos & info->tos_mask) ==
info->tos_value) ^ !!info->invert;
else
return ((ipv6_get_dsfield(ipv6_hdr(skb)) & info->tos_mask) ==
info->tos_value) ^ !!info->invert;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jan Engelhardt | 87 | 96.67% | 4 | 80.00% |
Pablo Neira Ayuso | 3 | 3.33% | 1 | 20.00% |
Total | 90 | 100.00% | 5 | 100.00% |
static struct xt_match dscp_mt_reg[] __read_mostly = {
{
.name = "dscp",
.family = NFPROTO_IPV4,
.checkentry = dscp_mt_check,
.match = dscp_mt,
.matchsize = sizeof(struct xt_dscp_info),
.me = THIS_MODULE,
},
{
.name = "dscp",
.family = NFPROTO_IPV6,
.checkentry = dscp_mt_check,
.match = dscp_mt6,
.matchsize = sizeof(struct xt_dscp_info),
.me = THIS_MODULE,
},
{
.name = "tos",
.revision = 1,
.family = NFPROTO_IPV4,
.match = tos_mt,
.matchsize = sizeof(struct xt_tos_match_info),
.me = THIS_MODULE,
},
{
.name = "tos",
.revision = 1,
.family = NFPROTO_IPV6,
.match = tos_mt,
.matchsize = sizeof(struct xt_tos_match_info),
.me = THIS_MODULE,
},
};
static int __init dscp_mt_init(void)
{
return xt_register_matches(dscp_mt_reg, ARRAY_SIZE(dscp_mt_reg));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 13 | 65.00% | 1 | 33.33% |
Patrick McHardy | 4 | 20.00% | 1 | 33.33% |
Jan Engelhardt | 3 | 15.00% | 1 | 33.33% |
Total | 20 | 100.00% | 3 | 100.00% |
static void __exit dscp_mt_exit(void)
{
xt_unregister_matches(dscp_mt_reg, ARRAY_SIZE(dscp_mt_reg));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 12 | 63.16% | 1 | 33.33% |
Patrick McHardy | 4 | 21.05% | 1 | 33.33% |
Jan Engelhardt | 3 | 15.79% | 1 | 33.33% |
Total | 19 | 100.00% | 3 | 100.00% |
module_init(dscp_mt_init);
module_exit(dscp_mt_exit);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Yasuyuki Kozakai | 254 | 49.42% | 1 | 5.00% |
Jan Engelhardt | 226 | 43.97% | 13 | 65.00% |
Patrick McHardy | 25 | 4.86% | 3 | 15.00% |
Arnaldo Carvalho de Melo | 6 | 1.17% | 2 | 10.00% |
Pablo Neira Ayuso | 3 | 0.58% | 1 | 5.00% |
Total | 514 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.