Release 4.7 net/netfilter/xt_TEE.c
/*
* "TEE" target extension for Xtables
* Copyright © Sebastian ClaÃen, 2007
* Jan Engelhardt, 2007-2010
*
* based on ipt_ROUTE.c from Cédric de Launois
* <delaunois@info.ucl.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 or later, as published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/route.h>
#include <linux/netfilter/x_tables.h>
#include <net/route.h>
#include <net/netfilter/ipv4/nf_dup_ipv4.h>
#include <net/netfilter/ipv6/nf_dup_ipv6.h>
#include <linux/netfilter/xt_TEE.h>
struct xt_tee_priv {
struct notifier_block notifier;
struct xt_tee_tginfo *tginfo;
int oif;
};
static const union nf_inet_addr tee_zero_address;
static unsigned int
tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_tee_tginfo *info = par->targinfo;
int oif = info->priv ? info->priv->oif : 0;
nf_dup_ipv4(par->net, skb, par->hooknum, &info->gw.in, oif);
return XT_CONTINUE;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan engelhardt | jan engelhardt | 42 | 61.76% | 3 | 50.00% |
eric dumazet | eric dumazet | 15 | 22.06% | 1 | 16.67% |
pablo neira ayuso | pablo neira ayuso | 7 | 10.29% | 1 | 16.67% |
eric w. biederman | eric w. biederman | 4 | 5.88% | 1 | 16.67% |
| Total | 68 | 100.00% | 6 | 100.00% |
#if IS_ENABLED(CONFIG_IPV6)
static unsigned int
tee_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_tee_tginfo *info = par->targinfo;
int oif = info->priv ? info->priv->oif : 0;
nf_dup_ipv6(par->net, skb, par->hooknum, &info->gw.in6, oif);
return XT_CONTINUE;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan engelhardt | jan engelhardt | 42 | 61.76% | 3 | 50.00% |
eric dumazet | eric dumazet | 15 | 22.06% | 1 | 16.67% |
pablo neira ayuso | pablo neira ayuso | 7 | 10.29% | 1 | 16.67% |
eric w. biederman | eric w. biederman | 4 | 5.88% | 1 | 16.67% |
| Total | 68 | 100.00% | 6 | 100.00% |
#endif
static int tee_netdev_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct xt_tee_priv *priv;
priv = container_of(this, struct xt_tee_priv, notifier);
switch (event) {
case NETDEV_REGISTER:
if (!strcmp(dev->name, priv->tginfo->oif))
priv->oif = dev->ifindex;
break;
case NETDEV_UNREGISTER:
if (dev->ifindex == priv->oif)
priv->oif = -1;
break;
case NETDEV_CHANGENAME:
if (!strcmp(dev->name, priv->tginfo->oif))
priv->oif = dev->ifindex;
else if (dev->ifindex == priv->oif)
priv->oif = -1;
break;
}
return NOTIFY_DONE;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
patrick mchardy | patrick mchardy | 147 | 98.00% | 1 | 50.00% |
jiri pirko | jiri pirko | 3 | 2.00% | 1 | 50.00% |
| Total | 150 | 100.00% | 2 | 100.00% |
static int tee_tg_check(const struct xt_tgchk_param *par)
{
struct xt_tee_tginfo *info = par->targinfo;
struct xt_tee_priv *priv;
/* 0.0.0.0 and :: not allowed */
if (memcmp(&info->gw, &tee_zero_address,
sizeof(tee_zero_address)) == 0)
return -EINVAL;
if (info->oif[0]) {
if (info->oif[sizeof(info->oif)-1] != '\0')
return -EINVAL;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
priv->tginfo = info;
priv->oif = -1;
priv->notifier.notifier_call = tee_netdev_event;
info->priv = priv;
register_netdevice_notifier(&priv->notifier);
} else
info->priv = NULL;
static_key_slow_inc(&xt_tee_enabled);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
patrick mchardy | patrick mchardy | 100 | 63.29% | 1 | 33.33% |
jan engelhardt | jan engelhardt | 52 | 32.91% | 1 | 33.33% |
florian westphal | florian westphal | 6 | 3.80% | 1 | 33.33% |
| Total | 158 | 100.00% | 3 | 100.00% |
static void tee_tg_destroy(const struct xt_tgdtor_param *par)
{
struct xt_tee_tginfo *info = par->targinfo;
if (info->priv) {
unregister_netdevice_notifier(&info->priv->notifier);
kfree(info->priv);
}
static_key_slow_dec(&xt_tee_enabled);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
patrick mchardy | patrick mchardy | 46 | 88.46% | 1 | 50.00% |
florian westphal | florian westphal | 6 | 11.54% | 1 | 50.00% |
| Total | 52 | 100.00% | 2 | 100.00% |
static struct xt_target tee_tg_reg[] __read_mostly = {
{
.name = "TEE",
.revision = 1,
.family = NFPROTO_IPV4,
.target = tee_tg4,
.targetsize = sizeof(struct xt_tee_tginfo),
.checkentry = tee_tg_check,
.destroy = tee_tg_destroy,
.me = THIS_MODULE,
},
#if IS_ENABLED(CONFIG_IPV6)
{
.name = "TEE",
.revision = 1,
.family = NFPROTO_IPV6,
.target = tee_tg6,
.targetsize = sizeof(struct xt_tee_tginfo),
.checkentry = tee_tg_check,
.destroy = tee_tg_destroy,
.me = THIS_MODULE,
},
#endif
};
static int __init tee_tg_init(void)
{
return xt_register_targets(tee_tg_reg, ARRAY_SIZE(tee_tg_reg));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan engelhardt | jan engelhardt | 20 | 100.00% | 1 | 100.00% |
| Total | 20 | 100.00% | 1 | 100.00% |
static void __exit tee_tg_exit(void)
{
xt_unregister_targets(tee_tg_reg, ARRAY_SIZE(tee_tg_reg));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan engelhardt | jan engelhardt | 19 | 100.00% | 1 | 100.00% |
| Total | 19 | 100.00% | 1 | 100.00% |
module_init(tee_tg_init);
module_exit(tee_tg_exit);
MODULE_AUTHOR("Sebastian ClaÃen <sebastian.classen@freenet.ag>");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Xtables: Reroute packet copy");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_TEE");
MODULE_ALIAS("ip6t_TEE");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jan engelhardt | jan engelhardt | 337 | 45.48% | 3 | 27.27% |
patrick mchardy | patrick mchardy | 320 | 43.18% | 1 | 9.09% |
eric dumazet | eric dumazet | 40 | 5.40% | 2 | 18.18% |
pablo neira ayuso | pablo neira ayuso | 19 | 2.56% | 1 | 9.09% |
florian westphal | florian westphal | 12 | 1.62% | 1 | 9.09% |
eric w. biederman | eric w. biederman | 8 | 1.08% | 1 | 9.09% |
jiri pirko | jiri pirko | 3 | 0.40% | 1 | 9.09% |
arnd bergmann | arnd bergmann | 2 | 0.27% | 1 | 9.09% |
| Total | 741 | 100.00% | 11 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.