when/how is the packet forwarded?
Hello everyone,
I am having problem in understanding that when/how
is the packet forwarded. I mean if i alter the daddr in the packets comming from eth0 to contain an addr that belongs to the network connected to another interface (e.g ppp0) in my NF_IP_PRE_ROUTING hook then should'nt this packet be next seen by my NF_IP_FORWARD hook instead of NF_IP_LOCAL_IN hook? I am attaching the source code with this email.
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
I'm not an expert but I think you should change sk_buff's route entry, may be using something like:
if( ip_route_me_harder( skb ) ) {
printk("Error routing\n");
return NF_DROP;
}Yours
Pablo
Quoted 14 lines · On Thu, 20 Nov 2003 12:56:11 -0800 (PST) Zeeshan Ali <[email protected]> wrote:
Hello everyone,
I am having problem in understanding that when/how
is the packet forwarded. I mean if i alter the daddr in the packets comming from eth0 to contain an addr that belongs to the network connected to another interface (e.g ppp0) in myNF_IP_PRE_ROUTINGhook then should'nt this packet be next seen by myNF_IP_FORWARDhook instead ofNF_IP_LOCAL_INhook? I am attaching the source code with this email.__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Hi,
Quoted 1 line
I'm not an expert
NP, the important thing is that you are willing to
help. Thanks.
Quoted 7 lines
but I think you should change
sk_buff's route entry, may be using something like:if( ip_route_me_harder( skb ) ) { printk("Error routing\n"); return NF_DROP; }
Not only did i do that but also changed the saddr.
Here is the new code for my NF_IP_PRE_ROUTING hook:
struct iphdr *ip;
__u8 ourip[] = {203, 175, 73, 128}; // my IP on ppp0
__u8 otherip[] = {203, 175, 73, 239};
ip = (*skb)->nh.iph;
if (strcmp (in->name, "lo") == 0) {
memcpy (&(ip->saddr), ourip, 4);
memcpy (&(ip->daddr), otherip, 4);
(*skb)->nfcache |= NFC_ALTERED; if (ip_route_me_harder (skb)) {
printk ("Error routing\n");
return NF_DROP;
}
else {
printk ("altered & routed\n");
}}
return NF_ACCEPT;
OK, Now atleast the packet is not going into the
hands of NF_IP_LOCAL_IN hook but its still not being given to my NF_IP_FORWARD hook. dmesg |tail does'nt show any routing error but the "altered & routed\n". Any clue? Thanks again. Bye.
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
I think that IP and TCP checksums should be recalculated if anything is changed in the packet. I think your packets may be silently discarded due to invalid checksum, to see if this is the problem, try taking a look at them with ethereal (or something like that), it will tell you whe checksums are wrong.
Yours
Pablo
Quoted 52 lines · On Fri, 21 Nov 2003 13:10:49 -0800 (PST) Zeeshan Ali <[email protected]> wrote:
Hi,
Quoted 1 line
I'm not an expert
NP, the important thing is that you are willing to
help. Thanks.Quoted 7 lines
but I think you should change
sk_buff's route entry, may be using something like:if( ip_route_me_harder( skb ) ) { printk("Error routing\n"); return NF_DROP; }Not only did i do that but also changed the saddr.
Here is the new code for myNF_IP_PRE_ROUTINGhook:struct iphdr *ip; __u8 ourip[] = {203, 175, 73, 128}; // my IP on ppp0 __u8 otherip[] = {203, 175, 73, 239}; ip = (*skb)->nh.iph; if (strcmp (in->name, "lo") == 0) { memcpy (&(ip->saddr), ourip, 4); memcpy (&(ip->daddr), otherip, 4); (*skb)->nfcache |= NFC_ALTERED;if (ip_route_me_harder (skb)) {(quoted diff) +0
-0printk ("Error routing\n"); return NF_DROP; } else { printk ("altered & routed\n"); } } return NF_ACCEPT; OK, Now atleast the packet is not going into thehands of
NF_IP_LOCAL_INhook but its still not being given to myNF_IP_FORWARDhook. dmesg |tail does'nt show any routing error but the "altered & routed\n". Any clue? Thanks again. Bye.__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Hello,
Thanks. You are quite right. ethereal say the IP
Header Checksums was incorrect. I correct this by re-calculating the checksum. Now ethereal shows no sign of errors in the packet. But the routing engine now seems to be dropping the packets instead of sending on to my NF_IP_FORWARD hook or the NF_IP_LOCAL_IN hook. Any more clues? Thanks for helping me out. Bye.
Quoted 10 lines · --- Pablo Cingolani
I think that IP and TCP checksums should be recalculated if anything is changed in the packet. I think your packets may be silently discarded due to invalid checksum, to see if this is the problem, try taking a look at them with ethereal (or something like that), it will tell you whe checksums are wrong.
Yours
Pablo
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree