@@ -19,13 +19,52 @@
#define barrier() __asm__ __volatile__("": : :"memory")
int _version SEC("version") = 1;
+struct __tcphdr {
+ __u16 source;
...
+ __u16 window;
+ __u16 check;
+ __u16 urg_ptr;
+}
+#if defined(__sparc__) || defined(__s390__)
+__packed
+#endif
+;
SEC("test1")
int process(struct __sk_buff *skb)
{
void *data_end = (void *)(long)skb->data_end;
void *data = (void *)(long)skb->data;
struct ethhdr *eth = (struct ethhdr *)(data);
- struct tcphdr *tcp = NULL;
+ struct __tcphdr *tcp = NULL;
__u8 proto = 255;
It's only needed for test_pkt_access.c test,
since it's being fancy and doing iph->ihl * 4.
Also such tcp->urg_ptr access into packed struct is more efficient
after JITing then sparc's own load_half_unaligned in asm, since it's
done inline and doesn't need a call.
Note that such tcphdr workaround is not necessary for more
real programs: test_l4lb.c and test_xdp.c, since they do:
if (iph->ihl != 5)
return drop;
Another idea:
x64, arm64, ppc have efficient unaligned.
s390 and mips64 have special instructions to do unaligned
access efficiently and we can make verifier convert unknown-align
load/stores into special internal load/stores, so they can be
executed differently by interpreter and by JITs.
Does sparc64 have some special instructions like that?