Skip to contentSkip to conversation

Announcement: MAP66 extension for ip6tables

DISCUSSION Sven-Ola Tuecke 3 participants 12 messages Oct 6, 2010 – Oct 7, 2010 netfilter

lore
Share & tools
lore
#1 lore raw
Quoted 2 lines · Sven-Ola Tuecke

Re: Announcement: MAP66 extension for ip6tables

For a moment that read like a Doom2 extension... ;-)

Quoted 10 lines

Hey,

FYI: just finished the readme for a netfilter IPv6-to-IPv6 address mapping target - time to say hello. Netfilter extension should compile from iptables-1.3.3++ and the kernel module with kernel-2.4.30 until kernel-2.6.32. Extension module status is beta, that is: a first test installation works fine. License is GPL2. Project and Readme are here:

http://map66.sf.net
http://map66.svn.sourceforge.net/viewvc/map66/README.html

And.. I take it you want a review?

- NAT, even if NAT66, still interferes with ETE connectivity. Think FTP-SSL connections. That may not be your problem, but it's the Working Group's and the Draft's.

- I would recommend using Xtables-addons to unclutter the source code from the #ifdef hackery. Most if it can be removed, since it does not look like you tested with Linux kernels earlier than 2.6.22 anyway.

- Conntrack will be confused because you change the packets' addresses while packets are in conntrack's domain. (In essence it will lead to state matching being nonfunctional if I am not mistaken because it sees two different tuples.)

- There are pointless casts from/to void*

- You should document what MAP66_lock is protecting.

#2 lore raw

Hi Jan,

Am Mittwoch, 6. Oktober 2010, um 20:01:11 schrieb Jan Engelhardt:

[...snip...]

Quoted 1 line

And.. I take it you want a review?

No - I'm only interested in a working solution. Of course, I take what I can get to make it better if required.

Quoted 3 lines

- NAT, even if NAT66, still interferes with ETE connectivity. Think FTP-SSL connections. That may not be your problem, but it's the Working Group's and the Draft's.

Yes - there are protocols that rely on addresses such as SIP, active FTP etc. I don't plan to add NAT helpers for them, thats pointless somehow.

Quoted 8 lines

- I would recommend using Xtables-addons to unclutter the source code from the #ifdef hackery. Most if it can be removed, since it does not look like you tested with Linux kernels earlier than 2.6.22 anyway.

- Conntrack will be confused because you change the packets' addresses while packets are in conntrack's domain. (In essence it will lead to state matching being nonfunctional if I am not mistaken because it sees two different tuples.)

Aha. Thanks for the tips. I'll try to dive in. This is my first netfilter addon and I don't think I'll write another in this live.

Quoted 1 line

- There are pointless casts from/to void*

That's for kernel-2.4: The target firmware uses that old kernel for Flash space reasons. Only 1.75 Mb Flash and 8 Mb RAM.

Quoted 1 line

- You should document what MAP66_lock is protecting.

OK. They lock printk()s on SMP. Unnecessary without #DEBUG

Again, thank you very much,
// Sven-Ola

#3 lore raw
Quoted 12 lines · Sven-Ola Tuecke

Hi Jan,

Am Mittwoch, 6. Oktober 2010, um 20:01:11 schrieb Jan Engelhardt:

[...snip...]

Quoted 1 line

And.. I take it you want a review?

No - I'm only interested in a working solution. Of course, I take what I can
get to make it better if required.

Quoted 7 lines
Quoted 3 lines

- NAT, even if NAT66, still interferes with ETE connectivity. Think FTP-SSL connections. That may not be your problem, but it's the Working Group's and the Draft's.

Yes - there are protocols that rely on addresses such as SIP, active FTP etc.
I don't plan to add NAT helpers for them, thats pointless somehow.

FWIW: FTP EPSV/EPRT extensions remove the need for layer-7 IPs and work with NAT44 and NAT66 nicely where the firewall supports them.

Quoted 3 lines
Quoted 1 line

