[PATCH v5 07/11] netlink: allow modification of transit net

Julian Orth ju.orth at gmail.com
Mon Dec 17 15:52:06 CET 2018


On 12/15/18 5:56 PM, Julian Orth wrote:
> +	ret = test_socket_net_capable(net ? : wg->transit_net);
I forgot to include the fix mentioned in [1]. I have fixed the commit in the
repository and I'll include the diff below.

diff --git a/src/netlink.c b/src/netlink.c
index f5c3a9e..90ff936 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -350,14 +350,20 @@ static int wg_get_device_done(struct netlink_callback *cb)

 static int set_socket(struct wg_device *wg, struct nlattr **attrs)
 {
-	struct wg_peer *peer;
-	struct nlattr *port_attr = attrs[WGDEVICE_A_LISTEN_PORT];
-	u16 port;
+	struct nlattr *netns_pid_attr, *netns_fd_attr, *port_attr;
 	struct net *net = NULL;
+	struct wg_peer *peer;
 	int ret = 0;
+	u16 port;
+
+	netns_pid_attr = attrs[WGDEVICE_A_TRANSIT_NETNS_PID];
+	netns_fd_attr = attrs[WGDEVICE_A_TRANSIT_NETNS_FD];
+	port_attr = attrs[WGDEVICE_A_LISTEN_PORT];
+
+	if (!netns_pid_attr && !netns_fd_attr && !port_attr)
+		return 0;

-	net = get_attr_net(attrs[WGDEVICE_A_TRANSIT_NETNS_PID],
-			attrs[WGDEVICE_A_TRANSIT_NETNS_FD]);
+	net = get_attr_net(netns_pid_attr, netns_fd_attr);
 	if (IS_ERR(net))
 		return PTR_ERR(net);
 	if (port_attr)

[1] https://lists.zx2c4.com/pipermail/wireguard/2018-October/003459.html


More information about the WireGuard mailing list