Re: test_progs packed...

2017-04-24 Thread Alexei Starovoitov

On 4/24/17 4:06 PM, David Miller wrote:


Alexei, why the packed attribute usage in test_progs.c?

There should be no reason for this and it results in the object(s)
having odd addresses (and thus be unaligned) on sparc.


because in:
static struct {
struct ethhdr eth;
struct iphdr iph;
struct tcphdr tcp;
} __packed pkt_v4 = {

iph is 4 byte aligned and eth is 2-byte.
We can add 2 byte hole in front of eth, but it's ugly since clean:
bpf_prog_test_run(prog_fd, 10, _v4, sizeof(pkt_v4),
would need to deal with this extra padding explicitly.

It's only a user space thing and not in critical path,
so inefficient loads shouldn't be a problem.

You're bringing a good point that bpf_prog_test_run_skb() on
the kernel side should probably do:
skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);



test_progs packed...

2017-04-24 Thread David Miller

Alexei, why the packed attribute usage in test_progs.c?

There should be no reason for this and it results in the object(s)
having odd addresses (and thus be unaligned) on sparc.