]> git.karo-electronics.de Git - karo-tx-linux.git/blob - net/tipc/netlink_compat.c
tipc: convert legacy nl net id set to nl compat
[karo-tx-linux.git] / net / tipc / netlink_compat.c
1 /*
2  * Copyright (c) 2014, Ericsson AB
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the names of the copyright holders nor the names of its
14  *    contributors may be used to endorse or promote products derived from
15  *    this software without specific prior written permission.
16  *
17  * Alternatively, this software may be distributed under the terms of the
18  * GNU General Public License ("GPL") version 2 as published by the Free
19  * Software Foundation.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include "core.h"
35 #include "config.h"
36 #include "bearer.h"
37 #include "link.h"
38 #include "name_table.h"
39 #include "socket.h"
40 #include "node.h"
41 #include "net.h"
42 #include <net/genetlink.h>
43 #include <linux/tipc_config.h>
44
45 /* The legacy API had an artificial message length limit called
46  * ULTRA_STRING_MAX_LEN.
47  */
48 #define ULTRA_STRING_MAX_LEN 32768
49
50 #define TIPC_SKB_MAX TLV_SPACE(ULTRA_STRING_MAX_LEN)
51
52 #define REPLY_TRUNCATED "<truncated>\n"
53
54 struct tipc_nl_compat_msg {
55         u16 cmd;
56         int rep_type;
57         int rep_size;
58         int req_type;
59         struct sk_buff *rep;
60         struct tlv_desc *req;
61         struct sock *dst_sk;
62 };
63
64 struct tipc_nl_compat_cmd_dump {
65         int (*header)(struct tipc_nl_compat_msg *);
66         int (*dumpit)(struct sk_buff *, struct netlink_callback *);
67         int (*format)(struct tipc_nl_compat_msg *msg, struct nlattr **attrs);
68 };
69
70 struct tipc_nl_compat_cmd_doit {
71         int (*doit)(struct sk_buff *skb, struct genl_info *info);
72         int (*transcode)(struct sk_buff *skb, struct tipc_nl_compat_msg *msg);
73 };
74
75 static int tipc_skb_tailroom(struct sk_buff *skb)
76 {
77         int tailroom;
78         int limit;
79
80         tailroom = skb_tailroom(skb);
81         limit = TIPC_SKB_MAX - skb->len;
82
83         if (tailroom < limit)
84                 return tailroom;
85
86         return limit;
87 }
88
89 static int tipc_add_tlv(struct sk_buff *skb, u16 type, void *data, u16 len)
90 {
91         struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(skb);
92
93         if (tipc_skb_tailroom(skb) < TLV_SPACE(len))
94                 return -EMSGSIZE;
95
96         skb_put(skb, TLV_SPACE(len));
97         tlv->tlv_type = htons(type);
98         tlv->tlv_len = htons(TLV_LENGTH(len));
99         if (len && data)
100                 memcpy(TLV_DATA(tlv), data, len);
101
102         return 0;
103 }
104
105 static void tipc_tlv_init(struct sk_buff *skb, u16 type)
106 {
107         struct tlv_desc *tlv = (struct tlv_desc *)skb->data;
108
109         TLV_SET_LEN(tlv, 0);
110         TLV_SET_TYPE(tlv, type);
111         skb_put(skb, sizeof(struct tlv_desc));
112 }
113
114 static int tipc_tlv_sprintf(struct sk_buff *skb, const char *fmt, ...)
115 {
116         int n;
117         u16 len;
118         u32 rem;
119         char *buf;
120         struct tlv_desc *tlv;
121         va_list args;
122
123         rem = tipc_skb_tailroom(skb);
124
125         tlv = (struct tlv_desc *)skb->data;
126         len = TLV_GET_LEN(tlv);
127         buf = TLV_DATA(tlv) + len;
128
129         va_start(args, fmt);
130         n = vscnprintf(buf, rem, fmt, args);
131         va_end(args);
132
133         TLV_SET_LEN(tlv, n + len);
134         skb_put(skb, n);
135
136         return n;
137 }
138
139 static struct sk_buff *tipc_tlv_alloc(int size)
140 {
141         int hdr_len;
142         struct sk_buff *buf;
143
144         size = TLV_SPACE(size);
145         hdr_len = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN);
146
147         buf = alloc_skb(hdr_len + size, GFP_KERNEL);
148         if (!buf)
149                 return NULL;
150
151         skb_reserve(buf, hdr_len);
152
153         return buf;
154 }
155
156 static struct sk_buff *tipc_get_err_tlv(char *str)
157 {
158         int str_len = strlen(str) + 1;
159         struct sk_buff *buf;
160
161         buf = tipc_tlv_alloc(TLV_SPACE(str_len));
162         if (buf)
163                 tipc_add_tlv(buf, TIPC_TLV_ERROR_STRING, str, str_len);
164
165         return buf;
166 }
167
168 static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
169                                    struct tipc_nl_compat_msg *msg,
170                                    struct sk_buff *arg)
171 {
172         int len = 0;
173         int err;
174         struct sk_buff *buf;
175         struct nlmsghdr *nlmsg;
176         struct netlink_callback cb;
177
178         memset(&cb, 0, sizeof(cb));
179         cb.nlh = (struct nlmsghdr *)arg->data;
180         cb.skb = arg;
181
182         buf = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
183         if (!buf)
184                 return -ENOMEM;
185
186         buf->sk = msg->dst_sk;
187
188         do {
189                 int rem;
190
191                 len = (*cmd->dumpit)(buf, &cb);
192
193                 nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) {
194                         struct nlattr **attrs;
195
196                         err = tipc_nlmsg_parse(nlmsg, &attrs);
197                         if (err)
198                                 goto err_out;
199
200                         err = (*cmd->format)(msg, attrs);
201                         if (err)
202                                 goto err_out;
203
204                         if (tipc_skb_tailroom(msg->rep) <= 1) {
205                                 err = -EMSGSIZE;
206                                 goto err_out;
207                         }
208                 }
209
210                 skb_reset_tail_pointer(buf);
211                 buf->len = 0;
212
213         } while (len);
214
215         err = 0;
216
217 err_out:
218         kfree_skb(buf);
219
220         if (err == -EMSGSIZE) {
221                 /* The legacy API only considered messages filling
222                  * "ULTRA_STRING_MAX_LEN" to be truncated.
223                  */
224                 if ((TIPC_SKB_MAX - msg->rep->len) <= 1) {
225                         char *tail = skb_tail_pointer(msg->rep);
226
227                         if (*tail != '\0')
228                                 sprintf(tail - sizeof(REPLY_TRUNCATED) - 1,
229                                         REPLY_TRUNCATED);
230                 }
231
232                 return 0;
233         }
234
235         return err;
236 }
237
238 static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
239                                  struct tipc_nl_compat_msg *msg)
240 {
241         int err;
242         struct sk_buff *arg;
243
244         if (msg->req_type && !TLV_CHECK_TYPE(msg->req, msg->req_type))
245                 return -EINVAL;
246
247         msg->rep = tipc_tlv_alloc(msg->rep_size);
248         if (!msg->rep)
249                 return -ENOMEM;
250
251         if (msg->rep_type)
252                 tipc_tlv_init(msg->rep, msg->rep_type);
253
254         if (cmd->header)
255                 (*cmd->header)(msg);
256
257         arg = nlmsg_new(0, GFP_KERNEL);
258         if (!arg) {
259                 kfree_skb(msg->rep);
260                 return -ENOMEM;
261         }
262
263         err = __tipc_nl_compat_dumpit(cmd, msg, arg);
264         if (err)
265                 kfree_skb(msg->rep);
266
267         kfree_skb(arg);
268
269         return err;
270 }
271
272 static int __tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd,
273                                  struct tipc_nl_compat_msg *msg)
274 {
275         int err;
276         struct sk_buff *doit_buf;
277         struct sk_buff *trans_buf;
278         struct nlattr **attrbuf;
279         struct genl_info info;
280
281         trans_buf = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
282         if (!trans_buf)
283                 return -ENOMEM;
284
285         err = (*cmd->transcode)(trans_buf, msg);
286         if (err)
287                 goto trans_out;
288
289         attrbuf = kmalloc((tipc_genl_family.maxattr + 1) *
290                         sizeof(struct nlattr *), GFP_KERNEL);
291         if (!attrbuf) {
292                 err = -ENOMEM;
293                 goto trans_out;
294         }
295
296         err = nla_parse(attrbuf, tipc_genl_family.maxattr,
297                         (const struct nlattr *)trans_buf->data,
298                         trans_buf->len, NULL);
299         if (err)
300                 goto parse_out;
301
302         doit_buf = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
303         if (!doit_buf) {
304                 err = -ENOMEM;
305                 goto parse_out;
306         }
307
308         doit_buf->sk = msg->dst_sk;
309
310         memset(&info, 0, sizeof(info));
311         info.attrs = attrbuf;
312
313         err = (*cmd->doit)(doit_buf, &info);
314
315         kfree_skb(doit_buf);
316 parse_out:
317         kfree(attrbuf);
318 trans_out:
319         kfree_skb(trans_buf);
320
321         return err;
322 }
323
324 static int tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd,
325                                struct tipc_nl_compat_msg *msg)
326 {
327         int err;
328
329         if (msg->req_type && !TLV_CHECK_TYPE(msg->req, msg->req_type))
330                 return -EINVAL;
331
332         err = __tipc_nl_compat_doit(cmd, msg);
333         if (err)
334                 return err;
335
336         /* The legacy API considered an empty message a success message */
337         msg->rep = tipc_tlv_alloc(0);
338         if (!msg->rep)
339                 return -ENOMEM;
340
341         return 0;
342 }
343
344 static int tipc_nl_compat_bearer_dump(struct tipc_nl_compat_msg *msg,
345                                       struct nlattr **attrs)
346 {
347         struct nlattr *bearer[TIPC_NLA_BEARER_MAX + 1];
348
349         nla_parse_nested(bearer, TIPC_NLA_BEARER_MAX, attrs[TIPC_NLA_BEARER],
350                          NULL);
351
352         return tipc_add_tlv(msg->rep, TIPC_TLV_BEARER_NAME,
353                             nla_data(bearer[TIPC_NLA_BEARER_NAME]),
354                             nla_len(bearer[TIPC_NLA_BEARER_NAME]));
355 }
356
357 static int tipc_nl_compat_bearer_enable(struct sk_buff *skb,
358                                         struct tipc_nl_compat_msg *msg)
359 {
360         struct nlattr *prop;
361         struct nlattr *bearer;
362         struct tipc_bearer_config *b;
363
364         b = (struct tipc_bearer_config *)TLV_DATA(msg->req);
365
366         bearer = nla_nest_start(skb, TIPC_NLA_BEARER);
367         if (!bearer)
368                 return -EMSGSIZE;
369
370         if (nla_put_string(skb, TIPC_NLA_BEARER_NAME, b->name))
371                 return -EMSGSIZE;
372
373         if (nla_put_u32(skb, TIPC_NLA_BEARER_DOMAIN, ntohl(b->disc_domain)))
374                 return -EMSGSIZE;
375
376         if (ntohl(b->priority) <= TIPC_MAX_LINK_PRI) {
377                 prop = nla_nest_start(skb, TIPC_NLA_BEARER_PROP);
378                 if (!prop)
379                         return -EMSGSIZE;
380                 if (nla_put_u32(skb, TIPC_NLA_PROP_PRIO, ntohl(b->priority)))
381                         return -EMSGSIZE;
382                 nla_nest_end(skb, prop);
383         }
384         nla_nest_end(skb, bearer);
385
386         return 0;
387 }
388
389 static int tipc_nl_compat_bearer_disable(struct sk_buff *skb,
390                                          struct tipc_nl_compat_msg *msg)
391 {
392         char *name;
393         struct nlattr *bearer;
394
395         name = (char *)TLV_DATA(msg->req);
396
397         bearer = nla_nest_start(skb, TIPC_NLA_BEARER);
398         if (!bearer)
399                 return -EMSGSIZE;
400
401         if (nla_put_string(skb, TIPC_NLA_BEARER_NAME, name))
402                 return -EMSGSIZE;
403
404         nla_nest_end(skb, bearer);
405
406         return 0;
407 }
408
409 static inline u32 perc(u32 count, u32 total)
410 {
411         return (count * 100 + (total / 2)) / total;
412 }
413
414 static void __fill_bc_link_stat(struct tipc_nl_compat_msg *msg,
415                                 struct nlattr *prop[], struct nlattr *stats[])
416 {
417         tipc_tlv_sprintf(msg->rep, "  Window:%u packets\n",
418                          nla_get_u32(prop[TIPC_NLA_PROP_WIN]));
419
420         tipc_tlv_sprintf(msg->rep,
421                          "  RX packets:%u fragments:%u/%u bundles:%u/%u\n",
422                          nla_get_u32(stats[TIPC_NLA_STATS_RX_INFO]),
423                          nla_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTS]),
424                          nla_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTED]),
425                          nla_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLES]),
426                          nla_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLED]));
427
428         tipc_tlv_sprintf(msg->rep,
429                          "  TX packets:%u fragments:%u/%u bundles:%u/%u\n",
430                          nla_get_u32(stats[TIPC_NLA_STATS_TX_INFO]),
431                          nla_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTS]),
432                          nla_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTED]),
433                          nla_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLES]),
434                          nla_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLED]));
435
436         tipc_tlv_sprintf(msg->rep, "  RX naks:%u defs:%u dups:%u\n",
437                          nla_get_u32(stats[TIPC_NLA_STATS_RX_NACKS]),
438                          nla_get_u32(stats[TIPC_NLA_STATS_RX_DEFERRED]),
439                          nla_get_u32(stats[TIPC_NLA_STATS_DUPLICATES]));
440
441         tipc_tlv_sprintf(msg->rep, "  TX naks:%u acks:%u dups:%u\n",
442                          nla_get_u32(stats[TIPC_NLA_STATS_TX_NACKS]),
443                          nla_get_u32(stats[TIPC_NLA_STATS_TX_ACKS]),
444                          nla_get_u32(stats[TIPC_NLA_STATS_RETRANSMITTED]));
445
446         tipc_tlv_sprintf(msg->rep,
447                          "  Congestion link:%u  Send queue max:%u avg:%u",
448                          nla_get_u32(stats[TIPC_NLA_STATS_LINK_CONGS]),
449                          nla_get_u32(stats[TIPC_NLA_STATS_MAX_QUEUE]),
450                          nla_get_u32(stats[TIPC_NLA_STATS_AVG_QUEUE]));
451 }
452
453 static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
454                                          struct nlattr **attrs)
455 {
456         char *name;
457         struct nlattr *link[TIPC_NLA_LINK_MAX + 1];
458         struct nlattr *prop[TIPC_NLA_PROP_MAX + 1];
459         struct nlattr *stats[TIPC_NLA_STATS_MAX + 1];
460
461         nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK], NULL);
462
463         nla_parse_nested(prop, TIPC_NLA_PROP_MAX, link[TIPC_NLA_LINK_PROP],
464                          NULL);
465
466         nla_parse_nested(stats, TIPC_NLA_STATS_MAX, link[TIPC_NLA_LINK_STATS],
467                          NULL);
468
469         name = (char *)TLV_DATA(msg->req);
470         if (strcmp(name, nla_data(link[TIPC_NLA_LINK_NAME])) != 0)
471                 return 0;
472
473         tipc_tlv_sprintf(msg->rep, "\nLink <%s>\n",
474                          nla_data(link[TIPC_NLA_LINK_NAME]));
475
476         if (link[TIPC_NLA_LINK_BROADCAST]) {
477                 __fill_bc_link_stat(msg, prop, stats);
478                 return 0;
479         }
480
481         if (link[TIPC_NLA_LINK_ACTIVE])
482                 tipc_tlv_sprintf(msg->rep, "  ACTIVE");
483         else if (link[TIPC_NLA_LINK_UP])
484                 tipc_tlv_sprintf(msg->rep, "  STANDBY");
485         else
486                 tipc_tlv_sprintf(msg->rep, "  DEFUNCT");
487
488         tipc_tlv_sprintf(msg->rep, "  MTU:%u  Priority:%u",
489                          nla_get_u32(link[TIPC_NLA_LINK_MTU]),
490                          nla_get_u32(prop[TIPC_NLA_PROP_PRIO]));
491
492         tipc_tlv_sprintf(msg->rep, "  Tolerance:%u ms  Window:%u packets\n",
493                          nla_get_u32(prop[TIPC_NLA_PROP_TOL]),
494                          nla_get_u32(prop[TIPC_NLA_PROP_WIN]));
495
496         tipc_tlv_sprintf(msg->rep,
497                          "  RX packets:%u fragments:%u/%u bundles:%u/%u\n",
498                          nla_get_u32(link[TIPC_NLA_LINK_RX]) -
499                          nla_get_u32(stats[TIPC_NLA_STATS_RX_INFO]),
500                          nla_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTS]),
501                          nla_get_u32(stats[TIPC_NLA_STATS_RX_FRAGMENTED]),
502                          nla_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLES]),
503                          nla_get_u32(stats[TIPC_NLA_STATS_RX_BUNDLED]));
504
505         tipc_tlv_sprintf(msg->rep,
506                          "  TX packets:%u fragments:%u/%u bundles:%u/%u\n",
507                          nla_get_u32(link[TIPC_NLA_LINK_TX]) -
508                          nla_get_u32(stats[TIPC_NLA_STATS_TX_INFO]),
509                          nla_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTS]),
510                          nla_get_u32(stats[TIPC_NLA_STATS_TX_FRAGMENTED]),
511                          nla_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLES]),
512                          nla_get_u32(stats[TIPC_NLA_STATS_TX_BUNDLED]));
513
514         tipc_tlv_sprintf(msg->rep,
515                          "  TX profile sample:%u packets  average:%u octets\n",
516                          nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_CNT]),
517                          nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_TOT]) /
518                          nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT]));
519
520         tipc_tlv_sprintf(msg->rep,
521                          "  0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% ",
522                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P0]),
523                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])),
524                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P1]),
525                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])),
526                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P2]),
527                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])),
528                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P3]),
529                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])));
530
531         tipc_tlv_sprintf(msg->rep, "-16384:%u%% -32768:%u%% -66000:%u%%\n",
532                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P4]),
533                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])),
534                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P5]),
535                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])),
536                          perc(nla_get_u32(stats[TIPC_NLA_STATS_MSG_LEN_P6]),
537                               nla_get_u32(stats[TIPC_NLA_STATS_MSG_PROF_TOT])));
538
539         tipc_tlv_sprintf(msg->rep,
540                          "  RX states:%u probes:%u naks:%u defs:%u dups:%u\n",
541                          nla_get_u32(stats[TIPC_NLA_STATS_RX_STATES]),
542                          nla_get_u32(stats[TIPC_NLA_STATS_RX_PROBES]),
543                          nla_get_u32(stats[TIPC_NLA_STATS_RX_NACKS]),
544                          nla_get_u32(stats[TIPC_NLA_STATS_RX_DEFERRED]),
545                          nla_get_u32(stats[TIPC_NLA_STATS_DUPLICATES]));
546
547         tipc_tlv_sprintf(msg->rep,
548                          "  TX states:%u probes:%u naks:%u acks:%u dups:%u\n",
549                          nla_get_u32(stats[TIPC_NLA_STATS_TX_STATES]),
550                          nla_get_u32(stats[TIPC_NLA_STATS_TX_PROBES]),
551                          nla_get_u32(stats[TIPC_NLA_STATS_TX_NACKS]),
552                          nla_get_u32(stats[TIPC_NLA_STATS_TX_ACKS]),
553                          nla_get_u32(stats[TIPC_NLA_STATS_RETRANSMITTED]));
554
555         tipc_tlv_sprintf(msg->rep,
556                          "  Congestion link:%u  Send queue max:%u avg:%u",
557                          nla_get_u32(stats[TIPC_NLA_STATS_LINK_CONGS]),
558                          nla_get_u32(stats[TIPC_NLA_STATS_MAX_QUEUE]),
559                          nla_get_u32(stats[TIPC_NLA_STATS_AVG_QUEUE]));
560
561         return 0;
562 }
563
564 static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
565                                     struct nlattr **attrs)
566 {
567         struct nlattr *link[TIPC_NLA_LINK_MAX + 1];
568         struct tipc_link_info link_info;
569
570         nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK], NULL);
571
572         link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
573         link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
574         strcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME]));
575
576         return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,
577                             &link_info, sizeof(link_info));
578 }
579
580 static int tipc_nl_compat_link_set(struct sk_buff *skb,
581                                    struct tipc_nl_compat_msg *msg)
582 {
583         struct nlattr *link;
584         struct nlattr *prop;
585         struct tipc_link_config *lc;
586
587         lc = (struct tipc_link_config *)TLV_DATA(msg->req);
588
589         link = nla_nest_start(skb, TIPC_NLA_LINK);
590         if (!link)
591                 return -EMSGSIZE;
592
593         if (nla_put_string(skb, TIPC_NLA_LINK_NAME, lc->name))
594                 return -EMSGSIZE;
595
596         prop = nla_nest_start(skb, TIPC_NLA_LINK_PROP);
597         if (!prop)
598                 return -EMSGSIZE;
599
600         if (msg->cmd == TIPC_CMD_SET_LINK_PRI) {
601                 if (nla_put_u32(skb, TIPC_NLA_PROP_PRIO, ntohl(lc->value)))
602                         return -EMSGSIZE;
603         } else if (msg->cmd == TIPC_CMD_SET_LINK_TOL) {
604                 if (nla_put_u32(skb, TIPC_NLA_PROP_TOL, ntohl(lc->value)))
605                         return -EMSGSIZE;
606         } else if (msg->cmd == TIPC_CMD_SET_LINK_WINDOW) {
607                 if (nla_put_u32(skb, TIPC_NLA_PROP_WIN, ntohl(lc->value)))
608                         return -EMSGSIZE;
609         }
610
611         nla_nest_end(skb, prop);
612         nla_nest_end(skb, link);
613
614         return 0;
615 }
616
617 static int tipc_nl_compat_link_reset_stats(struct sk_buff *skb,
618                                            struct tipc_nl_compat_msg *msg)
619 {
620         char *name;
621         struct nlattr *link;
622
623         name = (char *)TLV_DATA(msg->req);
624
625         link = nla_nest_start(skb, TIPC_NLA_LINK);
626         if (!link)
627                 return -EMSGSIZE;
628
629         if (nla_put_string(skb, TIPC_NLA_LINK_NAME, name))
630                 return -EMSGSIZE;
631
632         nla_nest_end(skb, link);
633
634         return 0;
635 }
636
637 static int tipc_nl_compat_name_table_dump_header(struct tipc_nl_compat_msg *msg)
638 {
639         int i;
640         u32 depth;
641         struct tipc_name_table_query *ntq;
642         static const char * const header[] = {
643                 "Type       ",
644                 "Lower      Upper      ",
645                 "Port Identity              ",
646                 "Publication Scope"
647         };
648
649         ntq = (struct tipc_name_table_query *)TLV_DATA(msg->req);
650
651         depth = ntohl(ntq->depth);
652
653         if (depth > 4)
654                 depth = 4;
655         for (i = 0; i < depth; i++)
656                 tipc_tlv_sprintf(msg->rep, header[i]);
657         tipc_tlv_sprintf(msg->rep, "\n");
658
659         return 0;
660 }
661
662 static int tipc_nl_compat_name_table_dump(struct tipc_nl_compat_msg *msg,
663                                           struct nlattr **attrs)
664 {
665         char port_str[27];
666         struct tipc_name_table_query *ntq;
667         struct nlattr *nt[TIPC_NLA_NAME_TABLE_MAX + 1];
668         struct nlattr *publ[TIPC_NLA_PUBL_MAX + 1];
669         u32 node, depth, type, lowbound, upbound;
670         static const char * const scope_str[] = {"", " zone", " cluster",
671                                                  " node"};
672
673         nla_parse_nested(nt, TIPC_NLA_NAME_TABLE_MAX,
674                          attrs[TIPC_NLA_NAME_TABLE], NULL);
675
676         nla_parse_nested(publ, TIPC_NLA_PUBL_MAX, nt[TIPC_NLA_NAME_TABLE_PUBL],
677                          NULL);
678
679         ntq = (struct tipc_name_table_query *)TLV_DATA(msg->req);
680
681         depth = ntohl(ntq->depth);
682         type = ntohl(ntq->type);
683         lowbound = ntohl(ntq->lowbound);
684         upbound = ntohl(ntq->upbound);
685
686         if (!(depth & TIPC_NTQ_ALLTYPES) &&
687             (type != nla_get_u32(publ[TIPC_NLA_PUBL_TYPE])))
688                 return 0;
689         if (lowbound && (lowbound > nla_get_u32(publ[TIPC_NLA_PUBL_UPPER])))
690                 return 0;
691         if (upbound && (upbound < nla_get_u32(publ[TIPC_NLA_PUBL_LOWER])))
692                 return 0;
693
694         tipc_tlv_sprintf(msg->rep, "%-10u ",
695                          nla_get_u32(publ[TIPC_NLA_PUBL_TYPE]));
696
697         if (depth == 1)
698                 goto out;
699
700         tipc_tlv_sprintf(msg->rep, "%-10u %-10u ",
701                          nla_get_u32(publ[TIPC_NLA_PUBL_LOWER]),
702                          nla_get_u32(publ[TIPC_NLA_PUBL_UPPER]));
703
704         if (depth == 2)
705                 goto out;
706
707         node = nla_get_u32(publ[TIPC_NLA_PUBL_NODE]);
708         sprintf(port_str, "<%u.%u.%u:%u>", tipc_zone(node), tipc_cluster(node),
709                 tipc_node(node), nla_get_u32(publ[TIPC_NLA_PUBL_REF]));
710         tipc_tlv_sprintf(msg->rep, "%-26s ", port_str);
711
712         if (depth == 3)
713                 goto out;
714
715         tipc_tlv_sprintf(msg->rep, "%-10u %s",
716                          nla_get_u32(publ[TIPC_NLA_PUBL_REF]),
717                          scope_str[nla_get_u32(publ[TIPC_NLA_PUBL_SCOPE])]);
718 out:
719         tipc_tlv_sprintf(msg->rep, "\n");
720
721         return 0;
722 }
723
724 static int __tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg,
725                                       struct nlattr **attrs)
726 {
727         u32 type, lower, upper;
728         struct nlattr *publ[TIPC_NLA_PUBL_MAX + 1];
729
730         nla_parse_nested(publ, TIPC_NLA_PUBL_MAX, attrs[TIPC_NLA_PUBL], NULL);
731
732         type = nla_get_u32(publ[TIPC_NLA_PUBL_TYPE]);
733         lower = nla_get_u32(publ[TIPC_NLA_PUBL_LOWER]);
734         upper = nla_get_u32(publ[TIPC_NLA_PUBL_UPPER]);
735
736         if (lower == upper)
737                 tipc_tlv_sprintf(msg->rep, " {%u,%u}", type, lower);
738         else
739                 tipc_tlv_sprintf(msg->rep, " {%u,%u,%u}", type, lower, upper);
740
741         return 0;
742 }
743
744 static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock)
745 {
746         int err;
747         void *hdr;
748         struct nlattr *nest;
749         struct sk_buff *args;
750         struct tipc_nl_compat_cmd_dump dump;
751
752         args = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
753         if (!args)
754                 return -ENOMEM;
755
756         hdr = genlmsg_put(args, 0, 0, &tipc_genl_family, NLM_F_MULTI,
757                           TIPC_NL_PUBL_GET);
758
759         nest = nla_nest_start(args, TIPC_NLA_SOCK);
760         if (!nest) {
761                 kfree_skb(args);
762                 return -EMSGSIZE;
763         }
764
765         if (nla_put_u32(args, TIPC_NLA_SOCK_REF, sock)) {
766                 kfree_skb(args);
767                 return -EMSGSIZE;
768         }
769
770         nla_nest_end(args, nest);
771         genlmsg_end(args, hdr);
772
773         dump.dumpit = tipc_nl_publ_dump;
774         dump.format = __tipc_nl_compat_publ_dump;
775
776         err = __tipc_nl_compat_dumpit(&dump, msg, args);
777
778         kfree_skb(args);
779
780         return err;
781 }
782
783 static int tipc_nl_compat_sk_dump(struct tipc_nl_compat_msg *msg,
784                                   struct nlattr **attrs)
785 {
786         int err;
787         u32 sock_ref;
788         struct nlattr *sock[TIPC_NLA_SOCK_MAX + 1];
789
790         nla_parse_nested(sock, TIPC_NLA_SOCK_MAX, attrs[TIPC_NLA_SOCK], NULL);
791
792         sock_ref = nla_get_u32(sock[TIPC_NLA_SOCK_REF]);
793         tipc_tlv_sprintf(msg->rep, "%u:", sock_ref);
794
795         if (sock[TIPC_NLA_SOCK_CON]) {
796                 u32 node;
797                 struct nlattr *con[TIPC_NLA_CON_MAX + 1];
798
799                 nla_parse_nested(con, TIPC_NLA_CON_MAX, sock[TIPC_NLA_SOCK_CON],
800                                  NULL);
801
802                 node = nla_get_u32(con[TIPC_NLA_CON_NODE]);
803                 tipc_tlv_sprintf(msg->rep, "  connected to <%u.%u.%u:%u>",
804                                  tipc_zone(node),
805                                  tipc_cluster(node),
806                                  tipc_node(node),
807                                  nla_get_u32(con[TIPC_NLA_CON_SOCK]));
808
809                 if (con[TIPC_NLA_CON_FLAG])
810                         tipc_tlv_sprintf(msg->rep, " via {%u,%u}\n",
811                                          nla_get_u32(con[TIPC_NLA_CON_TYPE]),
812                                          nla_get_u32(con[TIPC_NLA_CON_INST]));
813                 else
814                         tipc_tlv_sprintf(msg->rep, "\n");
815         } else if (sock[TIPC_NLA_SOCK_HAS_PUBL]) {
816                 tipc_tlv_sprintf(msg->rep, " bound to");
817
818                 err = tipc_nl_compat_publ_dump(msg, sock_ref);
819                 if (err)
820                         return err;
821         }
822         tipc_tlv_sprintf(msg->rep, "\n");
823
824         return 0;
825 }
826
827 static int tipc_nl_compat_media_dump(struct tipc_nl_compat_msg *msg,
828                                      struct nlattr **attrs)
829 {
830         struct nlattr *media[TIPC_NLA_MEDIA_MAX + 1];
831
832         nla_parse_nested(media, TIPC_NLA_MEDIA_MAX, attrs[TIPC_NLA_MEDIA],
833                          NULL);
834
835         return tipc_add_tlv(msg->rep, TIPC_TLV_MEDIA_NAME,
836                             nla_data(media[TIPC_NLA_MEDIA_NAME]),
837                             nla_len(media[TIPC_NLA_MEDIA_NAME]));
838 }
839
840 static int tipc_nl_compat_node_dump(struct tipc_nl_compat_msg *msg,
841                                     struct nlattr **attrs)
842 {
843         struct tipc_node_info node_info;
844         struct nlattr *node[TIPC_NLA_NODE_MAX + 1];
845
846         nla_parse_nested(node, TIPC_NLA_NODE_MAX, attrs[TIPC_NLA_NODE], NULL);
847
848         node_info.addr = htonl(nla_get_u32(node[TIPC_NLA_NODE_ADDR]));
849         node_info.up = htonl(nla_get_flag(node[TIPC_NLA_NODE_UP]));
850
851         return tipc_add_tlv(msg->rep, TIPC_TLV_NODE_INFO, &node_info,
852                             sizeof(node_info));
853 }
854
855 static int tipc_nl_compat_net_set(struct sk_buff *skb,
856                                   struct tipc_nl_compat_msg *msg)
857 {
858         u32 val;
859         struct nlattr *net;
860
861         val = ntohl(*(__be32 *)TLV_DATA(msg->req));
862
863         net = nla_nest_start(skb, TIPC_NLA_NET);
864         if (!net)
865                 return -EMSGSIZE;
866
867         if (msg->cmd == TIPC_CMD_SET_NODE_ADDR) {
868                 if (nla_put_u32(skb, TIPC_NLA_NET_ADDR, val))
869                         return -EMSGSIZE;
870         } else if (msg->cmd == TIPC_CMD_SET_NETID) {
871                 if (nla_put_u32(skb, TIPC_NLA_NET_ID, val))
872                         return -EMSGSIZE;
873         }
874         nla_nest_end(skb, net);
875
876         return 0;
877 }
878
879 static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
880 {
881         struct tipc_nl_compat_cmd_dump dump;
882         struct tipc_nl_compat_cmd_doit doit;
883
884         memset(&dump, 0, sizeof(dump));
885         memset(&doit, 0, sizeof(doit));
886
887         switch (msg->cmd) {
888         case TIPC_CMD_GET_BEARER_NAMES:
889                 msg->rep_size = MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME);
890                 dump.dumpit = tipc_nl_bearer_dump;
891                 dump.format = tipc_nl_compat_bearer_dump;
892                 return tipc_nl_compat_dumpit(&dump, msg);
893         case TIPC_CMD_ENABLE_BEARER:
894                 msg->req_type = TIPC_TLV_BEARER_CONFIG;
895                 doit.doit = tipc_nl_bearer_enable;
896                 doit.transcode = tipc_nl_compat_bearer_enable;
897                 return tipc_nl_compat_doit(&doit, msg);
898         case TIPC_CMD_DISABLE_BEARER:
899                 msg->req_type = TIPC_TLV_BEARER_NAME;
900                 doit.doit = tipc_nl_bearer_disable;
901                 doit.transcode = tipc_nl_compat_bearer_disable;
902                 return tipc_nl_compat_doit(&doit, msg);
903         case TIPC_CMD_SHOW_LINK_STATS:
904                 msg->req_type = TIPC_TLV_LINK_NAME;
905                 msg->rep_size = ULTRA_STRING_MAX_LEN;
906                 msg->rep_type = TIPC_TLV_ULTRA_STRING;
907                 dump.dumpit = tipc_nl_link_dump;
908                 dump.format = tipc_nl_compat_link_stat_dump;
909                 return tipc_nl_compat_dumpit(&dump, msg);
910         case TIPC_CMD_GET_LINKS:
911                 msg->req_type = TIPC_TLV_NET_ADDR;
912                 msg->rep_size = ULTRA_STRING_MAX_LEN;
913                 dump.dumpit = tipc_nl_link_dump;
914                 dump.format = tipc_nl_compat_link_dump;
915                 return tipc_nl_compat_dumpit(&dump, msg);
916         case TIPC_CMD_SET_LINK_TOL:
917         case TIPC_CMD_SET_LINK_PRI:
918         case TIPC_CMD_SET_LINK_WINDOW:
919                 msg->req_type =  TIPC_TLV_LINK_CONFIG;
920                 doit.doit = tipc_nl_link_set;
921                 doit.transcode = tipc_nl_compat_link_set;
922                 return tipc_nl_compat_doit(&doit, msg);
923         case TIPC_CMD_RESET_LINK_STATS:
924                 msg->req_type = TIPC_TLV_LINK_NAME;
925                 doit.doit = tipc_nl_link_reset_stats;
926                 doit.transcode = tipc_nl_compat_link_reset_stats;
927                 return tipc_nl_compat_doit(&doit, msg);
928         case TIPC_CMD_SHOW_NAME_TABLE:
929                 msg->req_type = TIPC_TLV_NAME_TBL_QUERY;
930                 msg->rep_size = ULTRA_STRING_MAX_LEN;
931                 msg->rep_type = TIPC_TLV_ULTRA_STRING;
932                 dump.header = tipc_nl_compat_name_table_dump_header;
933                 dump.dumpit = tipc_nl_name_table_dump;
934                 dump.format = tipc_nl_compat_name_table_dump;
935                 return tipc_nl_compat_dumpit(&dump, msg);
936         case TIPC_CMD_SHOW_PORTS:
937                 msg->rep_size = ULTRA_STRING_MAX_LEN;
938                 msg->rep_type = TIPC_TLV_ULTRA_STRING;
939                 dump.dumpit = tipc_nl_sk_dump;
940                 dump.format = tipc_nl_compat_sk_dump;
941                 return tipc_nl_compat_dumpit(&dump, msg);
942         case TIPC_CMD_GET_MEDIA_NAMES:
943                 msg->rep_size = MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME);
944                 dump.dumpit = tipc_nl_media_dump;
945                 dump.format = tipc_nl_compat_media_dump;
946                 return tipc_nl_compat_dumpit(&dump, msg);
947         case TIPC_CMD_GET_NODES:
948                 msg->rep_size = ULTRA_STRING_MAX_LEN;
949                 dump.dumpit = tipc_nl_node_dump;
950                 dump.format = tipc_nl_compat_node_dump;
951                 return tipc_nl_compat_dumpit(&dump, msg);
952         case TIPC_CMD_SET_NODE_ADDR:
953                 msg->req_type = TIPC_TLV_NET_ADDR;
954                 doit.doit = tipc_nl_net_set;
955                 doit.transcode = tipc_nl_compat_net_set;
956                 return tipc_nl_compat_doit(&doit, msg);
957         case TIPC_CMD_SET_NETID:
958                 msg->req_type = TIPC_TLV_UNSIGNED;
959                 doit.doit = tipc_nl_net_set;
960                 doit.transcode = tipc_nl_compat_net_set;
961                 return tipc_nl_compat_doit(&doit, msg);
962         }
963
964         return -EOPNOTSUPP;
965 }
966
967 static int tipc_nl_compat_recv(struct sk_buff *skb, struct genl_info *info)
968 {
969         int err;
970         int len;
971         struct tipc_nl_compat_msg msg;
972         struct nlmsghdr *req_nlh;
973         struct nlmsghdr *rep_nlh;
974         struct tipc_genlmsghdr *req_userhdr = info->userhdr;
975         struct net *net = genl_info_net(info);
976
977         memset(&msg, 0, sizeof(msg));
978
979         req_nlh = (struct nlmsghdr *)skb->data;
980         msg.req = nlmsg_data(req_nlh) + GENL_HDRLEN + TIPC_GENL_HDRLEN;
981         msg.cmd = req_userhdr->cmd;
982         msg.dst_sk = info->dst_sk;
983
984         if ((msg.cmd & 0xC000) && (!netlink_net_capable(skb, CAP_NET_ADMIN))) {
985                 msg.rep = tipc_get_err_tlv(TIPC_CFG_NOT_NET_ADMIN);
986                 err = -EACCES;
987                 goto send;
988         }
989
990         len = nlmsg_attrlen(req_nlh, GENL_HDRLEN + TIPC_GENL_HDRLEN);
991         if (TLV_GET_LEN(msg.req) && !TLV_OK(msg.req, len)) {
992                 msg.rep = tipc_get_err_tlv(TIPC_CFG_NOT_SUPPORTED);
993                 err = -EOPNOTSUPP;
994                 goto send;
995         }
996
997         err = tipc_nl_compat_handle(&msg);
998         if (err == -EOPNOTSUPP)
999                 msg.rep = tipc_get_err_tlv(TIPC_CFG_NOT_SUPPORTED);
1000         else if (err == -EINVAL)
1001                 msg.rep = tipc_get_err_tlv(TIPC_CFG_TLV_ERROR);
1002 send:
1003         if (!msg.rep)
1004                 return err;
1005
1006         len = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN);
1007         skb_push(msg.rep, len);
1008         rep_nlh = nlmsg_hdr(msg.rep);
1009         memcpy(rep_nlh, info->nlhdr, len);
1010         rep_nlh->nlmsg_len = msg.rep->len;
1011         genlmsg_unicast(net, msg.rep, NETLINK_CB(skb).portid);
1012
1013         return err;
1014 }
1015
1016 static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
1017 {
1018         struct net *net = genl_info_net(info);
1019         struct sk_buff *rep_buf;
1020         struct nlmsghdr *rep_nlh;
1021         struct nlmsghdr *req_nlh = info->nlhdr;
1022         struct tipc_genlmsghdr *req_userhdr = info->userhdr;
1023         int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN);
1024         u16 cmd;
1025
1026         if ((req_userhdr->cmd & 0xC000) &&
1027             (!netlink_net_capable(skb, CAP_NET_ADMIN)))
1028                 cmd = TIPC_CMD_NOT_NET_ADMIN;
1029         else
1030                 cmd = req_userhdr->cmd;
1031
1032         rep_buf = tipc_cfg_do_cmd(net, req_userhdr->dest, cmd,
1033                                   nlmsg_data(req_nlh) + GENL_HDRLEN +
1034                                   TIPC_GENL_HDRLEN,
1035                                   nlmsg_attrlen(req_nlh, GENL_HDRLEN +
1036                                   TIPC_GENL_HDRLEN), hdr_space);
1037
1038         if (rep_buf) {
1039                 skb_push(rep_buf, hdr_space);
1040                 rep_nlh = nlmsg_hdr(rep_buf);
1041                 memcpy(rep_nlh, req_nlh, hdr_space);
1042                 rep_nlh->nlmsg_len = rep_buf->len;
1043                 genlmsg_unicast(net, rep_buf, NETLINK_CB(skb).portid);
1044         }
1045
1046         return 0;
1047 }
1048
1049 /* Temporary function to keep functionality throughout the patchset
1050  * without having to mess with the global variables and other trickery
1051  * of the old API.
1052  */
1053 static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
1054 {
1055         struct tipc_genlmsghdr *req = info->userhdr;
1056
1057         switch (req->cmd) {
1058         case TIPC_CMD_GET_BEARER_NAMES:
1059         case TIPC_CMD_ENABLE_BEARER:
1060         case TIPC_CMD_DISABLE_BEARER:
1061         case TIPC_CMD_SHOW_LINK_STATS:
1062         case TIPC_CMD_GET_LINKS:
1063         case TIPC_CMD_SET_LINK_TOL:
1064         case TIPC_CMD_SET_LINK_PRI:
1065         case TIPC_CMD_SET_LINK_WINDOW:
1066         case TIPC_CMD_RESET_LINK_STATS:
1067         case TIPC_CMD_SHOW_NAME_TABLE:
1068         case TIPC_CMD_SHOW_PORTS:
1069         case TIPC_CMD_GET_MEDIA_NAMES:
1070         case TIPC_CMD_GET_NODES:
1071         case TIPC_CMD_SET_NODE_ADDR:
1072         case TIPC_CMD_SET_NETID:
1073                 return tipc_nl_compat_recv(skb, info);
1074         }
1075
1076         return handle_cmd(skb, info);
1077 }
1078
1079 static struct genl_family tipc_genl_compat_family = {
1080         .id             = GENL_ID_GENERATE,
1081         .name           = TIPC_GENL_NAME,
1082         .version        = TIPC_GENL_VERSION,
1083         .hdrsize        = TIPC_GENL_HDRLEN,
1084         .maxattr        = 0,
1085         .netnsok        = true,
1086 };
1087
1088 static struct genl_ops tipc_genl_compat_ops[] = {
1089         {
1090                 .cmd            = TIPC_GENL_CMD,
1091                 .doit           = tipc_nl_compat_tmp_wrap,
1092         },
1093 };
1094
1095 int tipc_netlink_compat_start(void)
1096 {
1097         int res;
1098
1099         res = genl_register_family_with_ops(&tipc_genl_compat_family,
1100                                             tipc_genl_compat_ops);
1101         if (res) {
1102                 pr_err("Failed to register legacy compat interface\n");
1103                 return res;
1104         }
1105
1106         return 0;
1107 }
1108
1109 void tipc_netlink_compat_stop(void)
1110 {
1111         genl_unregister_family(&tipc_genl_compat_family);
1112 }