Hi Ricky, ipip in the linux semantics refers usually to IP tunnel, for example: http://lxr.free-electrons.com/source/net/ipv4/ipip.c Traffic of ip tunnels is composed from an inner IP header which is encapsulated within a packet which as the external IP header,
(1) what is differences between ip_hdr and ipip_hdr? Why we have them? No ?>documentation whatever to figure it out.
ip_hdr() is the IP header of layer 3, the network ipip_hdr() is the IP header of layer 4, the transport layer. So this is the IP header of the internal IP header when you have a tunnel, not the external IP header. Hope this helps, Regards, Rami Rosen http://ramirose.wix.com/ramirosen On 18 August 2016 at 11:47, Ricky <zhangchaowang@gmail.com> wrote:
In include/linux/ip.h,
23 static inline struct iphdr *ip_hdr(const struct sk_buff *skb) 24 { 25 return (struct iphdr *)skb_network_header(skb); 26 } 27 28 static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb) 29 { 30 return (struct iphdr *)skb_inner_network_header(skb); 31 } 32 33 static inline struct iphdr *ipip_hdr(const struct sk_buff *skb) 34 { 35 return (struct iphdr *)skb_transport_header(skb); 36 } 37 #endif /* _LINUX_IP_H */
if I passed in sk_buff to ip_hdr and ipip_hdr
struct iphdr *ip_hdr ip_hdr_net = ip_hdr(skb); struct iphdr *ip_hdr ip_hdr_trans = ipip_hdr(skb);
Do ip_hdr_net->saddr and ip_hdr_trans->saddr point to the same thing? I tried it on code. It doesn't. It seems that only ip_hdr_net->saddr point to source IP address, which make sense. Because network layer has IP but not on transport layer.
So questions:
(1) what is differences between ip_hdr and ipip_hdr? Why we have them? No documentation whatever to figure it out.
(2) should I use ntohX function to convert ip_hdr member data when accessing them? eg, ip_hdr_net->saddr.
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies