mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-20 19:44:56 +02:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
431062c6ec | ||
![]() |
87adf3461f | ||
![]() |
f2e21e67a5 | ||
![]() |
ae307c0bf3 | ||
![]() |
ec8c6b8732 |
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT([xtables-addons], [2.4])
|
AC_INIT([xtables-addons], [2.5])
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
@@ -63,7 +63,7 @@ if test -n "$kbuilddir"; then
|
|||||||
echo "WARNING: Version detection did not succeed. Continue at own luck.";
|
echo "WARNING: Version detection did not succeed. Continue at own luck.";
|
||||||
else
|
else
|
||||||
echo "$kmajor.$kminor.$kmicro.$kstable in $kbuilddir";
|
echo "$kmajor.$kminor.$kmicro.$kstable in $kbuilddir";
|
||||||
if test "$kmajor" -gt 3 -o "$kmajor" -eq 3 -a "$kminor" -gt 13; then
|
if test "$kmajor" -gt 3 -o "$kmajor" -eq 3 -a "$kminor" -gt 15; then
|
||||||
echo "WARNING: That kernel version is not officially supported yet. Continue at own luck.";
|
echo "WARNING: That kernel version is not officially supported yet. Continue at own luck.";
|
||||||
elif test "$kmajor" -eq 3 -a "$kminor" -ge 7; then
|
elif test "$kmajor" -eq 3 -a "$kminor" -ge 7; then
|
||||||
:;
|
:;
|
||||||
|
@@ -3,6 +3,13 @@ HEAD
|
|||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
|
v2.5 (2014-04-18)
|
||||||
|
=================
|
||||||
|
Enhancements:
|
||||||
|
- Support for Linux 3.14 and 3.15
|
||||||
|
- xt_quota2: introduce support for network namespaces
|
||||||
|
|
||||||
|
|
||||||
v2.4 (2014-01-09)
|
v2.4 (2014-01-09)
|
||||||
=================
|
=================
|
||||||
Enhancements:
|
Enhancements:
|
||||||
@@ -10,6 +17,9 @@ Enhancements:
|
|||||||
Changes:
|
Changes:
|
||||||
- remove unmaintained RAWSNAT/RAWDNAT code
|
- remove unmaintained RAWSNAT/RAWDNAT code
|
||||||
- remove unused parts of compat_xtables that served Linux <3.7
|
- remove unused parts of compat_xtables that served Linux <3.7
|
||||||
|
Fixes:
|
||||||
|
- xt_quota2: --no-change should not alter quota to zero ever
|
||||||
|
- xt_quota2: --packet should not be set to zero based on skb->len
|
||||||
|
|
||||||
|
|
||||||
v2.3 (2013-06-18)
|
v2.3 (2013-06-18)
|
||||||
|
@@ -12,6 +12,10 @@
|
|||||||
# warning Kernels below 3.7 not supported.
|
# warning Kernels below 3.7 not supported.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
|
||||||
|
# define prandom_u32() random32()
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||||
# if !defined(CONFIG_NF_CONNTRACK_MARK)
|
# if !defined(CONFIG_NF_CONNTRACK_MARK)
|
||||||
# warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
|
# warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
|
||||||
|
@@ -701,7 +701,11 @@ msg_to_userspace_nl(const struct xt_pknock_mtinfo *info,
|
|||||||
|
|
||||||
memcpy(m + 1, &msg, m->len);
|
memcpy(m + 1, &msg, m->len);
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
|
||||||
|
cn_netlink_send(m, 0, multicast_group, GFP_ATOMIC);
|
||||||
|
#else
|
||||||
cn_netlink_send(m, multicast_group, GFP_ATOMIC);
|
cn_netlink_send(m, multicast_group, GFP_ATOMIC);
|
||||||
|
#endif
|
||||||
|
|
||||||
kfree(m);
|
kfree(m);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -68,7 +68,7 @@ xt_chaos_total(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
ret = xm_tcp->match(skb, &local_par);
|
ret = xm_tcp->match(skb, &local_par);
|
||||||
hotdrop = local_par.hotdrop;
|
hotdrop = local_par.hotdrop;
|
||||||
}
|
}
|
||||||
if (!ret || hotdrop || (unsigned int)net_random() > delude_percentage)
|
if (!ret || hotdrop || (unsigned int)prandom_u32() > delude_percentage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
destiny = (info->variant == XTCHAOS_TARPIT) ? xt_tarpit : xt_delude;
|
destiny = (info->variant == XTCHAOS_TARPIT) ? xt_tarpit : xt_delude;
|
||||||
@@ -98,7 +98,7 @@ chaos_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
const struct xt_chaos_tginfo *info = par->targinfo;
|
const struct xt_chaos_tginfo *info = par->targinfo;
|
||||||
const struct iphdr *iph = ip_hdr(skb);
|
const struct iphdr *iph = ip_hdr(skb);
|
||||||
|
|
||||||
if ((unsigned int)net_random() <= reject_percentage) {
|
if ((unsigned int)prandom_u32() <= reject_percentage) {
|
||||||
struct xt_action_param local_par;
|
struct xt_action_param local_par;
|
||||||
local_par.in = par->in;
|
local_par.in = par->in;
|
||||||
local_par.out = par->out;
|
local_par.out = par->out;
|
||||||
|
@@ -107,8 +107,8 @@ static bool xttarpit_honeypot(struct tcphdr *tcph, const struct tcphdr *oth,
|
|||||||
tcph->syn = true;
|
tcph->syn = true;
|
||||||
tcph->ack = true;
|
tcph->ack = true;
|
||||||
tcph->window = oth->window &
|
tcph->window = oth->window &
|
||||||
((net_random() & 0x1f) - 0xf);
|
((prandom_u32() & 0x1f) - 0xf);
|
||||||
tcph->seq = htonl(net_random() & ~oth->seq);
|
tcph->seq = htonl(prandom_u32() & ~oth->seq);
|
||||||
tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn);
|
tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ static bool xttarpit_honeypot(struct tcphdr *tcph, const struct tcphdr *oth,
|
|||||||
tcph->syn = false;
|
tcph->syn = false;
|
||||||
tcph->ack = true;
|
tcph->ack = true;
|
||||||
tcph->window = oth->window &
|
tcph->window = oth->window &
|
||||||
((net_random() & 0x1f) - 0xf);
|
((prandom_u32() & 0x1f) - 0xf);
|
||||||
tcph->ack_seq = payload > 100 ?
|
tcph->ack_seq = payload > 100 ?
|
||||||
htonl(ntohl(oth->seq) + payload) :
|
htonl(ntohl(oth->seq) + payload) :
|
||||||
oth->seq;
|
oth->seq;
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/nsproxy.h>
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
@@ -20,6 +21,9 @@
|
|||||||
#include <linux/uidgid.h>
|
#include <linux/uidgid.h>
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include <asm/atomic.h>
|
#include <asm/atomic.h>
|
||||||
|
#include <net/net_namespace.h>
|
||||||
|
#include <net/netns/generic.h>
|
||||||
|
#include <net/dst.h>
|
||||||
|
|
||||||
#include <linux/netfilter/x_tables.h>
|
#include <linux/netfilter/x_tables.h>
|
||||||
#include "xt_quota2.h"
|
#include "xt_quota2.h"
|
||||||
@@ -37,10 +41,19 @@ struct xt_quota_counter {
|
|||||||
struct proc_dir_entry *procfs_entry;
|
struct proc_dir_entry *procfs_entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
static LIST_HEAD(counter_list);
|
struct quota2_net {
|
||||||
|
struct list_head counter_list;
|
||||||
|
struct proc_dir_entry *proc_xt_quota;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int quota2_net_id;
|
||||||
|
static inline struct quota2_net *quota2_pernet(struct net *net)
|
||||||
|
{
|
||||||
|
return net_generic(net, quota2_net_id);
|
||||||
|
}
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(counter_list_lock);
|
static DEFINE_SPINLOCK(counter_list_lock);
|
||||||
|
|
||||||
static struct proc_dir_entry *proc_xt_quota;
|
|
||||||
static unsigned int quota_list_perms = S_IRUGO | S_IWUSR;
|
static unsigned int quota_list_perms = S_IRUGO | S_IWUSR;
|
||||||
static unsigned int quota_list_uid = 0;
|
static unsigned int quota_list_uid = 0;
|
||||||
static unsigned int quota_list_gid = 0;
|
static unsigned int quota_list_gid = 0;
|
||||||
@@ -120,16 +133,17 @@ q2_new_counter(const struct xt_quota_mtinfo2 *q, bool anon)
|
|||||||
* @name: name of counter
|
* @name: name of counter
|
||||||
*/
|
*/
|
||||||
static struct xt_quota_counter *
|
static struct xt_quota_counter *
|
||||||
q2_get_counter(const struct xt_quota_mtinfo2 *q)
|
q2_get_counter(struct net *net, const struct xt_quota_mtinfo2 *q)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *p;
|
struct proc_dir_entry *p;
|
||||||
struct xt_quota_counter *e;
|
struct xt_quota_counter *e;
|
||||||
|
struct quota2_net *quota2_net = quota2_pernet(net);
|
||||||
|
|
||||||
if (*q->name == '\0')
|
if (*q->name == '\0')
|
||||||
return q2_new_counter(q, true);
|
return q2_new_counter(q, true);
|
||||||
|
|
||||||
spin_lock_bh(&counter_list_lock);
|
spin_lock_bh(&counter_list_lock);
|
||||||
list_for_each_entry(e, &counter_list, list)
|
list_for_each_entry(e, "a2_net->counter_list, list)
|
||||||
if (strcmp(e->name, q->name) == 0) {
|
if (strcmp(e->name, q->name) == 0) {
|
||||||
atomic_inc(&e->ref);
|
atomic_inc(&e->ref);
|
||||||
spin_unlock_bh(&counter_list_lock);
|
spin_unlock_bh(&counter_list_lock);
|
||||||
@@ -140,7 +154,8 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
|
|||||||
if (e == NULL)
|
if (e == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
p = proc_create_data(e->name, quota_list_perms, proc_xt_quota,
|
p = proc_create_data(e->name, quota_list_perms,
|
||||||
|
quota2_net->proc_xt_quota,
|
||||||
"a_proc_fops, e);
|
"a_proc_fops, e);
|
||||||
if (p == NULL || IS_ERR(p))
|
if (p == NULL || IS_ERR(p))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -148,7 +163,7 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
|
|||||||
e->procfs_entry = p;
|
e->procfs_entry = p;
|
||||||
proc_set_user(p, make_kuid(&init_user_ns, quota_list_uid),
|
proc_set_user(p, make_kuid(&init_user_ns, quota_list_uid),
|
||||||
make_kgid(&init_user_ns, quota_list_gid));
|
make_kgid(&init_user_ns, quota_list_gid));
|
||||||
list_add_tail(&e->list, &counter_list);
|
list_add_tail(&e->list, "a2_net->counter_list);
|
||||||
spin_unlock_bh(&counter_list_lock);
|
spin_unlock_bh(&counter_list_lock);
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
@@ -171,7 +186,7 @@ static int quota_mt2_check(const struct xt_mtchk_param *par)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
q->master = q2_get_counter(q);
|
q->master = q2_get_counter(par->net, q);
|
||||||
if (q->master == NULL) {
|
if (q->master == NULL) {
|
||||||
printk(KERN_ERR "xt_quota.3: memory alloc failure\n");
|
printk(KERN_ERR "xt_quota.3: memory alloc failure\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@@ -184,6 +199,7 @@ static void quota_mt2_destroy(const struct xt_mtdtor_param *par)
|
|||||||
{
|
{
|
||||||
struct xt_quota_mtinfo2 *q = par->matchinfo;
|
struct xt_quota_mtinfo2 *q = par->matchinfo;
|
||||||
struct xt_quota_counter *e = q->master;
|
struct xt_quota_counter *e = q->master;
|
||||||
|
struct quota2_net *quota2_net = quota2_pernet(par->net);
|
||||||
|
|
||||||
if (*q->name == '\0') {
|
if (*q->name == '\0') {
|
||||||
kfree(e);
|
kfree(e);
|
||||||
@@ -197,7 +213,7 @@ static void quota_mt2_destroy(const struct xt_mtdtor_param *par)
|
|||||||
}
|
}
|
||||||
|
|
||||||
list_del(&e->list);
|
list_del(&e->list);
|
||||||
remove_proc_entry(e->name, proc_xt_quota);
|
remove_proc_entry(e->name, quota2_net->proc_xt_quota);
|
||||||
spin_unlock_bh(&counter_list_lock);
|
spin_unlock_bh(&counter_list_lock);
|
||||||
kfree(e);
|
kfree(e);
|
||||||
}
|
}
|
||||||
@@ -259,24 +275,60 @@ static struct xt_match quota_mt2_reg[] __read_mostly = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int __net_init quota2_net_init(struct net *net)
|
||||||
|
{
|
||||||
|
struct quota2_net *quota2_net = quota2_pernet(net);
|
||||||
|
INIT_LIST_HEAD("a2_net->counter_list);
|
||||||
|
|
||||||
|
quota2_net->proc_xt_quota = proc_mkdir("xt_quota", net->proc_net);
|
||||||
|
if (quota2_net->proc_xt_quota == NULL)
|
||||||
|
return -EACCES;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __net_exit quota2_net_exit(struct net *net)
|
||||||
|
{
|
||||||
|
struct quota2_net *quota2_net = quota2_pernet(net);
|
||||||
|
struct xt_quota_counter *e = NULL;
|
||||||
|
struct list_head *pos, *q;
|
||||||
|
|
||||||
|
remove_proc_entry("xt_quota", net->proc_net);
|
||||||
|
|
||||||
|
/* destroy counter_list while freeing it's content */
|
||||||
|
spin_lock_bh(&counter_list_lock);
|
||||||
|
list_for_each_safe(pos, q, "a2_net->counter_list) {
|
||||||
|
e = list_entry(pos, struct xt_quota_counter, list);
|
||||||
|
list_del(pos);
|
||||||
|
kfree(e);
|
||||||
|
}
|
||||||
|
spin_unlock_bh(&counter_list_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct pernet_operations quota2_net_ops = {
|
||||||
|
.init = quota2_net_init,
|
||||||
|
.exit = quota2_net_exit,
|
||||||
|
.id = "a2_net_id,
|
||||||
|
.size = sizeof(struct quota2_net),
|
||||||
|
};
|
||||||
|
|
||||||
static int __init quota_mt2_init(void)
|
static int __init quota_mt2_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
ret = register_pernet_subsys("a2_net_ops);
|
||||||
proc_xt_quota = proc_mkdir("xt_quota", init_net.proc_net);
|
if (ret < 0)
|
||||||
if (proc_xt_quota == NULL)
|
return ret;
|
||||||
return -EACCES;
|
|
||||||
|
|
||||||
ret = xt_register_matches(quota_mt2_reg, ARRAY_SIZE(quota_mt2_reg));
|
ret = xt_register_matches(quota_mt2_reg, ARRAY_SIZE(quota_mt2_reg));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
remove_proc_entry("xt_quota", init_net.proc_net);
|
unregister_pernet_subsys("a2_net_ops);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit quota_mt2_exit(void)
|
static void __exit quota_mt2_exit(void)
|
||||||
{
|
{
|
||||||
xt_unregister_matches(quota_mt2_reg, ARRAY_SIZE(quota_mt2_reg));
|
xt_unregister_matches(quota_mt2_reg, ARRAY_SIZE(quota_mt2_reg));
|
||||||
remove_proc_entry("xt_quota", init_net.proc_net);
|
unregister_pernet_subsys("a2_net_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(quota_mt2_init);
|
module_init(quota_mt2_init);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.TH xtables-addons 8 "US Hoarding All The Cold Edition" "" "v2.4 (2014-01-09)"
|
.TH xtables-addons 8 "SFUAN" "" "v2.5 (2014-04-18)"
|
||||||
.SH Name
|
.SH Name
|
||||||
Xtables-addons \(em additional extensions for iptables, ip6tables, etc.
|
Xtables-addons \(em additional extensions for iptables, ip6tables, etc.
|
||||||
.SH Targets
|
.SH Targets
|
||||||
|
Reference in New Issue
Block a user