Repository navigation
Commit 7aebfa1
bpf: Support narrow loads from bpf_sock_addr.user_port
bpf_sock_addr.user_port supports only 4-byte load and it leads to ugly
code in BPF programs, like:
volatile __u32 user_port = ctx->user_port;
__u16 port = bpf_ntohs(user_port);
Since otherwise clang may optimize the load to be 2-byte and it's
rejected by verifier.
Add support for 1- and 2-byte loads same way as it's supported for other
fields in bpf_sock_addr like user_ip4, msg_src_ip4, etc.
Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/c1e983f4c17573032601d0b2b1f9d1274f24bc16.1589420814.git.rdna@fb.com1 parent 6a09815 commit 7aebfa1
3 files changed
Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3728 | 3728 | | |
3729 | 3729 | | |
3730 | 3730 | | |
3731 | | - | |
| 3731 | + | |
3732 | 3732 | | |
3733 | 3733 | | |
3734 | 3734 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7029 | 7029 | | |
7030 | 7030 | | |
7031 | 7031 | | |
| 7032 | + | |
7032 | 7033 | | |
7033 | 7034 | | |
7034 | 7035 | | |
| |||
7059 | 7060 | | |
7060 | 7061 | | |
7061 | 7062 | | |
7062 | | - | |
7063 | | - | |
7064 | | - | |
7065 | | - | |
7066 | 7063 | | |
7067 | 7064 | | |
7068 | 7065 | | |
| |||
7958 | 7955 | | |
7959 | 7956 | | |
7960 | 7957 | | |
| 7958 | + | |
7961 | 7959 | | |
7962 | | - | |
7963 | 7960 | | |
7964 | 7961 | | |
7965 | 7962 | | |
| |||
7994 | 7991 | | |
7995 | 7992 | | |
7996 | 7993 | | |
7997 | | - | |
7998 | | - | |
7999 | | - | |
| 7994 | + | |
| 7995 | + | |
| 7996 | + | |
| 7997 | + | |
| 7998 | + | |
8000 | 7999 | | |
8001 | 8000 | | |
8002 | 8001 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3728 | 3728 | | |
3729 | 3729 | | |
3730 | 3730 | | |
3731 | | - | |
| 3731 | + | |
3732 | 3732 | | |
3733 | 3733 | | |
3734 | 3734 | | |
| |||
0 commit comments