@@ -196,7 +196,7 @@ struct tun_flow_entry {
196
196
197
197
#define TUN_NUM_FLOW_ENTRIES 1024
198
198
199
- struct tun_steering_prog {
199
+ struct tun_prog {
200
200
struct rcu_head rcu ;
201
201
struct bpf_prog * prog ;
202
202
};
@@ -238,7 +238,7 @@ struct tun_struct {
238
238
u32 rx_batched ;
239
239
struct tun_pcpu_stats __percpu * pcpu_stats ;
240
240
struct bpf_prog __rcu * xdp_prog ;
241
- struct tun_steering_prog __rcu * steering_prog ;
241
+ struct tun_prog __rcu * steering_prog ;
242
242
};
243
243
244
244
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)
590
590
591
591
static u16 tun_ebpf_select_queue (struct tun_struct * tun , struct sk_buff * skb )
592
592
{
593
- struct tun_steering_prog * prog ;
593
+ struct tun_prog * prog ;
594
594
u16 ret = 0 ;
595
595
596
596
prog = rcu_dereference (tun -> steering_prog );
@@ -2184,19 +2184,18 @@ static ssize_t tun_chr_read_iter(struct kiocb *iocb, struct iov_iter *to)
2184
2184
return ret ;
2185
2185
}
2186
2186
2187
- static void tun_steering_prog_free (struct rcu_head * rcu )
2187
+ static void tun_prog_free (struct rcu_head * rcu )
2188
2188
{
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 );
2191
2190
2192
2191
bpf_prog_destroy (prog -> prog );
2193
2192
kfree (prog );
2194
2193
}
2195
2194
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 )
2198
2197
{
2199
- struct tun_steering_prog * old , * new = NULL ;
2198
+ struct tun_prog * old , * new = NULL ;
2200
2199
2201
2200
if (prog ) {
2202
2201
new = kmalloc (sizeof (* new ), GFP_KERNEL );
@@ -2206,13 +2205,13 @@ static int __tun_set_steering_ebpf(struct tun_struct *tun,
2206
2205
}
2207
2206
2208
2207
spin_lock_bh (& tun -> lock );
2209
- old = rcu_dereference_protected (tun -> steering_prog ,
2208
+ old = rcu_dereference_protected (* prog_p ,
2210
2209
lockdep_is_held (& tun -> lock ));
2211
- rcu_assign_pointer (tun -> steering_prog , new );
2210
+ rcu_assign_pointer (* prog_p , new );
2212
2211
spin_unlock_bh (& tun -> lock );
2213
2212
2214
2213
if (old )
2215
- call_rcu (& old -> rcu , tun_steering_prog_free );
2214
+ call_rcu (& old -> rcu , tun_prog_free );
2216
2215
2217
2216
return 0 ;
2218
2217
}
@@ -2225,7 +2224,7 @@ static void tun_free_netdev(struct net_device *dev)
2225
2224
free_percpu (tun -> pcpu_stats );
2226
2225
tun_flow_uninit (tun );
2227
2226
security_tun_dev_free_security (tun -> security );
2228
- __tun_set_steering_ebpf (tun , NULL );
2227
+ __tun_set_ebpf (tun , & tun -> steering_prog , NULL );
2229
2228
}
2230
2229
2231
2230
static void tun_setup (struct net_device * dev )
@@ -2720,7 +2719,8 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
2720
2719
return ret ;
2721
2720
}
2722
2721
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 )
2724
2724
{
2725
2725
struct bpf_prog * prog ;
2726
2726
int fd ;
@@ -2736,7 +2736,7 @@ static int tun_set_steering_ebpf(struct tun_struct *tun, void __user *data)
2736
2736
return PTR_ERR (prog );
2737
2737
}
2738
2738
2739
- return __tun_set_steering_ebpf (tun , prog );
2739
+ return __tun_set_ebpf (tun , prog_p , prog );
2740
2740
}
2741
2741
2742
2742
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,
3016
3016
break ;
3017
3017
3018
3018
case TUNSETSTEERINGEBPF :
3019
- ret = tun_set_steering_ebpf (tun , argp );
3019
+ ret = tun_set_ebpf (tun , & tun -> steering_prog , argp );
3020
3020
break ;
3021
3021
3022
3022
default :
0 commit comments