History

bpf: offload: rename the ifindex field

bpf_target_prog seems long and clunky, rename it to prog_ifindex. We don't want to call this field just ifindex, because maps may need a similar field in the future and bpf_attr members for programs and maps are unnamed.

Jakub Kicinski committed 8 years ago

Commit 1f6f4cb1 parent 649f11d4 files · +5 −5Browse files

Unified · Split

4 files
  1. include/uapi/linux/bpf.h +1 −1
  2. kernel/bpf/offload.c +1 −1
  3. kernel/bpf/syscall.c +2 −2
  4. tools/include/uapi/linux/bpf.h +1 −1
include/uapi/linux/bpf.h+1−1
@@ -262,7 +262,7 @@ union bpf_attr { · 261 unmodified lines
262 __u32 kern_version; /* checked when prog_type=kprobe */262 __u32 kern_version; /* checked when prog_type=kprobe */
263 __u32 prog_flags;263 __u32 prog_flags;
264 char prog_name[BPF_OBJ_NAME_LEN];264 char prog_name[BPF_OBJ_NAME_LEN];
265 __u32 prog_target_ifindex; /* ifindex of netdev to prep for */265 __u32 prog_ifindex; /* ifindex of netdev to prep for */
266 };266 };
267 267
268 struct { /* anonymous struct used by BPF_OBJ_* commands */268 struct { /* anonymous struct used by BPF_OBJ_* commands */
kernel/bpf/offload.c+1−1
@@ -29,7 +29,7 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr) · 28 unmodified lines
29 init_waitqueue_head(&offload->verifier_done);29 init_waitqueue_head(&offload->verifier_done);
30 30
31 rtnl_lock();31 rtnl_lock();
32 offload->netdev = __dev_get_by_index(net, attr->prog_target_ifindex);32 offload->netdev = __dev_get_by_index(net, attr->prog_ifindex);
33 if (!offload->netdev) {33 if (!offload->netdev) {
34 rtnl_unlock();34 rtnl_unlock();
35 kfree(offload);35 kfree(offload);
kernel/bpf/syscall.c+2−2
@@ -1118,7 +1118,7 @@ struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type, · 1117 unmodified lines
1118EXPORT_SYMBOL_GPL(bpf_prog_get_type_dev);1118EXPORT_SYMBOL_GPL(bpf_prog_get_type_dev);
1119 1119
1120/* last field in 'union bpf_attr' used by this command */1120/* last field in 'union bpf_attr' used by this command */
1121#define BPF_PROG_LOAD_LAST_FIELD prog_target_ifindex1121#define BPF_PROG_LOAD_LAST_FIELD prog_ifindex
1122 1122
1123static int bpf_prog_load(union bpf_attr *attr)1123static int bpf_prog_load(union bpf_attr *attr)
1124{1124{
@@ -1181,7 +1181,7 @@ static int bpf_prog_load(union bpf_attr *attr) · 56 unmodified lines
1181 atomic_set(&prog->aux->refcnt, 1);1181 atomic_set(&prog->aux->refcnt, 1);
1182 prog->gpl_compatible = is_gpl ? 1 : 0;1182 prog->gpl_compatible = is_gpl ? 1 : 0;
1183 1183
1184 if (attr->prog_target_ifindex) {1184 if (attr->prog_ifindex) {
1185 err = bpf_prog_offload_init(prog, attr);1185 err = bpf_prog_offload_init(prog, attr);
1186 if (err)1186 if (err)
1187 goto free_prog;1187 goto free_prog;
tools/include/uapi/linux/bpf.h+1−1
@@ -262,7 +262,7 @@ union bpf_attr { · 261 unmodified lines
262 __u32 kern_version; /* checked when prog_type=kprobe */262 __u32 kern_version; /* checked when prog_type=kprobe */
263 __u32 prog_flags;263 __u32 prog_flags;
264 char prog_name[BPF_OBJ_NAME_LEN];264 char prog_name[BPF_OBJ_NAME_LEN];
265 __u32 prog_target_ifindex; /* ifindex of netdev to prep for */265 __u32 prog_ifindex; /* ifindex of netdev to prep for */
266 };266 };
267 267
268 struct { /* anonymous struct used by BPF_OBJ_* commands */268 struct { /* anonymous struct used by BPF_OBJ_* commands */