From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 1/3] iptables: take masks into consideration for replace command
Date: Tue, 24 Nov 2009 16:07:32 +0100 [thread overview]
Message-ID: <1259075255-25781-2-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1259075255-25781-1-git-send-email-jengelh@medozas.de>
The two commands:
-A OUPUT -d 10.11.12.13/32 -j LOG
-R OUTPUT 1 -j LOG -d 10.11.12.13
will replace 10.11.12.13/32 by 10.11.12.13/0, which is not right.
(No regression, this problem was there forever.)
Reported-by: Werner Pawlitschko <werner.pawlitschko@arcor.de>
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
ip6tables.c | 10 ++++++----
iptables.c | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/ip6tables.c b/ip6tables.c
index f6daa51..e2359df 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -758,13 +758,15 @@ static int
replace_entry(const ip6t_chainlabel chain,
struct ip6t_entry *fw,
unsigned int rulenum,
- const struct in6_addr *saddr,
- const struct in6_addr *daddr,
+ const struct in6_addr *saddr, const struct in6_addr *smask,
+ const struct in6_addr *daddr, const struct in6_addr *dmask,
int verbose,
struct ip6tc_handle *handle)
{
fw->ipv6.src = *saddr;
fw->ipv6.dst = *daddr;
+ fw->ipv6.smsk = *smask;
+ fw->ipv6.dmsk = *dmask;
if (verbose)
print_firewall_line(fw, handle);
@@ -1947,8 +1949,8 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
break;
case CMD_REPLACE:
ret = replace_entry(chain, e, rulenum - 1,
- saddrs, daddrs, options&OPT_VERBOSE,
- *handle);
+ saddrs, smasks, daddrs, dmasks,
+ options&OPT_VERBOSE, *handle);
break;
case CMD_INSERT:
ret = insert_entry(chain, e, rulenum - 1,
diff --git a/iptables.c b/iptables.c
index a69aab3..08eb134 100644
--- a/iptables.c
+++ b/iptables.c
@@ -760,13 +760,15 @@ static int
replace_entry(const ipt_chainlabel chain,
struct ipt_entry *fw,
unsigned int rulenum,
- const struct in_addr *saddr,
- const struct in_addr *daddr,
+ const struct in_addr *saddr, const struct in_addr *smask,
+ const struct in_addr *daddr, const struct in_addr *dmask,
int verbose,
struct iptc_handle *handle)
{
fw->ip.src.s_addr = saddr->s_addr;
fw->ip.dst.s_addr = daddr->s_addr;
+ fw->ip.smsk.s_addr = smask->s_addr;
+ fw->ip.dmsk.s_addr = dmask->s_addr;
if (verbose)
print_firewall_line(fw, handle);
@@ -1988,8 +1990,8 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
break;
case CMD_REPLACE:
ret = replace_entry(chain, e, rulenum - 1,
- saddrs, daddrs, options&OPT_VERBOSE,
- *handle);
+ saddrs, smasks, daddrs, dmasks,
+ options&OPT_VERBOSE, *handle);
break;
case CMD_INSERT:
ret = insert_entry(chain, e, rulenum - 1,
--
1.6.5.2
next prev parent reply other threads:[~2009-11-24 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-24 15:07 next iptables release Jan Engelhardt
2009-11-24 15:07 ` Jan Engelhardt [this message]
2009-11-24 15:07 ` [PATCH 2/3] doc: explain experienced --hitcount limit Jan Engelhardt
2009-11-24 15:07 ` [PATCH 3/3] doc: name resolution clarification Jan Engelhardt
2009-11-24 15:13 ` next iptables release Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259075255-25781-2-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).