From 75cb763b54a89bf9b9c61740c760abce89df06f3 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sun, 15 Nov 2009 15:51:27 +0100 Subject: iptables: take masks into consideration for replace command 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 Signed-off-by: Jan Engelhardt --- ip6tables.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ip6tables.c') diff --git a/ip6tables.c b/ip6tables.c index f6daa51c..e2359dfe 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, -- cgit v1.2.3