Commit d7cc75d3 authored by Richard Alpe's avatar Richard Alpe Committed by David S. Miller

tipc: convert legacy nl node addr set to nl compat

Convert TIPC_CMD_SET_NODE_ADDR to compat doit.
Signed-off-by: default avatarRichard Alpe <richard.alpe@ericsson.com>
Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Reviewed-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4b28cb58
...@@ -134,29 +134,6 @@ static struct sk_buff *tipc_show_stats(void) ...@@ -134,29 +134,6 @@ static struct sk_buff *tipc_show_stats(void)
return buf; return buf;
} }
static struct sk_buff *cfg_set_own_addr(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
u32 addr;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
if (addr == tn->own_addr)
return tipc_cfg_reply_none();
if (!tipc_addr_node_valid(addr))
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (node address)");
if (tn->own_addr)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)");
if (!tipc_net_start(net, addr))
return tipc_cfg_reply_none();
return tipc_cfg_reply_error_string("cannot change to network mode");
}
static struct sk_buff *cfg_set_netid(struct net *net) static struct sk_buff *cfg_set_netid(struct net *net)
{ {
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
...@@ -208,9 +185,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd, ...@@ -208,9 +185,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
case TIPC_CMD_SHOW_STATS: case TIPC_CMD_SHOW_STATS:
rep_tlv_buf = tipc_show_stats(); rep_tlv_buf = tipc_show_stats();
break; break;
case TIPC_CMD_SET_NODE_ADDR:
rep_tlv_buf = cfg_set_own_addr(net);
break;
case TIPC_CMD_SET_NETID: case TIPC_CMD_SET_NETID:
rep_tlv_buf = cfg_set_netid(net); rep_tlv_buf = cfg_set_netid(net);
break; break;
......
...@@ -208,7 +208,7 @@ int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -208,7 +208,7 @@ int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb)
int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
{ {
struct net *net = genl_info_net(info); struct net *net = sock_net(skb->sk);
struct tipc_net *tn = net_generic(net, tipc_net_id); struct tipc_net *tn = net_generic(net, tipc_net_id);
struct nlattr *attrs[TIPC_NLA_NET_MAX + 1]; struct nlattr *attrs[TIPC_NLA_NET_MAX + 1];
int err; int err;
......
...@@ -851,6 +851,26 @@ static int tipc_nl_compat_node_dump(struct tipc_nl_compat_msg *msg, ...@@ -851,6 +851,26 @@ static int tipc_nl_compat_node_dump(struct tipc_nl_compat_msg *msg,
sizeof(node_info)); sizeof(node_info));
} }
static int tipc_nl_compat_net_set(struct sk_buff *skb,
struct tipc_nl_compat_msg *msg)
{
u32 val;
struct nlattr *net;
val = ntohl(*(__be32 *)TLV_DATA(msg->req));
net = nla_nest_start(skb, TIPC_NLA_NET);
if (!net)
return -EMSGSIZE;
if (nla_put_u32(skb, TIPC_NLA_NET_ADDR, val))
return -EMSGSIZE;
nla_nest_end(skb, net);
return 0;
}
static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
{ {
struct tipc_nl_compat_cmd_dump dump; struct tipc_nl_compat_cmd_dump dump;
...@@ -924,6 +944,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) ...@@ -924,6 +944,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
dump.dumpit = tipc_nl_node_dump; dump.dumpit = tipc_nl_node_dump;
dump.format = tipc_nl_compat_node_dump; dump.format = tipc_nl_compat_node_dump;
return tipc_nl_compat_dumpit(&dump, msg); return tipc_nl_compat_dumpit(&dump, msg);
case TIPC_CMD_SET_NODE_ADDR:
msg->req_type = TIPC_TLV_NET_ADDR;
doit.doit = tipc_nl_net_set;
doit.transcode = tipc_nl_compat_net_set;
return tipc_nl_compat_doit(&doit, msg);
} }
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1033,6 +1058,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info) ...@@ -1033,6 +1058,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
case TIPC_CMD_SHOW_PORTS: case TIPC_CMD_SHOW_PORTS:
case TIPC_CMD_GET_MEDIA_NAMES: case TIPC_CMD_GET_MEDIA_NAMES:
case TIPC_CMD_GET_NODES: case TIPC_CMD_GET_NODES:
case TIPC_CMD_SET_NODE_ADDR:
return tipc_nl_compat_recv(skb, info); return tipc_nl_compat_recv(skb, info);
} }
......
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