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.
Unified · Split
| @@ -262,7 +262,7 @@ union bpf_attr { · 261 unmodified lines | ||
| 262 | 262 | __u32 kern_version; /* checked when prog_type=kprobe */ |
| 263 | 263 | __u32 prog_flags; |
| 264 | 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 | 268 | struct { /* anonymous struct used by BPF_OBJ_* commands */ |
| @@ -29,7 +29,7 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr) · 28 unmodified lines | ||
| 29 | 29 | init_waitqueue_head(&offload->verifier_done); |
| 30 | 30 | |
| 31 | 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 | 33 | if (!offload->netdev) { |
| 34 | 34 | rtnl_unlock(); |
| 35 | 35 | kfree(offload); |
| @@ -1118,7 +1118,7 @@ struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type, · 1117 unmodified lines | ||
| 1118 | 1118 | EXPORT_SYMBOL_GPL(bpf_prog_get_type_dev); |
| 1119 | 1119 | |
| 1120 | 1120 | /* last field in 'union bpf_attr' used by this command */ |
| 1121 | −#define BPF_PROG_LOAD_LAST_FIELD prog_target_ifindex | |
| 1121 | +#define BPF_PROG_LOAD_LAST_FIELD prog_ifindex | |
| 1122 | 1122 | |
| 1123 | 1123 | static 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 | 1181 | atomic_set(&prog->aux->refcnt, 1); |
| 1182 | 1182 | prog->gpl_compatible = is_gpl ? 1 : 0; |
| 1183 | 1183 | |
| 1184 | − if (attr->prog_target_ifindex) { | |
| 1184 | + if (attr->prog_ifindex) { | |
| 1185 | 1185 | err = bpf_prog_offload_init(prog, attr); |
| 1186 | 1186 | if (err) |
| 1187 | 1187 | goto free_prog; |
| @@ -262,7 +262,7 @@ union bpf_attr { · 261 unmodified lines | ||
| 262 | 262 | __u32 kern_version; /* checked when prog_type=kprobe */ |
| 263 | 263 | __u32 prog_flags; |
| 264 | 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 | 268 | struct { /* anonymous struct used by BPF_OBJ_* commands */ |