Compare commits

...

44 Commits
v1.20 ... v1.24

Author SHA1 Message Date
Jan Engelhardt
6340363394 Xtables-addons 1.24 2010-03-17 02:50:23 +01:00
Jan Engelhardt
c9b4e9c518 xt_SYSRQ: drop unprocessed packets 2010-03-17 02:50:23 +01:00
Jan Engelhardt
8dd316ed56 Revert "xt_TEE: cosmetic replace a version check"
This reverts commit ab13e58f96.

Whoops. There is no mark at all before 2.6.19.
2010-03-17 02:38:22 +01:00
Jan Engelhardt
48327605c6 modules: replace AF/PF with NFPROTO 2010-03-17 02:25:40 +01:00
Jan Engelhardt
414e95ffb1 extensions: replace AF/PF with NFPROTO
Needs one update of netfilter.h to something recent, too.
2010-03-17 02:20:39 +01:00
Jan Engelhardt
749e0b788a build: fix build of userspace modules against old headers from linux-glibc-devel 2010-03-17 02:10:56 +01:00
Jan Engelhardt
7512101bca modules: replace AF/PF with NFPROTO 2010-03-16 23:37:05 +01:00
Jan Engelhardt
1a17ed6a45 modules: strip unneeded XT_ALIGN from matchsize/targetsize
The x_tables kernel part already does calculate it.
2010-03-16 23:34:25 +01:00
Jan Engelhardt
1aeaadd740 modules: remove XT_ALIGN(0) lines 2010-03-16 23:26:05 +01:00
Jan Engelhardt
0acbe528ac xt_condition: remove some blank lines 2010-03-16 23:22:18 +01:00
Jan Engelhardt
f5fe2dc801 xt_condition: switch semaphore to a mutex 2010-03-16 23:16:07 +01:00
Jan Engelhardt
524201adcc xt_SYSRQ: allow processing of UDP-Lite 2010-03-16 17:27:59 +01:00
Jan Engelhardt
7cfd3b1dbb xt_SYSRQ: fix wrong define for crypto inclusion 2010-03-16 17:20:57 +01:00
Jan Engelhardt
ab13e58f96 xt_TEE: cosmetic replace a version check 2010-03-16 17:01:02 +01:00
Jan Engelhardt
548922388c SYSRQ: let module load when crypto is unavailable 2010-03-01 11:20:59 +01:00
Tomasz Tomkowiak
43864ac6f1 ipp2p: bittorrent commands
After testing I decide to write my patch to bittorrent GET commands
from xt_ipp2p.c because old procedure is useless for modified and/or
private trackers.

BTW: info_hash may be 3rd argument, passkey (private trackers) may be
1st argument (or not) etc. so we need to search.
2010-02-28 17:25:49 +01:00
Jan Engelhardt
2ef714cc93 compat_xtables: add a memmem function
This will be needed by xt_ipp2p right away.
2010-02-28 17:24:27 +01:00
Jan Engelhardt
8b71d90002 Xtables-addons 1.23 2010-02-24 20:59:38 +01:00
Jan Engelhardt
457e86b908 build: support for Linux 2.6.34 2010-02-24 12:11:10 +01:00
Jan Engelhardt
9b99211326 doc: changelog update 2010-02-24 12:10:26 +01:00
Peter Volkov
c96845a311 SYSRQ: make IPv6 optional
In case the kernel is built without IPv6 support the compilation of
this module fails as it assumes IPv6. This patch makes kernel support
conditional on kernel .config.
2010-02-24 00:34:14 +01:00
Peter Volkov
01e4bace4d RAWNAT: make IPv6 optional
In case the kernel is built without IPv6 support the compilation of
this module fails as it assumes IPv6. This patch makes kernel support
conditional on kernel .config.
2010-02-24 00:32:44 +01:00
Jan Engelhardt
84704346e7 RAWNAT: do not build ip6table_rawpost if IPv6 is not enabled 2010-02-24 00:31:48 +01:00
Jan Engelhardt
77bd7953fb length2: guard off IPv6-only functions 2010-02-24 00:29:55 +01:00
Jan Engelhardt
8c02b00a33 doc: a few extra words to pkgconfig overriding 2010-02-18 13:00:38 +01:00
Jonas Berlin
1f8b91ce53 doc: improve documentation for using non-standard location of libxtables
How to use PKG_CONFIG_PATH. Get rid of remaining references to
recently removed --with-xtables flag.
2010-02-18 12:56:46 +01:00
Jan Engelhardt
dac1b7d506 doc: remove unnecessasry --with-xtables option 2010-02-18 11:14:46 +01:00
Jan Engelhardt
40d0345f1e build: remove unnecessasry --with-xtables option
Jonas Berlin notes that --with-xtables only emitted a -I parameter
and -L was absent.

On second look, we would also be missing -Wl,-rpath, and that would
all be system-dependent. The --with-xtables option is actually not
needed; one can easily specify extra include directories and linker
flags by means of overriding libxtables_CFLAGS and libxtables_LIBS
(even when there are no installed pkgconfig files for libxtables).
2010-02-16 22:26:07 +01:00
Jan Engelhardt
3e70d6289d build: remove unused kinclude_CFLAGS 2010-02-16 22:26:07 +01:00
Jan Engelhardt
d99c8570f3 build: remove unused --with-ksource option 2010-02-16 22:26:07 +01:00
Jan Engelhardt
cf7a40fbe7 ECHO: update to use skb_dst 2010-02-03 19:35:33 +01:00
Jan Engelhardt
0de9f38412 ipset: update to 4.2 2010-01-25 11:54:34 +01:00
Jan Engelhardt
b4b0ab9ef4 Xtables-addons 1.22 2010-01-22 20:14:37 +01:00
Peter Volkov
b20e02869e build: fix installation when only modules in subdirs are enabled
In case only modules that are built in subdirectories of extensions
are enabled (and thus nothing is build in extensions directory itself)
installation fails with the error (only build_ACCOUNT=y in mconfig):

install -pm0755
"/vt/portage/tmp/portage/net-firewall/xtables-addons-1.21/image/
//usr/local/libexec/xtables";
install: missing destination file operand after
"/vt/portage/tmp/portage/net-firewall/xtables-addons-1.21/image/
//usr/local/libexec/xtables"
Try `install --help' for more information.
make[3]: *** [install] Error 1
2010-01-22 20:14:18 +01:00
Jan Engelhardt
ebd603b8fb doc: update changelog 2009-12-31 16:38:34 +01:00
Jan Engelhardt
1945c545dd geoip: use /usr/share/xt_geoip instead of /var/geoip 2009-12-31 16:37:42 +01:00
Michael Farrell
7952a7d253 quota2: add a no-change mode
This commit adds an option to xt_quota2 called "no-change". The
effect of this option, when used, is that it will skip incrementing
or decrementing the quota counter, effectively providing a quota test
only.

The reason for implementing this is so that I could have a rule check
if quota is available for a rule in the PREROUTING tables, without
actually decrementing the amount of available quota. I only wanted to
decrement the amount of available quota in the FORWARD rule.
Otherwise, the first packet of every connection would be counted
twice.
2009-12-31 16:24:47 +01:00
Kevin Locke
c82da14d2b ipset: build ip_set_setlist.ko module
Not sure if this was overlooked, or if it is not in a suitable state
for general use, but lets give it a shot and see how it works.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>

[j.eng: it was overlooked]
2009-12-31 16:17:12 +01:00
Kevin Locke
9f1af79901 Rename skb->iif to skb->skb_iif for 2.6.32+
The rename occurred in v2.6.32-rc7-1555-g8964be4, which will hit
mainline in 2.6.33.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2009-12-31 16:15:53 +01:00
Jan Engelhardt
50c4ee1a5e Xtables-addons 1.21 2009-12-09 21:24:12 +01:00
Jan Engelhardt
351b040f4a ACCOUNT: avoid collision with arp_tables setsockopt numbers 2009-11-29 20:35:39 +01:00
Olivier Mehani
6ed735a810 doc: add example usage to libxt_TEE.man 2009-11-25 11:46:39 +01:00
Olivier Mehani
d643fc4b6c doc: fix option mismatch --gw/--gateway (2) 2009-11-25 11:45:16 +01:00
Jan Engelhardt
0fe32e7443 doc: fix option mismatch --gw/--gateway in libxt_TEE.man 2009-11-25 10:57:23 +01:00
66 changed files with 370 additions and 281 deletions

31
INSTALL
View File

@@ -51,15 +51,6 @@ Configuring and compiling
For RPM building, it should be /usr/src/linux-obj/... For RPM building, it should be /usr/src/linux-obj/...
or whatever location the distro makes use of. or whatever location the distro makes use of.
--with-xtables=
Specifies the path to the directory where we may find
xtables.h, should it not be within the standard C compiler
include path (/usr/include), or if you want to override it.
The directory will be checked for xtables.h and
include/xtables.h. (The latter to support both standard
/usr/include and the iptables source root.)
--with-xtlibdir= --with-xtlibdir=
Specifies the path to where the newly built extensions should Specifies the path to where the newly built extensions should
@@ -73,6 +64,25 @@ If you want to enable debugging, use
(-O0 is used to turn off instruction reordering, which makes debugging (-O0 is used to turn off instruction reordering, which makes debugging
much easier.) much easier.)
To make use of a libxtables that is not in the default path, either
a) append the location of the pkg-config files like:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
(Assuming that files have been installed)
or,
b) override the pkg-config variables, for example:
./configure libxtables_CFLAGS="-I../iptables/include" \
libxtables_LIBS="-L../iptables/.libs \
-Wl,-rpath,../iptables/.libs -lxtables"
(Use this in case you wish to use it without having to
run `make install`. This is because the libxtables.pc pkgconfig
file in ../iptables would already point to e.g. /usr/local.)
Build-time options Build-time options
================== ==================
@@ -89,4 +99,5 @@ Except for --with-kbuild, distributions should not have a need to
supply any other flags (besides --prefix=/usr and perhaps supply any other flags (besides --prefix=/usr and perhaps
--libdir=/usr/lib64, etc.) to configure when all prerequired packages --libdir=/usr/lib64, etc.) to configure when all prerequired packages
are installed. If iptables-devel is installed, necessary headers should are installed. If iptables-devel is installed, necessary headers should
be in /usr/include, so --with-xtables is not needed. already be in /usr/include, so that overriding PKG_CONFIG_PATH,
libxtables_CFLAGS and libxtables_LIBS variables should not be needed.

View File

@@ -47,7 +47,7 @@ all: ${targets}
install: ${targets} install: ${targets}
@for i in ${subdirs_list}; do ${MAKE} -C $$i $@; done; @for i in ${subdirs_list}; do ${MAKE} -C $$i $@; done;
install -dm0755 "${DESTDIR}/${xtlibdir}"; install -dm0755 "${DESTDIR}/${xtlibdir}";
install -pm0755 $^ "${DESTDIR}/${xtlibdir}"; @for i in $^; do install -pm0755 $$i "${DESTDIR}/${xtlibdir}"; done;
clean: clean:
@for i in ${subdirs_list}; do ${MAKE} -C $$i $@; done; @for i in ${subdirs_list}; do ${MAKE} -C $$i $@; done;

View File

@@ -1,5 +1,5 @@
AC_INIT([xtables-addons], [1.20]) AC_INIT([xtables-addons], [1.24])
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
@@ -21,56 +21,21 @@ if [[ "$kbuilddir" == no ]]; then
kbuilddir=""; kbuilddir="";
fi fi
AC_ARG_WITH([ksource],,[ksourcedir="$withval"])
AC_ARG_WITH([xtables],
AS_HELP_STRING([--with-xtables=PATH],
[Path to the Xtables includes [[none]]]),
[xtables_location="$withval"])
AC_ARG_WITH([xtlibdir], AC_ARG_WITH([xtlibdir],
AS_HELP_STRING([--with-xtlibdir=PATH], AS_HELP_STRING([--with-xtlibdir=PATH],
[Path where to install Xtables extensions [[LIBEXECDIR/xtables]]]), [Path where to install Xtables extensions [[LIBEXECDIR/xtables]]]),
[xtlibdir="$withval"], [xtlibdir="$withval"],
[xtlibdir='${libexecdir}/xtables']) [xtlibdir='${libexecdir}/xtables'])
# PKG_CHECK_MODULES([libxtables], [xtables >= 1.4.3])
# --with-xtables= overrides a possibly installed pkgconfig file.
#
if [[ -n "$xtables_location" ]]; then
AC_MSG_CHECKING([xtables.h presence])
if [[ -f "$xtables_location/xtables.h" ]]; then
AC_MSG_RESULT([$xtables_location/xtables.h])
libxtables_CFLAGS="-I $xtables_location";
elif [[ -f "$xtables_location/include/xtables.h" ]]; then
AC_MSG_RESULT([$xtables_location/include/xtables.h])
libxtables_CFLAGS="-I $xtables_location/include";
fi;
if [[ -z "$xtables_CFLAGS" ]]; then
if [[ -f "$includedir/xtables.h" ]]; then
AC_MSG_RESULT([$includedir/xtables.h])
else
AC_MSG_RESULT([no])
fi;
fi;
libxtables_LIBS="-lxtables";
AC_SUBST([libxtables_CFLAGS])
AC_SUBST([libxtables_LIBS])
else
PKG_CHECK_MODULES([libxtables], [xtables >= 1.4.3])
fi;
AC_CHECK_HEADERS([linux/netfilter/x_tables.h], [], AC_CHECK_HEADERS([linux/netfilter/x_tables.h], [],
[AC_MSG_ERROR([You need to have linux/netfilter/x_tables.h, either through /usr/include or the iptables directory (--with-xtables=)])]) [AC_MSG_ERROR([You need to have linux/netfilter/x_tables.h, see INSTALL file for details])])
regular_CFLAGS="-D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 \ regular_CFLAGS="-D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 \
-D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations \ -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations \
-Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \ -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \
-Winline -pipe -DXTABLES_LIBDIR=\\\"\${xtlibdir}\\\""; -Winline -pipe -DXTABLES_LIBDIR=\\\"\${xtlibdir}\\\" \
kinclude_CFLAGS=""; -I\${XA_TOPSRCDIR}/include";
if [[ -n "$kbuilddir" ]]; then
kinclude_CFLAGS="$kinclude_CFLAGS -I $kbuilddir/include";
fi;
if [[ -n "$ksourcedir" ]]; then
kinclude_CFLAGS="$kinclude_CFLAGS -I $ksourcedir/include";
fi;
# #
# check kernel version # check kernel version
@@ -97,7 +62,7 @@ else
fi; fi;
fi; fi;
echo "Found kernel version $kmajor.$kminor.$kmicro.$kstable in $kbuilddir"; echo "Found kernel version $kmajor.$kminor.$kmicro.$kstable in $kbuilddir";
if test "$kmajor" -gt 2 -o "$kminor" -gt 6 -o "$kmicro" -gt 32; then if test "$kmajor" -gt 2 -o "$kminor" -gt 6 -o "$kmicro" -gt 34; then
echo "WARNING: You are trying a newer kernel. Results may vary. :-)"; echo "WARNING: You are trying a newer kernel. Results may vary. :-)";
elif test \( "$kmajor" -lt 2 -o "$kminor" -lt 6 -o "$kmicro" -lt 17 \) -o \ elif test \( "$kmajor" -lt 2 -o "$kminor" -lt 6 -o "$kmicro" -lt 17 \) -o \
\( "$kmajor" -eq 2 -a "$kminor" -eq 6 -a "$kmicro" -eq 18 -a \ \( "$kmajor" -eq 2 -a "$kminor" -eq 6 -a "$kmicro" -eq 18 -a \
@@ -107,9 +72,7 @@ elif test \( "$kmajor" -lt 2 -o "$kminor" -lt 6 -o "$kmicro" -lt 17 \) -o \
fi; fi;
AC_SUBST([regular_CFLAGS]) AC_SUBST([regular_CFLAGS])
AC_SUBST([kinclude_CFLAGS])
AC_SUBST([kbuilddir]) AC_SUBST([kbuilddir])
AC_SUBST([ksourcedir])
AC_SUBST([xtlibdir]) AC_SUBST([xtlibdir])
AC_CONFIG_FILES([Makefile Makefile.iptrules Makefile.mans AC_CONFIG_FILES([Makefile Makefile.iptrules Makefile.mans
extensions/Makefile extensions/ACCOUNT/Makefile extensions/Makefile extensions/ACCOUNT/Makefile

View File

@@ -3,6 +3,39 @@ HEAD
==== ====
Xtables-addons 1.24 (March 17 2010)
===================================
- build: fix build of userspace modules against old (pre-2.6.25)
headers from linux-glibc-devel (/usr/include/linux)
- ipp2p: updated bittorent command recognition
- SYSRQ: let module load when crypto is unavailable
- SYSRQ: allow processing of UDP-Lite
Xtables-addons 1.23 (February 24 2010)
======================================
- build: support for Linux 2.6.34
- build: remove unused --with-ksource option
- build: remove unneeded --with-xtables option
- build: fix compilations in RAWNAT, SYSRQ and length2 when CONFIG_IPV6=n
- ipset: update to 4.2
- ECHO: fix compilation w.r.t. skb_dst
Xtables-addons 1.22 (January 22 2010)
=====================================
- compat_xtables: support for 2.6.33 skb_iif changes
- geoip: for FHS compliance use /usr/share/xt_geoip instead of /var/geoip
- ipset: enable build of ip_set_setlist.ko
- quota2: add the --no-change mode
Xtables-addons 1.21 (December 09 2009)
======================================
- ACCOUNT: avoid collision with arp_tables setsockopt numbers
- doc: fix option mismatch --gw/--gateway in libxt_TEE.man
Xtables-addons 1.20 (November 19 2009) Xtables-addons 1.20 (November 19 2009)
====================================== ======================================
- ipp2p: add more boundary checks - ipp2p: add more boundary checks

View File

@@ -142,7 +142,7 @@ account_tg_save(const void *ip, const struct xt_entry_target *target)
static struct xtables_target account_tg_reg = { static struct xtables_target account_tg_reg = {
.name = "ACCOUNT", .name = "ACCOUNT",
.revision = 1, .revision = 1,
.family = AF_INET, .family = NFPROTO_IPV4,
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct ipt_acc_info)), .size = XT_ALIGN(sizeof(struct ipt_acc_info)),
.userspacesize = offsetof(struct ipt_acc_info, table_nr), .userspacesize = offsetof(struct ipt_acc_info, table_nr),

View File

@@ -1082,7 +1082,7 @@ static int ipt_acc_get_ctl(struct sock *sk, int cmd, void *user, int *len)
static struct xt_target xt_acc_reg __read_mostly = { static struct xt_target xt_acc_reg __read_mostly = {
.name = "ACCOUNT", .name = "ACCOUNT",
.revision = 1, .revision = 1,
.family = AF_INET, .family = NFPROTO_IPV4,
.target = ipt_acc_target, .target = ipt_acc_target,
.targetsize = sizeof(struct ipt_acc_info), .targetsize = sizeof(struct ipt_acc_info),
.checkentry = ipt_acc_checkentry, .checkentry = ipt_acc_checkentry,

View File

@@ -15,8 +15,13 @@
* Socket option interface shared between kernel (xt_ACCOUNT) and userspace * Socket option interface shared between kernel (xt_ACCOUNT) and userspace
* library (libxt_ACCOUNT_cl). Hopefully we are unique at least within our * library (libxt_ACCOUNT_cl). Hopefully we are unique at least within our
* kernel & xtables-addons space. * kernel & xtables-addons space.
*
* Turned out often enough we are not.
* 64-67 used by ip_tables, ip6_tables
* 96-100 used by arp_tables
* 128-131 used by ebtables
*/ */
#define SO_ACCOUNT_BASE_CTL 90 #define SO_ACCOUNT_BASE_CTL 70
#define IPT_SO_SET_ACCOUNT_HANDLE_FREE (SO_ACCOUNT_BASE_CTL + 1) #define IPT_SO_SET_ACCOUNT_HANDLE_FREE (SO_ACCOUNT_BASE_CTL + 1)
#define IPT_SO_SET_ACCOUNT_HANDLE_FREE_ALL (SO_ACCOUNT_BASE_CTL + 2) #define IPT_SO_SET_ACCOUNT_HANDLE_FREE_ALL (SO_ACCOUNT_BASE_CTL + 2)

View File

@@ -12,7 +12,10 @@ obj-${build_DHCPMAC} += xt_DHCPMAC.o
obj-${build_ECHO} += xt_ECHO.o obj-${build_ECHO} += xt_ECHO.o
obj-${build_IPMARK} += xt_IPMARK.o obj-${build_IPMARK} += xt_IPMARK.o
obj-${build_LOGMARK} += xt_LOGMARK.o obj-${build_LOGMARK} += xt_LOGMARK.o
obj-${build_RAWNAT} += xt_RAWNAT.o iptable_rawpost.o ip6table_rawpost.o obj-${build_RAWNAT} += xt_RAWNAT.o iptable_rawpost.o
ifneq (${CONFIG_IPV6},)
obj-${build_RAWNAT} += ip6table_rawpost.o
endif
obj-${build_SYSRQ} += xt_SYSRQ.o obj-${build_SYSRQ} += xt_SYSRQ.o
obj-${build_STEAL} += xt_STEAL.o obj-${build_STEAL} += xt_STEAL.o
obj-${build_TARPIT} += xt_TARPIT.o obj-${build_TARPIT} += xt_TARPIT.o

View File

@@ -25,9 +25,12 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
# define skb_ifindex(skb) \ # define skb_ifindex(skb) \
(((skb)->input_dev != NULL) ? (skb)->input_dev->ifindex : 0) (((skb)->input_dev != NULL) ? (skb)->input_dev->ifindex : 0)
# define skb_nfmark(skb) (((struct sk_buff *)(skb))->nfmark) # define skb_nfmark(skb) (((struct sk_buff *)(skb))->nfmark)
#else #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32)
# define skb_ifindex(skb) (skb)->iif # define skb_ifindex(skb) (skb)->iif
# define skb_nfmark(skb) (((struct sk_buff *)(skb))->mark) # define skb_nfmark(skb) (((struct sk_buff *)(skb))->mark)
#else
# define skb_ifindex(skb) (skb)->skb_iif
# define skb_nfmark(skb) (((struct sk_buff *)(skb))->mark)
#endif #endif
#ifdef CONFIG_NETWORK_SECMARK #ifdef CONFIG_NETWORK_SECMARK

View File

@@ -509,4 +509,18 @@ int xtnu_skb_linearize(struct sk_buff *skb)
EXPORT_SYMBOL_GPL(xtnu_skb_linearize); EXPORT_SYMBOL_GPL(xtnu_skb_linearize);
#endif #endif
void *HX_memmem(const void *space, size_t spacesize,
const void *point, size_t pointsize)
{
size_t i;
if (pointsize > spacesize)
return NULL;
for (i = 0; i <= spacesize - pointsize; ++i)
if (memcmp(space + i, point, pointsize) == 0)
return (void *)space + i;
return NULL;
}
EXPORT_SYMBOL_GPL(HX_memmem);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@@ -78,6 +78,15 @@
# define inet_proto_csum_replace4 xtnu_proto_csum_replace4 # define inet_proto_csum_replace4 xtnu_proto_csum_replace4
#endif #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
# define ipt_unregister_table(tbl) ipt_unregister_table(&init_net, (tbl))
# define ip6t_unregister_table(tbl) ip6t_unregister_table(&init_net, (tbl))
#else
# define ipt_unregister_table(tbl) ipt_unregister_table(tbl)
# define ip6t_unregister_table(tbl) ip6t_unregister_table(tbl)
#endif
#if !defined(NIP6) && !defined(NIP6_FMT) #if !defined(NIP6) && !defined(NIP6_FMT)
# define NIP6(addr) \ # define NIP6(addr) \
ntohs((addr).s6_addr16[0]), \ ntohs((addr).s6_addr16[0]), \

View File

@@ -154,4 +154,6 @@ extern void xtnu_proto_csum_replace4(__u16 __bitwise *, struct sk_buff *,
__be32, __be32, bool); __be32, __be32, bool);
extern int xtnu_skb_linearize(struct sk_buff *); extern int xtnu_skb_linearize(struct sk_buff *);
extern void *HX_memmem(const void *, size_t, const void *, size_t);
#endif /* _COMPAT_XTNU_H */ #endif /* _COMPAT_XTNU_H */

View File

@@ -3,4 +3,4 @@
obj-m += ipt_set.o ipt_SET.o obj-m += ipt_set.o ipt_SET.o
obj-m += ip_set.o ip_set_ipmap.o ip_set_portmap.o ip_set_macipmap.o obj-m += ip_set.o ip_set_ipmap.o ip_set_portmap.o ip_set_macipmap.o
obj-m += ip_set_iphash.o ip_set_nethash.o ip_set_ipporthash.o obj-m += ip_set_iphash.o ip_set_nethash.o ip_set_ipporthash.o
obj-m += ip_set_iptree.o ip_set_iptreemap.o obj-m += ip_set_iptree.o ip_set_iptreemap.o ip_set_setlist.o

View File

@@ -185,7 +185,6 @@ ipportnethash_add(struct ip_set *set,
if (ret == 0) { if (ret == 0) {
if (!map->nets[cidr-1]++) if (!map->nets[cidr-1]++)
add_cidr_size(map->cidr, cidr); add_cidr_size(map->cidr, cidr);
map->elements++;
} }
return ret; return ret;
} }

View File

@@ -136,7 +136,6 @@ nethash_add(struct ip_set *set, ip_set_ip_t ip, uint8_t cidr)
if (ret == 0) { if (ret == 0) {
if (!map->nets[cidr-1]++) if (!map->nets[cidr-1]++)
add_cidr_size(map->cidr, cidr); add_cidr_size(map->cidr, cidr);
map->elements++;
} }
return ret; return ret;

View File

@@ -30,7 +30,7 @@
#define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe" #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe"
#endif #endif
#define IPSET_VERSION "4.1" #define IPSET_VERSION "4.2"
char program_name[] = "ipset"; char program_name[] = "ipset";
char program_version[] = IPSET_VERSION; char program_version[] = IPSET_VERSION;

View File

@@ -200,8 +200,7 @@ iphash_printips(struct set *set UNUSED, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ip = data + offset; ip = data + offset;
if (*ip) printf("%s\n", ip_tostring(*ip, options));
printf("%s\n", ip_tostring(*ip, options));
offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align); offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align);
} }
} }
@@ -230,9 +229,7 @@ iphash_saveips(struct set *set UNUSED, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ip = data + offset; ip = data + offset;
if (*ip) printf("-A %s %s\n", set->name, ip_tostring(*ip, options));
printf("-A %s %s\n", set->name,
ip_tostring(*ip, options));
offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align); offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align);
} }
} }

View File

@@ -259,13 +259,11 @@ ipporthash_printips(struct set *set, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ipptr = data + offset; ipptr = data + offset;
if (*ipptr) { ip = (*ipptr>>16) + mysetdata->first_ip;
ip = (*ipptr>>16) + mysetdata->first_ip; port = (uint16_t) *ipptr;
port = (uint16_t) *ipptr; printf("%s,%s\n",
printf("%s,%s\n", ip_tostring(ip, options),
ip_tostring(ip, options), port_tostring(port, options));
port_tostring(port, options));
}
offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align); offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align);
} }
} }
@@ -296,13 +294,11 @@ ipporthash_saveips(struct set *set, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ipptr = data + offset; ipptr = data + offset;
if (*ipptr) { ip = (*ipptr>>16) + mysetdata->first_ip;
ip = (*ipptr>>16) + mysetdata->first_ip; port = (uint16_t) *ipptr;
port = (uint16_t) *ipptr; printf("-A %s %s,%s\n", set->name,
printf("-A %s %s,%s\n", set->name, ip_tostring(ip, options),
ip_tostring(ip, options), port_tostring(port, options));
port_tostring(port, options));
}
offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align); offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align);
} }
} }

View File

@@ -265,15 +265,13 @@ ipportiphash_printips(struct set *set, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ipptr = data + offset; ipptr = data + offset;
if (ipptr->ip && ipptr->ip1) { ip = (ipptr->ip>>16) + mysetdata->first_ip;
ip = (ipptr->ip>>16) + mysetdata->first_ip; port = (uint16_t) ipptr->ip;
port = (uint16_t) ipptr->ip; printf("%s,%s,",
printf("%s,%s,", ip_tostring(ip, options),
ip_tostring(ip, options), port_tostring(port, options));
port_tostring(port, options)); printf("%s\n",
printf("%s\n", ip_tostring(ipptr->ip1, options));
ip_tostring(ipptr->ip1, options));
}
offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align); offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align);
} }
} }
@@ -305,15 +303,13 @@ ipportiphash_saveips(struct set *set, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ipptr = data + offset; ipptr = data + offset;
if (ipptr->ip && ipptr->ip1) { ip = (ipptr->ip>>16) + mysetdata->first_ip;
ip = (ipptr->ip>>16) + mysetdata->first_ip; port = (uint16_t) ipptr->ip;
port = (uint16_t) ipptr->ip; printf("-A %s %s,%s,", set->name,
printf("-A %s %s,%s,", set->name, ip_tostring(ip, options),
ip_tostring(ip, options), port_tostring(port, options));
port_tostring(port, options)); printf("%s\n",
printf("%s\n", ip_tostring(ipptr->ip1, options));
ip_tostring(ipptr->ip1, options));
}
offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align); offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align);
} }
} }

View File

@@ -330,15 +330,13 @@ ipportnethash_printips(struct set *set, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ipptr = data + offset; ipptr = data + offset;
if (ipptr->ip || ipptr->ip1) { ip = (ipptr->ip>>16) + mysetdata->first_ip;
ip = (ipptr->ip>>16) + mysetdata->first_ip; port = (uint16_t) ipptr->ip;
port = (uint16_t) ipptr->ip; printf("%s,%s,",
printf("%s,%s,", ip_tostring(ip, options),
ip_tostring(ip, options), port_tostring(port, options));
port_tostring(port, options)); printf("%s\n",
printf("%s\n", unpack_ip_tostring(ipptr->ip1, options));
unpack_ip_tostring(ipptr->ip1, options));
}
offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align); offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align);
} }
} }
@@ -370,15 +368,13 @@ ipportnethash_saveips(struct set *set, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ipptr = data + offset; ipptr = data + offset;
if (ipptr) { ip = (ipptr->ip>>16) + mysetdata->first_ip;
ip = (ipptr->ip>>16) + mysetdata->first_ip; port = (uint16_t) ipptr->ip;
port = (uint16_t) ipptr->ip; printf("-A %s %s,%s,", set->name,
printf("-A %s %s,%s,", set->name, ip_tostring(ip, options),
ip_tostring(ip, options), port_tostring(port, options));
port_tostring(port, options)); printf("%s\n",
printf("%s\n", unpack_ip_tostring(ipptr->ip, options));
unpack_ip_tostring(ipptr->ip, options));
}
offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align); offset += IPSET_VALIGN(sizeof(struct ipportip), dont_align);
} }
} }

View File

@@ -232,8 +232,7 @@ nethash_printips(struct set *set UNUSED, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ip = data + offset; ip = data + offset;
if (*ip) printf("%s\n", unpack_ip_tostring(*ip, options));
printf("%s\n", unpack_ip_tostring(*ip, options));
offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align); offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align);
} }
} }
@@ -258,9 +257,8 @@ nethash_saveips(struct set *set UNUSED, void *data, u_int32_t len,
while (offset < len) { while (offset < len) {
ip = data + offset; ip = data + offset;
if (*ip) printf("-A %s %s\n", set->name,
printf("-A %s %s\n", set->name, unpack_ip_tostring(*ip, options));
unpack_ip_tostring(*ip, options));
offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align); offset += IPSET_VALIGN(sizeof(ip_set_ip_t), dont_align);
} }
} }

View File

@@ -95,7 +95,7 @@ static void chaos_tg_save(const void *ip, const struct xt_entry_target *target)
static struct xtables_target chaos_tg_reg = { static struct xtables_target chaos_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "CHAOS", .name = "CHAOS",
.family = AF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_chaos_tginfo)), .size = XT_ALIGN(sizeof(struct xt_chaos_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_chaos_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_chaos_tginfo)),
.help = chaos_tg_help, .help = chaos_tg_help,

View File

@@ -33,9 +33,7 @@ static struct xtables_target delude_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "DELUDE", .name = "DELUDE",
.revision = 0, .revision = 0,
.family = AF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(0),
.userspacesize = XT_ALIGN(0),
.help = delude_tg_help, .help = delude_tg_help,
.parse = delude_tg_parse, .parse = delude_tg_parse,
.final_check = delude_tg_check, .final_check = delude_tg_check,

View File

@@ -84,7 +84,7 @@ static struct xtables_target dhcpmac_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "DHCPMAC", .name = "DHCPMAC",
.revision = 0, .revision = 0,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct dhcpmac_info)), .size = XT_ALIGN(sizeof(struct dhcpmac_info)),
.userspacesize = XT_ALIGN(sizeof(struct dhcpmac_info)), .userspacesize = XT_ALIGN(sizeof(struct dhcpmac_info)),
.help = dhcpmac_tg_help, .help = dhcpmac_tg_help,

View File

@@ -29,9 +29,7 @@ static void echo_tg_check(unsigned int flags)
static struct xtables_target echo_tg_reg = { static struct xtables_target echo_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "ECHO", .name = "ECHO",
.family = AF_UNSPEC, .family = NFPROTO_UNSPEC,
.size = XT_ALIGN(0),
.userspacesize = XT_ALIGN(0),
.help = echo_tg_help, .help = echo_tg_help,
.parse = echo_tg_parse, .parse = echo_tg_parse,
.final_check = echo_tg_check, .final_check = echo_tg_check,

View File

@@ -151,7 +151,7 @@ ipmark_tg_save(const void *entry, const struct xt_entry_target *target)
static struct xtables_target ipmark_tg_reg = { static struct xtables_target ipmark_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "IPMARK", .name = "IPMARK",
.family = PF_UNSPEC, .family = NFPROTO_UNSPEC,
.revision = 1, .revision = 1,
.size = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)), .size = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)),

View File

@@ -100,7 +100,7 @@ static struct xtables_target logmark_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "LOGMARK", .name = "LOGMARK",
.revision = 0, .revision = 0,
.family = AF_UNSPEC, .family = NFPROTO_UNSPEC,
.size = XT_ALIGN(sizeof(struct xt_logmark_tginfo)), .size = XT_ALIGN(sizeof(struct xt_logmark_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_logmark_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_logmark_tginfo)),
.help = logmark_tg_help, .help = logmark_tg_help,

View File

@@ -154,7 +154,7 @@ static struct xtables_target rawdnat_tg4_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "RAWDNAT", .name = "RAWDNAT",
.revision = 0, .revision = 0,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawdnat_tg_help, .help = rawdnat_tg_help,
@@ -169,7 +169,7 @@ static struct xtables_target rawdnat_tg6_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "RAWDNAT", .name = "RAWDNAT",
.revision = 0, .revision = 0,
.family = PF_INET6, .family = NFPROTO_IPV6,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawdnat_tg_help, .help = rawdnat_tg_help,

View File

@@ -154,7 +154,7 @@ static struct xtables_target rawsnat_tg4_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "RAWSNAT", .name = "RAWSNAT",
.revision = 0, .revision = 0,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawsnat_tg_help, .help = rawsnat_tg_help,
@@ -169,7 +169,7 @@ static struct xtables_target rawsnat_tg6_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "RAWSNAT", .name = "RAWSNAT",
.revision = 0, .revision = 0,
.family = PF_INET6, .family = NFPROTO_IPV6,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawsnat_tg_help, .help = rawsnat_tg_help,

View File

@@ -19,9 +19,7 @@ static void steal_tg_check(unsigned int flags)
static struct xtables_target steal_tg_reg = { static struct xtables_target steal_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "STEAL", .name = "STEAL",
.family = AF_UNSPEC, .family = NFPROTO_UNSPEC,
.size = XT_ALIGN(0),
.userspacesize = XT_ALIGN(0),
.help = steal_tg_help, .help = steal_tg_help,
.parse = steal_tg_parse, .parse = steal_tg_parse,
.final_check = steal_tg_check, .final_check = steal_tg_check,

View File

@@ -25,9 +25,7 @@ static struct xtables_target sysrq_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "SYSRQ", .name = "SYSRQ",
.revision = 1, .revision = 1,
.family = PF_UNSPEC, .family = NFPROTO_UNSPEC,
.size = XT_ALIGN(0),
.userspacesize = XT_ALIGN(0),
.help = sysrq_tg_help, .help = sysrq_tg_help,
.parse = sysrq_tg_parse, .parse = sysrq_tg_parse,
.final_check = sysrq_tg_check, .final_check = sysrq_tg_check,

View File

@@ -24,9 +24,7 @@ static void tarpit_tg_check(unsigned int flags)
static struct xtables_target tarpit_tg_reg = { static struct xtables_target tarpit_tg_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "TARPIT", .name = "TARPIT",
.family = AF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(0),
.userspacesize = XT_ALIGN(0),
.help = tarpit_tg_help, .help = tarpit_tg_help,
.parse = tarpit_tg_parse, .parse = tarpit_tg_parse,
.final_check = tarpit_tg_check, .final_check = tarpit_tg_check,

View File

@@ -51,7 +51,7 @@ static int tee_tg_parse(int c, char **argv, int invert, unsigned int *flags,
case 'g': case 'g':
if (*flags & FLAG_GATEWAY) if (*flags & FLAG_GATEWAY)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Cannot specify --gw more than once"); "Cannot specify --gateway more than once");
ia = xtables_numeric_to_ipaddr(optarg); ia = xtables_numeric_to_ipaddr(optarg);
if (ia == NULL) if (ia == NULL)
@@ -76,7 +76,7 @@ static int tee_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
case 'g': case 'g':
if (*flags & FLAG_GATEWAY) if (*flags & FLAG_GATEWAY)
xtables_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Cannot specify --gw more than once"); "Cannot specify --gateway more than once");
ia = xtables_numeric_to_ip6addr(optarg); ia = xtables_numeric_to_ip6addr(optarg);
if (ia == NULL) if (ia == NULL)
@@ -138,7 +138,7 @@ static struct xtables_target tee_tg_reg = {
.name = "TEE", .name = "TEE",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.revision = 0, .revision = 0,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_tee_tginfo)), .size = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.help = tee_tg_help, .help = tee_tg_help,
@@ -153,7 +153,7 @@ static struct xtables_target tee_tg6_reg = {
.name = "TEE", .name = "TEE",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.revision = 0, .revision = 0,
.family = PF_INET6, .family = NFPROTO_IPV6,
.size = XT_ALIGN(sizeof(struct xt_tee_tginfo)), .size = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.help = tee_tg_help, .help = tee_tg_help,

View File

@@ -3,6 +3,10 @@ machine on the \fBlocal\fP network segment. In other words, the nexthop
must be the target, or you will have to configure the nexthop to forward it must be the target, or you will have to configure the nexthop to forward it
further if so desired. further if so desired.
.TP .TP
\fB\-\-gw\fP \fIipaddr\fP \fB\-\-gateway\fP \fIipaddr\fP
Send the cloned packet to the host reachable at the given IP address. Send the cloned packet to the host reachable at the given IP address.
Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid. Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid.
.PP
To forward all incoming traffic on eth0 to an Network Layer logging box:
.PP
\-t mangle \-A PREROUTING \-i eth0 \-j TEE \-\-gateway 2001:db8::1

View File

@@ -80,7 +80,7 @@ static void condition_save(const void *ip, const struct xt_entry_match *match)
static struct xtables_match condition_mt_reg = { static struct xtables_match condition_mt_reg = {
.name = "condition", .name = "condition",
.revision = 1, .revision = 1,
.family = PF_UNSPEC, .family = NFPROTO_UNSPEC,
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct xt_condition_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_condition_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)),

View File

@@ -85,7 +85,7 @@ static struct xtables_match dhcpmac_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "dhcpmac", .name = "dhcpmac",
.revision = 0, .revision = 0,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct dhcpmac_info)), .size = XT_ALIGN(sizeof(struct dhcpmac_info)),
.userspacesize = XT_ALIGN(sizeof(struct dhcpmac_info)), .userspacesize = XT_ALIGN(sizeof(struct dhcpmac_info)),
.help = dhcpmac_mt_help, .help = dhcpmac_mt_help,

View File

@@ -103,6 +103,7 @@ static struct xtables_match fuzzy_mt_reg = {
.name = "fuzzy", .name = "fuzzy",
.revision = 1, .revision = 1,
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.family = NFPROTO_UNSPEC,
.size = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)),
.userspacesize = offsetof(struct xt_fuzzy_mtinfo, packets_total), .userspacesize = offsetof(struct xt_fuzzy_mtinfo, packets_total),
.help = fuzzy_mt_help, .help = fuzzy_mt_help,

View File

@@ -24,7 +24,7 @@
#include <unistd.h> #include <unistd.h>
#include <xtables.h> #include <xtables.h>
#include "xt_geoip.h" #include "xt_geoip.h"
#define GEOIP_DB_DIR "/var/geoip" #define GEOIP_DB_DIR "/usr/share/xt_geoip"
static void geoip_help(void) static void geoip_help(void)
{ {
@@ -259,7 +259,7 @@ geoip_save(const void *ip, const struct xt_entry_match *match)
} }
static struct xtables_match geoip_match = { static struct xtables_match geoip_match = {
.family = AF_INET, .family = NFPROTO_IPV4,
.name = "geoip", .name = "geoip",
.revision = 1, .revision = 1,
.version = XTABLES_VERSION, .version = XTABLES_VERSION,

View File

@@ -7,10 +7,11 @@ Match packet coming from (one of) the specified country(ies)
Match packet going to (one of) the specified country(ies) Match packet going to (one of) the specified country(ies)
.TP .TP
NOTE: NOTE:
The country is inputed by its ISO3166 code. The country is inputed by its ISO-3166 code.
.P .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, available at
http://jengelh.hopto.org/files/geoip/ . The files MUST be moved to /var/geoip/ http://jengelh.hopto.org/files/geoip/ . The files MUST be moved 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.
/var/geoip/LE/de.iv0). /usr/share/xt_geoip/LE/de.iv0).

View File

@@ -200,7 +200,7 @@ static struct xtables_match iface_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "iface", .name = "iface",
.revision = 0, .revision = 0,
.family = AF_UNSPEC, .family = NFPROTO_UNSPEC,
.size = XT_ALIGN(sizeof(struct xt_iface_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.help = iface_mt_help, .help = iface_mt_help,

View File

@@ -229,7 +229,7 @@ static struct xtables_match ipp2p_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "ipp2p", .name = "ipp2p",
.revision = 1, .revision = 1,
.family = AF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct ipt_p2p_info)), .size = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.userspacesize = XT_ALIGN(sizeof(struct ipt_p2p_info)), .userspacesize = XT_ALIGN(sizeof(struct ipt_p2p_info)),
.help = ipp2p_mt_help, .help = ipp2p_mt_help,

View File

@@ -161,7 +161,7 @@ static struct xtables_match ipv4options_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "ipv4options", .name = "ipv4options",
.revision = 1, .revision = 1,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)), .size = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)),
.userspacesize = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)), .userspacesize = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)),
.help = ipv4options_mt_help, .help = ipv4options_mt_help,

View File

@@ -155,7 +155,7 @@ static struct xtables_match length2_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "length2", .name = "length2",
.revision = 2, .revision = 2,
.family = PF_UNSPEC, .family = NFPROTO_UNSPEC,
.size = XT_ALIGN(sizeof(struct xt_length_mtinfo2)), .size = XT_ALIGN(sizeof(struct xt_length_mtinfo2)),
.userspacesize = XT_ALIGN(sizeof(struct xt_length_mtinfo2)), .userspacesize = XT_ALIGN(sizeof(struct xt_length_mtinfo2)),
.init = length_mt_init, .init = length_mt_init,

View File

@@ -105,7 +105,7 @@ static struct xtables_match lscan_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "lscan", .name = "lscan",
.revision = 0, .revision = 0,
.family = AF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_lscan_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_lscan_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_lscan_mtinfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_lscan_mtinfo)),
.help = lscan_mt_help, .help = lscan_mt_help,

View File

@@ -139,7 +139,7 @@ static struct xtables_match psd_mt_reg = {
.name = "psd", .name = "psd",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.revision = 1, .revision = 1,
.family = PF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_psd_info)), .size = XT_ALIGN(sizeof(struct xt_psd_info)),
.userspacesize = XT_ALIGN(sizeof(struct xt_psd_info)), .userspacesize = XT_ALIGN(sizeof(struct xt_psd_info)),
.help = psd_mt_help, .help = psd_mt_help,

View File

@@ -17,17 +17,19 @@
#include "xt_quota2.h" #include "xt_quota2.h"
enum { enum {
FL_QUOTA = 1 << 0, FL_QUOTA = 1 << 0,
FL_NAME = 1 << 1, FL_NAME = 1 << 1,
FL_GROW = 1 << 2, FL_GROW = 1 << 2,
FL_PACKET = 1 << 3, FL_PACKET = 1 << 3,
FL_NO_CHANGE = 1 << 4,
}; };
static const struct option quota_mt2_opts[] = { static const struct option quota_mt2_opts[] = {
{.name = "grow", .has_arg = false, .val = 'g'}, {.name = "grow", .has_arg = false, .val = 'g'},
{.name = "name", .has_arg = true, .val = 'n'}, {.name = "no-change", .has_arg = false, .val = 'c'},
{.name = "quota", .has_arg = true, .val = 'q'}, {.name = "name", .has_arg = true, .val = 'n'},
{.name = "packets", .has_arg = false, .val = 'p'}, {.name = "quota", .has_arg = true, .val = 'q'},
{.name = "packets", .has_arg = false, .val = 'p'},
{NULL}, {NULL},
}; };
@@ -36,6 +38,7 @@ static void quota_mt2_help(void)
printf( printf(
"quota match options:\n" "quota match options:\n"
" --grow provide an increasing counter\n" " --grow provide an increasing counter\n"
" --no-change never change counter/quota value for matching packets\n"
" --name name name for the file in sysfs\n" " --name name name for the file in sysfs\n"
"[!] --quota quota initial quota (bytes or packets)\n" "[!] --quota quota initial quota (bytes or packets)\n"
" --packets count packets instead of bytes\n" " --packets count packets instead of bytes\n"
@@ -56,6 +59,12 @@ quota_mt2_parse(int c, char **argv, int invert, unsigned int *flags,
info->flags |= XT_QUOTA_GROW; info->flags |= XT_QUOTA_GROW;
*flags |= FL_GROW; *flags |= FL_GROW;
return true; return true;
case 'c': /* no-change */
xtables_param_act(XTF_ONLY_ONCE, "quota", "--no-change", *flags & FL_NO_CHANGE);
xtables_param_act(XTF_NO_INVERT, "quota", "--no-change", invert);
info->flags |= XT_QUOTA_NO_CHANGE;
*flags |= FL_NO_CHANGE;
return true;
case 'n': case 'n':
/* zero termination done on behalf of the kernel module */ /* zero termination done on behalf of the kernel module */
xtables_param_act(XTF_ONLY_ONCE, "quota", "--name", *flags & FL_NAME); xtables_param_act(XTF_ONLY_ONCE, "quota", "--name", *flags & FL_NAME);
@@ -92,6 +101,8 @@ quota_mt2_save(const void *ip, const struct xt_entry_match *match)
printf("! "); printf("! ");
if (q->flags & XT_QUOTA_GROW) if (q->flags & XT_QUOTA_GROW)
printf("--grow "); printf("--grow ");
if (q->flags & XT_QUOTA_NO_CHANGE)
printf("--no-change ");
if (q->flags & XT_QUOTA_PACKET) if (q->flags & XT_QUOTA_PACKET)
printf("--packets "); printf("--packets ");
if (*q->name != '\0') if (*q->name != '\0')
@@ -117,10 +128,12 @@ static void quota_mt2_print(const void *ip, const struct xt_entry_match *match,
printf("packets "); printf("packets ");
else else
printf("bytes "); printf("bytes ");
if (q->flags & XT_QUOTA_NO_CHANGE)
printf("(no-change mode) ");
} }
static struct xtables_match quota_mt2_reg = { static struct xtables_match quota_mt2_reg = {
.family = AF_UNSPEC, .family = NFPROTO_UNSPEC,
.revision = 3, .revision = 3,
.name = "quota2", .name = "quota2",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,

View File

@@ -10,6 +10,12 @@ the match will return false, just like the original "quota" match. In growing
\fB\-\-grow\fP \fB\-\-grow\fP
Count upwards instead of downwards. Count upwards instead of downwards.
.TP .TP
\fB\-\-no\-change\fP
Makes it so the counter or quota amount is never changed by packets matching
this rule. This is only really useful in "quota" mode, as it will allow you to
use complex prerouting rules in association with the quota system, without
counting a packet twice.
.TP
\fB\-\-name\fP \fIname\fP \fB\-\-name\fP \fIname\fP
Assign the counter a specific name. This option must be present, as an empty Assign the counter a specific name. This option must be present, as an empty
name is not allowed. Names starting with a dot or names containing a slash are name is not allowed. Names starting with a dot or names containing a slash are

View File

@@ -326,7 +326,7 @@ static struct xtables_match pknock_mt_reg = {
.name = "pknock", .name = "pknock",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.revision = 1, .revision = 1,
.family = AF_INET, .family = NFPROTO_IPV4,
.size = XT_ALIGN(sizeof(struct xt_pknock_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_pknock_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_pknock_mtinfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_pknock_mtinfo)),
.help = pknock_mt_help, .help = pknock_mt_help,

View File

@@ -139,7 +139,7 @@ static struct xt_match dhcpmac_mt_reg __read_mostly = {
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.proto = IPPROTO_UDP, .proto = IPPROTO_UDP,
.match = dhcpmac_mt, .match = dhcpmac_mt,
.matchsize = XT_ALIGN(sizeof(struct dhcpmac_info)), .matchsize = sizeof(struct dhcpmac_info),
.me = THIS_MODULE, .me = THIS_MODULE,
}; };

View File

@@ -32,7 +32,7 @@ echo_tg4(struct sk_buff **poldskb, const struct xt_target_param *par)
unsigned int addr_type, data_len; unsigned int addr_type, data_len;
void *payload; void *payload;
printk(KERN_INFO "dst_out=%p\n", (*poldskb)->dst->output); printk(KERN_INFO "dst_out=%p\n", skb_dst(*poldskb)->output);
/* 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(*poldskb) < 0) if (skb_linearize(*poldskb) < 0)
@@ -84,18 +84,17 @@ echo_tg4(struct sk_buff **poldskb, const struct xt_target_param *par)
#endif #endif
addr_type = RTN_LOCAL; addr_type = RTN_LOCAL;
/* ip_route_me_harder expects skb->dst to be set */ /* ip_route_me_harder expects the skb's dst to be set */
dst_hold(oldskb->dst); skb_dst_set(newskb, dst_clone(skb_dst(oldskb)));
newskb->dst = oldskb->dst;
if (ip_route_me_harder(&newskb, addr_type) < 0) if (ip_route_me_harder(&newskb, addr_type) < 0)
goto free_nskb; goto free_nskb;
newip->ttl = dst_metric(newskb->dst, RTAX_HOPLIMIT); newip->ttl = dst_metric(skb_dst(newskb), RTAX_HOPLIMIT);
newskb->ip_summed = CHECKSUM_NONE; newskb->ip_summed = CHECKSUM_NONE;
/* "Never happens" (?) */ /* "Never happens" (?) */
if (newskb->len > dst_mtu(newskb->dst)) if (newskb->len > dst_mtu(skb_dst(newskb)))
goto free_nskb; goto free_nskb;
nf_ct_attach(newskb, *poldskb); nf_ct_attach(newskb, *poldskb);
@@ -114,7 +113,6 @@ static struct xt_target echo_tg_reg __read_mostly = {
.proto = IPPROTO_UDP, .proto = IPPROTO_UDP,
.table = "filter", .table = "filter",
.target = echo_tg4, .target = echo_tg4,
.targetsize = XT_ALIGN(0),
.me = THIS_MODULE, .me = THIS_MODULE,
}; };

View File

@@ -86,7 +86,7 @@ static struct xt_target ipmark_tg_reg[] __read_mostly = {
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.table = "mangle", .table = "mangle",
.target = ipmark_tg4, .target = ipmark_tg4,
.targetsize = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)), .targetsize = sizeof(struct xt_ipmark_tginfo),
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
{ {
@@ -95,7 +95,7 @@ static struct xt_target ipmark_tg_reg[] __read_mostly = {
.family = NFPROTO_IPV6, .family = NFPROTO_IPV6,
.table = "mangle", .table = "mangle",
.target = ipmark_tg6, .target = ipmark_tg6,
.targetsize = XT_ALIGN(sizeof(struct xt_ipmark_tginfo)), .targetsize = sizeof(struct xt_ipmark_tginfo),
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
}; };

View File

@@ -22,6 +22,10 @@
#include "compat_xtables.h" #include "compat_xtables.h"
#include "xt_RAWNAT.h" #include "xt_RAWNAT.h"
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
# define WITH_IPV6 1
#endif
static inline __be32 static inline __be32
remask(__be32 addr, __be32 repl, unsigned int shift) remask(__be32 addr, __be32 repl, unsigned int shift)
{ {
@@ -29,6 +33,7 @@ remask(__be32 addr, __be32 repl, unsigned int shift)
return htonl((ntohl(addr) & mask) | (ntohl(repl) & ~mask)); return htonl((ntohl(addr) & mask) | (ntohl(repl) & ~mask));
} }
#ifdef WITH_IPV6
static void static void
rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask) rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask)
{ {
@@ -72,6 +77,7 @@ rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask)
break; break;
} }
} }
#endif
static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip) static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip)
{ {
@@ -162,6 +168,7 @@ rawdnat_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
return XT_CONTINUE; return XT_CONTINUE;
} }
#ifdef WITH_IPV6
static bool rawnat6_prepare_l4(struct sk_buff **pskb, unsigned int *l4offset, static bool rawnat6_prepare_l4(struct sk_buff **pskb, unsigned int *l4offset,
unsigned int *l4proto) unsigned int *l4proto)
{ {
@@ -274,6 +281,7 @@ rawdnat_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
memcpy(&iph->daddr, &new_addr, sizeof(new_addr)); memcpy(&iph->daddr, &new_addr, sizeof(new_addr));
return XT_CONTINUE; return XT_CONTINUE;
} }
#endif
static bool rawnat_tg_check(const struct xt_tgchk_param *par) static bool rawnat_tg_check(const struct xt_tgchk_param *par)
{ {
@@ -296,6 +304,7 @@ static struct xt_target rawnat_tg_reg[] __read_mostly = {
.checkentry = rawnat_tg_check, .checkentry = rawnat_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#ifdef WITH_IPV6
{ {
.name = "RAWSNAT", .name = "RAWSNAT",
.revision = 0, .revision = 0,
@@ -305,6 +314,7 @@ static struct xt_target rawnat_tg_reg[] __read_mostly = {
.checkentry = rawnat_tg_check, .checkentry = rawnat_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#endif
{ {
.name = "RAWDNAT", .name = "RAWDNAT",
.revision = 0, .revision = 0,
@@ -314,6 +324,7 @@ static struct xt_target rawnat_tg_reg[] __read_mostly = {
.checkentry = rawnat_tg_check, .checkentry = rawnat_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#ifdef WITH_IPV6
{ {
.name = "RAWDNAT", .name = "RAWDNAT",
.revision = 0, .revision = 0,
@@ -323,6 +334,7 @@ static struct xt_target rawnat_tg_reg[] __read_mostly = {
.checkentry = rawnat_tg_check, .checkentry = rawnat_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#endif
}; };
static int __init rawnat_tg_init(void) static int __init rawnat_tg_init(void)

View File

@@ -1,6 +1,6 @@
/* /*
* "SYSRQ" target extension for Netfilter * "SYSRQ" target extension for Netfilter
* Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008 * Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008 - 2010
* *
* Based upon the ipt_SYSRQ idea by Marek Zalem <marek [at] terminus sk> * Based upon the ipt_SYSRQ idea by Marek Zalem <marek [at] terminus sk>
* *
@@ -23,6 +23,14 @@
#include <net/ip.h> #include <net/ip.h>
#include "compat_xtables.h" #include "compat_xtables.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && \
(defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE))
# define WITH_CRYPTO 1
#endif
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
# define WITH_IPV6 1
#endif
static bool sysrq_once; static bool sysrq_once;
static char sysrq_password[64]; static char sysrq_password[64];
static char sysrq_hash[16] = "sha1"; static char sysrq_hash[16] = "sha1";
@@ -38,7 +46,7 @@ MODULE_PARM_DESC(hash, "hash algorithm, default sha1");
MODULE_PARM_DESC(seqno, "sequence number for remote sysrq"); MODULE_PARM_DESC(seqno, "sequence number for remote sysrq");
MODULE_PARM_DESC(debug, "debugging: 0=off, 1=on"); MODULE_PARM_DESC(debug, "debugging: 0=off, 1=on");
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) #ifdef WITH_CRYPTO
static struct crypto_hash *sysrq_tfm; static struct crypto_hash *sysrq_tfm;
static int sysrq_digest_size; static int sysrq_digest_size;
static unsigned char *sysrq_digest_password; static unsigned char *sysrq_digest_password;
@@ -200,8 +208,8 @@ sysrq_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
return NF_DROP; return NF_DROP;
iph = ip_hdr(skb); iph = ip_hdr(skb);
if (iph->protocol != IPPROTO_UDP) if (iph->protocol != IPPROTO_UDP && iph->protocol != IPPROTO_UDPLITE)
return NF_ACCEPT; /* sink it */ return NF_DROP;
udph = (const void *)iph + ip_hdrlen(skb); udph = (const void *)iph + ip_hdrlen(skb);
len = ntohs(udph->len) - sizeof(struct udphdr); len = ntohs(udph->len) - sizeof(struct udphdr);
@@ -214,6 +222,7 @@ sysrq_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
return sysrq_tg((void *)udph + sizeof(struct udphdr), len); return sysrq_tg((void *)udph + sizeof(struct udphdr), len);
} }
#ifdef WITH_IPV6
static unsigned int static unsigned int
sysrq_tg6(struct sk_buff **pskb, const struct xt_target_param *par) sysrq_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
{ {
@@ -230,7 +239,7 @@ sysrq_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
iph = ipv6_hdr(skb); iph = ipv6_hdr(skb);
if (ipv6_find_hdr(skb, &th_off, IPPROTO_UDP, &frag_off) < 0 || if (ipv6_find_hdr(skb, &th_off, IPPROTO_UDP, &frag_off) < 0 ||
frag_off > 0) frag_off > 0)
return NF_ACCEPT; /* sink it */ return NF_DROP;
udph = (const void *)iph + th_off; udph = (const void *)iph + th_off;
len = ntohs(udph->len) - sizeof(struct udphdr); len = ntohs(udph->len) - sizeof(struct udphdr);
@@ -242,6 +251,7 @@ sysrq_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
ntohs(udph->dest), len); ntohs(udph->dest), len);
return sysrq_tg(udph + sizeof(struct udphdr), len); return sysrq_tg(udph + sizeof(struct udphdr), len);
} }
#endif
static bool sysrq_tg_check(const struct xt_tgchk_param *par) static bool sysrq_tg_check(const struct xt_tgchk_param *par)
{ {
@@ -278,6 +288,7 @@ static struct xt_target sysrq_tg_reg[] __read_mostly = {
.checkentry = sysrq_tg_check, .checkentry = sysrq_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#ifdef WITH_IPV6
{ {
.name = "SYSRQ", .name = "SYSRQ",
.revision = 1, .revision = 1,
@@ -286,12 +297,28 @@ static struct xt_target sysrq_tg_reg[] __read_mostly = {
.checkentry = sysrq_tg_check, .checkentry = sysrq_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#endif
}; };
static int __init sysrq_tg_init(void) static void sysrq_crypto_exit(void)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) #ifdef WITH_CRYPTO
if (sysrq_tfm)
crypto_free_hash(sysrq_tfm);
if (sysrq_digest)
kfree(sysrq_digest);
if (sysrq_hexdigest)
kfree(sysrq_hexdigest);
if (sysrq_digest_password)
kfree(sysrq_digest_password);
#endif
}
static int __init sysrq_crypto_init(void)
{
#if defined(WITH_CRYPTO)
struct timeval now; struct timeval now;
int ret;
sysrq_tfm = crypto_alloc_hash(sysrq_hash, 0, CRYPTO_ALG_ASYNC); sysrq_tfm = crypto_alloc_hash(sysrq_hash, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(sysrq_tfm)) { if (IS_ERR(sysrq_tfm)) {
@@ -299,10 +326,12 @@ static int __init sysrq_tg_init(void)
": 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; sysrq_tfm = NULL;
ret = PTR_ERR(sysrq_tfm);
goto fail; goto fail;
} }
sysrq_digest_size = crypto_hash_digestsize(sysrq_tfm); sysrq_digest_size = crypto_hash_digestsize(sysrq_tfm);
sysrq_digest = kmalloc(sysrq_digest_size, GFP_KERNEL); sysrq_digest = kmalloc(sysrq_digest_size, GFP_KERNEL);
ret = -ENOMEM;
if (sysrq_digest == NULL) { if (sysrq_digest == NULL) {
printk(KERN_WARNING KBUILD_MODNAME printk(KERN_WARNING KBUILD_MODNAME
": Cannot allocate digest\n"); ": Cannot allocate digest\n");
@@ -322,33 +351,31 @@ static int __init sysrq_tg_init(void)
} }
do_gettimeofday(&now); do_gettimeofday(&now);
sysrq_seqno = now.tv_sec; sysrq_seqno = now.tv_sec;
return xt_register_targets(sysrq_tg_reg, ARRAY_SIZE(sysrq_tg_reg)); ret = xt_register_targets(sysrq_tg_reg, ARRAY_SIZE(sysrq_tg_reg));
if (ret < 0)
goto fail;
return ret;
fail: fail:
if (sysrq_tfm) sysrq_crypto_exit();
crypto_free_hash(sysrq_tfm); return ret;
if (sysrq_digest) #elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
kfree(sysrq_digest); printk(KERN_WARNING "xt_SYSRQ does not provide crypto for < 2.6.19\n");
if (sysrq_hexdigest)
kfree(sysrq_hexdigest);
if (sysrq_digest_password)
kfree(sysrq_digest_password);
return -EINVAL;
#else
printk(KERN_WARNING "xt_SYSRQ does not provide crypto for <= 2.6.18\n");
return xt_register_targets(sysrq_tg_reg, ARRAY_SIZE(sysrq_tg_reg));
#endif #endif
return -EINVAL;
}
static int __init sysrq_tg_init(void)
{
if (sysrq_crypto_init() < 0)
printk(KERN_WARNING "xt_SYSRQ starting without crypto\n");
return xt_register_targets(sysrq_tg_reg, ARRAY_SIZE(sysrq_tg_reg));
} }
static void __exit sysrq_tg_exit(void) static void __exit sysrq_tg_exit(void)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) sysrq_crypto_exit();
crypto_free_hash(sysrq_tfm); xt_unregister_targets(sysrq_tg_reg, ARRAY_SIZE(sysrq_tg_reg));
kfree(sysrq_digest);
kfree(sysrq_hexdigest);
kfree(sysrq_digest_password);
#endif
return xt_unregister_targets(sysrq_tg_reg, ARRAY_SIZE(sysrq_tg_reg));
} }
module_init(sysrq_tg_init); module_init(sysrq_tg_init);

View File

@@ -175,7 +175,8 @@ tee_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
/* /*
* Copy the skb, and route the copy. Will later return %XT_CONTINUE for * Copy the skb, and route the copy. Will later return %XT_CONTINUE for
* the original skb, which should continue on its way as if nothing has * the original skb, which should continue on its way as if nothing has
* happened. The copy should be independently delivered to the TEE --gw. * happened. The copy should be independently delivered to the TEE
* --gateway.
*/ */
skb = skb_copy(skb, GFP_ATOMIC); skb = skb_copy(skb, GFP_ATOMIC);
if (skb == NULL) { if (skb == NULL) {
@@ -231,6 +232,7 @@ tee_tg_route6(struct sk_buff *skb, const struct xt_tee_tginfo *info)
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
fl.iif = skb_ifindex(skb); fl.iif = skb_ifindex(skb);
/* No mark in flowi before 2.6.19 */
#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 19) #if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 19)
fl.nl_u.ip6_u.fwmark = skb_nfmark(skb); fl.nl_u.ip6_u.fwmark = skb_nfmark(skb);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)

View File

@@ -35,6 +35,7 @@ static unsigned int condition_gid_perms = 0;
MODULE_AUTHOR("Stephane Ouellette <ouellettes@videotron.ca>"); MODULE_AUTHOR("Stephane Ouellette <ouellettes@videotron.ca>");
MODULE_AUTHOR("Massimiliano Hofer <max@nucleus.it>"); MODULE_AUTHOR("Massimiliano Hofer <max@nucleus.it>");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Allows rules to match against condition variables"); MODULE_DESCRIPTION("Allows rules to match against condition variables");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_param(condition_list_perms, uint, S_IRUSR | S_IWUSR); module_param(condition_list_perms, uint, S_IRUSR | S_IWUSR);
@@ -55,7 +56,7 @@ struct condition_variable {
/* proc_lock is a user context only semaphore used for write access */ /* proc_lock is a user context only semaphore used for write access */
/* to the conditions' list. */ /* to the conditions' list. */
static struct semaphore proc_lock; static struct mutex proc_lock;
static LIST_HEAD(conditions_list); static LIST_HEAD(conditions_list);
static struct proc_dir_entry *proc_net_condition; static struct proc_dir_entry *proc_net_condition;
@@ -69,7 +70,6 @@ static int condition_proc_read(char __user *buffer, char **start, off_t offset,
buffer[1] = '\n'; buffer[1] = '\n';
if (length >= 2) if (length >= 2)
*eof = true; *eof = true;
return 2; return 2;
} }
@@ -92,7 +92,6 @@ static int condition_proc_write(struct file *file, const char __user *buffer,
break; break;
} }
} }
return length; return length;
} }
@@ -124,18 +123,17 @@ static bool condition_mt_check(const struct xt_mtchk_param *par)
info->name); info->name);
return false; return false;
} }
/* /*
* Let's acquire the lock, check for the condition and add it * Let's acquire the lock, check for the condition and add it
* or increase the reference counter. * or increase the reference counter.
*/ */
if (down_interruptible(&proc_lock)) if (mutex_lock_interruptible(&proc_lock) != 0)
return false; return false;
list_for_each_entry(var, &conditions_list, list) { list_for_each_entry(var, &conditions_list, list) {
if (strcmp(info->name, var->status_proc->name) == 0) { if (strcmp(info->name, var->status_proc->name) == 0) {
var->refcount++; var->refcount++;
up(&proc_lock); mutex_unlock(&proc_lock);
info->condvar = var; info->condvar = var;
return true; return true;
} }
@@ -143,19 +141,17 @@ static bool condition_mt_check(const struct xt_mtchk_param *par)
/* At this point, we need to allocate a new condition variable. */ /* At this point, we need to allocate a new condition variable. */
var = kmalloc(sizeof(struct condition_variable), GFP_KERNEL); var = kmalloc(sizeof(struct condition_variable), GFP_KERNEL);
if (var == NULL) { if (var == NULL) {
up(&proc_lock); mutex_unlock(&proc_lock);
return false; return false;
} }
/* Create the condition variable's proc file entry. */ /* Create the condition variable's proc file entry. */
var->status_proc = create_proc_entry(info->name, condition_list_perms, var->status_proc = create_proc_entry(info->name, condition_list_perms,
proc_net_condition); proc_net_condition);
if (var->status_proc == NULL) { if (var->status_proc == NULL) {
kfree(var); kfree(var);
up(&proc_lock); mutex_unlock(&proc_lock);
return false; return false;
} }
@@ -168,14 +164,10 @@ static bool condition_mt_check(const struct xt_mtchk_param *par)
wmb(); wmb();
var->status_proc->read_proc = condition_proc_read; var->status_proc->read_proc = condition_proc_read;
var->status_proc->write_proc = condition_proc_write; var->status_proc->write_proc = condition_proc_write;
list_add_rcu(&var->list, &conditions_list); list_add_rcu(&var->list, &conditions_list);
var->status_proc->uid = condition_uid_perms; var->status_proc->uid = condition_uid_perms;
var->status_proc->gid = condition_gid_perms; var->status_proc->gid = condition_gid_perms;
mutex_unlock(&proc_lock);
up(&proc_lock);
info->condvar = var; info->condvar = var;
return true; return true;
} }
@@ -185,11 +177,11 @@ static void condition_mt_destroy(const struct xt_mtdtor_param *par)
const struct xt_condition_mtinfo *info = par->matchinfo; const struct xt_condition_mtinfo *info = par->matchinfo;
struct condition_variable *var = info->condvar; struct condition_variable *var = info->condvar;
down(&proc_lock); mutex_lock(&proc_lock);
if (--var->refcount == 0) { if (--var->refcount == 0) {
list_del_rcu(&var->list); list_del_rcu(&var->list);
remove_proc_entry(var->status_proc->name, proc_net_condition); remove_proc_entry(var->status_proc->name, proc_net_condition);
up(&proc_lock); mutex_unlock(&proc_lock);
/* /*
* synchronize_rcu() would be good enough, but * synchronize_rcu() would be good enough, but
* synchronize_net() guarantees that no packet * synchronize_net() guarantees that no packet
@@ -200,7 +192,7 @@ static void condition_mt_destroy(const struct xt_mtdtor_param *par)
kfree(var); kfree(var);
return; return;
} }
up(&proc_lock); mutex_unlock(&proc_lock);
} }
static struct xt_match condition_mt_reg[] __read_mostly = { static struct xt_match condition_mt_reg[] __read_mostly = {
@@ -208,7 +200,7 @@ static struct xt_match condition_mt_reg[] __read_mostly = {
.name = "condition", .name = "condition",
.revision = 1, .revision = 1,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.matchsize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)), .matchsize = sizeof(struct xt_condition_mtinfo),
.match = condition_mt, .match = condition_mt,
.checkentry = condition_mt_check, .checkentry = condition_mt_check,
.destroy = condition_mt_destroy, .destroy = condition_mt_destroy,
@@ -218,7 +210,7 @@ static struct xt_match condition_mt_reg[] __read_mostly = {
.name = "condition", .name = "condition",
.revision = 1, .revision = 1,
.family = NFPROTO_IPV6, .family = NFPROTO_IPV6,
.matchsize = XT_ALIGN(sizeof(struct xt_condition_mtinfo)), .matchsize = sizeof(struct xt_condition_mtinfo),
.match = condition_mt, .match = condition_mt,
.checkentry = condition_mt_check, .checkentry = condition_mt_check,
.destroy = condition_mt_destroy, .destroy = condition_mt_destroy,
@@ -232,7 +224,7 @@ static int __init condition_mt_init(void)
{ {
int ret; int ret;
sema_init(&proc_lock, 1); mutex_init(&proc_lock);
proc_net_condition = proc_mkdir(dir_name, init_net__proc_net); proc_net_condition = proc_mkdir(dir_name, init_net__proc_net);
if (proc_net_condition == NULL) if (proc_net_condition == NULL)
return -EACCES; return -EACCES;

View File

@@ -146,7 +146,7 @@ static struct xt_match fuzzy_mt_reg[] __read_mostly = {
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.match = fuzzy_mt, .match = fuzzy_mt,
.checkentry = fuzzy_mt_check, .checkentry = fuzzy_mt_check,
.matchsize = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)), .matchsize = sizeof(struct xt_fuzzy_mtinfo),
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
{ {
@@ -155,7 +155,7 @@ static struct xt_match fuzzy_mt_reg[] __read_mostly = {
.family = NFPROTO_IPV6, .family = NFPROTO_IPV6,
.match = fuzzy_mt, .match = fuzzy_mt,
.checkentry = fuzzy_mt_check, .checkentry = fuzzy_mt_check,
.matchsize = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)), .matchsize = sizeof(struct xt_fuzzy_mtinfo),
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
}; };

View File

@@ -71,7 +71,7 @@ static struct xt_match xt_iface_mt_reg[] __read_mostly = {
.name = "iface", .name = "iface",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.matchsize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)), .matchsize = sizeof(struct xt_iface_mtinfo),
.match = xt_iface_mt, .match = xt_iface_mt,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
@@ -79,7 +79,7 @@ static struct xt_match xt_iface_mt_reg[] __read_mostly = {
.name = "iface", .name = "iface",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV6, .family = NFPROTO_IPV6,
.matchsize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)), .matchsize = sizeof(struct xt_iface_mtinfo),
.match = xt_iface_mt, .match = xt_iface_mt,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },

View File

@@ -505,19 +505,18 @@ search_bittorrent(const unsigned char *payload, const unsigned int plen)
if (payload[0] == 0x13) if (payload[0] == 0x13)
if (memcmp(payload + 1, "BitTorrent protocol", 19) == 0) if (memcmp(payload + 1, "BitTorrent protocol", 19) == 0)
return IPP2P_BIT * 100; return IPP2P_BIT * 100;
/* /*
* get tracker commandos, all starts with GET / * Any tracker command starts with GET / then *may be* some file on web server
* then it can follow: scrape| announce * (e.g. announce.php or dupa.pl or whatever.cgi or NOTHING for tracker on root dir)
* and then ?hash_info= * 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) {
/* message scrape */ if (HX_memmem(payload, plen, "info_hash=", 9) != NULL)
if (memcmp(payload + 5, "scrape?info_hash=", 17) == 0)
return IPP2P_BIT * 100 + 1; return IPP2P_BIT * 100 + 1;
/* message announce */ if (HX_memmem(payload, plen, "peer_id=", 8) != NULL)
if (memcmp(payload + 5, "announce?info_hash=", 19) == 0)
return IPP2P_BIT * 100 + 2; return IPP2P_BIT * 100 + 2;
if (HX_memmem(payload, plen, "passkey=", 8) != NULL)
return IPP2P_BIT * 100 + 4;
} }
} else { } else {
/* bitcomet encryptes the first packet, so we have to detect another /* bitcomet encryptes the first packet, so we have to detect another

View File

@@ -50,7 +50,7 @@ static struct xt_match ipv4options_mt_reg __read_mostly = {
.revision = 1, .revision = 1,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.match = ipv4options_mt, .match = ipv4options_mt,
.matchsize = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)), .matchsize = sizeof(struct xt_ipv4options_mtinfo1),
.me = THIS_MODULE, .me = THIS_MODULE,
}; };

View File

@@ -136,6 +136,30 @@ static bool xtlength_layer7(unsigned int *length, const struct sk_buff *skb,
} }
} }
static bool
length2_mt(const struct sk_buff *skb, const struct xt_match_param *par)
{
const struct xt_length_mtinfo2 *info = par->matchinfo;
const struct iphdr *iph = ip_hdr(skb);
unsigned int len = 0;
bool hit = true;
if (info->flags & XT_LENGTH_LAYER3)
len = ntohs(iph->tot_len);
else if (info->flags & XT_LENGTH_LAYER4)
len = ntohs(iph->tot_len) - par->thoff;
else if (info->flags & XT_LENGTH_LAYER5)
hit = xtlength_layer5(&len, skb, iph->protocol, par->thoff);
else if (info->flags & XT_LENGTH_LAYER7)
hit = xtlength_layer7(&len, skb, iph->protocol, par->thoff);
if (!hit)
return false;
return (len >= info->min && len <= info->max) ^
!!(info->flags & XT_LENGTH_INVERT);
}
#ifdef WITH_IPV6
/** /**
* llayer4_proto - figure out the L4 protocol in an IPv6 packet * llayer4_proto - figure out the L4 protocol in an IPv6 packet
* @skb: skb pointer * @skb: skb pointer
@@ -173,30 +197,6 @@ llayer4_proto(const struct sk_buff *skb, unsigned int *offset, bool *hotdrop)
return NEXTHDR_MAX; return NEXTHDR_MAX;
} }
static bool
length2_mt(const struct sk_buff *skb, const struct xt_match_param *par)
{
const struct xt_length_mtinfo2 *info = par->matchinfo;
const struct iphdr *iph = ip_hdr(skb);
unsigned int len = 0;
bool hit = true;
if (info->flags & XT_LENGTH_LAYER3)
len = ntohs(iph->tot_len);
else if (info->flags & XT_LENGTH_LAYER4)
len = ntohs(iph->tot_len) - par->thoff;
else if (info->flags & XT_LENGTH_LAYER5)
hit = xtlength_layer5(&len, skb, iph->protocol, par->thoff);
else if (info->flags & XT_LENGTH_LAYER7)
hit = xtlength_layer7(&len, skb, iph->protocol, par->thoff);
if (!hit)
return false;
return (len >= info->min && len <= info->max) ^
!!(info->flags & XT_LENGTH_INVERT);
}
#ifdef WITH_IPV6
static bool static bool
length2_mt6(const struct sk_buff *skb, const struct xt_match_param *par) length2_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
{ {

View File

@@ -312,7 +312,7 @@ out_match:
static struct xt_match xt_psd_reg __read_mostly = { static struct xt_match xt_psd_reg __read_mostly = {
.name = "psd", .name = "psd",
.family = AF_INET, .family = NFPROTO_IPV4,
.revision = 1, .revision = 1,
.match = xt_psd_match, .match = xt_psd_match,
.matchsize = sizeof(struct xt_psd_info), .matchsize = sizeof(struct xt_psd_info),

View File

@@ -5,4 +5,5 @@ config NETFILTER_XT_MATCH_QUOTA2
This option adds the "quota2" match which is an advanced form of This option adds the "quota2" match which is an advanced form of
xt_quota that also allows counting upwards, and where the counter can xt_quota that also allows counting upwards, and where the counter can
be set through procfs. This allows for simple interfacing of be set through procfs. This allows for simple interfacing of
accounting information. accounting information. It also allows for a test mode without changing
the quota value.

View File

@@ -199,12 +199,19 @@ quota_mt2(const struct sk_buff *skb, const struct xt_match_param *par)
spin_lock_bh(&e->lock); spin_lock_bh(&e->lock);
if (q->flags & XT_QUOTA_GROW) { if (q->flags & XT_QUOTA_GROW) {
e->quota += (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len; /*
q->quota = e->quota; * While no_change is pointless in "grow" mode, we will
* implement it here simply to have a consistent behavior.
*/
if (!(q->flags & XT_QUOTA_NO_CHANGE)) {
e->quota += (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
q->quota = e->quota;
}
ret = true; ret = true;
} else { } else {
if (e->quota >= skb->len) { if (e->quota >= skb->len) {
e->quota -= (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len; if (!(q->flags & XT_QUOTA_NO_CHANGE))
e->quota -= (q->flags & XT_QUOTA_PACKET) ? 1 : skb->len;
ret = !ret; ret = !ret;
} else { } else {
/* we do not allow even small packets from now on */ /* we do not allow even small packets from now on */

View File

@@ -2,10 +2,11 @@
#define _XT_QUOTA_H #define _XT_QUOTA_H
enum xt_quota_flags { enum xt_quota_flags {
XT_QUOTA_INVERT = 1 << 0, XT_QUOTA_INVERT = 1 << 0,
XT_QUOTA_GROW = 1 << 1, XT_QUOTA_GROW = 1 << 1,
XT_QUOTA_PACKET = 1 << 2, XT_QUOTA_PACKET = 1 << 2,
XT_QUOTA_MASK = 0x7, XT_QUOTA_NO_CHANGE = 1 << 3,
XT_QUOTA_MASK = 0x0F,
}; };
struct xt_quota_counter; struct xt_quota_counter;

View File

@@ -3,6 +3,7 @@
#include <linux/types.h> #include <linux/types.h>
/* Responses from hook functions. */ /* Responses from hook functions. */
#define NF_DROP 0 #define NF_DROP 0
#define NF_ACCEPT 1 #define NF_ACCEPT 1
@@ -37,6 +38,16 @@ enum nf_inet_hooks {
NF_INET_NUMHOOKS NF_INET_NUMHOOKS
}; };
enum {
NFPROTO_UNSPEC = 0,
NFPROTO_IPV4 = 2,
NFPROTO_ARP = 3,
NFPROTO_BRIDGE = 7,
NFPROTO_IPV6 = 10,
NFPROTO_DECNET = 12,
NFPROTO_NUMPROTO,
};
union nf_inet_addr { union nf_inet_addr {
__u32 all[4]; __u32 all[4];
__be32 ip; __be32 ip;

View File

@@ -1,4 +1,4 @@
.TH xtables-addons 8 "v1.20 (2009-11-19)" "" "v1.20 (2009-11-19)" .TH xtables-addons 8 "v1.24 (2010-03-17)" "" "v1.24 (2010-03-17)"
.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