Skip to contentSkip to conversation

masquerading/conntrack

RFC NICOLAS BOULIANE 3 participants 9 messages May 21, 2008 – May 22, 2008 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

Here is a problem which I used to have with MASQUERADE,

When the machine boots - naturally there are some connections which

begin to flow as soon as the first ppp interface comes up... Some of these connections remain open for days - for example - openvpn and iax2 trunks...

Since ppp0 always come up first, then these connections begin to flow via ppp0 and with the MASQ IP of ppp0...

Later, when the mangle-rules kick-in, these connections are being router via ppp4 (which is what I want)...
So far no problem..

The only problem is that these packets now exit via ppp4 but they continue to keep the source IP of ppp0

Ok, I tried to use the userspace conntrack-tool to search and remove these entries, but this tool doesn't allow me to do something like this

$> conntrack -L conntrack -d IP

...without asking me the complete tuple-information. I can't delete every

entry with a specific IP either without providing a complete tuple.

Maybe we could add a parameter to the target masquerade, which could add a flag in the conntrack that would mean "don't use the conntrack entry, we

want to go through the MASQUERADING code again".

What you guys think it should be wise to do ?

thank you
Nick

#1 lore raw
Quoted 6 lines · NICOLAS BOULIANE

Since ppp0 always come up first, then these connections begin to flow via ppp0 and with the MASQ IP of ppp0...

Later, when the mangle-rules kick-in, these connections are being router via ppp4 (which is what I want)...
So far no problem..

Don't enable forwarding until you have the routing (including policies, mangle etc) properly configured.

Regards
Henrik

#2 lore raw
In reply to NICOLAS BOULIANE
Quoted 8 lines · NICOLAS BOULIANE

Since ppp0 always come up first, then these connections begin to flow via ppp0 and with the MASQ IP of ppp0...

Later, when the mangle-rules kick-in, these connections are being router via ppp4 (which is what I want)...
So far no problem..

Quoted 8 lines

The only problem is that these packets now exit via ppp4 but they continue to keep the source IP of ppp0

Ok, I tried to use the userspace conntrack-tool to search and remove these entries, but this tool doesn't allow me to do something like this

$> conntrack -L conntrack -d IP

Check Git, next version (0.9.7) allows it.

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers
#3 lore raw

Hi,

thank you for your comments.
---

Pablo:

cc1: warnings being treated as errors
read_config_lex.l: In function 'yylex':
read_config_lex.l:113: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:114: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:115: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:126: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.c:3845: warning: label 'find_rule' defined but not used make[1]: *** [read_config_lex.o] Error 1

I get this while compiling the last git snapshot
probably string.h is missing ?

Thank you

Quoted 23 lines · Pablo Neira Ayuso
Quoted 8 lines · NICOLAS BOULIANE

Since ppp0 always come up first, then these connections begin to flow via ppp0 and with the MASQ IP of ppp0...

Later, when the mangle-rules kick-in, these connections are being router via ppp4 (which is what I want)...
So far no problem..

Quoted 8 lines

The only problem is that these packets now exit via ppp4 but they continue to keep the source IP of ppp0

Ok, I tried to use the userspace conntrack-tool to search and remove these entries, but this tool doesn't allow me to do something like this

$> conntrack -L conntrack -d IP

Check Git, next version (0.9.7) allows it.

--
"Los honestos son inadaptados sociales" -- Les Luthiers

#4 lore raw
Quoted 20 lines · NICOLAS BOULIANE

Hi,

thank you for your comments.
---

Pablo:

cc1: warnings being treated as errors
read_config_lex.l: In function 'yylex':
read_config_lex.l:113: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:114: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:115: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:126: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.c:3845: warning: label 'find_rule' defined but not used make[1]: *** [read_config_lex.o] Error 1

Quoted 2 lines

I get this while compiling the last git snapshot
probably string.h is missing ?

Does the patch attached fix it?

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers
src/read_config_lex.l +2 -0
index eb3368a..7daaeab 100644
@@ -19,6 +19,8 @@
  * Description: configuration file syntax
  */
 
+#include <string.h>
+
 #include "read_config_yy.h"
 %}
 
#5 lore raw

Pablo,

It fixed the strdup(). But now:

cc1: warnings being treated as errors
read_config_lex.c: In function 'yylex':
read_config_lex.c:3846: warning: label 'find_rule' defined but not used make[1]: *** [read_config_lex.o] Error 1

if I strip this label (find_rule), then I get:

read_config_lex.c:3593: warning: 'yy_full_match' defined but not used make[1]: *** [read_config_lex.o] Error 1
make[1]: Leaving directory `/usr/local/src/conntrack-tools/src'
make: *** [all-recursive] Error 1

If I remove this function (yy_full_match), then I get:

cc1: warnings being treated as errors
read_config_lex.c: In function 'yylex':
read_config_lex.c:3782: warning: 'yy_act' may be used uninitialized in this function
make[1]: *** [read_config_lex.o] Error 1

If I initialize this var (register int yy_act = 0;), then I get:

everything compile now.

I'm using a version I compiled without the -Werror flag, it was more clean.

Nick

Quoted 44 lines · Pablo Neira Ayuso
Quoted 20 lines · NICOLAS BOULIANE

Hi,

thank you for your comments.
---

Pablo:

cc1: warnings being treated as errors
read_config_lex.l: In function 'yylex':
read_config_lex.l:113: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:114: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:115: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.l:126: warning: incompatible implicit declaration of built-in function 'strdup'
read_config_lex.c:3845: warning: label 'find_rule' defined but not used make[1]: *** [read_config_lex.o] Error 1

Quoted 2 lines

I get this while compiling the last git snapshot
probably string.h is missing ?

Does the patch attached fix it?

--
"Los honestos son inadaptados sociales" -- Les Luthiers

src/read_config_lex.l +2 -0
index eb3368a..7daaeab 100644
@@ -19,6 +19,8 @@
 * Description: configuration file syntax
 */
 
+#include <string.h>
+
 #include "read_config_yy.h"
 %}
 
#6 lore raw
Quoted 26 lines · NICOLAS BOULIANE

Pablo,

It fixed the strdup(). But now:

cc1: warnings being treated as errors
read_config_lex.c: In function 'yylex':
read_config_lex.c:3846: warning: label 'find_rule' defined but not used make[1]: *** [read_config_lex.o] Error 1

if I strip this label (find_rule), then I get:

read_config_lex.c:3593: warning: 'yy_full_match' defined but not used make[1]: *** [read_config_lex.o] Error 1
make[1]: Leaving directory `/usr/local/src/conntrack-tools/src'
make: *** [all-recursive] Error 1

