Mangle on a Connection, not on a Packet
Ok, (read the POM docco) this looks pretty cool .. couple of questions, then;
1. for my input/output rules I would add rules to send any new connections on my "special ports/protos" to the CONNMARK target for marking .. but I'd want an arbitrary unique mark per connection, not a static one .. is this possible? (and I'd need that mark to be made free when the connection is removed from netfilter).
2. in the mangle table, I would use connmark matching to send all marked connections to the XOR target .. but am I able to access the arbitrary unique mark from within the XOR target module itself (programatically)?
.. I guess the alternative would be to smash together the two modules into a single CONNXOR target ...? That way the code that identifies and marks new connections in CONNMARK could be readily matched and altered via the XOR code ... I'll take a look at the CONNMARK code .. maybe this is easier ..
----- Original Message -----
Quoted 14 lines
From: "Henrik Nordstrom" <[email protected]>
To: "Ian Latter" <[email protected]>
Subject: Re: Mangle on a Connection, not on a Packet
Date: Thu, 16 Oct 2003 16:30:44 +0200Quoted 6 lines · Ian Latter
I want to extend the functionality of the XOR module. I am cool with the connection tracking helper concepts, and I am cool with the way XOR is doing its mangling as a target .. but what I'm not so cool with is how I register my intent to mangle a "connection" with conntrack, rather than the currently registerd mangle .. per a packet .. as with the target.
Quoted 8 lines
For this purpose I think you should be able to use the CONNMARK patch to mark the connection. The CONNMARK patch provides you with a 32bit piece of memory per conntrack, and can be used very much like the MARK target.
Regards
Henrik
--
Ian Latter
Internet and Networking Security Officer
Macquarie University
Quoted 6 lines · Ian Latter
1. for my input/output rules I would add rules to send any new connections on my "special ports/protos" to the CONNMARK target for marking .. but I'd want an arbitrary unique mark per connection, not a static one .. is this possible? (and I'd need that mark to be made free when the connection is removed from netfilter).
Then you need something a little more advanced than CONNMARK I think.
Quoted 1 line
From your description it sounds like you could be using the conntract
handle as is. This will give you an arbitrary integer of size (void *).
Quoted 4 lines
2. in the mangle table, I would use connmark matching to send all marked connections to the XOR target .. but am I able to access the arbitrary unique mark from within the XOR target module itself (programatically)?
The conntrack mark is available as ct->mark.
Examle code snipped accessing the conntrack mark:
enum ip_conntrack_info ctinfo;
struct ip_conntrack *ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo);
if (!ct)
return 0;
mark = ct->mark;Regards
Henrik