- There are pointless casts from/to void*

That's for kernel-2.4: The target firmware uses that old kernel for

Flash

Quoted 3 lines

space
reasons. Only 1.75 Mb Flash and 8 Mb RAM.

Are there really working IPv6-enabled 2.4 kernels in use?

Quoted 6 lines
Quoted 1 line

- You should document what MAP66_lock is protecting.

OK. They lock printk()s on SMP. Unnecessary without #DEBUG

Again, thank you very much,
// Sven-Ola

NAT66 is designed to work stateless AFAICT. As such the mapping likely does not need conntrack at all.

Is there perhapse some way to only configure the map once but have it apply to both src and dst depending on the packet direction?

Why is /128 not allowed? that would be extremely useful for roaming devices internal firewalls and high-security setups with multi-homing.

AYJ

#4 lore raw

Good morning Amos,

Am Donnerstag, 7. Oktober 2010, um 02:13:58 schrieb Amos Jeffries:

[snip]

Quoted 4 lines
Quoted 1 line

I don't plan to add NAT helpers for them, thats pointless somehow.

FWIW: FTP EPSV/EPRT extensions remove the need for layer-7 IPs and work with NAT44 and NAT66 nicely where the firewall supports them.

Scanned RFC2428 for this. The EPRT command needs an address mapping helper because it communicates the lower address within the high level application proto. Opening a new connection from server to client will be blocked by most stateful FWs anyhow. I woud say: old & bad design now compatible with a new protocol. Nothing to worry about - anybody will use EPSV <grin>

[snap]

Quoted 4 lines
Quoted 2 lines

space
reasons. Only 1.75 Mb Flash and 8 Mb RAM.

Are there really working IPv6-enabled 2.4 kernels in use?

Yes. The Broadcom router reference design was adopted by a dozen manufacturers. Besides space limitations, there is a binary-only WLAN driver module that forces the use of Linux-2.4. Embedded devices need some years to die and (with the help of the opensourced "OpenWrt") I woud say that there are 10^7 devices around. IPv6 stack is basically working with the drawback that some things are un-implemented (e.g. IP6IP6 tunnel is a no-no)

[snup]

Quoted 10 lines

NAT66 is designed to work stateless AFAICT. As such the mapping likely does not need conntrack at all.

Is there perhapse some way to only configure the map once but have it apply to both src and dst depending on the packet direction?

Why is /128 not allowed? that would be extremely useful for roaming devices internal firewalls and high-security setups with multi-homing.

AYJ

As Jan pointed out: copy of the addresses may be stored elsewhere in the form of hash keys. At least, I will place a warning in the docs and check for oopses if conntrack is active. You think about a single rule either in POSTROUTING or PREROUTING. May overcome above conntrack hash prob... Good point - I place it on the TODO.

/128? No. To keep checksum neutrality you need to balance the address change with some other bits in the header. Which requires a network range on the resulting addresses by design. I would also recommend mobile IPv6 for roaming and such.

While I mentioned "TODO": I plan to add a "---salt" option for the mapping. Why? Because IPv6 privacy extensions (aka use_tempaddr) hide the EUI48/64 to the outside. This may not be appliable in some environments. Adding a MAP66 fromIPv6 -> sameIPv6 XOR salt pattern on the border router may be of help here. At least if you change --salt over time.

// Sven-Ola

#5 lore raw
Quoted 8 lines · Sven-Ola Tuecke
Quoted 4 lines
Quoted 2 lines

space
reasons. Only 1.75 Mb Flash and 8 Mb RAM.

Are there really working IPv6-enabled 2.4 kernels in use?

Yes. The Broadcom router reference design was adopted by a dozen manufacturers. Besides space limitations, there is a binary-only WLAN driver module that forces the use of Linux-2.4.

1.75 MB sounds like an older model, however, that "linux 2.4 use forced" statement is bogus for WRT54GL (4MB Flash) since at least openwrt 8.09/Linux 2.6.25.

