All of lore.kernel.org
 help / color / mirror / Atom feed
* sizeof pointer vs sizeof struct
@ 2024-03-01  1:20 Logan B
  2024-03-01  2:10 ` Jay Vosburgh
  0 siblings, 1 reply; 3+ messages in thread
From: Logan B @ 2024-03-01  1:20 UTC (permalink / raw)
  To: xdp-newbies

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-01  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01  1:20 sizeof pointer vs sizeof struct Logan B
2024-03-01  2:10 ` Jay Vosburgh
2024-03-01  2:30   ` Logan B

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.