net.c (fd3cf2ad519f73c2f7a46460ebedf32ad246520c) net.c (27c21416727af73df45051acb05331c0f10e50f6)
1/*
2 * net/tipc/net.c: TIPC network routing code
3 *
4 * Copyright (c) 1995-2006, 2014, Ericsson AB
5 * Copyright (c) 2005, 2010-2011, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 183 unchanged lines hidden (view full) ---

192 goto out;
193
194 done = 1;
195out:
196 cb->args[0] = done;
197
198 return skb->len;
199}
1/*
2 * net/tipc/net.c: TIPC network routing code
3 *
4 * Copyright (c) 1995-2006, 2014, Ericsson AB
5 * Copyright (c) 2005, 2010-2011, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 183 unchanged lines hidden (view full) ---

192 goto out;
193
194 done = 1;
195out:
196 cb->args[0] = done;
197
198 return skb->len;
199}
200
201int tipc_nl_net_set(struct sk_buff *skb, struct genl_info *info)
202{
203 int err;
204 struct nlattr *attrs[TIPC_NLA_NET_MAX + 1];
205
206 if (!info->attrs[TIPC_NLA_NET])
207 return -EINVAL;
208
209 err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX,
210 info->attrs[TIPC_NLA_NET],
211 tipc_nl_net_policy);
212 if (err)
213 return err;
214
215 if (attrs[TIPC_NLA_NET_ID]) {
216 u32 val;
217
218 /* Can't change net id once TIPC has joined a network */
219 if (tipc_own_addr)
220 return -EPERM;
221
222 val = nla_get_u32(attrs[TIPC_NLA_NET_ID]);
223 if (val < 1 || val > 9999)
224 return -EINVAL;
225
226 tipc_net_id = val;
227 }
228
229 if (attrs[TIPC_NLA_NET_ADDR]) {
230 u32 addr;
231
232 /* Can't change net addr once TIPC has joined a network */
233 if (tipc_own_addr)
234 return -EPERM;
235
236 addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]);
237 if (!tipc_addr_node_valid(addr))
238 return -EINVAL;
239
240 rtnl_lock();
241 tipc_net_start(addr);
242 rtnl_unlock();
243 }
244
245 return 0;
246}