diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2016-09-08 20:45:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-09 22:36:03 -0400 |
commit | 6088b5823b4cb132a838878747384cbfb5ce6646 (patch) | |
tree | 83d13b9cc765fa76212ba29d4eda9723f6c02e5e /kernel/bpf/helpers.c | |
parent | bf8d85d4f907d2156e6e5d2831378527957d9bde (diff) |
bpf: minor cleanups in helpers
Some minor misc cleanups, f.e. use sizeof(__u32) instead of hardcoding
and in __bpf_skb_max_len(), I missed that we always have skb->dev valid
anyway, so we can drop the unneeded test for dev; also few more other
misc bits addressed here.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/helpers.c')
-rw-r--r-- | kernel/bpf/helpers.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 1ea3afba1a4f..6df73bd1ba34 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c | |||
@@ -126,7 +126,7 @@ static u64 bpf_get_current_pid_tgid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) | |||
126 | { | 126 | { |
127 | struct task_struct *task = current; | 127 | struct task_struct *task = current; |
128 | 128 | ||
129 | if (!task) | 129 | if (unlikely(!task)) |
130 | return -EINVAL; | 130 | return -EINVAL; |
131 | 131 | ||
132 | return (u64) task->tgid << 32 | task->pid; | 132 | return (u64) task->tgid << 32 | task->pid; |
@@ -144,12 +144,12 @@ static u64 bpf_get_current_uid_gid(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) | |||
144 | kuid_t uid; | 144 | kuid_t uid; |
145 | kgid_t gid; | 145 | kgid_t gid; |
146 | 146 | ||
147 | if (!task) | 147 | if (unlikely(!task)) |
148 | return -EINVAL; | 148 | return -EINVAL; |
149 | 149 | ||
150 | current_uid_gid(&uid, &gid); | 150 | current_uid_gid(&uid, &gid); |
151 | return (u64) from_kgid(&init_user_ns, gid) << 32 | | 151 | return (u64) from_kgid(&init_user_ns, gid) << 32 | |
152 | from_kuid(&init_user_ns, uid); | 152 | from_kuid(&init_user_ns, uid); |
153 | } | 153 | } |
154 | 154 | ||
155 | const struct bpf_func_proto bpf_get_current_uid_gid_proto = { | 155 | const struct bpf_func_proto bpf_get_current_uid_gid_proto = { |