Skip to content

Commit cd5681d

Browse files
jasowangdavem330
authored andcommitted
tuntap: rename struct tun_steering_prog to struct tun_prog
To be reused by other eBPF program other than queue selection. Signed-off-by: Jason Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ca46abd commit cd5681d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

drivers/net/tun.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ struct tun_flow_entry {
196196

197197
#define TUN_NUM_FLOW_ENTRIES 1024
198198

199-
struct tun_steering_prog {
199+
struct tun_prog {
200200
struct rcu_head rcu;
201201
struct bpf_prog *prog;
202202
};
@@ -238,7 +238,7 @@ struct tun_struct {
238238
u32 rx_batched;
239239
struct tun_pcpu_stats __percpu *pcpu_stats;
240240
struct bpf_prog __rcu *xdp_prog;
241-
struct tun_steering_prog __rcu *steering_prog;
241+
struct tun_prog __rcu *steering_prog;
242242
};
243243

244244
bool tun_is_xdp_buff(void *ptr)
@@ -590,7 +590,7 @@ static u16 tun_automq_select_queue(struct tun_struct *tun, struct sk_buff *skb)
590590

591591
static u16 tun_ebpf_select_queue(struct tun_struct *tun, struct sk_buff *skb)
592592
{
593-
struct tun_steering_prog *prog;
593+
struct tun_prog *prog;
594594
u16 ret = 0;
595595

596596
prog = rcu_dereference(tun->steering_prog);
@@ -2184,19 +2184,18 @@ static ssize_t tun_chr_read_iter(struct kiocb *iocb, struct iov_iter *to)
21842184
return ret;
21852185
}
21862186

2187-
static void tun_steering_prog_free(struct rcu_head *rcu)
2187+
static void tun_prog_free(struct rcu_head *rcu)
21882188
{
2189-
struct tun_steering_prog *prog = container_of(rcu,
2190-
struct tun_steering_prog, rcu);
2189+
struct tun_prog *prog = container_of(rcu, struct tun_prog, rcu);
21912190

21922191
bpf_prog_destroy(prog->prog);
21932192
kfree(prog);
21942193
}
21952194

2196-
static int __tun_set_steering_ebpf(struct tun_struct *tun,
2197-
struct bpf_prog *prog)
2195+
static int __tun_set_ebpf(struct tun_struct *tun, struct tun_prog **prog_p,
2196+
struct bpf_prog *prog)
21982197
{
2199-
struct tun_steering_prog *old, *new = NULL;
2198+
struct tun_prog *old, *new = NULL;
22002199

22012200
if (prog) {
22022201
new = kmalloc(sizeof(*new), GFP_KERNEL);
@@ -2206,13 +2205,13 @@ static int __tun_set_steering_ebpf(struct tun_struct *tun,
22062205
}
22072206

22082207
spin_lock_bh(&tun->lock);
2209-
old = rcu_dereference_protected(tun->steering_prog,
2208+
old = rcu_dereference_protected(*prog_p,
22102209
lockdep_is_held(&tun->lock));
2211-
rcu_assign_pointer(tun->steering_prog, new);
2210+
rcu_assign_pointer(*prog_p, new);
22122211
spin_unlock_bh(&tun->lock);
22132212

22142213
if (old)
2215-
call_rcu(&old->rcu, tun_steering_prog_free);
2214+
call_rcu(&old->rcu, tun_prog_free);
22162215

22172216
return 0;
22182217
}
@@ -2225,7 +2224,7 @@ static void tun_free_netdev(struct net_device *dev)
22252224
free_percpu(tun->pcpu_stats);
22262225
tun_flow_uninit(tun);
22272226
security_tun_dev_free_security(tun->security);
2228-
__tun_set_steering_ebpf(tun, NULL);
2227+
__tun_set_ebpf(tun, &tun->steering_prog, NULL);
22292228
}
22302229

22312230
static void tun_setup(struct net_device *dev)
@@ -2720,7 +2719,8 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
27202719
return ret;
27212720
}
27222721

2723-
static int tun_set_steering_ebpf(struct tun_struct *tun, void __user *data)
2722+
static int tun_set_ebpf(struct tun_struct *tun, struct tun_prog **prog_p,
2723+
void __user *data)
27242724
{
27252725
struct bpf_prog *prog;
27262726
int fd;
@@ -2736,7 +2736,7 @@ static int tun_set_steering_ebpf(struct tun_struct *tun, void __user *data)
27362736
return PTR_ERR(prog);
27372737
}
27382738

2739-
return __tun_set_steering_ebpf(tun, prog);
2739+
return __tun_set_ebpf(tun, prog_p, prog);
27402740
}
27412741

27422742
static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
@@ -3016,7 +3016,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
30163016
break;
30173017

30183018
case TUNSETSTEERINGEBPF:
3019-
ret = tun_set_steering_ebpf(tun, argp);
3019+
ret = tun_set_ebpf(tun, &tun->steering_prog, argp);
30203020
break;
30213021

30223022
default:

0 commit comments

Comments
 (0)