Re: Networking on 2.4: Finding source of a masqgraded packet and source/destination MAC address

Rusty Russell (rusty@linuxcare.com.au)
Thu, 01 Mar 2001 17:30:50 +1100


In message <01a001c0a1cc$22bd5e50$5f01a8c0@worm> you write:
> Hi,
>
> I am the author of the WRR (http://wipl-wrr.dkik.dk/wrr) qdisc, an extension
to the 2.2 kernels which is supposed to run on a router/bridge/firewall and do
Weighted Round Robin scheduling with a class for each local machine.
>
> Now, I want to port this scheduler to 2.4. One of the problems is that someti
mes I have an outgoing (to the world) packet which has been masqgraded. I want
to account this packet to the local machine which has originally generated it.
On 2.2. I used the following code to get the IP address of the local machine:
>

If they are using masquerading, the nfct will be set. Use
#include <linux/netfilter_ipv4/ip_conntrack.h>

enum ip_conntrack_info ctinfo;
struct ip_conntrack *ct;

ct = ip_conntrack_get(skb, &ctinfo);
if (ct) {
/* We want the initial source. */
ipaddr = ct->tuplehash[CTINFO2DIR(ctinfo)].tuple.src.ip;
} else {
ipaddr = skb->nh.iph.saddr;
}

Cheers!
Rusty.

--
Premature optmztion is rt of all evl. --DK
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/