diff options
| author | Daniel Borkmann <daniel@iogearbox.net> | 2015-03-01 06:31:42 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-03-01 14:05:18 -0500 |
| commit | a2c83fff582ae133d9f5bb187404ea9ce4da1f96 (patch) | |
| tree | 93293fffedc76b48e5ccaefdfd95728719d11753 /kernel/bpf | |
| parent | f91fe17e243d1f279d425071a35e3d41290758a0 (diff) | |
ebpf: constify various function pointer structs
We can move bpf_map_ops and bpf_verifier_ops and other structs into ro
section, bpf_map_type_list and bpf_prog_type_list into read mostly.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf')
| -rw-r--r-- | kernel/bpf/arraymap.c | 6 | ||||
| -rw-r--r-- | kernel/bpf/hashtab.c | 6 | ||||
| -rw-r--r-- | kernel/bpf/helpers.c | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 9eb4d8a7cd87..8a6616583f38 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c | |||
| @@ -134,7 +134,7 @@ static void array_map_free(struct bpf_map *map) | |||
| 134 | kvfree(array); | 134 | kvfree(array); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | static struct bpf_map_ops array_ops = { | 137 | static const struct bpf_map_ops array_ops = { |
| 138 | .map_alloc = array_map_alloc, | 138 | .map_alloc = array_map_alloc, |
| 139 | .map_free = array_map_free, | 139 | .map_free = array_map_free, |
| 140 | .map_get_next_key = array_map_get_next_key, | 140 | .map_get_next_key = array_map_get_next_key, |
| @@ -143,14 +143,14 @@ static struct bpf_map_ops array_ops = { | |||
| 143 | .map_delete_elem = array_map_delete_elem, | 143 | .map_delete_elem = array_map_delete_elem, |
| 144 | }; | 144 | }; |
| 145 | 145 | ||
| 146 | static struct bpf_map_type_list tl = { | 146 | static struct bpf_map_type_list array_type __read_mostly = { |
| 147 | .ops = &array_ops, | 147 | .ops = &array_ops, |
| 148 | .type = BPF_MAP_TYPE_ARRAY, | 148 | .type = BPF_MAP_TYPE_ARRAY, |
| 149 | }; | 149 | }; |
| 150 | 150 | ||
| 151 | static int __init register_array_map(void) | 151 | static int __init register_array_map(void) |
| 152 | { | 152 | { |
| 153 | bpf_register_map_type(&tl); | 153 | bpf_register_map_type(&array_type); |
| 154 | return 0; | 154 | return 0; |
| 155 | } | 155 | } |
| 156 | late_initcall(register_array_map); | 156 | late_initcall(register_array_map); |
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index b3ba43674310..83c209d9b17a 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c | |||
| @@ -345,7 +345,7 @@ static void htab_map_free(struct bpf_map *map) | |||
| 345 | kfree(htab); | 345 | kfree(htab); |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | static struct bpf_map_ops htab_ops = { | 348 | static const struct bpf_map_ops htab_ops = { |
| 349 | .map_alloc = htab_map_alloc, | 349 | .map_alloc = htab_map_alloc, |
| 350 | .map_free = htab_map_free, | 350 | .map_free = htab_map_free, |
| 351 | .map_get_next_key = htab_map_get_next_key, | 351 | .map_get_next_key = htab_map_get_next_key, |
| @@ -354,14 +354,14 @@ static struct bpf_map_ops htab_ops = { | |||
| 354 | .map_delete_elem = htab_map_delete_elem, | 354 | .map_delete_elem = htab_map_delete_elem, |
| 355 | }; | 355 | }; |
| 356 | 356 | ||
| 357 | static struct bpf_map_type_list tl = { | 357 | static struct bpf_map_type_list htab_type __read_mostly = { |
| 358 | .ops = &htab_ops, | 358 | .ops = &htab_ops, |
| 359 | .type = BPF_MAP_TYPE_HASH, | 359 | .type = BPF_MAP_TYPE_HASH, |
| 360 | }; | 360 | }; |
| 361 | 361 | ||
| 362 | static int __init register_htab_map(void) | 362 | static int __init register_htab_map(void) |
| 363 | { | 363 | { |
| 364 | bpf_register_map_type(&tl); | 364 | bpf_register_map_type(&htab_type); |
| 365 | return 0; | 365 | return 0; |
| 366 | } | 366 | } |
| 367 | late_initcall(register_htab_map); | 367 | late_initcall(register_htab_map); |
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 9e3414d85459..a3c7701a8b5e 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c | |||
| @@ -41,7 +41,7 @@ static u64 bpf_map_lookup_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) | |||
| 41 | return (unsigned long) value; | 41 | return (unsigned long) value; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | struct bpf_func_proto bpf_map_lookup_elem_proto = { | 44 | const struct bpf_func_proto bpf_map_lookup_elem_proto = { |
| 45 | .func = bpf_map_lookup_elem, | 45 | .func = bpf_map_lookup_elem, |
| 46 | .gpl_only = false, | 46 | .gpl_only = false, |
| 47 | .ret_type = RET_PTR_TO_MAP_VALUE_OR_NULL, | 47 | .ret_type = RET_PTR_TO_MAP_VALUE_OR_NULL, |
| @@ -60,7 +60,7 @@ static u64 bpf_map_update_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) | |||
| 60 | return map->ops->map_update_elem(map, key, value, r4); | 60 | return map->ops->map_update_elem(map, key, value, r4); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | struct bpf_func_proto bpf_map_update_elem_proto = { | 63 | const struct bpf_func_proto bpf_map_update_elem_proto = { |
| 64 | .func = bpf_map_update_elem, | 64 | .func = bpf_map_update_elem, |
| 65 | .gpl_only = false, | 65 | .gpl_only = false, |
| 66 | .ret_type = RET_INTEGER, | 66 | .ret_type = RET_INTEGER, |
| @@ -80,7 +80,7 @@ static u64 bpf_map_delete_elem(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5) | |||
| 80 | return map->ops->map_delete_elem(map, key); | 80 | return map->ops->map_delete_elem(map, key); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | struct bpf_func_proto bpf_map_delete_elem_proto = { | 83 | const struct bpf_func_proto bpf_map_delete_elem_proto = { |
| 84 | .func = bpf_map_delete_elem, | 84 | .func = bpf_map_delete_elem, |
| 85 | .gpl_only = false, | 85 | .gpl_only = false, |
| 86 | .ret_type = RET_INTEGER, | 86 | .ret_type = RET_INTEGER, |
