Skip to contentSkip to conversation

RFC: NAT configuration over ctnetlink

PATCH Patrick McHardy 3 participants 12 messages Apr 28, 2006 – May 12, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I added ctnetlink support to a SIP proxy (siproxd) yesterday and stumbled over some problems with NAT. The CTA_NAT attribute only allows to set up a single manip, since NAT mappings can't be changed for existing conntracks there is no way to add both a src- and a dst-manip. This patch removes the overloading of the status bits with netlink-relevant semantic and changes the CTA_NAT attribute to CTA_NAT_SRC and CTA_NAT_DST. It breaks compatiblity, but I don't think its worth trying to keep it for this stupid behaviour. Any comments?

[NETFILTER]: Fix ctnetlink NAT configuration

---
commit 420869deee91a3bb78701885c3fd616015e38024
tree 211d2fcc33a6f129e3eda854362d342f9d8c8109
parent 22748548e0e83899fddf877f556e5220569ed8fd
author Patrick McHardy <[email protected]> Thu, 27 Apr 2006 19:22:18 +0200 committer Patrick McHardy <[email protected]> Thu, 27 Apr 2006 19:22:18 +0200

 include/linux/netfilter/nfnetlink_conntrack.h |    3 +
 net/ipv4/netfilter/ip_conntrack_netlink.c     |   53 ++++++++++---------------
 2 files changed, 24 insertions(+), 32 deletions(-)
include/linux/netfilter/nfnetlink_conntrack.h +2 -1
index 668ec94..850526b 100644
@@ -27,13 +27,14 @@ enum ctattr_type {
 	CTA_STATUS,
 	CTA_PROTOINFO,
 	CTA_HELP,
-	CTA_NAT,
+	CTA_NAT_SRC,
 	CTA_TIMEOUT,
 	CTA_MARK,
 	CTA_COUNTERS_ORIG,
 	CTA_COUNTERS_REPLY,
 	CTA_USE,
 	CTA_ID,
+	CTA_NAT_DST,
 	__CTA_MAX
 };
 #define CTA_MAX (__CTA_MAX - 1)
net/ipv4/netfilter/ip_conntrack_netlink.c +22 -31

82 lines not on this page · raw message

#1 lore raw

Hi Patrick!

Quoted 9 lines · Patrick McHardy

I added ctnetlink support to a SIP proxy (siproxd) yesterday and stumbled over some problems with NAT. The CTA_NAT attribute only allows to set up a single manip, since NAT mappings can't be changed for existing conntracks there is no way to add both a src- and a dst-manip. This patch removes the overloading of the status bits with netlink-relevant semantic and changes the CTA_NAT attribute to CTA_NAT_SRC and CTA_NAT_DST. It breaks compatiblity, but I don't think its worth trying to keep it for this stupid behaviour. Any comments?

Why not keep using the status bits logic? It doesn't break anything and you can still add support for source and destination NAT handlings at the same time. Is the status thing so ugly to break this?

Signature · 1 line
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
#2 lore raw
Quoted 15 lines · Pablo Neira Ayuso

Hi Patrick!

Quoted 9 lines · Patrick McHardy

I added ctnetlink support to a SIP proxy (siproxd) yesterday and stumbled over some problems with NAT. The CTA_NAT attribute only allows to set up a single manip, since NAT mappings can't be changed for existing conntracks there is no way to add both a src- and a dst-manip. This patch removes the overloading of the status bits with netlink-relevant semantic and changes the CTA_NAT attribute to CTA_NAT_SRC and CTA_NAT_DST. It breaks compatiblity, but I don't think its worth trying to keep it for this stupid behaviour. Any comments?

Quoted 3 lines

Why not keep using the status bits logic? It doesn't break anything and you can still add support for source and destination NAT handlings at the same time. Is the status thing so ugly to break this?

It is definitely ugly and broken. I'm really not happy that we added this stuff in a hurry instead of just leaving it out and adding it when it is in the proper shape.

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

#3 lore raw
Quoted 21 lines · Patrick McHardy
Quoted 12 lines · Pablo Neira Ayuso
Quoted 9 lines · Patrick McHardy

I added ctnetlink support to a SIP proxy (siproxd) yesterday and stumbled over some problems with NAT. The CTA_NAT attribute only allows to set up a single manip, since NAT mappings can't be changed for existing conntracks there is no way to add both a src- and a dst-manip. This patch removes the overloading of the status bits with netlink-relevant semantic and changes the CTA_NAT attribute to CTA_NAT_SRC and CTA_NAT_DST. It breaks compatiblity, but I don't think its worth trying to keep it for this stupid behaviour. Any comments?

Quoted 3 lines

