HI Friends,
Have been working on this Issue for Quite Some Time & Really looking for Some Help to Proceed Further on this !!!
I am Receiving a Tunneled OR Encapsulated Packet which is having Two IP/UDP headers. Once after Capturing the Socket Buffer in PRE_ROUTING Hook; Manipulated the Socket Buffer by using the "skb_pull" Kernel Function. Using skb_pull; stripped 28 bytes (IP+UDP) which are the Part of outer IP/UDP Header. Now; My intention was to route the skb based on the Inner IP Header which is sitting after stripping 28 bytes. At the END; returned NF_ACCEPT.
My Query was;
1] After Returning NF_ACCEPT; Will Kernel Route the Packets based on Inner IP Header's Destination Address Automatically ?? (Becoz; skb_pull is expected to Change all the Pointers Automatically & also I am returning the Packet in PRE_ROUTING Hook Only.)
2] Assuming Kernel dont route the packet ; I started writing the Routing related code & was struck with __ip_route_output_key() Function as it is returning Error in my case even though the Route for the Destination Network exists in my PC (Router). The Same Function worked Fine in different case where after adding Extra IP+UDP Headers and for Routing the Packet based on the Newly Added IP header. But; it is Failing in the Former case after Stripping the Outer Header to get me the Cached Routed Entry based on the Flow that I provied . Played with Some of the Available Exported Kernel Functions but ending with Kernel Panic :(.
Here is the sample Code ...
#################################################
fi.fl4_dst=iph->daddr;
fi.fl4_src=iph->saddr;
fi.oif=0;
Var1 = __ip_route_output_key(&init_net,&rt,&fi);
dst_release (sock_buff->dst);
sock_buff->dst = &rt->u.dst;
Var2 = dst_output(sock_buff);
##################################################
Any Document Pointer/Right Functions to proceed are Really Appreciated !!!
Thanks in Advance !!!
-Regards,
VKS
Have been working on this Issue for Quite Some Time & Really looking for Some Help to Proceed Further on this !!!
I am Receiving a Tunneled OR Encapsulated Packet which is having Two IP/UDP headers. Once after Capturing the Socket Buffer in PRE_ROUTING Hook; Manipulated the Socket Buffer by using the "skb_pull" Kernel Function. Using skb_pull; stripped 28 bytes (IP+UDP) which are the Part of outer IP/UDP Header. Now; My intention was to route the skb based on the Inner IP Header which is sitting after stripping 28 bytes. At the END; returned NF_ACCEPT.
My Query was;
1] After Returning NF_ACCEPT; Will Kernel Route the Packets based on Inner IP Header's Destination Address Automatically ?? (Becoz; skb_pull is expected to Change all the Pointers Automatically & also I am returning the Packet in PRE_ROUTING Hook Only.)
2] Assuming Kernel dont route the packet ; I started writing the Routing related code & was struck with __ip_route_output_key() Function as it is returning Error in my case even though the Route for the Destination Network exists in my PC (Router). The Same Function worked Fine in different case where after adding Extra IP+UDP Headers and for Routing the Packet based on the Newly Added IP header. But; it is Failing in the Former case after Stripping the Outer Header to get me the Cached Routed Entry based on the Flow that I provied . Played with Some of the Available Exported Kernel Functions but ending with Kernel Panic :(.
Here is the sample Code ...
#################################################
fi.fl4_dst=iph->daddr;
fi.fl4_src=iph->saddr;
fi.oif=0;
Var1 = __ip_route_output_key(&init_net,&rt,&fi);
dst_release (sock_buff->dst);
sock_buff->dst = &rt->u.dst;
Var2 = dst_output(sock_buff);
##################################################
Any Document Pointer/Right Functions to proceed are Really Appreciated !!!
Thanks in Advance !!!
-Regards,
VKS