]> git.ipfire.org Git - thirdparty/iptables.git/log
thirdparty/iptables.git
14 years agov4: rename print_rule() to print_rule4()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:37:13 +0000 (15:37 +0200)] 
v4: rename print_rule() to print_rule4()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov6: rename delete_chain() to delete_chain6()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:36:45 +0000 (15:36 +0200)] 
v6: rename delete_chain() to delete_chain6()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov4: rename delete_chain() to delete_chain4()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:36:14 +0000 (15:36 +0200)] 
v4: rename delete_chain() to delete_chain4()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov6: rename flush_entries() to flush_entries6()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:35:47 +0000 (15:35 +0200)] 
v6: rename flush_entries() to flush_entries6()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov4: rename flush_entries() to flush_entries4()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:35:20 +0000 (15:35 +0200)] 
v4: rename flush_entries() to flush_entries4()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov6: rename for_each_chain() to for_each_chain6()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:34:54 +0000 (15:34 +0200)] 
v6: rename for_each_chain() to for_each_chain6()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov4: rename for_each_chain() to for_each_chain4()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:34:28 +0000 (15:34 +0200)] 
v4: rename for_each_chain() to for_each_chain4()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoxtables.h: init_extensions() no longer exists
Maciej Zenczykowski [Mon, 4 Apr 2011 13:33:58 +0000 (15:33 +0200)] 
xtables.h: init_extensions() no longer exists

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov6: rename init_extensions() to init_extensions6()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:33:25 +0000 (15:33 +0200)] 
v6: rename init_extensions() to init_extensions6()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agov4: rename init_extensions() to init_extensions4()
Maciej Zenczykowski [Mon, 4 Apr 2011 13:32:39 +0000 (15:32 +0200)] 
v4: rename init_extensions() to init_extensions4()

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoxtables: delay (statically built) match/target initialization
Maciej Zenczykowski [Mon, 4 Apr 2011 13:31:43 +0000 (15:31 +0200)] 
xtables: delay (statically built) match/target initialization

Matches and targets built into the iptables static binary will always
be registered as the binary starts up, this may potentially (as a result
of kernel version support checking) result in modules being autoloaded.

This is undesirable (for example it may cause CONNMARK target to load
and thus cause the kernel to load the conntrack module, which isn't a
no-op).

Transition to a system where matches and targets are registered into
a pending list, from whence they get fully registered only when
required.

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoxtables_ip6addr_to_numeric: fix typo in comment
Maciej Zenczykowski [Mon, 4 Apr 2011 13:31:09 +0000 (15:31 +0200)] 
xtables_ip6addr_to_numeric: fix typo in comment

An IPv6 address consists of eight hexadecimal 16-bit values seperated
by colons, or alternatively, six (not five) of these followed by a colon
and an IPv4 address in standard dotted decimal quad notation
(for IPv4 mapped addresses and the like).

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agomark newly opened fds as FD_CLOEXEC (close on exec)
Maciej Zenczykowski [Mon, 4 Apr 2011 13:30:32 +0000 (15:30 +0200)] 
mark newly opened fds as FD_CLOEXEC (close on exec)

(This is iptables-1.4.3.1-cloexec.patch from RedHat iptables.src.rpm)

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoman pages: allow underscores in match and target names
Maciej Zenczykowski [Mon, 4 Apr 2011 13:29:40 +0000 (15:29 +0200)] 
man pages: allow underscores in match and target names

Signed-off-by: Maciej Zenczykowski <maze@google.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoiptables: documentation for iptables and ip6tables "security" tables
Mark Montague [Mon, 4 Apr 2011 12:54:52 +0000 (14:54 +0200)] 
iptables: documentation for iptables and ip6tables "security" tables

Add documentation for the iptables and ip6tables "security" tables.
Based on http://lwn.net/Articles/267140/ and kernel source.

Signed-off-by: Mark Montague <mark@catseye.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoiptables: add manual page section for AUDIT target
Thomas Graf [Wed, 16 Mar 2011 15:30:09 +0000 (16:30 +0100)] 
iptables: add manual page section for AUDIT target

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoiptables: add -C to check for existing rules
Stefan Tomanek [Tue, 8 Mar 2011 21:42:51 +0000 (22:42 +0100)] 
iptables: add -C to check for existing rules

