mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-21 12:04:56 +02:00
Compare commits
41 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
254c6926d3 | ||
![]() |
2e78cf03a4 | ||
![]() |
bf63a25a64 | ||
![]() |
94656621ed | ||
![]() |
95d4f9e113 | ||
![]() |
123e1a14e9 | ||
![]() |
f4f3f98609 | ||
![]() |
9b1c7c1c04 | ||
![]() |
ed8e496750 | ||
![]() |
5339fcc65b | ||
![]() |
2265c1b854 | ||
![]() |
2c574f992d | ||
![]() |
3a24468a68 | ||
![]() |
7682cc8c34 | ||
![]() |
215b3c5b12 | ||
![]() |
4dbb36b723 | ||
![]() |
10f951e61d | ||
![]() |
a4c50ae405 | ||
![]() |
38d89983ca | ||
![]() |
25985650a9 | ||
![]() |
4de9ff1505 | ||
![]() |
46b7cf206b | ||
![]() |
29d10e11fa | ||
![]() |
60a26f1dea | ||
![]() |
cdf90737be | ||
![]() |
5713415014 | ||
![]() |
230bc1f327 | ||
![]() |
d360f5578c | ||
![]() |
dd32060f6a | ||
![]() |
d5eb4e586c | ||
![]() |
1b4b4347c5 | ||
![]() |
2f37af43c5 | ||
![]() |
56e5970c64 | ||
![]() |
2b76b68c65 | ||
![]() |
d2eeac4c32 | ||
![]() |
0e9037b000 | ||
![]() |
0a6091b64a | ||
![]() |
b565a85fb6 | ||
![]() |
89c80f5981 | ||
![]() |
8579fd2b3b | ||
![]() |
0a836e9677 |
7
INSTALL
7
INSTALL
@@ -12,16 +12,17 @@ in combination with the kernel's Kbuild system.
|
|||||||
Supported configurations for this release
|
Supported configurations for this release
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
* iptables >= 1.4.5
|
* iptables >= 1.6.0
|
||||||
|
|
||||||
* kernel-devel >= 3.7
|
* kernel-devel >= 4.15
|
||||||
with prepared build/output directory
|
with prepared build/output directory
|
||||||
- CONFIG_NF_CONNTRACK
|
- CONFIG_NF_CONNTRACK
|
||||||
- CONFIG_NF_CONNTRACK_MARK enabled =y or as module (=m)
|
- CONFIG_NF_CONNTRACK_MARK enabled =y or as module (=m)
|
||||||
- CONFIG_CONNECTOR y/m if you wish to receive userspace
|
- CONFIG_CONNECTOR y/m if you wish to receive userspace
|
||||||
notifications from pknock through netlink/connector
|
notifications from pknock through netlink/connector
|
||||||
|
|
||||||
(Use xtables-addons-1.x if you need support for Linux < 3.7.)
|
(Use xtables-addons-1.x if you need support for Linux < 3.7.
|
||||||
|
Use xtables-addons-2.x if you need support for Linux < 4.15.)
|
||||||
|
|
||||||
|
|
||||||
Selecting extensions
|
Selecting extensions
|
||||||
|
10
configure.ac
10
configure.ac
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT([xtables-addons], [2.13])
|
AC_INIT([xtables-addons], [3.0])
|
||||||
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])
|
||||||
@@ -57,12 +57,10 @@ 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 4 -o "$kmajor" -eq 4 -a "$kminor" -gt 12; then
|
if test "$kmajor" -gt 4 -o "$kmajor" -eq 4 -a "$kminor" -gt 16; 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 4 -a "$kminor" -le 10; then
|
elif test "$kmajor" -eq 4 -a "$kminor" -ge 15; then
|
||||||
:;
|
:
|
||||||
elif test "$kmajor" -eq 3 -a "$kminor" -ge 7; then
|
|
||||||
:;
|
|
||||||
else
|
else
|
||||||
echo "WARNING: That kernel version is not officially supported.";
|
echo "WARNING: That kernel version is not officially supported.";
|
||||||
fi;
|
fi;
|
||||||
|
@@ -1,6 +1,18 @@
|
|||||||
|
|
||||||
HEAD
|
HEAD
|
||||||
====
|
====
|
||||||
|
Enhancements:
|
||||||
|
- support for Linux 4.15, 4.16
|
||||||
|
Changes:
|
||||||
|
- remove support for Linux 3.7--4.14
|
||||||
|
|
||||||
|
|
||||||
|
v2.14 (2017-11-22)
|
||||||
|
==================
|
||||||
|
Enhancements:
|
||||||
|
- support for Linux up to 4.14
|
||||||
|
Fixes:
|
||||||
|
- xt_DNETMAP: fix some reports from PVSStudio (a static checker)
|
||||||
|
|
||||||
|
|
||||||
v2.13 (2017-06-29)
|
v2.13 (2017-06-29)
|
||||||
@@ -119,5 +131,5 @@ Changes:
|
|||||||
Enhancements:
|
Enhancements:
|
||||||
- Support for Linux 3.7
|
- Support for Linux 3.7
|
||||||
|
|
||||||
If you want to use Xtables-addons with kernels older than 3.7,
|
If you want to use Xtables-addons with kernels older than 4.15,
|
||||||
use the addons 1.x series (maintained but without new features).
|
use the addons 2.x series.
|
||||||
|
@@ -482,16 +482,7 @@ static void ipt_acc_depth2_insert(struct ipt_acc_mask_8 *mask_8,
|
|||||||
static unsigned int
|
static unsigned int
|
||||||
ipt_acc_target(struct sk_buff *skb, const struct xt_action_param *par)
|
ipt_acc_target(struct sk_buff *skb, const struct xt_action_param *par)
|
||||||
{
|
{
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
struct ipt_acc_net *ian = net_generic(par->state->net, ipt_acc_net_id);
|
struct ipt_acc_net *ian = net_generic(par->state->net, ipt_acc_net_id);
|
||||||
#else
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
|
|
||||||
struct ipt_acc_net *ian = net_generic(par->net, ipt_acc_net_id);
|
|
||||||
#else
|
|
||||||
struct net *net = dev_net(par->in ? par->in : par->out);
|
|
||||||
struct ipt_acc_net *ian = net_generic(net, ipt_acc_net_id);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
struct ipt_acc_table *ipt_acc_tables = ian->ipt_acc_tables;
|
struct ipt_acc_table *ipt_acc_tables = ian->ipt_acc_tables;
|
||||||
const struct ipt_acc_info *info =
|
const struct ipt_acc_info *info =
|
||||||
par->targinfo;
|
par->targinfo;
|
||||||
|
@@ -8,12 +8,8 @@
|
|||||||
|
|
||||||
#define DEBUGP Use__pr_debug__instead
|
#define DEBUGP Use__pr_debug__instead
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
|
||||||
# warning Kernels below 3.7 not supported.
|
# warning Kernels below 4.15 not supported.
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
|
|
||||||
# define prandom_u32() random32()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||||
@@ -46,51 +42,13 @@
|
|||||||
# define NIPQUAD_FMT "%hhu.%hhu.%hhu.%hhu"
|
# define NIPQUAD_FMT "%hhu.%hhu.%hhu.%hhu"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
|
|
||||||
static inline struct inode *file_inode(struct file *f)
|
|
||||||
{
|
|
||||||
return f->f_path.dentry->d_inode;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *PDE_DATA(struct inode *inode)
|
|
||||||
{
|
|
||||||
return PDE(inode)->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void proc_remove(struct proc_dir_entry *de)
|
|
||||||
{
|
|
||||||
if (de != NULL)
|
|
||||||
remove_proc_entry(de->name, de->parent);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
|
|
||||||
# define ip6_local_out(xnet, xsk, xskb) ip6_local_out(xskb)
|
|
||||||
# define ip6_route_me_harder(xnet, xskb) ip6_route_me_harder(xskb)
|
|
||||||
# define ip_local_out(xnet, xsk, xskb) ip_local_out(xskb)
|
|
||||||
# define ip_route_me_harder(xnet, xskb, xaddrtype) ip_route_me_harder((xskb), (xaddrtype))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline struct net *par_net(const struct xt_action_param *par)
|
static inline struct net *par_net(const struct xt_action_param *par)
|
||||||
{
|
{
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
|
|
||||||
return par->state->net;
|
return par->state->net;
|
||||||
#else
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
|
|
||||||
return par->net;
|
|
||||||
#else
|
|
||||||
return dev_net((par->in != NULL) ? par->in : par->out);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NF_CT_ASSERT
|
||||||
|
# define NF_CT_ASSERT(x) WARN_ON(!(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _XTABLES_COMPAT_H */
|
#endif /* _XTABLES_COMPAT_H */
|
||||||
|
@@ -357,11 +357,10 @@ has_logged_during_this_minute(const struct peer *peer)
|
|||||||
*
|
*
|
||||||
* @r: rule
|
* @r: rule
|
||||||
*/
|
*/
|
||||||
static void
|
static void peer_gc(struct timer_list *tl)
|
||||||
peer_gc(unsigned long r)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct xt_pknock_rule *rule = (struct xt_pknock_rule *)r;
|
struct xt_pknock_rule *rule = from_timer(rule, tl, timer);
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct list_head *pos, *n;
|
struct list_head *pos, *n;
|
||||||
|
|
||||||
@@ -468,11 +467,7 @@ add_rule(struct xt_pknock_mtinfo *info)
|
|||||||
rule->peer_head = alloc_hashtable(peer_hashsize);
|
rule->peer_head = alloc_hashtable(peer_hashsize);
|
||||||
if (rule->peer_head == NULL)
|
if (rule->peer_head == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
timer_setup(&rule->timer, peer_gc, 0);
|
||||||
init_timer(&rule->timer);
|
|
||||||
rule->timer.function = peer_gc;
|
|
||||||
rule->timer.data = (unsigned long)rule;
|
|
||||||
|
|
||||||
rule->status_proc = proc_create_data(info->rule_name, 0, pde,
|
rule->status_proc = proc_create_data(info->rule_name, 0, pde,
|
||||||
&pknock_proc_ops, rule);
|
&pknock_proc_ops, rule);
|
||||||
if (rule->status_proc == NULL)
|
if (rule->status_proc == NULL)
|
||||||
@@ -619,8 +614,9 @@ static void add_peer(struct peer *peer, struct xt_pknock_rule *rule)
|
|||||||
*/
|
*/
|
||||||
static void remove_peer(struct peer *peer)
|
static void remove_peer(struct peer *peer)
|
||||||
{
|
{
|
||||||
|
if (peer == NULL)
|
||||||
|
return;
|
||||||
list_del(&peer->head);
|
list_del(&peer->head);
|
||||||
if (peer != NULL)
|
|
||||||
kfree(peer);
|
kfree(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,13 +694,7 @@ msg_to_userspace_nl(const struct xt_pknock_mtinfo *info,
|
|||||||
scnprintf(msg.rule_name, info->rule_name_len + 1, info->rule_name);
|
scnprintf(msg.rule_name, info->rule_name_len + 1, info->rule_name);
|
||||||
|
|
||||||
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);
|
cn_netlink_send(m, 0, multicast_group, GFP_ATOMIC);
|
||||||
#else
|
|
||||||
cn_netlink_send(m, multicast_group, GFP_ATOMIC);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
kfree(m);
|
kfree(m);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@@ -58,12 +58,7 @@ xt_chaos_total(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
|
|
||||||
{
|
{
|
||||||
struct xt_action_param local_par;
|
struct xt_action_param local_par;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
local_par.state = par->state;
|
local_par.state = par->state;
|
||||||
#else
|
|
||||||
local_par.in = par->in,
|
|
||||||
local_par.out = par->out,
|
|
||||||
#endif
|
|
||||||
local_par.match = xm_tcp;
|
local_par.match = xm_tcp;
|
||||||
local_par.matchinfo = &tcp_params;
|
local_par.matchinfo = &tcp_params;
|
||||||
local_par.fragoff = fragoff;
|
local_par.fragoff = fragoff;
|
||||||
@@ -78,14 +73,7 @@ xt_chaos_total(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
destiny = (info->variant == XTCHAOS_TARPIT) ? xt_tarpit : xt_delude;
|
destiny = (info->variant == XTCHAOS_TARPIT) ? xt_tarpit : xt_delude;
|
||||||
{
|
{
|
||||||
struct xt_action_param local_par;
|
struct xt_action_param local_par;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
local_par.state = par->state;
|
local_par.state = par->state;
|
||||||
#else
|
|
||||||
local_par.in = par->in;
|
|
||||||
local_par.out = par->out;
|
|
||||||
local_par.hooknum = par->hooknum;
|
|
||||||
local_par.family = par->family;
|
|
||||||
#endif
|
|
||||||
local_par.target = destiny;
|
local_par.target = destiny;
|
||||||
local_par.targinfo = par->targinfo;
|
local_par.targinfo = par->targinfo;
|
||||||
destiny->target(skb, &local_par);
|
destiny->target(skb, &local_par);
|
||||||
@@ -108,27 +96,15 @@ chaos_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
|
|
||||||
if ((unsigned int)prandom_u32() <= reject_percentage) {
|
if ((unsigned int)prandom_u32() <= reject_percentage) {
|
||||||
struct xt_action_param local_par;
|
struct xt_action_param local_par;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
local_par.state = par->state;
|
local_par.state = par->state;
|
||||||
#else
|
|
||||||
local_par.in = par->in;
|
|
||||||
local_par.out = par->out;
|
|
||||||
local_par.hooknum = par->hooknum;
|
|
||||||
#endif
|
|
||||||
local_par.target = xt_reject;
|
local_par.target = xt_reject;
|
||||||
local_par.targinfo = &reject_params;
|
local_par.targinfo = &reject_params;
|
||||||
return xt_reject->target(skb, &local_par);
|
return xt_reject->target(skb, &local_par);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TARPIT/DELUDE may not be called from the OUTPUT chain */
|
/* TARPIT/DELUDE may not be called from the OUTPUT chain */
|
||||||
if (iph->protocol == IPPROTO_TCP &&
|
if (iph->protocol == IPPROTO_TCP && info->variant != XTCHAOS_NORMAL &&
|
||||||
info->variant != XTCHAOS_NORMAL &&
|
par->state->hook != NF_INET_LOCAL_OUT)
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
par->state->hook
|
|
||||||
#else
|
|
||||||
par->hooknum
|
|
||||||
#endif
|
|
||||||
!= NF_INET_LOCAL_OUT)
|
|
||||||
xt_chaos_total(skb, par);
|
xt_chaos_total(skb, par);
|
||||||
|
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
|
@@ -79,7 +79,7 @@ static void delude_send_reset(struct net *net, struct sk_buff *oldskb,
|
|||||||
tcph->doff = sizeof(struct tcphdr) / 4;
|
tcph->doff = sizeof(struct tcphdr) / 4;
|
||||||
|
|
||||||
/* DELUDE essential part */
|
/* DELUDE essential part */
|
||||||
if (oth->syn && !oth->ack && !oth->rst && !oth->fin) {
|
if (oth->syn && !oth->ack && !oth->fin) {
|
||||||
tcph->syn = true;
|
tcph->syn = true;
|
||||||
tcph->seq = 0;
|
tcph->seq = 0;
|
||||||
tcph->ack = true;
|
tcph->ack = true;
|
||||||
@@ -107,13 +107,8 @@ static void delude_send_reset(struct net *net, struct sk_buff *oldskb,
|
|||||||
|
|
||||||
addr_type = RTN_UNSPEC;
|
addr_type = RTN_UNSPEC;
|
||||||
#ifdef CONFIG_BRIDGE_NETFILTER
|
#ifdef CONFIG_BRIDGE_NETFILTER
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
|
|
||||||
if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
|
if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
|
||||||
nskb->nf_bridge->physoutdev))
|
nskb->nf_bridge->physoutdev))
|
||||||
#else
|
|
||||||
if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
|
|
||||||
nskb->nf_bridge->mask & BRNF_BRIDGED))
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
if (hook != NF_INET_FORWARD)
|
if (hook != NF_INET_FORWARD)
|
||||||
#endif
|
#endif
|
||||||
@@ -151,13 +146,7 @@ delude_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
* a problem, as that is supported since Linux 2.6.35. But since we do not
|
* a problem, as that is supported since Linux 2.6.35. But since we do not
|
||||||
* actually want to have a connection open, we are still going to drop it.
|
* actually want to have a connection open, we are still going to drop it.
|
||||||
*/
|
*/
|
||||||
delude_send_reset(par_net(par), skb,
|
delude_send_reset(par_net(par), skb, par->state->hook);
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
par->state->hook
|
|
||||||
#else
|
|
||||||
par->hooknum
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -356,11 +356,7 @@ out:
|
|||||||
static unsigned int
|
static unsigned int
|
||||||
dnetmap_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
dnetmap_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
||||||
{
|
{
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
struct net *net = dev_net(par->state->in ? par->state->in : par->state->out);
|
struct net *net = dev_net(par->state->in ? par->state->in : par->state->out);
|
||||||
#else
|
|
||||||
struct net *net = dev_net(par->in ? par->in : par->out);
|
|
||||||
#endif
|
|
||||||
struct dnetmap_net *dnetmap_net = dnetmap_pernet(net);
|
struct dnetmap_net *dnetmap_net = dnetmap_pernet(net);
|
||||||
struct nf_conn *ct;
|
struct nf_conn *ct;
|
||||||
enum ip_conntrack_info ctinfo;
|
enum ip_conntrack_info ctinfo;
|
||||||
@@ -371,15 +367,7 @@ dnetmap_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
struct dnetmap_entry *e;
|
struct dnetmap_entry *e;
|
||||||
struct dnetmap_prefix *p;
|
struct dnetmap_prefix *p;
|
||||||
__s32 jttl;
|
__s32 jttl;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
unsigned int hooknum = par->state->hook;
|
unsigned int hooknum = par->state->hook;
|
||||||
#else
|
|
||||||
unsigned int hooknum = par->hooknum;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NF_CT_ASSERT(hooknum == NF_INET_POST_ROUTING ||
|
|
||||||
hooknum == NF_INET_LOCAL_OUT ||
|
|
||||||
hooknum == NF_INET_PRE_ROUTING);
|
|
||||||
ct = nf_ct_get(skb, &ctinfo);
|
ct = nf_ct_get(skb, &ctinfo);
|
||||||
|
|
||||||
jttl = tginfo->flags & XT_DNETMAP_TTL ? tginfo->ttl * HZ : jtimeout;
|
jttl = tginfo->flags & XT_DNETMAP_TTL ? tginfo->ttl * HZ : jtimeout;
|
||||||
@@ -398,7 +386,7 @@ dnetmap_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
/* if prefix is specified, we check if
|
/* if prefix is specified, we check if
|
||||||
it matches lookedup entry */
|
it matches lookedup entry */
|
||||||
if (tginfo->flags & XT_DNETMAP_PREFIX)
|
if (tginfo->flags & XT_DNETMAP_PREFIX)
|
||||||
if (memcmp(mr, &e->prefix, sizeof(*mr)))
|
if (memcmp(mr, &e->prefix->prefix, sizeof(*mr)))
|
||||||
goto no_rev_map;
|
goto no_rev_map;
|
||||||
/* don't reset ttl if flag is set */
|
/* don't reset ttl if flag is set */
|
||||||
if (jttl >= 0 && (! (e->flags & XT_DNETMAP_STATIC) ) ) {
|
if (jttl >= 0 && (! (e->flags & XT_DNETMAP_STATIC) ) ) {
|
||||||
@@ -504,12 +492,7 @@ bind_new_prefix:
|
|||||||
newrange.max_addr.ip = postnat_ip;
|
newrange.max_addr.ip = postnat_ip;
|
||||||
newrange.min_proto = mr->min_proto;
|
newrange.min_proto = mr->min_proto;
|
||||||
newrange.max_proto = mr->max_proto;
|
newrange.max_proto = mr->max_proto;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(par->state->hook));
|
return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(par->state->hook));
|
||||||
#else
|
|
||||||
return nf_nat_setup_info(ct, &newrange, HOOK2MANIP(par->hooknum));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
no_rev_map:
|
no_rev_map:
|
||||||
no_free_ip:
|
no_free_ip:
|
||||||
spin_unlock_bh(&dnetmap_lock);
|
spin_unlock_bh(&dnetmap_lock);
|
||||||
|
@@ -35,11 +35,7 @@ echo_tg6(struct sk_buff *oldskb, const struct xt_action_param *par)
|
|||||||
void *payload;
|
void *payload;
|
||||||
struct flowi6 fl;
|
struct flowi6 fl;
|
||||||
struct dst_entry *dst = NULL;
|
struct dst_entry *dst = NULL;
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
struct net *net = dev_net((par->state->in != NULL) ? par->state->in : par->state->out);
|
struct net *net = dev_net((par->state->in != NULL) ? par->state->in : par->state->out);
|
||||||
#else
|
|
||||||
struct net *net = dev_net((par->in != NULL) ? par->in : par->out);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This allows us to do the copy operation in fewer lines of code. */
|
/* This allows us to do the copy operation in fewer lines of code. */
|
||||||
if (skb_linearize(oldskb) < 0)
|
if (skb_linearize(oldskb) < 0)
|
||||||
|
@@ -64,12 +64,7 @@ static void logmark_ct(const struct nf_conn *ct, enum ip_conntrack_info ctinfo)
|
|||||||
printk("%s""CONFIRMED", prev ? "," : "");
|
printk("%s""CONFIRMED", prev ? "," : "");
|
||||||
prev = true;
|
prev = true;
|
||||||
}
|
}
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
|
|
||||||
printk(" lifetime=%lus", nf_ct_expires(ct) / HZ);
|
printk(" lifetime=%lus", nf_ct_expires(ct) / HZ);
|
||||||
#else
|
|
||||||
printk(" lifetime=%lus",
|
|
||||||
(jiffies - ct->timeout.expires) / HZ);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
@@ -82,21 +77,13 @@ logmark_tg(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
printk("<%u>%.*s""iif=%d hook=%s nfmark=0x%x "
|
printk("<%u>%.*s""iif=%d hook=%s nfmark=0x%x "
|
||||||
"secmark=0x%x classify=0x%x",
|
"secmark=0x%x classify=0x%x",
|
||||||
info->level, (unsigned int)sizeof(info->prefix), info->prefix,
|
info->level, (unsigned int)sizeof(info->prefix), info->prefix,
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
skb_ifindex(skb), hook_names[par->state->hook],
|
skb_ifindex(skb), hook_names[par->state->hook],
|
||||||
#else
|
|
||||||
skb_ifindex(skb), hook_names[par->hooknum],
|
|
||||||
#endif
|
|
||||||
skb_nfmark(skb), skb_secmark(skb), skb->priority);
|
skb_nfmark(skb), skb_secmark(skb), skb->priority);
|
||||||
|
|
||||||
ct = nf_ct_get(skb, &ctinfo);
|
ct = nf_ct_get(skb, &ctinfo);
|
||||||
printk(" ctdir=%s", dir_names[ctinfo >= IP_CT_IS_REPLY]);
|
printk(" ctdir=%s", dir_names[ctinfo >= IP_CT_IS_REPLY]);
|
||||||
if (ct == NULL)
|
if (ct == NULL)
|
||||||
printk(" ct=NULL ctmark=NULL ctstate=INVALID ctstatus=NONE");
|
printk(" ct=NULL ctmark=NULL ctstate=INVALID ctstatus=NONE");
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
|
|
||||||
else if (nf_ct_is_untracked(ct))
|
|
||||||
printk(" ct=UNTRACKED ctmark=NULL ctstate=UNTRACKED ctstatus=NONE");
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
logmark_ct(ct, ctinfo);
|
logmark_ct(ct, ctinfo);
|
||||||
|
|
||||||
|
@@ -249,13 +249,8 @@ static void tarpit_tcp4(struct net *net, struct sk_buff *oldskb,
|
|||||||
niph->id = ~oldhdr->id + 1;
|
niph->id = ~oldhdr->id + 1;
|
||||||
|
|
||||||
#ifdef CONFIG_BRIDGE_NETFILTER
|
#ifdef CONFIG_BRIDGE_NETFILTER
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
|
|
||||||
if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
|
if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
|
||||||
nskb->nf_bridge->physoutdev != NULL))
|
nskb->nf_bridge->physoutdev != NULL))
|
||||||
#else
|
|
||||||
if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
|
|
||||||
nskb->nf_bridge->mask & BRNF_BRIDGED))
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
if (hook != NF_INET_FORWARD)
|
if (hook != NF_INET_FORWARD)
|
||||||
#endif
|
#endif
|
||||||
@@ -283,17 +278,8 @@ static void tarpit_tcp4(struct net *net, struct sk_buff *oldskb,
|
|||||||
goto free_nskb;
|
goto free_nskb;
|
||||||
|
|
||||||
nf_ct_attach(nskb, oldskb);
|
nf_ct_attach(nskb, oldskb);
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
|
|
||||||
NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, net, nskb->sk, nskb, NULL,
|
NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, net, nskb->sk, nskb, NULL,
|
||||||
skb_dst(nskb)->dev, dst_output);
|
skb_dst(nskb)->dev, dst_output);
|
||||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
|
|
||||||
NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, nskb->sk, nskb, NULL,
|
|
||||||
skb_dst(nskb)->dev, dst_output_sk);
|
|
||||||
#else
|
|
||||||
NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, nskb, NULL,
|
|
||||||
skb_dst(nskb)->dev, dst_output);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
free_nskb:
|
free_nskb:
|
||||||
@@ -406,17 +392,8 @@ static void tarpit_tcp6(struct net *net, struct sk_buff *oldskb,
|
|||||||
nskb->ip_summed = CHECKSUM_NONE;
|
nskb->ip_summed = CHECKSUM_NONE;
|
||||||
|
|
||||||
nf_ct_attach(nskb, oldskb);
|
nf_ct_attach(nskb, oldskb);
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
|
|
||||||
NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, nskb->sk, nskb, NULL,
|
NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, nskb->sk, nskb, NULL,
|
||||||
skb_dst(nskb)->dev, dst_output);
|
skb_dst(nskb)->dev, dst_output);
|
||||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
|
|
||||||
NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, nskb->sk, nskb, NULL,
|
|
||||||
skb_dst(nskb)->dev, dst_output_sk);
|
|
||||||
#else
|
|
||||||
NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, nskb, NULL,
|
|
||||||
skb_dst(nskb)->dev, dst_output);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
free_nskb:
|
free_nskb:
|
||||||
@@ -454,12 +431,7 @@ tarpit_tg4(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
/* We are not interested in fragments */
|
/* We are not interested in fragments */
|
||||||
if (iph->frag_off & htons(IP_OFFSET))
|
if (iph->frag_off & htons(IP_OFFSET))
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
tarpit_tcp4(par_net(par), skb, par->state->hook, info->variant);
|
tarpit_tcp4(par_net(par), skb, par->state->hook, info->variant);
|
||||||
#else
|
|
||||||
tarpit_tcp4(par_net(par), skb, par->hooknum, info->variant);
|
|
||||||
#endif
|
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,12 +472,7 @@ tarpit_tg6(struct sk_buff *skb, const struct xt_action_param *par)
|
|||||||
pr_debug("addr is not unicast.\n");
|
pr_debug("addr is not unicast.\n");
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
tarpit_tcp6(par_net(par), skb, par->state->hook, info->variant);
|
tarpit_tcp6(par_net(par), skb, par->state->hook, info->variant);
|
||||||
#else
|
|
||||||
tarpit_tcp6(par_net(par), skb, par->hooknum, info->variant);
|
|
||||||
#endif
|
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -45,17 +45,9 @@ static const struct net_device *iface_get(const struct xt_iface_mtinfo *info,
|
|||||||
const struct xt_action_param *par, struct net_device **put)
|
const struct xt_action_param *par, struct net_device **put)
|
||||||
{
|
{
|
||||||
if (info->flags & XT_IFACE_DEV_IN)
|
if (info->flags & XT_IFACE_DEV_IN)
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
return par->state->in;
|
return par->state->in;
|
||||||
#else
|
|
||||||
return par->in;
|
|
||||||
#endif
|
|
||||||
else if (info->flags & XT_IFACE_DEV_OUT)
|
else if (info->flags & XT_IFACE_DEV_OUT)
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
return par->state->out;
|
return par->state->out;
|
||||||
#else
|
|
||||||
return par->out;
|
|
||||||
#endif
|
|
||||||
return *put = dev_get_by_name(&init_net, info->ifname);
|
return *put = dev_get_by_name(&init_net, info->ifname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -511,7 +511,7 @@ search_bittorrent(const unsigned char *payload, const unsigned int plen)
|
|||||||
* but *must have* one (or more) of strings listed below (true for scrape and announce)
|
* but *must have* one (or more) of strings listed below (true for scrape and announce)
|
||||||
*/
|
*/
|
||||||
if (memcmp(payload, "GET /", 5) == 0) {
|
if (memcmp(payload, "GET /", 5) == 0) {
|
||||||
if (HX_memmem(payload, plen, "info_hash=", 9) != NULL)
|
if (HX_memmem(payload, plen, "info_hash=", 10) != NULL)
|
||||||
return IPP2P_BIT * 100 + 1;
|
return IPP2P_BIT * 100 + 1;
|
||||||
if (HX_memmem(payload, plen, "peer_id=", 8) != NULL)
|
if (HX_memmem(payload, plen, "peer_id=", 8) != NULL)
|
||||||
return IPP2P_BIT * 100 + 2;
|
return IPP2P_BIT * 100 + 2;
|
||||||
|
@@ -204,11 +204,7 @@ lscan_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
|||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
n = lscan_mt_full(ctdata->mark & connmark_mask, ctstate,
|
n = lscan_mt_full(ctdata->mark & connmark_mask, ctstate,
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
|
|
||||||
par->state->in == init_net.loopback_dev, tcph,
|
par->state->in == init_net.loopback_dev, tcph,
|
||||||
#else
|
|
||||||
par->in == init_net.loopback_dev, tcph,
|
|
||||||
#endif
|
|
||||||
skb->len - par->thoff - 4 * tcph->doff);
|
skb->len - par->thoff - 4 * tcph->doff);
|
||||||
|
|
||||||
ctdata->mark = (ctdata->mark & ~connmark_mask) | n;
|
ctdata->mark = (ctdata->mark & ~connmark_mask) | n;
|
||||||
|
@@ -8,23 +8,45 @@ use IO::Handle;
|
|||||||
use Text::CSV_XS; # or trade for Text::CSV
|
use Text::CSV_XS; # or trade for Text::CSV
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
my $le32 = pack("V", 0x10000000);
|
||||||
|
my $be32 = pack("N", 0x10000000);
|
||||||
|
my $u32 = undef;
|
||||||
|
|
||||||
|
sub wantBE { return !$u32 || $u32 eq $be32; }
|
||||||
|
sub wantLE { return !$u32 || $u32 eq $le32; }
|
||||||
|
|
||||||
my $csv = Text::CSV_XS->new({
|
my $csv = Text::CSV_XS->new({
|
||||||
allow_whitespace => 1,
|
allow_whitespace => 1,
|
||||||
binary => 1,
|
binary => 1,
|
||||||
eol => $/,
|
eol => $/,
|
||||||
}); # or Text::CSV
|
}); # or Text::CSV
|
||||||
my $target_dir = ".";
|
my $target_dir = ".";
|
||||||
|
my $native_only = 0;
|
||||||
|
|
||||||
&Getopt::Long::Configure(qw(bundling));
|
&Getopt::Long::Configure(qw(bundling));
|
||||||
&GetOptions(
|
&GetOptions(
|
||||||
"D=s" => \$target_dir,
|
"D=s" => \$target_dir,
|
||||||
|
"n" => \$native_only,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!-d $target_dir) {
|
if (!-d $target_dir) {
|
||||||
print STDERR "Target directory $target_dir does not exist.\n";
|
print STDERR "Target directory $target_dir does not exist.\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
foreach (qw(LE BE)) {
|
my @dbs = qw(LE BE);
|
||||||
|
if ($native_only) {
|
||||||
|
$u32 = pack("L", 0x10000000);
|
||||||
|
if ($u32 eq $le32) {
|
||||||
|
@dbs = qw(LE);
|
||||||
|
} elsif ($u32 eq $be32) {
|
||||||
|
@dbs = qw(BE);
|
||||||
|
} else {
|
||||||
|
print STDERRR "Cannot determine endianness.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (@dbs) {
|
||||||
my $dir = "$target_dir/$_";
|
my $dir = "$target_dir/$_";
|
||||||
if (!-e $dir && !mkdir($dir)) {
|
if (!-e $dir && !mkdir($dir)) {
|
||||||
print STDERR "Could not mkdir $dir: $!\n";
|
print STDERR "Could not mkdir $dir: $!\n";
|
||||||
@@ -80,11 +102,18 @@ sub dump_one
|
|||||||
scalar(@{$country->{pool_v6}}),
|
scalar(@{$country->{pool_v6}}),
|
||||||
$iso_code, $country->{name};
|
$iso_code, $country->{name};
|
||||||
|
|
||||||
|
if (wantLE) {
|
||||||
$file = "$target_dir/LE/".uc($iso_code).".iv6";
|
$file = "$target_dir/LE/".uc($iso_code).".iv6";
|
||||||
if (!open($fh_le, "> $file")) {
|
if (!open($fh_le, "> $file")) {
|
||||||
print STDERR "Error opening $file: $!\n";
|
print STDERR "Error opening $file: $!\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
foreach my $range (@{$country->{pool_v6}}) {
|
||||||
|
print $fh_le &ip6_swap($range->[0]), &ip6_swap($range->[1]);
|
||||||
|
}
|
||||||
|
close $fh_le;
|
||||||
|
}
|
||||||
|
if (wantBE) {
|
||||||
$file = "$target_dir/BE/".uc($iso_code).".iv6";
|
$file = "$target_dir/BE/".uc($iso_code).".iv6";
|
||||||
if (!open($fh_be, "> $file")) {
|
if (!open($fh_be, "> $file")) {
|
||||||
print STDERR "Error opening $file: $!\n";
|
print STDERR "Error opening $file: $!\n";
|
||||||
@@ -92,31 +121,36 @@ sub dump_one
|
|||||||
}
|
}
|
||||||
foreach my $range (@{$country->{pool_v6}}) {
|
foreach my $range (@{$country->{pool_v6}}) {
|
||||||
print $fh_be $range->[0], $range->[1];
|
print $fh_be $range->[0], $range->[1];
|
||||||
print $fh_le &ip6_swap($range->[0]), &ip6_swap($range->[1]);
|
|
||||||
}
|
}
|
||||||
close $fh_le;
|
|
||||||
close $fh_be;
|
close $fh_be;
|
||||||
|
}
|
||||||
|
|
||||||
printf "%5u IPv4 ranges for %s %s\n",
|
printf "%5u IPv4 ranges for %s %s\n",
|
||||||
scalar(@{$country->{pool_v4}}),
|
scalar(@{$country->{pool_v4}}),
|
||||||
$iso_code, $country->{name};
|
$iso_code, $country->{name};
|
||||||
|
|
||||||
|
if (wantLE) {
|
||||||
$file = "$target_dir/LE/".uc($iso_code).".iv4";
|
$file = "$target_dir/LE/".uc($iso_code).".iv4";
|
||||||
if (!open($fh_le, "> $file")) {
|
if (!open($fh_le, "> $file")) {
|
||||||
print STDERR "Error opening $file: $!\n";
|
print STDERR "Error opening $file: $!\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
foreach my $range (@{$country->{pool_v4}}) {
|
||||||
|
print $fh_le pack("VV", $range->[0], $range->[1]);
|
||||||
|
}
|
||||||
|
close $fh_le;
|
||||||
|
}
|
||||||
|
if (wantBE) {
|
||||||
$file = "$target_dir/BE/".uc($iso_code).".iv4";
|
$file = "$target_dir/BE/".uc($iso_code).".iv4";
|
||||||
if (!open($fh_be, "> $file")) {
|
if (!open($fh_be, "> $file")) {
|
||||||
print STDERR "Error opening $file: $!\n";
|
print STDERR "Error opening $file: $!\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
foreach my $range (@{$country->{pool_v4}}) {
|
foreach my $range (@{$country->{pool_v4}}) {
|
||||||
print $fh_le pack("VV", $range->[0], $range->[1]);
|
|
||||||
print $fh_be pack("NN", $range->[0], $range->[1]);
|
print $fh_be pack("NN", $range->[0], $range->[1]);
|
||||||
}
|
}
|
||||||
close $fh_le;
|
|
||||||
close $fh_be;
|
close $fh_be;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ip6_pack
|
sub ip6_pack
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.TH xtables-addons 8 "" "" "v2.13 (2017-06-27)"
|
.TH xtables-addons 8 "Lilac" "" "v3.0 (2018-02-12)"
|
||||||
.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