Why not keep using the status bits logic? It doesn't break anything and you can still add support for source and destination NAT handlings at the same time. Is the status thing so ugly to break this?

It is definitely ugly and broken. I'm really not happy that we added this stuff in a hurry instead of just leaving it out and adding it when it is in the proper shape.

Quoted 5 lines

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

Not really, if it's trash better remove this sooner than later. Now that we are going to break backward compatibility, please let me know if you don't like anything else that we could change at this point.

#4 lore raw
Quoted 10 lines · Pablo Neira Ayuso
Quoted 5 lines

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

Not really, if it's trash better remove this sooner than later. Now that we are going to break backward compatibility, please let me know if you don't like anything else that we could change at this point.

One thing that would make a lot of sense is to change or introduce a new interface in libnetfilter_conntrack that allows to add netfilter attributes to a conntrack "object" one at a time, so we don't have to change function prototypes each time we're introducing something new.

#5 lore raw
Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso
Quoted 5 lines

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

Quoted 8 lines
Quoted 3 lines

Not really, if it's trash better remove this sooner than later. Now that we are going to break backward compatibility, please let me know if you don't like anything else that we could change at this point.

One thing that would make a lot of sense is to change or introduce a new interface in libnetfilter_conntrack that allows to add netfilter attributes to a conntrack "object" one at a time, so we don't have to change function prototypes each time we're introducing something new.

what do you think about the incomplete patch attached? Still missing the getters and the expectations.

I think that with the setters/getters we can make private nfct_conntrack and friends.

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
libnetfilter_conntrack/linux_nfnetlink_conntrack.h +2 -1
Index: include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h
===================================================================
@@ -27,13 +27,14 @@
 	CTA_STATUS,
 	CTA_PROTOINFO,
 	CTA_HELP,
-	CTA_NAT,
+	CTA_NAT_SRC,
 	CTA_TIMEOUT,
 	CTA_MARK,
 	CTA_COUNTERS_ORIG,
 	CTA_COUNTERS_REPLY,
 	CTA_USE,
 	CTA_ID,
+	CTA_NAT_DST,
 	__CTA_MAX
 };
 #define CTA_MAX (__CTA_MAX - 1)
libnetfilter_conntrack/libnetfilter_conntrack.h +37 -7

67 lines not on this page · raw message

libnetfilter_conntrack.c +158 -22

212 lines not on this page · raw message

#6 lore raw
Quoted 21 lines · Pablo Neira Ayuso
Quoted 9 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso
Quoted 5 lines

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

Quoted 8 lines
Quoted 3 lines

Not really, if it's trash better remove this sooner than later. Now that we are going to break backward compatibility, please let me know if you don't like anything else that we could change at this point.

One thing that would make a lot of sense is to change or introduce a new interface in libnetfilter_conntrack that allows to add netfilter attributes to a conntrack "object" one at a time, so we don't have to change function prototypes each time we're introducing something new.

Quoted 5 lines

what do you think about the incomplete patch attached? Still missing the getters and the expectations.

I think that with the setters/getters we can make private nfct_conntrack and friends.

This goes even further than what I meant :) I'll have a closer look, but probably going to take a bit, I'm quite busy currently.

Another item I would like to bring up for discussion is whether we want to continue with (some) of these libraries at all. For a small pet-project of mine I've been working a bit on Thomas Graf's libnl, which provides a very nice netlink infrastructure, support for basically all kernel netlink interfaces, nice object representation of the individual items, cache management for replication of kernel databases, and quite a few things more. Besides lots of nice infrastructure, one main advantage of using libnl would be that there is a single library which can be used for communication with any kernel subsystem using netlink in a uniform way.

Comments?

#7 lore raw
Quoted 10 lines · Patrick McHardy

Another item I would like to bring up for discussion is whether we want to continue with (some) of these libraries at all. For a small pet-project of mine I've been working a bit on Thomas Graf's libnl, which provides a very nice netlink infrastructure, support for basically all kernel netlink interfaces, nice object representation of the individual items, cache management for replication of kernel databases, and quite a few things more. Besides lots of nice infrastructure, one main advantage of using libnl would be that there is a single library which can be used for communication with any kernel subsystem using netlink in a uniform way.

well, certainly that work is interesting. However, I don't really see how this fits into the picture. First of all, nfnetlink is different in that it has its peculiar byteorder. Also, we specifically divided the libraries into separate packages so they can be updated independently. It is unlikely that conntrack bugfixes affect logging and vice versa.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#8 lore raw
Quoted 15 lines · Harald Welte
Quoted 10 lines · Patrick McHardy