It is often useful to check whether a specific rule is already present
in a chain without actually modifying the iptables config.

Services like fail2ban usually employ techniques like grepping through
the output of "iptables -L" which is quite error prone.

This patch adds a new operation -C to the iptables command which
mostly works like -D; it can detect and indicate the existence of the
specified rule by modifying the exit code. The new operation
TC_CHECK_ENTRY uses the same code as the -D operation, whose functions
got a dry-run parameter appended.

Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoip(6)tables-multi: unify subcommand handling
Stefan Tomanek [Mon, 7 Mar 2011 17:30:27 +0000 (18:30 +0100)] 
ip(6)tables-multi: unify subcommand handling

I found the subcommand handling and naming done by iptables-multi and
ip6tables-multi very confusing and complicated; this patch
reorganizes the subcommands in a single table, allowing both variants
of them to be used (iptables/main) and also prints a list of the
allowed commands if an unknown command is entered by the user.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agodoc: add VERSION section to manpages
Jan Engelhardt [Tue, 1 Mar 2011 11:51:21 +0000 (12:51 +0100)] 
doc: add VERSION section to manpages

This shall make it easier to identify outdated HTML renditions on the
interwebs, since many of them do not display the .TH header like man(1)
does.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: fix an inversion
Jan Engelhardt [Tue, 1 Mar 2011 01:45:34 +0000 (02:45 +0100)] 
iptables: fix an inversion

Revisiting the original condition (viewable in git log -1 -p
v1.4.10-57-gacef604), one can notice an unforuntate inversion. This
commit corrects this.

Testcase: -A INPUT -p tcp --dport 1

Reported-by: Florian Westphal
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoxtables: use all IPv6 addresses resolved from a hostname
Wes Campaigne [Tue, 22 Feb 2011 00:10:10 +0000 (19:10 -0500)] 
xtables: use all IPv6 addresses resolved from a hostname

Fixes a long-standing issue where host_to_ip6addr would only ever
examine/return the first item of the address chain returned by
getaddrinfo, instead of traversing the chain and copying each of them.

This has always been how host_to_ip6addr behaves, and all of the other
related IPv6 code is already written to handle multiple possible
addresses.

[Style fixups. Removal of redundant i<*naddrs check. -j.eng]

Signed-off-by: Wes Campaigne <westacular@gmail.com>
14 years agoxtables: fix the broken detection/removal of redundant addresses
Wes Campaigne [Tue, 22 Feb 2011 00:10:12 +0000 (19:10 -0500)] 
xtables: fix the broken detection/removal of redundant addresses

[To observe this issue, populate a hostname (DNS or local db)
with multiple adresses across multiple subnets (cf. prefixlen
below)

# e.g. /etc/hosts
127.0.0.2       lo-x
127.0.0.3       lo-x
127.0.1.4       lo-x
127.0.1.5       lo-x
127.0.2.6       lo-x

Then invoke xtables_ipparse_any by e.g. `-m conntrack
--ctorigsrc lo-x/24`. -j.eng]

This same block of code, apparently to detect if addresses are
identical after applying the mask, and to skip the duplicates and the
ones made redundant by the mask, has been present and unchanged from
as far back as I could find (circa iptables 1.2).

By inspection, it was wrong, and always has been: once the code finds
a duplicate, it will drop the rest of the array one by one as it
re-detects the same duplicate over and over. When the addresses came
from a single hostname lookup, and their order was random, then this
created unpredictable behaviour by iptables, which seem to ignore some
of those addresses at random times.

I suspect the original idea also involved a swap between the duplicate
and the address from the (current) end of the array, but a line of
code to do that seems to have never existed. I have finally added it.
(Well, as much as is needed: there does not need to be a full swap,
because we are just going to ignore the duplicate, pretend the array
is one shorter, and never look at the contents of the end again. So,
we can get away with just copying from the end.)

[Reword comment about shuffle: replace by mentioning tail copy to
replace dup. -j.eng]

Signed-off-by: Wes Campaigne <westacular@gmail.com>
14 years agoxtables: fix excessive memory allocation in host_to_ipaddr
Wes Campaigne [Tue, 22 Feb 2011 00:10:11 +0000 (19:10 -0500)] 
xtables: fix excessive memory allocation in host_to_ipaddr

host_to_ipaddr was unnecessarily asking for an array of length n^2 to
store just n addresses.

Signed-off-by: Wes Campaigne <westacular@gmail.com>
14 years agolibxtables: avoid confusing use of ai_protocol=IPPROTO_IPV6
Wes Campaigne [Tue, 22 Feb 2011 00:10:10 +0000 (19:10 -0500)] 
libxtables: avoid confusing use of ai_protocol=IPPROTO_IPV6

[Split hunk from Wes's submission. Added commit message. -j.eng]

ai_protocol normally specifies the L4 protocol one wants to
specifically inquire about when a service (2nd parameter to
getaddrinfo) is specified. Such a service lookup would potentially
yield nothing, because there just is not any "mytunnel 2222/ipv6" in
/etc/services, since IPPROTO_IPV6 itself is not a protocol with a
concept of (port-based) services to begin with.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxtables: fix memory scribble beyond end of array
Jan Engelhardt [Mon, 21 Feb 2011 02:21:18 +0000 (03:21 +0100)] 
libxtables: fix memory scribble beyond end of array

When using -s "", the "n" variable in the code remains uninitialized
and usually scribbes beyond the end of the array.

Furthermore, "n" is just as big as entries in the last host lookup.
When specifying more than one item to -s, e.g. "-s host,host", "n" is
less than "count", and we are not masking the addresses at all
(leaving them at addr/32 resp. addr/128).

The issue goes back to the initial code from v1.4.5~21.

References: http://bugs.debian.org/611990
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agodoc: rateest options can be optional
Jan Engelhardt [Mon, 21 Feb 2011 01:59:50 +0000 (02:59 +0100)] 
doc: rateest options can be optional

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_quota: require --quota to be specified
Jan Engelhardt [Sun, 20 Feb 2011 19:30:56 +0000 (20:30 +0100)] 
libxt_quota: require --quota to be specified

It is pretty pointless to use -m quota without specifying --quota.
There would be nothing left to count down on.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agodoc: fix odd partial sentence in libipt_TTL
Jan Engelhardt [Sun, 20 Feb 2011 16:15:14 +0000 (17:15 +0100)] 
doc: fix odd partial sentence in libipt_TTL

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agodoc: mention other possible nf_loggers for TRACE
Jan Engelhardt [Sun, 20 Feb 2011 16:13:03 +0000 (17:13 +0100)] 
doc: mention other possible nf_loggers for TRACE

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibipt_ECN: set proper option flags
Jan Engelhardt [Sat, 19 Feb 2011 19:00:06 +0000 (20:00 +0100)] 
libipt_ECN: set proper option flags

When specifying --ecn-tcp-remove, *flags will be wrongly set to denote
that --ecn-ip-ect had been specified.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoextensions: add missing checks for specific flags
Jan Engelhardt [Sat, 19 Feb 2011 18:37:53 +0000 (19:37 +0100)] 
extensions: add missing checks for specific flags

With "!flags", any option will be accepted. The extensions however
want one very specific option to be used (or wrong help text).

Commits: DNAT: v1.3.8~23, osf: v1.4.6~3

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibip6t_hbh: remove unimplemented --hbh-not-strict
Jan Engelhardt [Sat, 19 Feb 2011 14:29:21 +0000 (15:29 +0100)] 
libip6t_hbh: remove unimplemented --hbh-not-strict

Same as with ip6t_dst.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibip6t_dst: remove unimplemented --dst-not-strict
Jan Engelhardt [Fri, 18 Feb 2011 00:48:33 +0000 (01:48 +0100)] 
libip6t_dst: remove unimplemented --dst-not-strict

This was never ever implemented in the kernel, so just remove it.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoRemove unused CVS expanded keywords
Jan Engelhardt [Fri, 18 Feb 2011 01:29:14 +0000 (02:29 +0100)] 
Remove unused CVS expanded keywords

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoextensions: remove redundant init functions
Jan Engelhardt [Fri, 18 Feb 2011 01:00:33 +0000 (02:00 +0100)] 
extensions: remove redundant init functions

The main program already zeroes the per-extension data block.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agodoc: fix misspelling of "field"
Jan Engelhardt [Fri, 18 Feb 2011 00:45:05 +0000 (01:45 +0100)] 
doc: fix misspelling of "field"

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agodoc: fix wrong sentence about negation in xt_limit
Jan Engelhardt [Thu, 17 Feb 2011 13:56:05 +0000 (14:56 +0100)] 
doc: fix wrong sentence about negation in xt_limit

This is an update to commit v1.4.7~6.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoxtables: use strspn() to check if string needs to be quoted
Max Kellerman [Thu, 17 Feb 2011 10:57:19 +0000 (11:57 +0100)] 
xtables: use strspn() to check if string needs to be quoted

Problem: the call xtables_save_string("'") prints just a single quote,
not enclosed in double quoted and not escaped.

Steps to reproduce:

 $ iptables -A foo -m comment --comment "'" -j ACCEPT
 $ iptables-multi save|grep foo
 -A foo -m comment --comment ' -j ACCEPT

The cause was the use of strcspn() to locate the first character which
justified quoting the string in double quotes.  That however was
wrong, because the way strcspn() was called, it returned a pointer to
the first character that was not to be escaped, which did the right
thing most of the time, but not for strings consisting only of quote
characters.  This patch changes strcspn() to strspn().

Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoextensions: fix indent of vtable
Jan Engelhardt [Tue, 15 Feb 2011 11:02:51 +0000 (12:02 +0100)] 
extensions: fix indent of vtable

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_devgroup: option whitespace update following v1.4.10-49-g7386635
Jan Engelhardt [Wed, 16 Feb 2011 01:42:21 +0000 (02:42 +0100)] 
libxt_devgroup: option whitespace update following v1.4.10-49-g7386635

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoip6tables: spacing fixes for -o argument
Jan Engelhardt [Wed, 16 Feb 2011 01:41:22 +0000 (02:41 +0100)] 
ip6tables: spacing fixes for -o argument

For aesthetic consistency, put a space after -o.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: fix segfault target option parsing
Jan Engelhardt [Fri, 11 Feb 2011 00:45:26 +0000 (01:45 +0100)] 
iptables: fix segfault target option parsing

With v1.4.10-58-g94e247b, target option parsing started to happen in the
wrong case.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoMerge branch 'master' of git://dev.medozas.de/iptables
Patrick McHardy [Wed, 9 Feb 2011 07:13:23 +0000 (08:13 +0100)] 
Merge branch 'master' of git://dev.medozas.de/iptables

14 years agoiptables: fix error message for unknown options
Jan Engelhardt [Mon, 7 Feb 2011 02:45:26 +0000 (03:45 +0100)] 
iptables: fix error message for unknown options

-From: iptables v1.4.10: option "-q" requires an argument
+To:   iptables v1.4.10: unknown option "-q"

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: move match option handling from do_command6 into its own functions
Jan Engelhardt [Mon, 7 Feb 2011 02:42:47 +0000 (03:42 +0100)] 
src: move match option handling from do_command6 into its own functions

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: move jump option handling from do_command6 into its own function
Jan Engelhardt [Mon, 7 Feb 2011 02:39:36 +0000 (03:39 +0100)] 
src: move jump option handling from do_command6 into its own function

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: unclutter command_default function
Jan Engelhardt [Mon, 7 Feb 2011 02:20:02 +0000 (03:20 +0100)] 
src: unclutter command_default function

(Essentially, 5 levels of indentation have been stripped compared to the
original layout, and this is surely a result that looks a lot better
than it did before.)

Things to note:

1. If the m->parse call succeeded, we can return from the function and
do not need to go through the other code. As such, "m" is guaranteed to
be useless at the end of the match loop, and so, conditions can be
removed.

2. Since the per-extension parse function only ever get their own option
codes (since v1.4.10-26-gd09b6d5), their return value no longer has a
meaning and can be ignored.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: deduplicate and simplify implicit protocol extension loading
Jan Engelhardt [Mon, 7 Feb 2011 02:18:53 +0000 (03:18 +0100)] 
src: deduplicate and simplify implicit protocol extension loading

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: put shared option flags into xshared
Jan Engelhardt [Mon, 7 Feb 2011 02:16:14 +0000 (03:16 +0100)] 
src: put shared option flags into xshared

This will be needed for the find_proto function.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: move OPT_FRAGMENT to the end so the list can be shared
Jan Engelhardt [Mon, 7 Feb 2011 02:13:43 +0000 (03:13 +0100)] 
src: move OPT_FRAGMENT to the end so the list can be shared

14 years agosrc: deduplicate find_proto function
Jan Engelhardt [Mon, 7 Feb 2011 02:05:49 +0000 (03:05 +0100)] 
src: deduplicate find_proto function

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: share iptables_command_state across the two programs
Jan Engelhardt [Sun, 6 Feb 2011 23:00:42 +0000 (00:00 +0100)] 
src: share iptables_command_state across the two programs

struct iptables_command_state and quite a bit of the code looks worthy
of deduplication.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: move large default: block from do_command6 into its own function
Jan Engelhardt [Sun, 6 Feb 2011 16:14:48 +0000 (17:14 +0100)] 
src: move large default: block from do_command6 into its own function

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: collect do_command variables in a struct
Jan Engelhardt [Sun, 6 Feb 2011 14:52:11 +0000 (15:52 +0100)] 
src: collect do_command variables in a struct

This will make it easier to put the code for the cases into separate
functions.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_cluster: fix inversion in the cluster match
Pablo Neira Ayuso [Sun, 6 Feb 2011 20:34:33 +0000 (21:34 +0100)] 
libxt_cluster: fix inversion in the cluster match

In libxt_cluster.c, we use:

info->flags |= (1 << XT_CLUSTER_F_INV);

but we should use instead:

info->flags |= XT_CLUSTER_F_INV;

since the definition of XT_CLUSTER_F_INV is:

enum xt_cluster_flags {
        XT_CLUSTER_F_INV        = (1 << 0)
};

This fixes the inversion in the cluster match.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
14 years agoextensions: add extension for devgroup match
Patrick McHardy [Thu, 3 Feb 2011 05:10:41 +0000 (06:10 +0100)] 
extensions: add extension for devgroup match

Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoiptables: do not print trailing whitespaces
Jan Engelhardt [Sat, 18 Dec 2010 01:04:59 +0000 (02:04 +0100)] 
iptables: do not print trailing whitespaces

Due to the use of printf("foobar "), iptables emits spaces at the
end-of-line, which looks odd to some users because it causes the
terminal to wrap even if there is seemingly nothing to print.

It may also have other points of annoyance, such as mailers
interpreting a trailing space as an indicator that the paragraph
continues when format=flowed is also on.
And git highlights trailing spaces in red, so let's avoid :)

Preexisting inconsistencies in outputting spaces in the right
spot are also addressed right away.

References: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=429579
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: remove more redundant casts
Jan Engelhardt [Mon, 31 Jan 2011 01:41:23 +0000 (02:41 +0100)] 
iptables: remove more redundant casts

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: remove bogus address-of
Jan Engelhardt [Mon, 31 Jan 2011 01:39:46 +0000 (02:39 +0100)] 
iptables: remove bogus address-of

Casts are bad. &curtable is actually of type char (*)[], which is
quite different from what add_argv expects.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: warn when parameter limit is exceeded
Jan Engelhardt [Mon, 31 Jan 2011 01:34:49 +0000 (02:34 +0100)] 
iptables: warn when parameter limit is exceeded

While testing many match extensions in a single rule, I ran into this
error not warned about. Arguments were just ignored, causing
surprising "Need to specify an argument to --whatever" when the
argument was in fact given on the command line.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoxtables: set custom opts to NULL on free
Jan Engelhardt [Mon, 31 Jan 2011 01:33:43 +0000 (02:33 +0100)] 
xtables: set custom opts to NULL on free

When inside ip6tables-restore, xtables_free_opts can be called
multiple times, especially when trying to exit with an error message
from outside do_command. So set it to NULL so that we do not attempt
to free a dangling pointer.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_u32: enclose argument in quotes
Jan Engelhardt [Mon, 31 Jan 2011 00:43:20 +0000 (01:43 +0100)] 
libxt_u32: enclose argument in quotes

Otherwise ip6tables-save piped to ip6tables-restore can cause a parse
error when the expression list is empty.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: improve error reporting with extension loading troubles
Jan Engelhardt [Sun, 30 Jan 2011 13:18:17 +0000 (14:18 +0100)] 
iptables: improve error reporting with extension loading troubles

ip6tables v1.4.8: Could not load match "osf":
/usr/lib/xtables/libip6t_osf.so: cannot open shared object file: No
such file or directory

Given that libxt_osf.so exists, a better error is now emitted.

References: http://bugzilla.netfilter.org/show_bug.cgi?id=637
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_quota: clarifications on matching
Jan Engelhardt [Tue, 25 Jan 2011 17:31:16 +0000 (18:31 +0100)] 
libxt_quota: clarifications on matching

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoFix listing/saving the new revision of the SET target
Jozsef Kadlecsik [Fri, 21 Jan 2011 20:55:05 +0000 (21:55 +0100)] 
Fix listing/saving the new revision of the SET target

Instead of the dimension of the set, the max dimension was used at
listing/saving the src,dst parameters, which produced broken output.

14 years agolibxt_connlimit: remove duplicate member that caused size change
Jan Engelhardt [Thu, 20 Jan 2011 13:14:46 +0000 (14:14 +0100)] 
libxt_connlimit: remove duplicate member that caused size change

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoextensions: libxt_conntrack: add support for specifying port ranges
Patrick McHardy [Thu, 20 Jan 2011 10:45:12 +0000 (11:45 +0100)] 
extensions: libxt_conntrack: add support for specifying port ranges

Add support for revision 3 of the conntrack match, which allows to
specify port ranges for origsrc/origdst/replsrc/repldst.

Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoextensions: libxt_NFQUEUE: add v2 revision with --queue-bypass option
Florian Westphal [Thu, 20 Jan 2011 10:27:42 +0000 (11:27 +0100)] 
extensions: libxt_NFQUEUE: add v2 revision with --queue-bypass option

--queue-bypass: if no userpace program is listening on the queue, then
allow packets to continue through the ruleset instead of dropping them.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agolibxt_AUDIT: add AUDIT target
Thomas Graf [Thu, 20 Jan 2011 10:24:13 +0000 (11:24 +0100)] 
libxt_AUDIT: add AUDIT target

libxt module for the AUDIT target.

-j AUDIT --type (accept|reject|drop)

Signed-off-by: Thomas Graf <tgraf@redhat.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agolibxt_connlimit: support for dstaddr-supporting revision 1
Jan Engelhardt [Wed, 19 Jan 2011 01:09:39 +0000 (02:09 +0100)] 
libxt_connlimit: support for dstaddr-supporting revision 1

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_connlimit: add a --connlimit-upto option
Jan Engelhardt [Tue, 18 Jan 2011 17:04:57 +0000 (18:04 +0100)] 
libxt_connlimit: add a --connlimit-upto option

Direct specifications like "upto" are easier to grasp than "not
above". This patch adds such an upto variant similar to what
libxt_hashlimit already has.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_connlimit: reword help text to say prefix length
Jan Engelhardt [Tue, 18 Jan 2011 16:17:00 +0000 (17:17 +0100)] 
libxt_connlimit: reword help text to say prefix length

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_quota: print negation when it has been selected
Jan Engelhardt [Tue, 18 Jan 2011 10:02:04 +0000 (11:02 +0100)] 
libxt_quota: print negation when it has been selected

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoxtables: fix typo in error message of xtables_register_match()
Li Yewang [Sun, 9 Jan 2011 21:26:58 +0000 (22:26 +0100)] 
xtables: fix typo in error message of xtables_register_match()

Signed-off-by: Li Yewang <lyw@cn.fujitsu.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
14 years agolibxt_time: fix random --datestart skips
Florian Westphal [Sun, 9 Jan 2011 21:00:31 +0000 (22:00 +0100)] 
libxt_time: fix random --datestart skips

Frank Lichtenheld points out that -m time --datestart ...
sometimes messes up --datestart:

$ iptables -A INPUT -m time --datestart 2010-11-24T16:50:00 -j ACCEPT
$ iptables-save | grep 11
-A INPUT -m time --datestart 2010-11-24T16:50:00 -j ACCEPT
$ iptables-save | iptables-restore
$ iptables-save | grep 11
-A INPUT -m time --datestart 2010-11-24T15:50:00 -j ACCEPT

--datestart moved by one hour.

As the --timestart option does not care about DST, always set
dst=0 when parsing --starttime input.

Reported-by: Frank Lichtenheld <flichtenheld@astaro.com>
Signed-off-by: Florian Westphal <fwestphal@astaro.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
14 years agolibipt_REDIRECT: avoid dereference of uninitialized pointer
Stephen Beahm [Thu, 9 Dec 2010 11:15:50 +0000 (06:15 -0500)] 
libipt_REDIRECT: avoid dereference of uninitialized pointer

When using --to-ports with a port name instead of a numerical
specification, a segfault occurs.

References: http://bugzilla.netfilter.org/show_bug.cgi?id=691
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxtables: do some option structure checking
Jan Engelhardt [Sat, 8 Jan 2011 02:31:04 +0000 (03:31 +0100)] 
libxtables: do some option structure checking

libxt_recent's use of numeric values >200 always looked worrisome. Now
here is a validation routine for such.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibipt_CLUSTERIP: const annotations
Jan Engelhardt [Sat, 8 Jan 2011 02:16:51 +0000 (03:16 +0100)] 
libipt_CLUSTERIP: const annotations

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_sctp: fix a typo
Jan Engelhardt [Sat, 8 Jan 2011 02:16:14 +0000 (03:16 +0100)] 
libxt_sctp: fix a typo

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoextensions: remove no longer necessary default: cases
Jan Engelhardt [Sat, 8 Jan 2011 02:02:37 +0000 (03:02 +0100)] 
extensions: remove no longer necessary default: cases

Match and target parse functions now only get option characters they
have defined themselves.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoip[6]tables: only call target's parse function when option char is in range
Jan Engelhardt [Sat, 8 Jan 2011 01:47:02 +0000 (02:47 +0100)] 
ip[6]tables: only call target's parse function when option char is in range

Same as previous commit. Doing this actually allows to remove code
that is no longer needed.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoip[6]tables: only call match's parse function when option char is in range
Jan Engelhardt [Sat, 8 Jan 2011 01:25:28 +0000 (02:25 +0100)] 
ip[6]tables: only call match's parse function when option char is in range

Normally, extensions use a "default:" case in switch(c) to just return
if they do not handle c. Apparently, libip6t_hl does that too late and
checks for hl-specific parsing state before it has established that c
refers to one of its own options.

Also affected: libipt_ttl, libxt_ipvs, libxt_policy, libxt_statistic.

One way to fix this is to move the flags checks into case '2', '3',
'4'. Doing this replication feels bad, so as an alternative, let's
just free extensions from having to deal with other extension's
options passing thru.

References: http://marc.info/?l=netfilter-devel&m=129444759532377&w=2
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoxtables: reorder num_old substraction for clarity
Jan Engelhardt [Sat, 8 Jan 2011 01:10:52 +0000 (02:10 +0100)] 
xtables: reorder num_old substraction for clarity

When going over this again, I noticed we happen to malloc too much.
That is no problem, but I felt moving the num_old adjustment upwards
makes things more clear, and also addresses the allocation.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: abort on empty interface specification
Jan Engelhardt [Fri, 7 Jan 2011 11:26:59 +0000 (12:26 +0100)] 
iptables: abort on empty interface specification

Fiedler Roman brings to attention that if, in a faulty script,
"$some_variable" expands to an empty string, iptables should probably
catch this most likely undesired invocation. If no/all interfaces were
really desired, one can either omit -i completely, or use -i +.

References: http://marc.info/?l=netfilter&m=129439862903487&w=2
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosrc: use C99/POSIX types
Jan Engelhardt [Fri, 7 Jan 2011 11:34:04 +0000 (12:34 +0100)] 
src: use C99/POSIX types

"u_int" was a non-standardized extension predating C99 on some platforms.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoxt_comment: remove redundant cast
Jan Engelhardt [Sun, 26 Dec 2010 09:31:03 +0000 (10:31 +0100)] 
xt_comment: remove redundant cast

14 years agosrc: const annotations
Jan Engelhardt [Sat, 18 Dec 2010 00:40:04 +0000 (01:40 +0100)] 
src: const annotations

Also one int -> uint here on the way through.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables-restore: resolve confusing policy error message
Rob Leslie [Tue, 28 Sep 2010 07:43:00 +0000 (00:43 -0700)] 
iptables-restore: resolve confusing policy error message

When iptables-restore (and ip6tables-restore) is unable to set a
chain's policy, it responds with a confusing message, e.g.:

iptables-restore v1.4.9: Can't set policy "PREROUTING" on "ACCEPT"
line 16: Bad built-in chain name

This is due to the chain and policy arguments being used in the wrong
order. The attached patch corrects this problem.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoMerge branch 'master' of git://dev.medozas.de/iptables
Patrick McHardy [Wed, 15 Dec 2010 22:36:19 +0000 (23:36 +0100)] 
Merge branch 'master' of git://dev.medozas.de/iptables

14 years agobuild: stop on error in subcommand
Jan Engelhardt [Sat, 11 Dec 2010 02:35:48 +0000 (03:35 +0100)] 
build: stop on error in subcommand

make only evaluates $? of an entire shell invocation. As such, if any
command in the chain can fail, $? needs to be thrown, and early so.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoMerge commit 'v1.4.10'
Jan Engelhardt [Mon, 6 Dec 2010 12:44:03 +0000 (13:44 +0100)] 
Merge commit 'v1.4.10'

14 years agolibxt_owner: output numeric IDs when save is requested
Jan Engelhardt [Mon, 6 Dec 2010 12:32:58 +0000 (13:32 +0100)] 
libxt_owner: output numeric IDs when save is requested

References: http://bugzilla.netfilter.org/show_bug.cgi?id=683
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agobuild: fix globbing of extensions in other locales
Jan Engelhardt [Sat, 4 Dec 2010 01:53:20 +0000 (02:53 +0100)] 
build: fix globbing of extensions in other locales

In the fi_FI locale, [a-z] would not include 'w', for example. Rectify
this by using [[:alnum:]] (to counter against different ordering) and
forcing the POSIX locale (so that the alphabet has at least the 26
base characters).

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agosocket: add support for revision 1
Jan Engelhardt [Fri, 3 Dec 2010 21:55:34 +0000 (22:55 +0100)] 
socket: add support for revision 1

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoTPROXY: add support for revision 1
Jan Engelhardt [Fri, 3 Dec 2010 21:08:32 +0000 (22:08 +0100)] 
TPROXY: add support for revision 1

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoinclude: update files with headers from Linux 2.6.37-rc1
Jan Engelhardt [Fri, 3 Dec 2010 19:15:35 +0000 (20:15 +0100)] 
include: update files with headers from Linux 2.6.37-rc1

Also includes the type change to __u{8,16,32} kernel types already.

14 years agoiptables: do not emit orig_opts twice
Jan Engelhardt [Sun, 28 Nov 2010 14:42:00 +0000 (15:42 +0100)] 
iptables: do not emit orig_opts twice

This just happened to cross my eye; there was no error, but fixing
this up saves a pitfall, and some memory.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agoiptables: reset options at the start of each command
Jan Engelhardt [Sun, 28 Nov 2010 14:35:06 +0000 (15:35 +0100)] 
iptables: reset options at the start of each command

For each new command, iptables is supposed to start afresh with a
blank option set (opts) that only contains the program-specific
options (orig_opts), without any extension options. We failed to
restore this pointer (in function do_command) after the previous free
call in xtables_free_opts.

Reported-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
14 years agolibxt_conntrack: fix --ctdir save/dump output format
Florian Westphal [Wed, 17 Nov 2010 14:54:18 +0000 (15:54 +0100)] 
libxt_conntrack: fix --ctdir save/dump output format

$ iptables-save | iptables-restore
iptables-restore v1.4.6: conntrack: Bad value for "--ctdir" option: "ORIGINAL-j"

Signed-off-by: Florian Westphal <fwestphal@astaro.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
14 years agoMerge branch 'master' of git://dev.medozas.de/iptables into m2
Jan Engelhardt [Mon, 15 Nov 2010 13:39:50 +0000 (14:39 +0100)] 
Merge branch 'master' of git://dev.medozas.de/iptables into m2