If I remove this function (yy_full_match), then I get:

cc1: warnings being treated as errors
read_config_lex.c: In function 'yylex':
read_config_lex.c:3782: warning: 'yy_act' may be used uninitialized in this function
make[1]: *** [read_config_lex.o] Error 1

Quoted 3 lines

If I initialize this var (register int yy_act = 0;), then I get:

everything compile now.

This report is really strange, your flex implementation is generating useless code. What version are you using? Here I'm using flex 2.5.33.

Quoted 1 line

I'm using a version I compiled without the -Werror flag, it was more clean.

The -Werror is there to catch this sort of problems and force users to report them ;), I plan to keep it there until conntrack-tools hits 1.0 at least.

Probably we have to check for a specific version of flex.

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers
#7 lore raw

Pablo,

Quoted 27 lines · Pablo Neira Ayuso
Quoted 26 lines · NICOLAS BOULIANE

Pablo,

It fixed the strdup(). But now:

cc1: warnings being treated as errors
read_config_lex.c: In function 'yylex':
read_config_lex.c:3846: warning: label 'find_rule' defined but not used make[1]: *** [read_config_lex.o] Error 1

if I strip this label (find_rule), then I get:

read_config_lex.c:3593: warning: 'yy_full_match' defined but not used make[1]: *** [read_config_lex.o] Error 1
make[1]: Leaving directory `/usr/local/src/conntrack-tools/src'
make: *** [all-recursive] Error 1

If I remove this function (yy_full_match), then I get:

cc1: warnings being treated as errors
read_config_lex.c: In function 'yylex':
read_config_lex.c:3782: warning: 'yy_act' may be used uninitialized in this function
make[1]: *** [read_config_lex.o] Error 1

Quoted 7 lines
Quoted 3 lines

If I initialize this var (register int yy_act = 0;), then I get:

everything compile now.

This report is really strange, your flex implementation is generating useless code. What version are you using? Here I'm using flex 2.5.33.

[nib@bwm ~]$ flex --version
flex version 2.5.4
[nib@bwm ~]$

[nib@bwm ~]$ yum info flex
Loading "installonlyn" plugin
Setting up repositories
Reading repository metadata in from local files
Installed Packages
Name : flex
Arch : i386
Version: 2.5.4a
Release: 41.fc6
Size : 239 k
Repo : installed
...

Centos is running on this machine.

Quoted 5 lines
Quoted 1 line

I'm using a version I compiled without the -Werror flag, it was more clean.

The -Werror is there to catch this sort of problems and force users to report them ;), I plan to keep it there until conntrack-tools hits 1.0 at least.

It's a good idea :)

Quoted 6 lines

Probably we have to check for a specific version of flex.

--
"Los honestos son inadaptados sociales" -- Les Luthiers

Nick

#8 lore raw
Quoted 21 lines · NICOLAS BOULIANE
Quoted 3 lines

This report is really strange, your flex implementation is generating useless code. What version are you using? Here I'm using flex 2.5.33.

[nib@bwm ~]$ flex --version
flex version 2.5.4
[nib@bwm ~]$

[nib@bwm ~]$ yum info flex
Loading "installonlyn" plugin
Setting up repositories
Reading repository metadata in from local files
Installed Packages
Name : flex
Arch : i386
Version: 2.5.4a
Release: 41.fc6
Size : 239 k
Repo : installed
...

Quoted 1 line

Centos is running on this machine.

Centos seems to be using a caveman flex version! From 1997, 11 years ago!

I have committed the following patch to warn people about using old flex version.

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers
configure.in +15 -0
index f3b8785..0a6b8fe 100644
@@ -49,6 +49,21 @@ then
 	exit 1
 fi
 
+AC_MSG_CHECKING(flex version)
+flex_version=`$LEX --version | sed 's/version//g' | awk '/flex/ {print $2}'`
+flex_major=`echo $flex_version| cut -d . -f 1`
+flex_minor=`echo $flex_version| cut -d . -f 2`
+flex_rev=`echo $flex_version| cut -d . -f 3`
+ 
+if test "$flex_major" -eq "2" && test "$flex_minor" -eq "5" && test "$flex_rev" -ge "33"; then
+	AC_MSG_RESULT([$flex_version. OK])
+else
+	AC_MSG_WARN([flex version $flex_version found.
+	Version 2.5.33 or greater is required. You may experience problems
+	while compilating the conntrack-tools. Please, consider to upgrade 
+	flex.])
+fi
+
 AC_CHECK_HEADERS([linux/capability.h],, [AC_MSG_ERROR([Cannot find linux/capabibility.h])])
 
 # Checks for libraries.