Quoted 5 lines

As Jan pointed out: copy of the addresses may be stored elsewhere in the form of hash keys. At least, I will place a warning in the docs and check for oopses if conntrack is active. You think about a single rule either in POSTROUTING or PREROUTING. May overcome above conntrack hash prob... Good point - I place it on the TODO.

RAWS/DNAT in Xtables-addons has this solved by using the raw and rawpost tables.

#6 lore raw

Hi Jan,

Am Donnerstag, 7. Oktober 2010, um 09:16:59 schrieben Sie:

Quoted 3 lines

1.75 MB sounds like an older model, however, that "linux 2.4 use forced" statement is bogus for WRT54GL (4MB Flash) since at least openwrt 8.09/Linux 2.6.25.

Yep, e.g. WAP54Gv2/v3. Only 2.4 Watt. And no: OpenWrt Backfire still supports a brcm-2.4 target. You can use 2.6, but the opensourced WLAN driver does not work well. You loose e.g. IBSS, AP mode, distance setting and (more criticial) stability. Maybe the latest Broadcom code-drop may solve this but I don't expect this to show up in 2010...

Quoted 9 lines
Quoted 6 lines

As Jan pointed out: copy of the addresses may be stored elsewhere in the form of hash keys. At least, I will place a warning in the docs and check for oopses if conntrack is active. You think about a single rule either in POSTROUTING or PREROUTING. May overcome above conntrack hash prob... Good point - I place it on the TODO.

RAWS/DNAT in Xtables-addons has this solved by using the raw and rawpost tables.

No RAW table in 2.4 AFAICT. But a good hint, I'll check that. As a first measure I placed a big fat warning at the start of the readme. Ref:

http://map66.svn.sourceforge.net/viewvc/map66/README.html

// Sven-Ola

#7 lore raw
Quoted 10 lines · Sven-Ola Tuecke

Am Donnerstag, 7. Oktober 2010, um 09:16:59 schrieben Sie:

Quoted 3 lines

1.75 MB sounds like an older model, however, that "linux 2.4 use forced" statement is bogus for WRT54GL (4MB Flash) since at least openwrt 8.09/Linux 2.6.25.

Yep, e.g. WAP54Gv2/v3. Only 2.4 Watt. And no: OpenWrt Backfire still supports a brcm-2.4 target. You can use 2.6, but the opensourced WLAN driver does not work well. You loose e.g. IBSS, AP mode, distance setting and (more criticial) stability.

Can't say. It does work well enough here. Sometimes I indeed lose the AP association, but that's probably because I have a long distance of ~60-80 freeland meters to the AP. It is easily remedied by calling iwconfig in a loop. Works now for over 1 3/4 years already.

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

As Jan pointed out: copy of the addresses may be stored elsewhere in the form of hash keys. At least, I will place a warning in the docs and check for oopses if conntrack is active. You think about a single rule either in POSTROUTING or PREROUTING. May overcome above conntrack hash prob... Good point - I place it on the TODO.

RAWS/DNAT in Xtables-addons has this solved by using the raw and rawpost tables.

No RAW table in 2.4 AFAICT.

Yeah it's 2.6.6. You should update, or let a slightly better box do the 6-6 mapping ;-)

Quoted 4 lines

But a good hint, I'll check that. As a first
measure I placed a big fat warning at the start of the readme. Ref:

http://map66.svn.sourceforge.net/viewvc/map66/README.html

No oopses should happen. It's just that conntrack will record two different connections for what is one, and the states thus don't work reliably.

#8 lore raw

Hey Jan,

Am Donnerstag, 7. Oktober 2010, um 09:52:26 schrieb Jan Engelhardt:

Quoted 3 lines
Quoted 1 line

No RAW table in 2.4 AFAICT.

Yeah it's 2.6.6. You should update, or let a slightly better box do the 6-6 mapping ;-)

Yep. I'd prefer Atheros chips if possible - but those boxes are deployed here and there and someone has to maintain things -> ff-firmware.sf.net

