diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2015-02-09 03:50:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-09 16:20:49 -0500 |
commit | d7cc75d3cb6beac88a2bd041a7700154b73a989d (patch) | |
tree | bd74842f38504d8113d4bd42f537fefac4eee016 /net/tipc | |
parent | 4b28cb581dd0df8d8ff19151f39683f641e576ba (diff) |
tipc: convert legacy nl node addr set to nl compat
Convert TIPC_CMD_SET_NODE_ADDR to compat doit.
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/config.c | 26 | ||||
-rw-r--r-- | net/tipc/net.c | 2 | ||||
-rw-r--r-- | net/tipc/netlink_compat.c | 26 |
3 files changed, 27 insertions, 27 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 74babd75c07d..2a2d05be8a27 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -134,29 +134,6 @@ static struct sk_buff *tipc_show_stats(void) | |||
134 | return buf; | 134 | return buf; |
135 | } | 135 | } |
136 | 136 | ||
137 | static struct sk_buff *cfg_set_own_addr(struct net *net) | ||
138 | { | ||
139 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
140 | u32 addr; | ||
141 | |||
142 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) | ||
143 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
144 | |||
145 | addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | ||
146 | if (addr == tn->own_addr) | ||
147 | return tipc_cfg_reply_none(); | ||
148 | if (!tipc_addr_node_valid(addr)) | ||
149 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | ||
150 | " (node address)"); | ||
151 | if (tn->own_addr) | ||
152 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
153 | " (cannot change node address once assigned)"); | ||
154 | if (!tipc_net_start(net, addr)) | ||
155 | return tipc_cfg_reply_none(); | ||
156 | |||
157 | return tipc_cfg_reply_error_string("cannot change to network mode"); | ||
158 | } | ||
159 | |||
160 | static struct sk_buff *cfg_set_netid(struct net *net) | 137 | static struct sk_buff *cfg_set_netid(struct net *net) |
161 | { | 138 | { |
162 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 139 | 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 | case TIPC_CMD_SHOW_STATS: | 185 | case TIPC_CMD_SHOW_STATS: |
209 | rep_tlv_buf = tipc_show_stats(); | 186 | rep_tlv_buf = tipc_show_stats(); |
210 | break; | 187 | break; |
211 | case TIPC_CMD_SET_NODE_ADDR: | ||
212 | rep_tlv_buf = cfg_set_own_addr(net); | ||
213 | break; | ||
214 | case TIPC_CMD_SET_NETID: | 188 | case TIPC_CMD_SET_NETID: |
215 | rep_tlv_buf = cfg_set_netid(net); | 189 | rep_tlv_buf = cfg_set_netid(net); |
216 | break; | 190 | break; |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 8b0fb0966628..e4028f927c8a 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -208,7 +208,7 @@ out: | |||
208 | 208 | ||
209 | int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) | 209 | int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info) |
210 | { | 210 | { |
211 | struct net *net = genl_info_net(info); | 211 | struct net *net = sock_net(skb->sk); |
212 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 212 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
213 | struct nlattr *attrs[TIPC_NLA_NET_MAX + 1]; | 213 | struct nlattr *attrs[TIPC_NLA_NET_MAX + 1]; |
214 | int err; | 214 | int err; |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 0dc448e77e13..aa0e3256ae93 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
@@ -851,6 +851,26 @@ static int tipc_nl_compat_node_dump(struct tipc_nl_compat_msg *msg, | |||
851 | sizeof(node_info)); | 851 | sizeof(node_info)); |
852 | } | 852 | } |
853 | 853 | ||
854 | static int tipc_nl_compat_net_set(struct sk_buff *skb, | ||
855 | struct tipc_nl_compat_msg *msg) | ||
856 | { | ||
857 | u32 val; | ||
858 | struct nlattr *net; | ||
859 | |||
860 | val = ntohl(*(__be32 *)TLV_DATA(msg->req)); | ||
861 | |||
862 | net = nla_nest_start(skb, TIPC_NLA_NET); | ||
863 | if (!net) | ||
864 | return -EMSGSIZE; | ||
865 | |||
866 | if (nla_put_u32(skb, TIPC_NLA_NET_ADDR, val)) | ||
867 | return -EMSGSIZE; | ||
868 | |||
869 | nla_nest_end(skb, net); | ||
870 | |||
871 | return 0; | ||
872 | } | ||
873 | |||
854 | static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | 874 | static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) |
855 | { | 875 | { |
856 | struct tipc_nl_compat_cmd_dump dump; | 876 | struct tipc_nl_compat_cmd_dump dump; |
@@ -924,6 +944,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) | |||
924 | dump.dumpit = tipc_nl_node_dump; | 944 | dump.dumpit = tipc_nl_node_dump; |
925 | dump.format = tipc_nl_compat_node_dump; | 945 | dump.format = tipc_nl_compat_node_dump; |
926 | return tipc_nl_compat_dumpit(&dump, msg); | 946 | return tipc_nl_compat_dumpit(&dump, msg); |
947 | case TIPC_CMD_SET_NODE_ADDR: | ||
948 | msg->req_type = TIPC_TLV_NET_ADDR; | ||
949 | doit.doit = tipc_nl_net_set; | ||
950 | doit.transcode = tipc_nl_compat_net_set; | ||
951 | return tipc_nl_compat_doit(&doit, msg); | ||
927 | } | 952 | } |
928 | 953 | ||
929 | return -EOPNOTSUPP; | 954 | return -EOPNOTSUPP; |
@@ -1033,6 +1058,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info) | |||
1033 | case TIPC_CMD_SHOW_PORTS: | 1058 | case TIPC_CMD_SHOW_PORTS: |
1034 | case TIPC_CMD_GET_MEDIA_NAMES: | 1059 | case TIPC_CMD_GET_MEDIA_NAMES: |
1035 | case TIPC_CMD_GET_NODES: | 1060 | case TIPC_CMD_GET_NODES: |
1061 | case TIPC_CMD_SET_NODE_ADDR: | ||
1036 | return tipc_nl_compat_recv(skb, info); | 1062 | return tipc_nl_compat_recv(skb, info); |
1037 | } | 1063 | } |
1038 | 1064 | ||