From 6e93844647f2af858cf1ee4d6351f6f78dc1e5b7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 14 Oct 2013 01:51:25 +0200 Subject: Set netns for created socket --- fastd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fastd.c b/fastd.c index d660c35..c9afc67 100644 --- a/fastd.c +++ b/fastd.c @@ -352,6 +352,7 @@ err_module_put: static int fastd_cmd_bind(struct sk_buff *skb, struct genl_info *info) { + struct net *net = genl_info_net(info); int err; sa_family_t af; struct fastd_socket *socket; @@ -369,10 +370,12 @@ static int fastd_cmd_bind(struct sk_buff *skb, struct genl_info *info) if (!socket) return -ENOMEM; - err = sock_create_kern(af, SOCK_DGRAM, 0, &socket->sock); + err = sock_create_kern(af, SOCK_DGRAM, IPPROTO_UDP, &socket->sock); if (err) goto err_free_socket; + sk_change_net(socket->sock->sk, net); + err = kernel_bind(socket->sock, nla_data(info->attrs[FASTD_A_LOCALADDR]), nla_len(info->attrs[FASTD_A_LOCALADDR])); @@ -381,7 +384,7 @@ static int fastd_cmd_bind(struct sk_buff *skb, struct genl_info *info) rcu_read_lock(); - fastd = fastd_find(genl_info_net(info), info->snd_portid); + fastd = fastd_find(net, info->snd_portid); if (!fastd) { err = -EINVAL; goto err_unlock_rcu; -- cgit v1.2.3