.. | .. |
---|
41 | 41 | #include "socket.h" |
---|
42 | 42 | #include "node.h" |
---|
43 | 43 | #include "bcast.h" |
---|
| 44 | +#include "link.h" |
---|
44 | 45 | #include "netlink.h" |
---|
45 | 46 | #include "monitor.h" |
---|
46 | 47 | |
---|
.. | .. |
---|
105 | 106 | * - A local spin_lock protecting the queue of subscriber events. |
---|
106 | 107 | */ |
---|
107 | 108 | |
---|
108 | | -struct tipc_net_work { |
---|
109 | | - struct work_struct work; |
---|
110 | | - struct net *net; |
---|
111 | | - u32 addr; |
---|
112 | | -}; |
---|
113 | | - |
---|
114 | 109 | static void tipc_net_finalize(struct net *net, u32 addr); |
---|
115 | 110 | |
---|
116 | 111 | int tipc_net_init(struct net *net, u8 *node_id, u32 addr) |
---|
.. | .. |
---|
142 | 137 | TIPC_CLUSTER_SCOPE, 0, addr); |
---|
143 | 138 | } |
---|
144 | 139 | |
---|
145 | | -static void tipc_net_finalize_work(struct work_struct *work) |
---|
| 140 | +void tipc_net_finalize_work(struct work_struct *work) |
---|
146 | 141 | { |
---|
147 | | - struct tipc_net_work *fwork; |
---|
| 142 | + struct tipc_net *tn = container_of(work, struct tipc_net, work); |
---|
148 | 143 | |
---|
149 | | - fwork = container_of(work, struct tipc_net_work, work); |
---|
150 | | - tipc_net_finalize(fwork->net, fwork->addr); |
---|
151 | | - kfree(fwork); |
---|
152 | | -} |
---|
153 | | - |
---|
154 | | -void tipc_sched_net_finalize(struct net *net, u32 addr) |
---|
155 | | -{ |
---|
156 | | - struct tipc_net_work *fwork = kzalloc(sizeof(*fwork), GFP_ATOMIC); |
---|
157 | | - |
---|
158 | | - if (!fwork) |
---|
159 | | - return; |
---|
160 | | - INIT_WORK(&fwork->work, tipc_net_finalize_work); |
---|
161 | | - fwork->net = net; |
---|
162 | | - fwork->addr = addr; |
---|
163 | | - schedule_work(&fwork->work); |
---|
| 144 | + tipc_net_finalize(tipc_link_net(tn->bcl), tn->trial_addr); |
---|
164 | 145 | } |
---|
165 | 146 | |
---|
166 | 147 | void tipc_net_stop(struct net *net) |
---|
.. | .. |
---|
189 | 170 | if (!hdr) |
---|
190 | 171 | return -EMSGSIZE; |
---|
191 | 172 | |
---|
192 | | - attrs = nla_nest_start(msg->skb, TIPC_NLA_NET); |
---|
| 173 | + attrs = nla_nest_start_noflag(msg->skb, TIPC_NLA_NET); |
---|
193 | 174 | if (!attrs) |
---|
194 | 175 | goto msg_full; |
---|
195 | 176 | |
---|
.. | .. |
---|
247 | 228 | if (!info->attrs[TIPC_NLA_NET]) |
---|
248 | 229 | return -EINVAL; |
---|
249 | 230 | |
---|
250 | | - err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX, |
---|
251 | | - info->attrs[TIPC_NLA_NET], tipc_nl_net_policy, |
---|
252 | | - info->extack); |
---|
| 231 | + err = nla_parse_nested_deprecated(attrs, TIPC_NLA_NET_MAX, |
---|
| 232 | + info->attrs[TIPC_NLA_NET], |
---|
| 233 | + tipc_nl_net_policy, info->extack); |
---|
253 | 234 | |
---|
254 | 235 | if (err) |
---|
255 | 236 | return err; |
---|
.. | .. |
---|
302 | 283 | |
---|
303 | 284 | return err; |
---|
304 | 285 | } |
---|
| 286 | + |
---|
| 287 | +static int __tipc_nl_addr_legacy_get(struct net *net, struct tipc_nl_msg *msg) |
---|
| 288 | +{ |
---|
| 289 | + struct tipc_net *tn = tipc_net(net); |
---|
| 290 | + struct nlattr *attrs; |
---|
| 291 | + void *hdr; |
---|
| 292 | + |
---|
| 293 | + hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, |
---|
| 294 | + 0, TIPC_NL_ADDR_LEGACY_GET); |
---|
| 295 | + if (!hdr) |
---|
| 296 | + return -EMSGSIZE; |
---|
| 297 | + |
---|
| 298 | + attrs = nla_nest_start(msg->skb, TIPC_NLA_NET); |
---|
| 299 | + if (!attrs) |
---|
| 300 | + goto msg_full; |
---|
| 301 | + |
---|
| 302 | + if (tn->legacy_addr_format) |
---|
| 303 | + if (nla_put_flag(msg->skb, TIPC_NLA_NET_ADDR_LEGACY)) |
---|
| 304 | + goto attr_msg_full; |
---|
| 305 | + |
---|
| 306 | + nla_nest_end(msg->skb, attrs); |
---|
| 307 | + genlmsg_end(msg->skb, hdr); |
---|
| 308 | + |
---|
| 309 | + return 0; |
---|
| 310 | + |
---|
| 311 | +attr_msg_full: |
---|
| 312 | + nla_nest_cancel(msg->skb, attrs); |
---|
| 313 | +msg_full: |
---|
| 314 | + genlmsg_cancel(msg->skb, hdr); |
---|
| 315 | + |
---|
| 316 | + return -EMSGSIZE; |
---|
| 317 | +} |
---|
| 318 | + |
---|
| 319 | +int tipc_nl_net_addr_legacy_get(struct sk_buff *skb, struct genl_info *info) |
---|
| 320 | +{ |
---|
| 321 | + struct net *net = sock_net(skb->sk); |
---|
| 322 | + struct tipc_nl_msg msg; |
---|
| 323 | + struct sk_buff *rep; |
---|
| 324 | + int err; |
---|
| 325 | + |
---|
| 326 | + rep = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); |
---|
| 327 | + if (!rep) |
---|
| 328 | + return -ENOMEM; |
---|
| 329 | + |
---|
| 330 | + msg.skb = rep; |
---|
| 331 | + msg.portid = info->snd_portid; |
---|
| 332 | + msg.seq = info->snd_seq; |
---|
| 333 | + |
---|
| 334 | + err = __tipc_nl_addr_legacy_get(net, &msg); |
---|
| 335 | + if (err) { |
---|
| 336 | + nlmsg_free(msg.skb); |
---|
| 337 | + return err; |
---|
| 338 | + } |
---|
| 339 | + |
---|
| 340 | + return genlmsg_reply(msg.skb, info); |
---|
| 341 | +} |
---|