Commit 93d11e0d authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files


Fast path bpf marge for some -next work.

Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 6b5567b1 7a2fb912
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -220,11 +220,9 @@ static inline bool map_value_has_timer(const struct bpf_map *map)
static inline void check_and_init_map_value(struct bpf_map *map, void *dst)
{
	if (unlikely(map_value_has_spin_lock(map)))
		*(struct bpf_spin_lock *)(dst + map->spin_lock_off) =
			(struct bpf_spin_lock){};
		memset(dst + map->spin_lock_off, 0, sizeof(struct bpf_spin_lock));
	if (unlikely(map_value_has_timer(map)))
		*(struct bpf_timer *)(dst + map->timer_off) =
			(struct bpf_timer){};
		memset(dst + map->timer_off, 0, sizeof(struct bpf_timer));
}

/* copy everything but bpf_spin_lock and bpf_timer. There could be one of each. */
@@ -235,7 +233,8 @@ static inline void copy_map_value(struct bpf_map *map, void *dst, void *src)
	if (unlikely(map_value_has_spin_lock(map))) {
		s_off = map->spin_lock_off;
		s_sz = sizeof(struct bpf_spin_lock);
	} else if (unlikely(map_value_has_timer(map))) {
	}
	if (unlikely(map_value_has_timer(map))) {
		t_off = map->timer_off;
		t_sz = sizeof(struct bpf_timer);
	}
+3 −2
Original line number Diff line number Diff line
@@ -5789,7 +5789,8 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env,
			}
			if (check_ptr_off_reg(env, reg, regno))
				return -EINVAL;
		} else if (is_kfunc && (reg->type == PTR_TO_BTF_ID || reg2btf_ids[reg->type])) {
		} else if (is_kfunc && (reg->type == PTR_TO_BTF_ID ||
			   (reg2btf_ids[base_type(reg->type)] && !type_flag(reg->type)))) {
			const struct btf_type *reg_ref_t;
			const struct btf *reg_btf;
			const char *reg_ref_tname;
@@ -5817,7 +5818,7 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env,
				}
			} else {
				reg_btf = btf_vmlinux;
				reg_ref_id = *reg2btf_ids[reg->type];
				reg_ref_id = *reg2btf_ids[base_type(reg->type)];
			}

			reg_ref_t = btf_type_skip_modifiers(reg_btf, reg_ref_id,
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
 */
#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/bpf-cgroup.h>
#include <linux/rcupdate.h>
#include <linux/random.h>
@@ -1109,6 +1110,7 @@ static enum hrtimer_restart bpf_timer_cb(struct hrtimer *hrtimer)
	void *key;
	u32 idx;

	BTF_TYPE_EMIT(struct bpf_timer);
	callback_fn = rcu_dereference_check(t->callback_fn, rcu_read_lock_bh_held());
	if (!callback_fn)
		goto out;
+3 −0
Original line number Diff line number Diff line
@@ -1354,6 +1354,7 @@ int generic_map_delete_batch(struct bpf_map *map,
		maybe_wait_bpf_programs(map);
		if (err)
			break;
		cond_resched();
	}
	if (copy_to_user(&uattr->batch.count, &cp, sizeof(cp)))
		err = -EFAULT;
@@ -1411,6 +1412,7 @@ int generic_map_update_batch(struct bpf_map *map,

		if (err)
			break;
		cond_resched();
	}

	if (copy_to_user(&uattr->batch.count, &cp, sizeof(cp)))
@@ -1508,6 +1510,7 @@ int generic_map_lookup_batch(struct bpf_map *map,
		swap(prev_key, key);
		retry = MAP_LOOKUP_RETRIES;
		cp++;
		cond_resched();
	}

	if (err == -EFAULT)
+3 −0
Original line number Diff line number Diff line
@@ -2710,6 +2710,9 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
	if (unlikely(flags))
		return -EINVAL;

	if (unlikely(len == 0))
		return 0;

	/* First find the starting scatterlist element */
	i = msg->sg.start;
	do {
Loading