mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-20 19:44:56 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a576f4d43e | ||
![]() |
cc17e1d0fe | ||
![]() |
c08835d65c | ||
![]() |
4c21811919 | ||
![]() |
431062c6ec | ||
![]() |
87adf3461f | ||
![]() |
f2e21e67a5 | ||
![]() |
ae307c0bf3 | ||
![]() |
ec8c6b8732 |
@@ -1,4 +1,4 @@
|
||||
AC_INIT([xtables-addons], [2.4])
|
||||
AC_INIT([xtables-addons], [2.6])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
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.";
|
||||
else
|
||||
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 17; then
|
||||
echo "WARNING: That kernel version is not officially supported yet. Continue at own luck.";
|
||||
elif test "$kmajor" -eq 3 -a "$kminor" -ge 7; then
|
||||
:;
|
||||
|
@@ -3,6 +3,22 @@ HEAD
|
||||
====
|
||||
|
||||
|
||||
v2.6 (2014-09-29)
|
||||
=================
|
||||
Enhancements:
|
||||
- Support for Linux 3.16, 3.17
|
||||
Fixes:
|
||||
- xt_pknock: UDP SPA mode erroneously returned an error saying
|
||||
crypto was unavailable
|
||||
|
||||
|
||||
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)
|
||||
=================
|
||||
Enhancements:
|
||||
@@ -10,6 +26,9 @@ Enhancements:
|
||||
Changes:
|
||||
- remove unmaintained RAWSNAT/RAWDNAT code
|
||||
- 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)
|
||||
|
@@ -12,6 +12,10 @@
|
||||
# warning Kernels below 3.7 not supported.
|
||||
#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_MARK)
|
||||
# warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
|
||||
@@ -50,8 +54,8 @@ static inline struct inode *file_inode(struct file *f)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
|
||||
static inline void
|
||||
proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
|
||||
static inline void proc_set_user(struct proc_dir_entry *de,
|
||||
typeof(de->uid) uid, typeof(de->gid) gid)
|
||||
{
|
||||
de->uid = uid;
|
||||
de->gid = gid;
|
||||
|
@@ -701,7 +701,11 @@ msg_to_userspace_nl(const struct xt_pknock_mtinfo *info,
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
kfree(m);
|
||||
#endif
|
||||
@@ -1054,9 +1058,6 @@ static int pknock_mt_check(const struct xt_mtchk_param *par)
|
||||
|
||||
if (!(info->option & XT_PKNOCK_NAME))
|
||||
RETURN_ERR("You must specify --name option.\n");
|
||||
if (info->option & (XT_PKNOCK_OPENSECRET | XT_PKNOCK_CLOSESECRET))
|
||||
RETURN_ERR("No crypto support available; "
|
||||
"cannot use opensecret/closescret\n");
|
||||
if (info->option & XT_PKNOCK_OPENSECRET && info->ports_count != 1)
|
||||
RETURN_ERR("--opensecret must have just one knock port\n");
|
||||
if (info->option & XT_PKNOCK_KNOCKPORT) {
|
||||
|
@@ -68,7 +68,7 @@ xt_chaos_total(struct sk_buff *skb, const struct xt_action_param *par)
|
||||
ret = xm_tcp->match(skb, &local_par);
|
||||
hotdrop = local_par.hotdrop;
|
||||
}
|
||||
if (!ret || hotdrop || (unsigned int)net_random() > delude_percentage)
|
||||
if (!ret || hotdrop || (unsigned int)prandom_u32() > delude_percentage)
|
||||
return;
|
||||
|
||||
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 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;
|
||||
local_par.in = par->in;
|
||||
local_par.out = par->out;
|
||||
|
@@ -107,8 +107,8 @@ static bool xttarpit_honeypot(struct tcphdr *tcph, const struct tcphdr *oth,
|
||||
tcph->syn = true;
|
||||
tcph->ack = true;
|
||||
tcph->window = oth->window &
|
||||
((net_random() & 0x1f) - 0xf);
|
||||
tcph->seq = htonl(net_random() & ~oth->seq);
|
||||
((prandom_u32() & 0x1f) - 0xf);
|
||||
tcph->seq = htonl(prandom_u32() & ~oth->seq);
|
||||
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->ack = true;
|
||||
tcph->window = oth->window &
|
||||
((net_random() & 0x1f) - 0xf);
|
||||
((prandom_u32() & 0x1f) - 0xf);
|
||||
tcph->ack_seq = payload > 100 ?
|
||||
htonl(ntohl(oth->seq) + payload) :
|
||||
oth->seq;
|
||||
|
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
#include <linux/list.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/nsproxy.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/skbuff.h>
|
||||
@@ -20,6 +21,9 @@
|
||||
#include <linux/uidgid.h>
|
||||
#include <linux/version.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 "xt_quota2.h"
|
||||
@@ -37,10 +41,19 @@ struct xt_quota_counter {
|
||||
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 struct proc_dir_entry *proc_xt_quota;
|
||||
static unsigned int quota_list_perms = S_IRUGO | S_IWUSR;
|
||||
static unsigned int quota_list_uid = 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
|
||||
*/
|
||||
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 xt_quota_counter *e;
|
||||
struct quota2_net *quota2_net = quota2_pernet(net);
|
||||
|
||||
if (*q->name == '\0')
|
||||
return q2_new_counter(q, true);
|
||||
|
||||
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) {
|
||||
atomic_inc(&e->ref);
|
||||
spin_unlock_bh(&counter_list_lock);
|
||||
@@ -140,7 +154,8 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
|
||||
if (e == NULL)
|
||||
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);
|
||||
if (p == NULL || IS_ERR(p))
|
||||
goto out;
|
||||
@@ -148,7 +163,7 @@ q2_get_counter(const struct xt_quota_mtinfo2 *q)
|
||||
e->procfs_entry = p;
|
||||
proc_set_user(p, make_kuid(&init_user_ns, quota_list_uid),
|
||||
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);
|
||||
return e;
|
||||
|
||||
@@ -171,7 +186,7 @@ static int quota_mt2_check(const struct xt_mtchk_param *par)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
q->master = q2_get_counter(q);
|
||||
q->master = q2_get_counter(par->net, q);
|
||||
if (q->master == NULL) {
|
||||
printk(KERN_ERR "xt_quota.3: memory alloc failure\n");
|
||||
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_counter *e = q->master;
|
||||
struct quota2_net *quota2_net = quota2_pernet(par->net);
|
||||
|
||||
if (*q->name == '\0') {
|
||||
kfree(e);
|
||||
@@ -197,7 +213,7 @@ static void quota_mt2_destroy(const struct xt_mtdtor_param *par)
|
||||
}
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
int ret;
|
||||
|
||||
proc_xt_quota = proc_mkdir("xt_quota", init_net.proc_net);
|
||||
if (proc_xt_quota == NULL)
|
||||
return -EACCES;
|
||||
ret = register_pernet_subsys("a2_net_ops);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = xt_register_matches(quota_mt2_reg, ARRAY_SIZE(quota_mt2_reg));
|
||||
if (ret < 0)
|
||||
remove_proc_entry("xt_quota", init_net.proc_net);
|
||||
unregister_pernet_subsys("a2_net_ops);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit quota_mt2_exit(void)
|
||||
{
|
||||
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);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
.TH xtables-addons 8 "US Hoarding All The Cold Edition" "" "v2.4 (2014-01-09)"
|
||||
.TH xtables-addons 8 "Red October" "" "v2.6 (2014-09-29)"
|
||||
.SH Name
|
||||
Xtables-addons \(em additional extensions for iptables, ip6tables, etc.
|
||||
.SH Targets
|
||||
|
Reference in New Issue
Block a user