Quoted 3 lines

No oopses should happen. It's just that conntrack will record two different connections for what is one, and the states thus don't work reliably.

Thanks for the estimation - but untested stuff tends to trigger mem leaks and whatnot. I leave the warning there. While I'm here: I wasn't aware that sme. has written a complete book on writing NF modules as well as maintaining a compat framework as well. Next time I'd try google first, then start hacking, Promised ;-)

// Sven-Ola

#9 lore raw
Quoted 7 lines · Sven-Ola Tuecke
Quoted 4 lines

No oopses should happen. It's just that conntrack will record two different connections for what is one, and the states thus don't work reliably.

Thanks for the estimation - but untested stuff tends to trigger mem leaks and whatnot.

Well since it has to record twice the connections it will use twice as much memory, yes. It is probably best to tag every packet that is going to be MAP66'd with -j NOTRACK anyway (when you don't use raw/rawpost), to avoid wasting conntrack resources on something it won't do.

Quoted 4 lines

I leave the warning there. While I'm here: I wasn't aware that sme. has written a complete book on writing NF modules as well as maintaining a compat framework as well. Next time I'd try google first, then start hacking, Promised ;-)

You should come to NFWS in Sevilla later this month. ;)

#10 lore raw
In reply to Amos Jeffries
Quoted 11 lines · Amos Jeffries
Quoted 8 lines
Quoted 4 lines

- NAT, even if NAT66, still interferes with ETE connectivity. Think FTP-SSL connections. That may not be your problem, but it's the Working Group's and the Draft's.

Yes - there are protocols that rely on addresses such as SIP, active FTP etc.
I don't plan to add NAT helpers for them, thats pointless somehow.

FWIW: FTP EPSV/EPRT extensions remove the need for layer-7 IPs and work with NAT44 and NAT66 nicely where the firewall supports them.

Yeah but if both sides are behind NAT, all bets are off with encrypted connections.

Quoted 2 lines

NAT66 is designed to work stateless AFAICT. As such the mapping likely does not need conntrack at all.

It does not /need/ it. But it interferes with it, given that conntrack runs before mangle and thus sees received packet with their original contents (2001:db8:1::<->2002:db8:1)), but locally originating packets with (fefe:babe:1::<->2001:db8:1::).

Quoted 2 lines

Is there perhapse some way to only configure the map once but have it apply to both src and dst depending on the packet direction?

No, for the following reason(s).

conntrack first has to figure out the direction of the flow too, by looking at src/dst and comparing it with a table of known connections. So if you wanted MAP66 to be a single rule too, you would have to make MAP66 stateful at the very least.

Let alone there is, with the exception of the FORWARD chain, no place that is entered by both receiving and sending side.

Even nf_nat's DNAT, which is normally only usable in PREROUTING, has a secret hidden hook (NF_IP_PRI_NAT_SRC) on the "POST side" so that reverse-direction mapping works.

Quoted 2 lines

Why is /128 not allowed? that would be extremely useful for roaming devices internal firewalls and high-security setups with multi-homing.

To avoid user confusion, I suspect. When you declare

-j MAP66 --from fefe:db8:1::12/128 --to 2001:db8:1::15/128,

you won't actually get 2001:db8:1::15, but something that fulfills the checksum constraint. Like 2001:db8:1::f00d or so - which would then be the point of user confusion.

#11 lore raw
In reply to Sven-Ola Tuecke
Quoted 4 lines · Sven-Ola Tuecke
Quoted 1 line

- There are pointless casts from/to void*

That's for kernel-2.4: The target firmware uses that old kernel for Flash space reasons. Only 1.75 Mb Flash and 8 Mb RAM.

Even in 2.4, targinfo/matchinfo was already void*.

Quoted 3 lines
Quoted 1 line

- You should document what MAP66_lock is protecting.

OK. They lock printk()s on SMP. Unnecessary without #DEBUG

They should not overlap anyway because all of the strings use a newline already.