skbuffer and Intel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The following custom written method is called from the
kernel networking code (in dev_queue_xmit(struct
sk_buff *skb) in /net/core/dev.c):

int check_packet(struct sk_buff *skb)
{
  struct iphdr *iph = skb->nh.iph;
  __u8 ttl = iph->ttl;
  
  printk("ttl = %d\n", ttl);

  return 0;
}

When I run this code I get the following output:
ttl = 201

But the problem is that I _know_ that the TTL is 64. 

Now to the most interesting part. I've noticed that I
get another part of the header when I would like to
get the ttl. So 201 is actual another part of the IP
header. If I decrease the pointer to the ttl in the
skb I get the correct value. Thus, I do:
__u8 ttl = *(&iph->ttl - 2);

and I get the output:
ttl = 64

The same thing is true for all other fields in the
ip-header (with some minor differences). It seems as
if the whole header is shifted 1-3 bytes. What is
happening and how do I solve this problem? I'm running
a Intel machine. It seems as if the problem is
little/big endian related.

/
  h_e_w_i

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux