浏览代码

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Daniel Borkmann says:

====================
pull-request: bpf 2018-10-14

The following pull-request contains BPF updates for your *net* tree.

The main changes are:

1) Fix xsk map update and delete operation to not call synchronize_net()
   but to piggy back on SOCK_RCU_FREE for sockets instead as we are not
   allowed to sleep under RCU, from Björn.

2) Do not change RLIMIT_MEMLOCK in reuseport_bpf selftest if the process
   already has unlimited RLIMIT_MEMLOCK, from Eric.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
David S. Miller 6 年之前
父节点
当前提交
028c99fa91
共有 3 个文件被更改,包括 13 次插入12 次删除
  1. 2 8
      kernel/bpf/xskmap.c
  2. 2 0
      net/xdp/xsk.c
  3. 9 4
      tools/testing/selftests/net/reuseport_bpf.c

+ 2 - 8
kernel/bpf/xskmap.c

@@ -192,11 +192,8 @@ static int xsk_map_update_elem(struct bpf_map *map, void *key, void *value,
 	sock_hold(sock->sk);
 	sock_hold(sock->sk);
 
 
 	old_xs = xchg(&m->xsk_map[i], xs);
 	old_xs = xchg(&m->xsk_map[i], xs);
-	if (old_xs) {
-		/* Make sure we've flushed everything. */
-		synchronize_net();
+	if (old_xs)
 		sock_put((struct sock *)old_xs);
 		sock_put((struct sock *)old_xs);
-	}
 
 
 	sockfd_put(sock);
 	sockfd_put(sock);
 	return 0;
 	return 0;
@@ -212,11 +209,8 @@ static int xsk_map_delete_elem(struct bpf_map *map, void *key)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	old_xs = xchg(&m->xsk_map[k], NULL);
 	old_xs = xchg(&m->xsk_map[k], NULL);
-	if (old_xs) {
-		/* Make sure we've flushed everything. */
-		synchronize_net();
+	if (old_xs)
 		sock_put((struct sock *)old_xs);
 		sock_put((struct sock *)old_xs);
-	}
 
 
 	return 0;
 	return 0;
 }
 }

+ 2 - 0
net/xdp/xsk.c

@@ -744,6 +744,8 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol,
 	sk->sk_destruct = xsk_destruct;
 	sk->sk_destruct = xsk_destruct;
 	sk_refcnt_debug_inc(sk);
 	sk_refcnt_debug_inc(sk);
 
 
+	sock_set_flag(sk, SOCK_RCU_FREE);
+
 	xs = xdp_sk(sk);
 	xs = xdp_sk(sk);
 	mutex_init(&xs->mutex);
 	mutex_init(&xs->mutex);
 	spin_lock_init(&xs->tx_completion_lock);
 	spin_lock_init(&xs->tx_completion_lock);

+ 9 - 4
tools/testing/selftests/net/reuseport_bpf.c

@@ -437,14 +437,19 @@ void enable_fastopen(void)
 	}
 	}
 }
 }
 
 
-static struct rlimit rlim_old, rlim_new;
+static struct rlimit rlim_old;
 
 
 static  __attribute__((constructor)) void main_ctor(void)
 static  __attribute__((constructor)) void main_ctor(void)
 {
 {
 	getrlimit(RLIMIT_MEMLOCK, &rlim_old);
 	getrlimit(RLIMIT_MEMLOCK, &rlim_old);
-	rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
-	rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
-	setrlimit(RLIMIT_MEMLOCK, &rlim_new);
+
+	if (rlim_old.rlim_cur != RLIM_INFINITY) {
+		struct rlimit rlim_new;
+
+		rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
+		rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
+		setrlimit(RLIMIT_MEMLOCK, &rlim_new);
+	}
 }
 }
 
 
 static __attribute__((destructor)) void main_dtor(void)
 static __attribute__((destructor)) void main_dtor(void)