Another item I would like to bring up for discussion is whether we want to continue with (some) of these libraries at all. For a small pet-project of mine I've been working a bit on Thomas Graf's libnl, which provides a very nice netlink infrastructure, support for basically all kernel netlink interfaces, nice object representation of the individual items, cache management for replication of kernel databases, and quite a few things more. Besides lots of nice infrastructure, one main advantage of using libnl would be that there is a single library which can be used for communication with any kernel subsystem using netlink in a uniform way.

Quoted 3 lines

well, certainly that work is interesting. However, I don't really see how this fits into the picture. First of all, nfnetlink is different in that it has its peculiar byteorder.

Unfortunately that is true, but it shouldn't be that hard to adapt libnl. But you're certainly right that this needs to be looked into before reasonably continuing this discussion.

Also, we specifically divided the

Quoted 2 lines

libraries into separate packages so they can be updated independently. It is unlikely that conntrack bugfixes affect logging and vice versa.

I don't see that as a problem, what does it matter whether I need to update one library dealing with logging or another library dealing with everything .. given that it is a pure bugfix update. Using that library would IMO not only give us lots of nice features (at least parts of which we would need to duplicate otherwise), but also benefit users by providing uniform access to the kernel.

#9 lore raw
In reply to Pablo Neira Ayuso
Quoted 21 lines · Pablo Neira Ayuso
Quoted 9 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso
Quoted 5 lines

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

Quoted 8 lines
Quoted 3 lines

Not really, if it's trash better remove this sooner than later. Now that we are going to break backward compatibility, please let me know if you don't like anything else that we could change at this point.

One thing that would make a lot of sense is to change or introduce a new interface in libnetfilter_conntrack that allows to add netfilter attributes to a conntrack "object" one at a time, so we don't have to change function prototypes each time we're introducing something new.

Quoted 5 lines

what do you think about the incomplete patch attached? Still missing the getters and the expectations.

I think that with the setters/getters we can make private nfct_conntrack and friends.

I talked to Harald about this and we decided how to proceed. Harald made some changes to libnfnetlink which break libnetfilter_conntrack and others, so he wants to fix them and do a new release of all the libraries first. After that your patch should go in, but we decided not to change the existing create_conntrack prototype, but add a few new functions instead for allocating and sending the conntrack message. This way old code will at least compile, and everything besides setting up NAT mappings will keep working.

#10 lore raw

Hi,

Quoted 25 lines · Patrick McHardy
Quoted 23 lines · Pablo Neira Ayuso
Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Pablo Neira Ayuso
Quoted 5 lines

I don't know. I would prefer to just remove it. Since the library takes all parameters as arguments to a single function (one more thing I definitely don't like), compatibility of the library will break anyway when we add support for multiple manips. Do you really think its worth keeping around?

Quoted 8 lines
Quoted 3 lines

Not really, if it's trash better remove this sooner than later. Now that we are going to break backward compatibility, please let me know if you don't like anything else that we could change at this point.

One thing that would make a lot of sense is to change or introduce a new interface in libnetfilter_conntrack that allows to add netfilter attributes to a conntrack "object" one at a time, so we don't have to change function prototypes each time we're introducing something new.

what do you think about the incomplete patch attached? Still missing the getters and the expectations.

Quoted 8 lines
Quoted 2 lines

I think that with the setters/getters we can make private nfct_conntrack and friends.

I talked to Harald about this and we decided how to proceed. Harald made some changes to libnfnetlink which break libnetfilter_conntrack and others, so he wants to fix them and do a new release of all the libraries first.

BTW: @Harald, do you plan to include part of this patch in the changes?
http://patchwork.netfilter.org/netfilter-devel/patch.pl?id=3315

Quoted 5 lines

After that your patch should go in, but we decided
not to change the existing create_conntrack prototype, but add a few new functions instead for allocating and sending the conntrack message. This way old code will at least compile, and everything besides setting up NAT mappings will keep working.

OK, I'll finish the patch then. I'm thinking about hiding the definition of nfct_conntrack/nfct_tuple/... and provide the getters to access the attributes of the object. Since this structure could evolve in time, we wouldn't have any problems to introduce new changes in future. But that would definitely break code that initialize the structure by setting up the structure fields. Ideas?

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
#11 lore raw
Quoted 6 lines · Pablo Neira Ayuso

OK, I'll finish the patch then. I'm thinking about hiding the definition of nfct_conntrack/nfct_tuple/... and provide the getters to access the attributes of the object. Since this structure could evolve in time, we wouldn't have any problems to introduce new changes in future. But that would definitely break code that initialize the structure by setting up the structure fields. Ideas?

I don't think thats necessary (and I'm no fan of hiding things unless there's a good reason), basically all of these structures are similar to semantically well-defined structures in the kernel that are very unlikely to change in an incompatible way.