aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/net.c
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2014-11-20 04:29:18 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 15:01:31 -0500
commitfd3cf2ad519f73c2f7a46460ebedf32ad246520c (patch)
tree805def541890ad8d3343fff208f43d3d747c56a9 /net/tipc/net.c
parent3e4b6ab58d614934e7ca99bdf448089695d34ffa (diff)
tipc: add net dump to new netlink api
Add TIPC_NL_NET_GET command to the new tipc netlink API. This command dumps the network id of the node. Netlink logical layout of returned network data: -> net -> id Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/net.c')
-rw-r--r--net/tipc/net.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 93b9944a6a8b..d9e666a1be9d 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -42,6 +42,11 @@
42#include "node.h" 42#include "node.h"
43#include "config.h" 43#include "config.h"
44 44
45static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
46 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
47 [TIPC_NLA_NET_ID] = { .type = NLA_U32 }
48};
49
45/* 50/*
46 * The TIPC locking policy is designed to ensure a very fine locking 51 * The TIPC locking policy is designed to ensure a very fine locking
47 * granularity, permitting complete parallel access to individual 52 * granularity, permitting complete parallel access to individual
@@ -138,3 +143,57 @@ void tipc_net_stop(void)
138 143
139 pr_info("Left network mode\n"); 144 pr_info("Left network mode\n");
140} 145}
146
147static int __tipc_nl_add_net(struct tipc_nl_msg *msg)
148{
149 void *hdr;
150 struct nlattr *attrs;
151
152 hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family,
153 NLM_F_MULTI, TIPC_NL_NET_GET);
154 if (!hdr)
155 return -EMSGSIZE;
156
157 attrs = nla_nest_start(msg->skb, TIPC_NLA_NET);
158 if (!attrs)
159 goto msg_full;
160
161 if (nla_put_u32(msg->skb, TIPC_NLA_NET_ID, tipc_net_id))
162 goto attr_msg_full;
163
164 nla_nest_end(msg->skb, attrs);
165 genlmsg_end(msg->skb, hdr);
166
167 return 0;
168
169attr_msg_full:
170 nla_nest_cancel(msg->skb, attrs);
171msg_full:
172 genlmsg_cancel(msg->skb, hdr);
173
174 return -EMSGSIZE;
175}
176
177int tipc_nl_net_dump(struct sk_buff *skb, struct netlink_callback *cb)
178{
179 int err;
180 int done = cb->args[0];
181 struct tipc_nl_msg msg;
182
183 if (done)
184 return 0;
185
186 msg.skb = skb;
187 msg.portid = NETLINK_CB(cb->skb).portid;
188 msg.seq = cb->nlh->nlmsg_seq;
189
190 err = __tipc_nl_add_net(&msg);
191 if (err)
192 goto out;
193
194 done = 1;
195out:
196 cb->args[0] = done;
197
198 return skb->len;
199}