File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -251,10 +251,16 @@ int ingress_read_sock_fields(struct __sk_buff *skb)
251
251
return CG_OK ;
252
252
}
253
253
254
+ /*
255
+ * NOTE: 4-byte load from bpf_sock at dst_port offset is quirky. It
256
+ * gets rewritten by the access converter to a 2-byte load for
257
+ * backward compatibility. Treating the load result as a be16 value
258
+ * makes the code portable across little- and big-endian platforms.
259
+ */
254
260
static __noinline bool sk_dst_port__load_word (struct bpf_sock * sk )
255
261
{
256
262
__u32 * word = (__u32 * )& sk -> dst_port ;
257
- return word [0 ] == bpf_htonl ( 0xcafe0000 );
263
+ return word [0 ] == bpf_htons ( 0xcafe );
258
264
}
259
265
260
266
static __noinline bool sk_dst_port__load_half (struct bpf_sock * sk )
You can’t perform that action at this time.
0 commit comments