sizeof pointer vs sizeof struct

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

 



Hello,
I was recently working through the xdp tutorial and in the
packet01-parsing lesson the sizeof a pointer to the ethernet header
struct is used, not the sizeof the struct itself[0]. I peeked and the
solution for this section also still uses the sizeof a pointer and not
the struct so this isn't part of the tutorial and I was wondering what
is going on? I don't think the verifier is re-writing these addresses,
only those for the memory access into the packet data.

#include <stdio.h>
#include <linux/if_ether.h>

int main(void)

       {

                           struct ethhdr normal = {0};
    struct ethhdr *eth_hdr_ptr;

     printf("Size of struct %lu\n",sizeof(normal)); // prints 14
    printf("Size of struct pointer %lu\n",sizeof(eth_hdr_ptr)); //
prints 8
    return 0;
}


[0]https://github.com/xdp-project/xdp-tutorial/blob/master/packet01-parsing/xdp_prog_kern.c#L34
--
Logan




[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux