* iptables: SAME, -p 0, libiptc pkgconfig
@ 2011-12-18 2:06 Jan Engelhardt
2011-12-18 2:06 ` [PATCH 1/3] libipt_SAME: set PROTO_RANDOM on all ranges Jan Engelhardt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-12-18 2:06 UTC (permalink / raw)
To: netfilter-devel
The following changes since commit 79ddbf202a06e6f018e087a328c2ca91e65a8463:
libxt_recent: Add support for --reap option (2011-12-09 05:11:45 +0100)
are available in the git repository at:
git://dev.medozas.de/iptables stable -> stable
Jan Engelhardt (3):
libipt_SAME: set PROTO_RANDOM on all ranges
doc: clarification on the meaning of -p 0
libiptc: provide separate pkgconfig files
configure.ac | 4 +++-
extensions/libipt_DNAT.c | 17 ++++++++++-------
extensions/libipt_SAME.c | 24 ++++++++++++++----------
extensions/libipt_SNAT.c | 17 ++++++++++-------
iptables/ip6tables.8.in | 16 ++++++++++++----
iptables/iptables.8.in | 10 +++++++---
libiptc/.gitignore | 2 +-
libiptc/Makefile.am | 2 +-
libiptc/libip4tc.pc.in | 10 ++++++++++
libiptc/libip6tc.pc.in | 10 ++++++++++
libiptc/libiptc.pc.in | 6 ++----
11 files changed, 80 insertions(+), 38 deletions(-)
create mode 100644 libiptc/libip4tc.pc.in
create mode 100644 libiptc/libip6tc.pc.in
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] libipt_SAME: set PROTO_RANDOM on all ranges
2011-12-18 2:06 iptables: SAME, -p 0, libiptc pkgconfig Jan Engelhardt
@ 2011-12-18 2:06 ` Jan Engelhardt
2011-12-18 2:06 ` [PATCH 2/3] doc: clarification on the meaning of -p 0 Jan Engelhardt
2011-12-18 2:06 ` [PATCH 3/3] libiptc: provide separate pkgconfig files Jan Engelhardt
2 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-12-18 2:06 UTC (permalink / raw)
To: netfilter-devel
Resolve the (justified) WTF remark to a clearer version of when/why
PROTO_RANDOM needs to be set.
Especially when --random is used before --to in SAME, it would have
not been appleid.
---
extensions/libipt_DNAT.c | 17 ++++++++++-------
extensions/libipt_SAME.c | 24 ++++++++++++++----------
extensions/libipt_SNAT.c | 17 ++++++++++-------
3 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/extensions/libipt_DNAT.c b/extensions/libipt_DNAT.c
index 3b55c69..466c9de 100644
--- a/extensions/libipt_DNAT.c
+++ b/extensions/libipt_DNAT.c
@@ -174,21 +174,23 @@ static void DNAT_parse(struct xt_option_call *cb)
"DNAT: Multiple --to-destination not supported");
}
*cb->target = parse_to(cb->arg, portok, info);
- /* WTF do we need this for?? */
- if (cb->xflags & F_RANDOM)
- info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
cb->xflags |= F_X_TO_DEST;
break;
- case O_RANDOM:
- if (cb->xflags & F_TO_DEST)
- info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
- break;
case O_PERSISTENT:
info->mr.range[0].flags |= IP_NAT_RANGE_PERSISTENT;
break;
}
}
+static void DNAT_fcheck(struct xt_fcheck_call *cb)
+{
+ static const unsigned int f = F_TO_DEST | F_RANDOM;
+ struct nf_nat_multi_range *mr = cb->data;
+
+ if ((cb->xflags & f) == f)
+ mr->range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
+}
+
static void print_range(const struct nf_nat_range *r)
{
if (r->flags & IP_NAT_RANGE_MAP_IPS) {
@@ -248,6 +250,7 @@ static struct xtables_target dnat_tg_reg = {
.userspacesize = XT_ALIGN(sizeof(struct nf_nat_multi_range)),
.help = DNAT_help,
.x6_parse = DNAT_parse,
+ .x6_fcheck = DNAT_fcheck,
.print = DNAT_print,
.save = DNAT_save,
.x6_options = DNAT_opts,
diff --git a/extensions/libipt_SAME.c b/extensions/libipt_SAME.c
index 2ff6c82..e603ef6 100644
--- a/extensions/libipt_SAME.c
+++ b/extensions/libipt_SAME.c
@@ -9,7 +9,8 @@ enum {
O_TO_ADDR = 0,
O_NODST,
O_RANDOM,
- F_RANDOM = 1 << O_RANDOM,
+ F_TO_ADDR = 1 << O_TO_ADDR,
+ F_RANDOM = 1 << O_RANDOM,
};
static void SAME_help(void)
@@ -73,7 +74,6 @@ static void parse_to(const char *orig_arg, struct nf_nat_range *range)
static void SAME_parse(struct xt_option_call *cb)
{
struct ipt_same_info *mr = cb->data;
- unsigned int count;
xtables_option_parse(cb);
switch (cb->entry->id) {
@@ -84,22 +84,25 @@ static void SAME_parse(struct xt_option_call *cb)
"is %i ranges.\n",
IPT_SAME_MAX_RANGE);
parse_to(cb->arg, &mr->range[mr->rangesize]);
- /* WTF do we need this for? */
- if (cb->xflags & F_RANDOM)
- mr->range[mr->rangesize].flags
- |= IP_NAT_RANGE_PROTO_RANDOM;
mr->rangesize++;
break;
case O_NODST:
mr->info |= IPT_SAME_NODST;
break;
- case O_RANDOM:
- for (count=0; count < mr->rangesize; count++)
- mr->range[count].flags |= IP_NAT_RANGE_PROTO_RANDOM;
- break;
}
}
+static void SAME_fcheck(struct xt_fcheck_call *cb)
+{
+ static const unsigned int f = F_TO_ADDR | F_RANDOM;
+ struct ipt_same_info *mr = cb->data;
+ unsigned int count;
+
+ if ((cb->xflags & f) == f)
+ for (count = 0; count < mr->rangesize; ++count)
+ mr->range[count].flags |= IP_NAT_RANGE_PROTO_RANDOM;
+}
+
static void SAME_print(const void *ip, const struct xt_entry_target *target,
int numeric)
{
@@ -166,6 +169,7 @@ static struct xtables_target same_tg_reg = {
.userspacesize = XT_ALIGN(sizeof(struct ipt_same_info)),
.help = SAME_help,
.x6_parse = SAME_parse,
+ .x6_fcheck = SAME_fcheck,
.print = SAME_print,
.save = SAME_save,
.x6_options = SAME_opts,
diff --git a/extensions/libipt_SNAT.c b/extensions/libipt_SNAT.c
index 8023306..c8cb26d 100644
--- a/extensions/libipt_SNAT.c
+++ b/extensions/libipt_SNAT.c
@@ -174,21 +174,23 @@ static void SNAT_parse(struct xt_option_call *cb)
"SNAT: Multiple --to-source not supported");
}
*cb->target = parse_to(cb->arg, portok, info);
- /* WTF do we need this for?? */
- if (cb->xflags & F_RANDOM)
- info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
cb->xflags |= F_X_TO_SRC;
break;
- case O_RANDOM:
- if (cb->xflags & F_TO_SRC)
- info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
- break;
case O_PERSISTENT:
info->mr.range[0].flags |= IP_NAT_RANGE_PERSISTENT;
break;
}
}
+static void SNAT_fcheck(struct xt_fcheck_call *cb)
+{
+ static const unsigned int f = F_TO_SRC | F_RANDOM;
+ struct nf_nat_multi_range *mr = cb->data;
+
+ if ((cb->xflags & f) == f)
+ mr->range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
+}
+
static void print_range(const struct nf_nat_range *r)
{
if (r->flags & IP_NAT_RANGE_MAP_IPS) {
@@ -248,6 +250,7 @@ static struct xtables_target snat_tg_reg = {
.userspacesize = XT_ALIGN(sizeof(struct nf_nat_multi_range)),
.help = SNAT_help,
.x6_parse = SNAT_parse,
+ .x6_fcheck = SNAT_fcheck,
.print = SNAT_print,
.save = SNAT_save,
.x6_options = SNAT_opts,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] doc: clarification on the meaning of -p 0
2011-12-18 2:06 iptables: SAME, -p 0, libiptc pkgconfig Jan Engelhardt
2011-12-18 2:06 ` [PATCH 1/3] libipt_SAME: set PROTO_RANDOM on all ranges Jan Engelhardt
@ 2011-12-18 2:06 ` Jan Engelhardt
2011-12-18 2:06 ` [PATCH 3/3] libiptc: provide separate pkgconfig files Jan Engelhardt
2 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-12-18 2:06 UTC (permalink / raw)
To: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
iptables/ip6tables.8.in | 16 ++++++++++++----
iptables/iptables.8.in | 10 +++++++---
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/iptables/ip6tables.8.in b/iptables/ip6tables.8.in
index 748cebb..65f3864 100644
--- a/iptables/ip6tables.8.in
+++ b/iptables/ip6tables.8.in
@@ -250,7 +250,11 @@ But IPv6 extension headers except \fBesp\fP are not allowed.
\fBesp\fP and \fBipv6\-nonext\fP
can be used with Kernel version 2.6.11 or later.
A "!" argument before the protocol inverts the
-test. The number zero is equivalent to \fBall\fP. "\fBall\fP"
+test. The number zero is equivalent to \fBall\fP, which means that you cannot
+test the protocol field for the value 0 directly. To match on a HBH header,
+even if it were the last, you cannot use \fB\-p 0\fP, but always need
+\fB\-m hbh\fP.
+"\fBall\fP"
will match with all protocols and is taken as default when this
option is omitted.
.TP
@@ -357,15 +361,19 @@ corresponding to that rule's position in the chain.
When adding or inserting rules into a chain, use \fIcommand\fP
to load any necessary modules (targets, match extensions, etc).
.SH MATCH EXTENSIONS
-ip6tables can use extended packet matching modules. These are loaded
-in two ways: implicitly, when \fB\-p\fP or \fB\-\-protocol\fP
-is specified, or with the \fB\-m\fP or \fB\-\-match\fP
+.PP
+ip6tables can use extended packet matching modules
+with the \fB\-m\fP or \fB\-\-match\fP
options, followed by the matching module name; after these, various
extra command line options become available, depending on the specific
module. You can specify multiple extended match modules in one line,
and you can use the \fB\-h\fP or \fB\-\-help\fP
options after the module has been specified to receive help specific
to that module.
+.PP
+If the \fB\-p\fP or \fB\-\-protocol\fP was specified and if and only if an
+unknown option is encountered, ip6tables will try load a match module of the
+same name as the protocol, to try making the option available.
.\" @MATCH@
.SH TARGET EXTENSIONS
ip6tables can use extended target modules: the following are included
diff --git a/iptables/iptables.8.in b/iptables/iptables.8.in
index 24618b7..59d6e04 100644
--- a/iptables/iptables.8.in
+++ b/iptables/iptables.8.in
@@ -356,15 +356,19 @@ corresponding to that rule's position in the chain.
When adding or inserting rules into a chain, use \fIcommand\fP
to load any necessary modules (targets, match extensions, etc).
.SH MATCH EXTENSIONS
-iptables can use extended packet matching modules. These are loaded
-in two ways: implicitly, when \fB\-p\fP or \fB\-\-protocol\fP
-is specified, or with the \fB\-m\fP or \fB\-\-match\fP
+.PP
+iptables can use extended packet matching modules
+with the \fB\-m\fP or \fB\-\-match\fP
options, followed by the matching module name; after these, various
extra command line options become available, depending on the specific
module. You can specify multiple extended match modules in one line,
and you can use the \fB\-h\fP or \fB\-\-help\fP
options after the module has been specified to receive help specific
to that module.
+.PP
+If the \fB\-p\fP or \fB\-\-protocol\fP was specified and if and only if an
+unknown option is encountered, iptables will try load a match module of the
+same name as the protocol, to try making the option available.
.\" @MATCH@
.SH TARGET EXTENSIONS
iptables can use extended target modules: the following are included
--
1.7.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] libiptc: provide separate pkgconfig files
2011-12-18 2:06 iptables: SAME, -p 0, libiptc pkgconfig Jan Engelhardt
2011-12-18 2:06 ` [PATCH 1/3] libipt_SAME: set PROTO_RANDOM on all ranges Jan Engelhardt
2011-12-18 2:06 ` [PATCH 2/3] doc: clarification on the meaning of -p 0 Jan Engelhardt
@ 2011-12-18 2:06 ` Jan Engelhardt
2 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2011-12-18 2:06 UTC (permalink / raw)
To: netfilter-devel
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
configure.ac | 4 +++-
libiptc/.gitignore | 2 +-
libiptc/Makefile.am | 2 +-
libiptc/libip4tc.pc.in | 10 ++++++++++
libiptc/libip6tc.pc.in | 10 ++++++++++
libiptc/libiptc.pc.in | 6 ++----
6 files changed, 27 insertions(+), 7 deletions(-)
create mode 100644 libiptc/libip4tc.pc.in
create mode 100644 libiptc/libip6tc.pc.in
diff --git a/configure.ac b/configure.ac
index 8afba8c..298d551 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,6 +112,8 @@ AC_SUBST([libxtables_vmajor])
AC_CONFIG_FILES([Makefile extensions/GNUmakefile include/Makefile
iptables/Makefile iptables/xtables.pc
libipq/Makefile libipq/libipq.pc
- libiptc/Makefile libiptc/libiptc.pc libxtables/Makefile utils/Makefile
+ libiptc/Makefile libiptc/libiptc.pc
+ libiptc/libip4tc.pc libiptc/libip6tc.pc
+ libxtables/Makefile utils/Makefile
include/xtables.h include/iptables/internal.h])
AC_OUTPUT
diff --git a/libiptc/.gitignore b/libiptc/.gitignore
index 8767550..49ca83d 100644
--- a/libiptc/.gitignore
+++ b/libiptc/.gitignore
@@ -1 +1 @@
-/libiptc.pc
+/*.pc
diff --git a/libiptc/Makefile.am b/libiptc/Makefile.am
index 22c920f..c170cb2 100644
--- a/libiptc/Makefile.am
+++ b/libiptc/Makefile.am
@@ -3,7 +3,7 @@
AM_CFLAGS = ${regular_CFLAGS}
AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include -I${top_srcdir}/include ${kinclude_CPPFLAGS}
-pkgconfig_DATA = libiptc.pc
+pkgconfig_DATA = libiptc.pc libip4tc.pc libip6tc.pc
lib_LTLIBRARIES = libip4tc.la libip6tc.la libiptc.la
libiptc_la_SOURCES =
diff --git a/libiptc/libip4tc.pc.in b/libiptc/libip4tc.pc.in
new file mode 100644
index 0000000..5efa1ca
--- /dev/null
+++ b/libiptc/libip4tc.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libip4tc
+Description: iptables IPv4 ruleset ADT and kernel interface
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lip4tc
+Cflags: -I${includedir}
diff --git a/libiptc/libip6tc.pc.in b/libiptc/libip6tc.pc.in
new file mode 100644
index 0000000..30a61b2
--- /dev/null
+++ b/libiptc/libip6tc.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libip6tc
+Description: iptables IPv6 ruleset ADT and kernel interface
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lip6tc
+Cflags: -I${includedir}
diff --git a/libiptc/libiptc.pc.in b/libiptc/libiptc.pc.in
index 99a3544..0264bf0 100644
--- a/libiptc/libiptc.pc.in
+++ b/libiptc/libiptc.pc.in
@@ -5,8 +5,6 @@ libdir=@libdir@
includedir=@includedir@
Name: libiptc
-Description: iptables ruleset ADT and kernel interface
+Description: iptables v4/v6 ruleset ADT and kernel interface
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -liptc
-Libs.private: -lip4tc -lip6tc
-Cflags: -I${includedir}
+Requires: libip4tc libip6tc
--
1.7.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-18 2:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-18 2:06 iptables: SAME, -p 0, libiptc pkgconfig Jan Engelhardt
2011-12-18 2:06 ` [PATCH 1/3] libipt_SAME: set PROTO_RANDOM on all ranges Jan Engelhardt
2011-12-18 2:06 ` [PATCH 2/3] doc: clarification on the meaning of -p 0 Jan Engelhardt
2011-12-18 2:06 ` [PATCH 3/3] libiptc: provide separate pkgconfig files Jan Engelhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).