netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 5/5] netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths
Date: Thu,  4 Apr 2013 14:56:09 +0200	[thread overview]
Message-ID: <1365080169-6880-6-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1365080169-6880-1-git-send-email-pablo@netfilter.org>

From: Matthias Schiffer <mschiffer@universe-factory.net>

The bitmask used for the prefix mangling was being calculated
incorrectly, leading to the wrong part of the address being replaced
when the prefix length wasn't a multiple of 32.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/ipv6/netfilter/ip6t_NPT.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
index 33608c6..cb63114 100644
--- a/net/ipv6/netfilter/ip6t_NPT.c
+++ b/net/ipv6/netfilter/ip6t_NPT.c
@@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
 		if (pfx_len - i >= 32)
 			mask = 0;
 		else
-			mask = htonl(~((1 << (pfx_len - i)) - 1));
+			mask = htonl((1 << (i - pfx_len + 32)) - 1);
 
 		idx = i / 32;
 		addr->s6_addr32[idx] &= mask;
-- 
1.7.10.4

  parent reply	other threads:[~2013-04-04 12:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04 12:56 [PATCH 0/5] netfilter updates for net Pablo Neira Ayuso
2013-04-04 12:56 ` [PATCH 1/5] netfilter: reset nf_trace in nf_reset Pablo Neira Ayuso
2013-04-04 12:56 ` [PATCH 2/5] netfilter: nfnetlink_queue: fix error return code in nfnetlink_queue_init() Pablo Neira Ayuso
2013-04-04 12:56 ` [PATCH 3/5] netfilter: nfnetlink_acct: return -EINVAL if object name is empty Pablo Neira Ayuso
2013-04-04 12:56 ` [PATCH 4/5] netfilter: nf_conntrack: fix error return code Pablo Neira Ayuso
2013-04-04 12:56 ` Pablo Neira Ayuso [this message]
2013-04-04 21:42 ` [PATCH 0/5] netfilter updates for net David Miller

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=1365080169-6880-6-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --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).