Commit d49e2041 authored by Ying Xue's avatar Ying Xue Committed by David S. Miller

tipc: make netlink support net namespace

Currently tipc module only allows users sitting on "init_net" namespace
to configure it through netlink interface. But now almost each tipc
component is able to be aware of net namespace, so it's time to open
the permission for users residing in other namespaces, allowing them
to configure their own tipc stack instance through netlink interface.
Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
Tested-by: default avatarTero Aho <Tero.Aho@coriant.com>
Reviewed-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bafa29e3
...@@ -54,7 +54,8 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info) ...@@ -54,7 +54,8 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN); int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN);
u16 cmd; u16 cmd;
if ((req_userhdr->cmd & 0xC000) && (!netlink_capable(skb, CAP_NET_ADMIN))) if ((req_userhdr->cmd & 0xC000) &&
(!netlink_net_capable(skb, CAP_NET_ADMIN)))
cmd = TIPC_CMD_NOT_NET_ADMIN; cmd = TIPC_CMD_NOT_NET_ADMIN;
else else
cmd = req_userhdr->cmd; cmd = req_userhdr->cmd;
...@@ -70,7 +71,7 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info) ...@@ -70,7 +71,7 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
rep_nlh = nlmsg_hdr(rep_buf); rep_nlh = nlmsg_hdr(rep_buf);
memcpy(rep_nlh, req_nlh, hdr_space); memcpy(rep_nlh, req_nlh, hdr_space);
rep_nlh->nlmsg_len = rep_buf->len; rep_nlh->nlmsg_len = rep_buf->len;
genlmsg_unicast(&init_net, rep_buf, NETLINK_CB(skb).portid); genlmsg_unicast(net, rep_buf, NETLINK_CB(skb).portid);
} }
return 0; return 0;
...@@ -95,6 +96,7 @@ static struct genl_family tipc_genl_family = { ...@@ -95,6 +96,7 @@ static struct genl_family tipc_genl_family = {
.version = TIPC_GENL_VERSION, .version = TIPC_GENL_VERSION,
.hdrsize = TIPC_GENL_HDRLEN, .hdrsize = TIPC_GENL_HDRLEN,
.maxattr = 0, .maxattr = 0,
.netnsok = true,
}; };
/* Legacy ASCII API */ /* Legacy ASCII API */
...@@ -114,6 +116,7 @@ struct genl_family tipc_genl_v2_family = { ...@@ -114,6 +116,7 @@ struct genl_family tipc_genl_v2_family = {
.version = TIPC_GENL_V2_VERSION, .version = TIPC_GENL_V2_VERSION,
.hdrsize = 0, .hdrsize = 0,
.maxattr = TIPC_NLA_MAX, .maxattr = TIPC_NLA_MAX,
.netnsok = true,
}; };
static const struct genl_ops tipc_genl_v2_ops[] = { static const struct genl_ops tipc_genl_v2_ops[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment