Example #1
0
int imain(struct __sk_buff *skb)
{
	struct bpf_elf_map *map_inner;
	int key = 0, *val;

	map_inner = map_lookup_elem(&map_outer, &key);
	if (map_inner) {
		val = map_lookup_elem(map_inner, &key);
		if (val)
			printt("map val: %d\n", *val);
	}

	return BPF_H_DEFAULT;
}
Example #2
0
int emain(struct __sk_buff *skb)
{
	struct bpf_elf_map *map_inner;
	int key = 0, *val;

	map_inner = map_lookup_elem(&map_outer, &key);
	if (map_inner) {
		val = map_lookup_elem(map_inner, &key);
		if (val)
			lock_xadd(val, 1);
	}

	return BPF_H_DEFAULT;
}
Example #3
0
int cls_exit(struct __sk_buff *skb)
{
	char fmt[] = "exit: map-val: %d from:%u\n";
	int key = 0, *val;

	val = map_lookup_elem(&map_sh, &key);
	if (val)
		trace_printk(fmt, sizeof(fmt), *val, skb->cb[0]);

	/* Termination point. */
	return BPF_H_DEFAULT;
}
Example #4
0
int cls_case2(struct __sk_buff *skb)
{
	char fmt[] = "case2: map-val: %d from:%u\n";
	int key = 0, *val;

	val = map_lookup_elem(&map_sh, &key);
	if (val)
		trace_printk(fmt, sizeof(fmt), *val, skb->cb[0]);

	skb->cb[0] = ENTRY_1;
	tail_call(skb, &jmp_tc, ENTRY_0);

	return BPF_H_DEFAULT;
}
Example #5
0
__section_cls_entry
int cls_entry(struct __sk_buff *skb)
{
	char fmt[] = "fallthrough\n";
	int key = 0, *val;

	/* For transferring state, we can use skb->cb[0] ... skb->cb[4]. */
	val = map_lookup_elem(&map_sh, &key);
	if (val) {
		lock_xadd(val, 1);

		skb->cb[0] = ENTRY_INIT;
		tail_call(skb, &jmp_tc, skb->hash & (MAX_JMP_SIZE - 1));
	}

	trace_printk(fmt, sizeof(fmt));
	return BPF_H_DEFAULT;
}