summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fastd.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/fastd.c b/fastd.c
index 00dd41e..abdd17f 100644
--- a/fastd.c
+++ b/fastd.c
@@ -287,6 +287,8 @@ static int fastd_cmd_create(struct sk_buff *skb, struct genl_info *info)
u16 mtu = FASTD_DEFAULT_MTU;
const char *name = "fastd%d";
int err;
+ struct sk_buff *ret;
+ void *skb_head;
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM;
@@ -331,19 +333,41 @@ static int fastd_cmd_create(struct sk_buff *skb, struct genl_info *info)
fastd_netdev_init(dev);
dev->mtu = mtu;
+ ret = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+ if (!ret) {
+ err = -ENOMEM;
+ goto err_free_dev;
+ }
+
+ skb_head = genlmsg_put(ret, 0, info->snd_seq, &fastd_nl_family, 0, FASTD_CMD_CREATE);
+ if (!skb_head) {
+ err = -ENOMEM;
+ goto err_free_skb;
+ }
+
rtnl_lock();
err = register_netdevice(dev);
- if (err < 0) {
+ if (err) {
rtnl_unlock();
goto err_free_dev;
}
list_add_rcu(&fastd->list, &fastd_list);
+ nla_put_string(ret, FASTD_A_IFNAME, dev->name);
+
rtnl_unlock();
+ genlmsg_end(ret, skb_head);
+ err = genlmsg_reply(ret, info);
+ if (err)
+ return err;
+
return 0;
+err_free_skb:
+ kfree_skb(ret);
+
err_free_dev:
free_netdev(dev);