diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-10-15 22:16:29 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-10-15 22:16:29 +0200 |
commit | d4b6cacbbb73ceef19c68c404b2d5eadf42d99c2 (patch) | |
tree | 9b6e41ecff0daa247da11c23cb12a3f9e00bfbb2 | |
parent | 807fde8a03408dd659112cce7bd75813366fea9b (diff) | |
download | modfastd-d4b6cacbbb73ceef19c68c404b2d5eadf42d99c2.tar modfastd-d4b6cacbbb73ceef19c68c404b2d5eadf42d99c2.zip |
Return allocated ifname on create
-rw-r--r-- | fastd.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -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); |