/* Copyright (c) 2016 Facebook * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ #include #include #include #include #include "bpf_helpers.h" #define MAX_ENTRIES 1000 struct bpf_map_def SEC("maps") hash_map = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(u32), .value_size = sizeof(long), .max_entries = MAX_ENTRIES, }; struct bpf_map_def SEC("maps") lru_hash_map = { .type = BPF_MAP_TYPE_LRU_HASH, .key_size = sizeof(u32), .value_size = sizeof(long), .max_entries = 10000, }; struct bpf_map_def SEC("maps") percpu_lru_hash_map = { .type = BPF_MAP_TYPE_LRU_HASH, .key_size = sizeof(u32), .value_size = sizeof(long), .max_entries = 10000, .map_flags = BPF_F_NO_COMMON_LRU, }; struct bpf_map_def SEC("maps") percpu_hash_map = { .type = BPF_MAP_TYPE_PERCPU_HASH, .key_size = sizeof(u32), .value_size = sizeof(long), .max_entries = MAX_ENTRIES, }; struct bpf_map_def SEC("maps") hash_map_alloc = { .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(u32), .value_size = sizeof(long), .max_entries = MAX_ENTRIES, .map_flags = BPF_F_NO_PREALLOC, }; struct bpf_map_def SEC("maps") percpu_hash_map_alloc = { .type = BPF_MAP_TYPE_PERCPU_HASH, .key_size = sizeof(u32), .value_size = sizeof(long), .max_entries = MAX_ENTRIES, .map_flags = BPF_F_NO_PREALLOC, }; SEC("kprobe/sys_getuid") int stress_hmap(struct pt_regs *ctx) { u32 key = bpf_get_current_pid_tgid(); long init_val = 1; long *value; bpf_map_update_elem(&hash_map, &key, &init_val, BPF_ANY); value = bpf_map_lookup_elem(&hash_map, &key); if (value) bpf_map_delete_elem(&hash_map, &key); return 0; } SEC("kprobe/sys_geteuid") int stress_percpu_hmap(struct pt_regs *ctx) { u32 key = bpf_get_current_pid_tgid(); long init_val = 1; long *value; bpf_map_update_elem(&percpu_hash_map, &key, &init_val, BPF_ANY); value = bpf_map_lookup_elem(&percpu_hash_map, &key); if (value) bpf_map_delete_elem(&percpu_hash_map, &key); return 0; } SEC("kprobe/sys_getgid") int stress_hmap_alloc(struct pt_regs *ctx) { u32 key = bpf_get_current_pid_tgid(); long init_val = 1; long *value; bpf_map_update_elem(&hash_map_alloc, &key, &init_val, BPF_ANY); value = bpf_map_lookup_elem(&hash_map_alloc, &key); if (value) bpf_map_delete_elem(&hash_map_alloc, &key); return 0; } SEC("kprobe/sys_getegid") int stress_percpu_hmap_alloc(struct pt_regs *ctx) { u32 key = bpf_get_current_pid_tgid(); long init_val = 1; long *value; bpf_map_update_elem(&percpu_hash_map_alloc, &key, &init_val, BPF_ANY); value = bpf_map_lookup_elem(&percpu_hash_map_alloc, &key); if (value) bpf_map_delete_elem(&percpu_hash_map_alloc, &key); return 0; } SEC("kprobe/sys_getpid") int stress_lru_hmap_alloc(struct pt_regs *ctx) { u32 key = bpf_get_prandom_u32(); long val = 1; bpf_map_update_elem(&lru_hash_map, &key, &val, BPF_ANY); return 0; } SEC("kprobe/sys_getppid") int stress_percpu_lru_hmap_alloc(struct pt_regs *ctx) { u32 key = bpf_get_prandom_u32(); long val = 1; bpf_map_update_elem(&percpu_lru_hash_map, &key, &val, BPF_ANY); return 0; } char _license[] SEC("license") = "GPL"; u32 _version SEC("version") = LINUX_VERSION_CODE; /a>
diff options
context:
space:
mode:
authorVincent <vincent.stehle@laposte.net>2017-01-30 15:06:43 +0100
committerDavid S. Miller <davem@davemloft.net>2017-01-31 13:07:40 -0500
commitc73e44269369e936165f0f9b61f1f09a11dae01c (patch)
treee2188e900ba06302f8ed2746cb07edd3efbc5c35 /net/x25/Kconfig
parent040587af31228d82c52267f717c9fcdb65f36335 (diff)
net: thunderx: avoid dereferencing xcv when NULL
This fixes the following smatch and coccinelle warnings: drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch] drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle] Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support") Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Cc: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/x25/Kconfig')