mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-20 19:44:56 +02:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
24491d55d7 | ||
![]() |
7ab69a17fa | ||
![]() |
d2339410b2 | ||
![]() |
649caf61e8 | ||
![]() |
922a9be87d | ||
![]() |
4d48511f01 | ||
![]() |
6dedbef3d4 | ||
![]() |
fe49f9b6a4 | ||
![]() |
283974cbbe | ||
![]() |
7deca86132 | ||
![]() |
7d6435f422 | ||
![]() |
748f5cfdd0 | ||
![]() |
d402cec807 | ||
![]() |
b42190c04b | ||
![]() |
4dcefe4b95 | ||
![]() |
a2662b0121 | ||
![]() |
03354eed44 | ||
![]() |
ddda6972a4 | ||
![]() |
8e7359bb92 | ||
![]() |
40786af1c0 |
@@ -1,7 +1,7 @@
|
|||||||
# -*- Makefile -*-
|
# -*- Makefile -*-
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
SUBDIRS = extensions
|
SUBDIRS = extensions geoip
|
||||||
|
|
||||||
man_MANS := xtables-addons.8
|
man_MANS := xtables-addons.8
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ xtlibdir = @xtlibdir@
|
|||||||
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CCLD = ${CC}
|
CCLD = ${CC}
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
|
||||||
regular_CFLAGS = @regular_CFLAGS@
|
regular_CFLAGS = @regular_CFLAGS@
|
||||||
libxtables_CFLAGS = @libxtables_CFLAGS@
|
libxtables_CFLAGS = @libxtables_CFLAGS@
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
srcdir := @srcdir@
|
srcdir := @srcdir@
|
||||||
|
|
||||||
wcman_matches := $(shell find "${srcdir}" -name 'libxt_[a-z]*.man')
|
wcman_matches := $(shell find "${srcdir}" -name 'libxt_[a-z]*.man' | sort)
|
||||||
wcman_targets := $(shell find "${srcdir}" -name 'libxt_[A-Z]*.man')
|
wcman_targets := $(shell find "${srcdir}" -name 'libxt_[A-Z]*.man' | sort)
|
||||||
wlist_matches := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_matches})
|
wlist_matches := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_matches})
|
||||||
wlist_targets := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_targets})
|
wlist_targets := $(patsubst ${srcdir}/libxt_%.man,%,${wcman_targets})
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
AC_INIT([xtables-addons], [1.27])
|
AC_INIT([xtables-addons], [1.28])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
@@ -74,7 +74,7 @@ fi;
|
|||||||
AC_SUBST([regular_CFLAGS])
|
AC_SUBST([regular_CFLAGS])
|
||||||
AC_SUBST([kbuilddir])
|
AC_SUBST([kbuilddir])
|
||||||
AC_SUBST([xtlibdir])
|
AC_SUBST([xtlibdir])
|
||||||
AC_CONFIG_FILES([Makefile Makefile.iptrules Makefile.mans
|
AC_CONFIG_FILES([Makefile Makefile.iptrules Makefile.mans geoip/Makefile
|
||||||
extensions/Makefile extensions/ACCOUNT/Makefile
|
extensions/Makefile extensions/ACCOUNT/Makefile
|
||||||
extensions/ipset/Makefile extensions/pknock/Makefile])
|
extensions/ipset/Makefile extensions/pknock/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@@ -3,6 +3,15 @@ HEAD
|
|||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
|
Xtables-addons 1.28 (July 24 2010)
|
||||||
|
==================================
|
||||||
|
- RAWNAT: IPv6 variants erroneously rejected masks /33-/128
|
||||||
|
- new target xt_CHECKSUM
|
||||||
|
- xt_length2: add support for IPv6 jumbograms
|
||||||
|
- xt_geoip: fix possible out-of-bounds access
|
||||||
|
- import xt_geoip database scripts
|
||||||
|
|
||||||
|
|
||||||
Xtables-addons 1.27 (May 16 2010)
|
Xtables-addons 1.27 (May 16 2010)
|
||||||
=================================
|
=================================
|
||||||
- further updates for the upcoming 2.6.35 changes
|
- further updates for the upcoming 2.6.35 changes
|
||||||
|
@@ -7,6 +7,7 @@ obj-m += compat_xtables.o
|
|||||||
|
|
||||||
obj-${build_ACCOUNT} += ACCOUNT/
|
obj-${build_ACCOUNT} += ACCOUNT/
|
||||||
obj-${build_CHAOS} += xt_CHAOS.o
|
obj-${build_CHAOS} += xt_CHAOS.o
|
||||||
|
obj-${build_CHECKSUM} += xt_CHECKSUM.o
|
||||||
obj-${build_DELUDE} += xt_DELUDE.o
|
obj-${build_DELUDE} += xt_DELUDE.o
|
||||||
obj-${build_DHCPMAC} += xt_DHCPMAC.o
|
obj-${build_DHCPMAC} += xt_DHCPMAC.o
|
||||||
obj-${build_ECHO} += xt_ECHO.o
|
obj-${build_ECHO} += xt_ECHO.o
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
obj-${build_ACCOUNT} += ACCOUNT/
|
obj-${build_ACCOUNT} += ACCOUNT/
|
||||||
obj-${build_CHAOS} += libxt_CHAOS.so
|
obj-${build_CHAOS} += libxt_CHAOS.so
|
||||||
|
obj-${build_CHECKSUM} += libxt_CHECKSUM.so
|
||||||
obj-${build_DELUDE} += libxt_DELUDE.so
|
obj-${build_DELUDE} += libxt_DELUDE.so
|
||||||
obj-${build_DHCPMAC} += libxt_DHCPMAC.so libxt_dhcpmac.so
|
obj-${build_DHCPMAC} += libxt_DHCPMAC.so libxt_dhcpmac.so
|
||||||
obj-${build_ECHO} += libxt_ECHO.so
|
obj-${build_ECHO} += libxt_ECHO.so
|
||||||
|
93
extensions/libxt_CHECKSUM.c
Normal file
93
extensions/libxt_CHECKSUM.c
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* (C) 2002 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
* (C) 2010 by Red Hat, Inc
|
||||||
|
* Author: Michael S. Tsirkin <mst@redhat.com>
|
||||||
|
*
|
||||||
|
* This program is distributed under the terms of GNU GPL v2, 1991
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <xtables.h>
|
||||||
|
#include "xt_CHECKSUM.h"
|
||||||
|
|
||||||
|
static void CHECKSUM_help(void)
|
||||||
|
{
|
||||||
|
printf(
|
||||||
|
"CHECKSUM target options\n"
|
||||||
|
" --checksum-fill Fill in packet checksum.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct option CHECKSUM_opts[] = {
|
||||||
|
{ "checksum-fill", 0, NULL, 'F' },
|
||||||
|
{ .name = NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static int CHECKSUM_parse(int c, char **argv, int invert, unsigned int *flags,
|
||||||
|
const void *entry, struct xt_entry_target **target)
|
||||||
|
{
|
||||||
|
struct xt_CHECKSUM_info *einfo
|
||||||
|
= (struct xt_CHECKSUM_info *)(*target)->data;
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'F':
|
||||||
|
xtables_param_act(XTF_ONLY_ONCE, "CHECKSUM", "--checksum-fill",
|
||||||
|
*flags & XT_CHECKSUM_OP_FILL);
|
||||||
|
einfo->operation = XT_CHECKSUM_OP_FILL;
|
||||||
|
*flags |= XT_CHECKSUM_OP_FILL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CHECKSUM_check(unsigned int flags)
|
||||||
|
{
|
||||||
|
if (!flags)
|
||||||
|
xtables_error(PARAMETER_PROBLEM,
|
||||||
|
"CHECKSUM target: Parameter --checksum-fill is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CHECKSUM_print(const void *ip, const struct xt_entry_target *target,
|
||||||
|
int numeric)
|
||||||
|
{
|
||||||
|
const struct xt_CHECKSUM_info *einfo =
|
||||||
|
(const struct xt_CHECKSUM_info *)target->data;
|
||||||
|
|
||||||
|
printf("CHECKSUM ");
|
||||||
|
|
||||||
|
if (einfo->operation & XT_CHECKSUM_OP_FILL)
|
||||||
|
printf("fill ");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CHECKSUM_save(const void *ip, const struct xt_entry_target *target)
|
||||||
|
{
|
||||||
|
const struct xt_CHECKSUM_info *einfo =
|
||||||
|
(const struct xt_CHECKSUM_info *)target->data;
|
||||||
|
|
||||||
|
if (einfo->operation & XT_CHECKSUM_OP_FILL)
|
||||||
|
printf("--checksum-fill ");
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct xtables_target checksum_tg_reg = {
|
||||||
|
.name = "CHECKSUM",
|
||||||
|
.version = XTABLES_VERSION,
|
||||||
|
.family = NFPROTO_UNSPEC,
|
||||||
|
.size = XT_ALIGN(sizeof(struct xt_CHECKSUM_info)),
|
||||||
|
.userspacesize = XT_ALIGN(sizeof(struct xt_CHECKSUM_info)),
|
||||||
|
.help = CHECKSUM_help,
|
||||||
|
.parse = CHECKSUM_parse,
|
||||||
|
.final_check = CHECKSUM_check,
|
||||||
|
.print = CHECKSUM_print,
|
||||||
|
.save = CHECKSUM_save,
|
||||||
|
.extra_opts = CHECKSUM_opts,
|
||||||
|
};
|
||||||
|
|
||||||
|
static __attribute__((constructor)) void _init(void)
|
||||||
|
{
|
||||||
|
xtables_register_target(&checksum_tg_reg);
|
||||||
|
}
|
8
extensions/libxt_CHECKSUM.man
Normal file
8
extensions/libxt_CHECKSUM.man
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
This target allows to selectively work around broken/old applications.
|
||||||
|
It can only be used in the mangle table.
|
||||||
|
.TP
|
||||||
|
\fB\-\-checksum\-fill\fP
|
||||||
|
Compute and fill in the checksum in a packet that lacks a checksum.
|
||||||
|
This is particularly useful, if you need to work around old applications
|
||||||
|
such as dhcp clients, that do not work well with checksum offloads,
|
||||||
|
but don't want to disable checksum offload in your device.
|
@@ -79,7 +79,7 @@ rawdnat_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
|
|||||||
end = strchr(optarg, '/');
|
end = strchr(optarg, '/');
|
||||||
if (end != NULL) {
|
if (end != NULL) {
|
||||||
*end++ = '\0';
|
*end++ = '\0';
|
||||||
if (!xtables_strtoui(end, NULL, &mask, 0, 32))
|
if (!xtables_strtoui(end, NULL, &mask, 0, 128))
|
||||||
xtables_param_act(XTF_BAD_VALUE, "RAWDNAT",
|
xtables_param_act(XTF_BAD_VALUE, "RAWDNAT",
|
||||||
"--to-destination", optarg);
|
"--to-destination", optarg);
|
||||||
info->mask = mask;
|
info->mask = mask;
|
||||||
|
@@ -79,7 +79,7 @@ rawsnat_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
|
|||||||
end = strchr(optarg, '/');
|
end = strchr(optarg, '/');
|
||||||
if (end != NULL) {
|
if (end != NULL) {
|
||||||
*end++ = '\0';
|
*end++ = '\0';
|
||||||
if (!xtables_strtoui(end, NULL, &mask, 0, 32))
|
if (!xtables_strtoui(end, NULL, &mask, 0, 128))
|
||||||
xtables_param_act(XTF_BAD_VALUE, "RAWSNAT",
|
xtables_param_act(XTF_BAD_VALUE, "RAWSNAT",
|
||||||
"--to-source", optarg);
|
"--to-source", optarg);
|
||||||
info->mask = mask;
|
info->mask = mask;
|
||||||
|
@@ -10,8 +10,8 @@ NOTE:
|
|||||||
The country is inputed by its ISO-3166 code.
|
The country is inputed by its ISO-3166 code.
|
||||||
.PP
|
.PP
|
||||||
The extra files you will need is the binary database files. They are generated
|
The extra files you will need is the binary database files. They are generated
|
||||||
from a country-subnet database with the geoip_csv_iv0.pl tool, available at
|
from a country-subnet database with the geoip_csv_iv0.pl tool that should be
|
||||||
http://jengelh.hopto.org/files/geoip/ . The files MUST be moved to
|
available in /usr/lib(exec)/xtables-addons/ . The resulting files MUST be moved
|
||||||
/usr/share/xt_geoip/
|
to /usr/share/xt_geoip/
|
||||||
as the shared library is statically looking for this pathname (e.g.
|
as the shared library is statically looking for this pathname (e.g.
|
||||||
/usr/share/xt_geoip/LE/de.iv0).
|
/usr/share/xt_geoip/LE/de.iv0).
|
||||||
|
72
extensions/xt_CHECKSUM.c
Normal file
72
extensions/xt_CHECKSUM.c
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* (C) 2002 by Harald Welte <laforge@netfilter.org>
|
||||||
|
* (C) 2010 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* Author: Michael S. Tsirkin <mst@redhat.com>
|
||||||
|
*
|
||||||
|
* 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/netfilter/x_tables.h>
|
||||||
|
#include "xt_CHECKSUM.h"
|
||||||
|
#include "compat_xtables.h"
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_AUTHOR("Michael S. Tsirkin <mst@redhat.com>");
|
||||||
|
MODULE_DESCRIPTION("Xtables: checksum modification");
|
||||||
|
MODULE_ALIAS("ipt_CHECKSUM");
|
||||||
|
MODULE_ALIAS("ip6t_CHECKSUM");
|
||||||
|
|
||||||
|
static unsigned int
|
||||||
|
checksum_tg(struct sk_buff **pskb, const struct xt_action_param *par)
|
||||||
|
{
|
||||||
|
struct sk_buff *skb = *pskb;
|
||||||
|
|
||||||
|
if (skb->ip_summed == CHECKSUM_PARTIAL)
|
||||||
|
skb_checksum_help(skb);
|
||||||
|
|
||||||
|
return XT_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int checksum_tg_check(const struct xt_tgchk_param *par)
|
||||||
|
{
|
||||||
|
const struct xt_CHECKSUM_info *einfo = par->targinfo;
|
||||||
|
|
||||||
|
if (einfo->operation & ~XT_CHECKSUM_OP_FILL) {
|
||||||
|
pr_info("unsupported CHECKSUM operation %x\n", einfo->operation);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (!einfo->operation) {
|
||||||
|
pr_info("no CHECKSUM operation enabled\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct xt_target checksum_tg_reg __read_mostly = {
|
||||||
|
.name = "CHECKSUM",
|
||||||
|
.family = NFPROTO_UNSPEC,
|
||||||
|
.target = checksum_tg,
|
||||||
|
.targetsize = sizeof(struct xt_CHECKSUM_info),
|
||||||
|
.table = "mangle",
|
||||||
|
.checkentry = checksum_tg_check,
|
||||||
|
.me = THIS_MODULE,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init checksum_tg_init(void)
|
||||||
|
{
|
||||||
|
return xt_register_target(&checksum_tg_reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __exit checksum_tg_exit(void)
|
||||||
|
{
|
||||||
|
xt_unregister_target(&checksum_tg_reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
module_init(checksum_tg_init);
|
||||||
|
module_exit(checksum_tg_exit);
|
18
extensions/xt_CHECKSUM.h
Normal file
18
extensions/xt_CHECKSUM.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* Header file for iptables ipt_CHECKSUM target
|
||||||
|
*
|
||||||
|
* (C) 2002 by Harald Welte <laforge@gnumonks.org>
|
||||||
|
* (C) 2010 Red Hat Inc
|
||||||
|
* Author: Michael S. Tsirkin <mst@redhat.com>
|
||||||
|
*
|
||||||
|
* This software is distributed under GNU GPL v2, 1991
|
||||||
|
*/
|
||||||
|
#ifndef _IPT_CHECKSUM_TARGET_H
|
||||||
|
#define _IPT_CHECKSUM_TARGET_H
|
||||||
|
|
||||||
|
#define XT_CHECKSUM_OP_FILL 0x01 /* fill in checksum in IP header */
|
||||||
|
|
||||||
|
struct xt_CHECKSUM_info {
|
||||||
|
__u8 operation; /* bitset of operations */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _IPT_CHECKSUM_TARGET_H */
|
@@ -48,7 +48,7 @@ rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask)
|
|||||||
break;
|
break;
|
||||||
case 33 ... 63:
|
case 33 ... 63:
|
||||||
addr[0] = repl[0];
|
addr[0] = repl[0];
|
||||||
addr[1] = remask(addr[1], repl[1], mask - 64);
|
addr[1] = remask(addr[1], repl[1], mask - 32);
|
||||||
break;
|
break;
|
||||||
case 64:
|
case 64:
|
||||||
addr[0] = repl[0];
|
addr[0] = repl[0];
|
||||||
@@ -57,7 +57,7 @@ rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask)
|
|||||||
case 65 ... 95:
|
case 65 ... 95:
|
||||||
addr[0] = repl[0];
|
addr[0] = repl[0];
|
||||||
addr[1] = repl[1];
|
addr[1] = repl[1];
|
||||||
addr[2] = remask(addr[2], repl[2], mask - 96);
|
addr[2] = remask(addr[2], repl[2], mask - 64);
|
||||||
case 96:
|
case 96:
|
||||||
addr[0] = repl[0];
|
addr[0] = repl[0];
|
||||||
addr[1] = repl[1];
|
addr[1] = repl[1];
|
||||||
@@ -67,7 +67,7 @@ rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask)
|
|||||||
addr[0] = repl[0];
|
addr[0] = repl[0];
|
||||||
addr[1] = repl[1];
|
addr[1] = repl[1];
|
||||||
addr[2] = repl[2];
|
addr[2] = repl[2];
|
||||||
addr[3] = remask(addr[3], repl[3], mask - 128);
|
addr[3] = remask(addr[3], repl[3], mask - 96);
|
||||||
break;
|
break;
|
||||||
case 128:
|
case 128:
|
||||||
addr[0] = repl[0];
|
addr[0] = repl[0];
|
||||||
|
@@ -135,13 +135,13 @@ static unsigned int sysrq_tg(const void *pdata, uint16_t len)
|
|||||||
"0123456789abcdef"[sysrq_digest[i] & 0xf];
|
"0123456789abcdef"[sysrq_digest[i] & 0xf];
|
||||||
}
|
}
|
||||||
sysrq_hexdigest[2*sysrq_digest_size] = '\0';
|
sysrq_hexdigest[2*sysrq_digest_size] = '\0';
|
||||||
if (len - n < sysrq_digest_size) {
|
if (len - n < sysrq_digest_size * 2) {
|
||||||
if (sysrq_debug)
|
if (sysrq_debug)
|
||||||
printk(KERN_INFO KBUILD_MODNAME ": Short digest,"
|
printk(KERN_INFO KBUILD_MODNAME ": Short digest,"
|
||||||
" expected %s\n", sysrq_hexdigest);
|
" expected %s\n", sysrq_hexdigest);
|
||||||
return NF_DROP;
|
return NF_DROP;
|
||||||
}
|
}
|
||||||
if (strncmp(data + n, sysrq_hexdigest, sysrq_digest_size) != 0) {
|
if (strncmp(data + n, sysrq_hexdigest, sysrq_digest_size * 2) != 0) {
|
||||||
if (sysrq_debug)
|
if (sysrq_debug)
|
||||||
printk(KERN_INFO KBUILD_MODNAME ": Bad digest,"
|
printk(KERN_INFO KBUILD_MODNAME ": Bad digest,"
|
||||||
" expected %s\n", sysrq_hexdigest);
|
" expected %s\n", sysrq_hexdigest);
|
||||||
@@ -324,8 +324,8 @@ static int __init sysrq_crypto_init(void)
|
|||||||
printk(KERN_WARNING KBUILD_MODNAME
|
printk(KERN_WARNING KBUILD_MODNAME
|
||||||
": Error: Could not find or load %s hash\n",
|
": Error: Could not find or load %s hash\n",
|
||||||
sysrq_hash);
|
sysrq_hash);
|
||||||
sysrq_tfm = NULL;
|
|
||||||
ret = PTR_ERR(sysrq_tfm);
|
ret = PTR_ERR(sysrq_tfm);
|
||||||
|
sysrq_tfm = NULL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
sysrq_digest_size = crypto_hash_digestsize(sysrq_tfm);
|
sysrq_digest_size = crypto_hash_digestsize(sysrq_tfm);
|
||||||
|
@@ -126,13 +126,13 @@ static bool geoip_bsearch(const struct geoip_subnet *range,
|
|||||||
{
|
{
|
||||||
int mid;
|
int mid;
|
||||||
|
|
||||||
if (hi < lo)
|
if (hi <= lo)
|
||||||
return false;
|
return false;
|
||||||
mid = (lo + hi) / 2;
|
mid = (lo + hi) / 2;
|
||||||
if (range[mid].begin <= addr && addr <= range[mid].end)
|
if (range[mid].begin <= addr && addr <= range[mid].end)
|
||||||
return true;
|
return true;
|
||||||
if (range[mid].begin > addr)
|
if (range[mid].begin > addr)
|
||||||
return geoip_bsearch(range, addr, lo, mid - 1);
|
return geoip_bsearch(range, addr, lo, mid);
|
||||||
else if (range[mid].end < addr)
|
else if (range[mid].end < addr)
|
||||||
return geoip_bsearch(range, addr, mid + 1, hi);
|
return geoip_bsearch(range, addr, mid + 1, hi);
|
||||||
|
|
||||||
|
@@ -207,7 +207,11 @@ length2_mt6(const struct sk_buff *skb, struct xt_action_param *par)
|
|||||||
bool hit = true;
|
bool hit = true;
|
||||||
|
|
||||||
if (info->flags & XT_LENGTH_LAYER3) {
|
if (info->flags & XT_LENGTH_LAYER3) {
|
||||||
len = sizeof(struct ipv6hdr) + ntohs(iph->payload_len);
|
if (iph->payload_len == 0)
|
||||||
|
/* Jumbogram */
|
||||||
|
len = skb->len;
|
||||||
|
else
|
||||||
|
len = sizeof(struct ipv6hdr) + ntohs(iph->payload_len);
|
||||||
} else {
|
} else {
|
||||||
l4proto = llayer4_proto(skb, &thoff, &par->hotdrop);
|
l4proto = llayer4_proto(skb, &thoff, &par->hotdrop);
|
||||||
if (l4proto == NEXTHDR_MAX)
|
if (l4proto == NEXTHDR_MAX)
|
||||||
|
6
geoip/.gitignore
vendored
Normal file
6
geoip/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/BE
|
||||||
|
/LE
|
||||||
|
/GeoIPCountryCSV.zip
|
||||||
|
/GeoIPCountryWhois.csv
|
||||||
|
/GeoIPv6.csv
|
||||||
|
/GeoIPv6.csv.gz
|
3
geoip/Makefile.am
Normal file
3
geoip/Makefile.am
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- Makefile -*-
|
||||||
|
|
||||||
|
pkglibexec_SCRIPTS = geoip_build_db.pl geoip_download.sh
|
54
geoip/geoip_build_db.pl
Executable file
54
geoip/geoip_build_db.pl
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# Converter for MaxMind CSV database to binary, for xt_geoip
|
||||||
|
# Copyright © Jan Engelhardt <jengelh@medozas.de>, 2008
|
||||||
|
#
|
||||||
|
# Use -b argument to create big-endian tables.
|
||||||
|
#
|
||||||
|
use Getopt::Long;
|
||||||
|
use IO::Handle;
|
||||||
|
use Text::CSV_XS; # or trade for Text::CSV
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my %country;
|
||||||
|
my %names;
|
||||||
|
my $csv = Text::CSV_XS->new({binary => 0, eol => $/}); # or Text::CSV
|
||||||
|
my $mode = "VV";
|
||||||
|
my $target_dir = ".";
|
||||||
|
|
||||||
|
&Getopt::Long::Configure(qw(bundling));
|
||||||
|
&GetOptions(
|
||||||
|
"D=s" => \$target_dir,
|
||||||
|
"b" => sub { $mode = "NN"; },
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!-d $target_dir) {
|
||||||
|
print STDERR "Target directory $target_dir does not exist.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (my $row = $csv->getline(*ARGV)) {
|
||||||
|
if (!defined($country{$row->[4]})) {
|
||||||
|
$country{$row->[4]} = [];
|
||||||
|
$names{$row->[4]} = $row->[5];
|
||||||
|
}
|
||||||
|
my $c = $country{$row->[4]};
|
||||||
|
push(@$c, [$row->[2], $row->[3]]);
|
||||||
|
if ($. % 4096 == 0) {
|
||||||
|
print STDERR "\r\e[2K$. entries";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print STDERR "\r\e[2K$. entries total\n";
|
||||||
|
|
||||||
|
foreach my $iso_code (sort keys %country) {
|
||||||
|
printf "%5u ranges for %s %s\n",
|
||||||
|
scalar(@{$country{$iso_code}}),
|
||||||
|
$iso_code, $names{$iso_code};
|
||||||
|
|
||||||
|
open(my $fh, "> $target_dir/".uc($iso_code).".iv0");
|
||||||
|
foreach my $range (@{$country{$iso_code}}) {
|
||||||
|
print $fh pack($mode, $range->[0], $range->[1]);
|
||||||
|
}
|
||||||
|
close $fh;
|
||||||
|
}
|
8
geoip/geoip_download.sh
Executable file
8
geoip/geoip_download.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -f GeoIPv6.csv{,.gz} GeoIPCountryCSV.zip GeoIPCountryWhois.csv;
|
||||||
|
wget \
|
||||||
|
http://geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz \
|
||||||
|
http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip;
|
||||||
|
gzip -d GeoIPv6.csv.gz;
|
||||||
|
unzip GeoIPCountryCSV.zip;
|
1
mconfig
1
mconfig
@@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
build_ACCOUNT=m
|
build_ACCOUNT=m
|
||||||
build_CHAOS=m
|
build_CHAOS=m
|
||||||
|
build_CHECKSUM=m
|
||||||
build_DELUDE=m
|
build_DELUDE=m
|
||||||
build_DHCPMAC=m
|
build_DHCPMAC=m
|
||||||
build_ECHO=
|
build_ECHO=
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
.TH xtables-addons 8 "v1.27 (2010-05-16)" "" "v1.27 (2010-05-16)"
|
.TH xtables-addons 8 "v1.28 (2010-07-24)" "" "v1.28 (2010-07-24)"
|
||||||
.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