Access MAC address from sk_buff
linux
Solution
Where exactly in the kernel are you doing this?
a8:c0 looks quite suspicious. It translates to 168.192 in decimal, which makes me suspect that you're in fact looking at the IPv4 header rather than the Ethernet header.
Problem
I'm writing a kernel module to get the MAC address from a packet stored in sk_buff. I've used the following code to print the MAC address of source and destination: ``` struct ethhdr *mh = eth_hdr(skb); printk(KERN_EMERG "Source MAC=%x:%x:%x:%x:%x:%x\n",mh->h_source[0],mh->h_source[1],mh->h_source[2],mh->h_source[3],mh->h_source[4],mh->h_source[5]); ``` The destination address can be accessed using `h_dest` inplace of `h_source`. My problem is that the source MAC address is always `a8:c0:0:0:a8:c0` and the destination MAC address is always some junk value instead of my own MAC address. Can anyone help me out on this? I want to get the correct MAC addresses.