summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2015-02-09 03:50:16 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-09 16:20:49 -0500
commit3c26181c5b1b0b49e147bac8a8d012234f813a5e (patch)
tree5a4d880521fb884f811619c069db60df04e849ea
parent964f9501c1910c0835eee3cf870ba5aa44db1241 (diff)
tipc: convert legacy nl net id get to nl compat
Convert TIPC_CMD_GET_NETID to compat dumpit. 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>
-rw-r--r--net/tipc/config.c23
-rw-r--r--net/tipc/netlink_compat.c18
2 files changed, 18 insertions, 23 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 080cc92eedca..019f46c0690c 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -72,25 +72,6 @@ int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
72 return 1; 72 return 1;
73} 73}
74 74
75static struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value)
76{
77 struct sk_buff *buf;
78 __be32 value_net;
79
80 buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value)));
81 if (buf) {
82 value_net = htonl(value);
83 tipc_cfg_append_tlv(buf, tlv_type, &value_net,
84 sizeof(value_net));
85 }
86 return buf;
87}
88
89static struct sk_buff *tipc_cfg_reply_unsigned(u32 value)
90{
91 return tipc_cfg_reply_unsigned_type(TIPC_TLV_UNSIGNED, value);
92}
93
94struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) 75struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string)
95{ 76{
96 struct sk_buff *buf; 77 struct sk_buff *buf;
@@ -139,7 +120,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
139 int reply_headroom) 120 int reply_headroom)
140{ 121{
141 struct sk_buff *rep_tlv_buf; 122 struct sk_buff *rep_tlv_buf;
142 struct tipc_net *tn = net_generic(net, tipc_net_id);
143 123
144 rtnl_lock(); 124 rtnl_lock();
145 125
@@ -165,9 +145,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
165 case TIPC_CMD_SHOW_STATS: 145 case TIPC_CMD_SHOW_STATS:
166 rep_tlv_buf = tipc_show_stats(); 146 rep_tlv_buf = tipc_show_stats();
167 break; 147 break;
168 case TIPC_CMD_GET_NETID:
169 rep_tlv_buf = tipc_cfg_reply_unsigned(tn->net_id);
170 break;
171 case TIPC_CMD_NOT_NET_ADMIN: 148 case TIPC_CMD_NOT_NET_ADMIN:
172 rep_tlv_buf = 149 rep_tlv_buf =
173 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN); 150 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN);
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index c355476a6e7c..415909054ec0 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -876,6 +876,18 @@ static int tipc_nl_compat_net_set(struct sk_buff *skb,
876 return 0; 876 return 0;
877} 877}
878 878
879static int tipc_nl_compat_net_dump(struct tipc_nl_compat_msg *msg,
880 struct nlattr **attrs)
881{
882 __be32 id;
883 struct nlattr *net[TIPC_NLA_NET_MAX + 1];
884
885 nla_parse_nested(net, TIPC_NLA_NET_MAX, attrs[TIPC_NLA_NET], NULL);
886 id = htonl(nla_get_u32(net[TIPC_NLA_NET_ID]));
887
888 return tipc_add_tlv(msg->rep, TIPC_TLV_UNSIGNED, &id, sizeof(id));
889}
890
879static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) 891static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
880{ 892{
881 struct tipc_nl_compat_cmd_dump dump; 893 struct tipc_nl_compat_cmd_dump dump;
@@ -959,6 +971,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
959 doit.doit = tipc_nl_net_set; 971 doit.doit = tipc_nl_net_set;
960 doit.transcode = tipc_nl_compat_net_set; 972 doit.transcode = tipc_nl_compat_net_set;
961 return tipc_nl_compat_doit(&doit, msg); 973 return tipc_nl_compat_doit(&doit, msg);
974 case TIPC_CMD_GET_NETID:
975 msg->rep_size = sizeof(u32);
976 dump.dumpit = tipc_nl_net_dump;
977 dump.format = tipc_nl_compat_net_dump;
978 return tipc_nl_compat_dumpit(&dump, msg);
962 } 979 }
963 980
964 return -EOPNOTSUPP; 981 return -EOPNOTSUPP;
@@ -1070,6 +1087,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
1070 case TIPC_CMD_GET_NODES: 1087 case TIPC_CMD_GET_NODES:
1071 case TIPC_CMD_SET_NODE_ADDR: 1088 case TIPC_CMD_SET_NODE_ADDR:
1072 case TIPC_CMD_SET_NETID: 1089 case TIPC_CMD_SET_NETID:
1090 case TIPC_CMD_GET_NETID:
1073 return tipc_nl_compat_recv(skb, info); 1091 return tipc_nl_compat_recv(skb, info);
1074 } 1092 }
1075 1093