Linux 6.10-rc3
[linux-block.git] / net / hsr / hsr_netlink.c
CommitLineData
0e7623bd 1// SPDX-License-Identifier: GPL-2.0
70ebe4a4 2/* Copyright 2011-2014 Autronica Fire and Security AS
f421436a
AB
3 *
4 * Author(s):
70ebe4a4 5 * 2011-2014 Arvid Brodin, arvid.brodin@alten.se
f421436a 6 *
8f4c0e01 7 * Routines for handling Netlink messages for HSR and PRP.
f421436a
AB
8 */
9
10#include "hsr_netlink.h"
11#include <linux/kernel.h>
12#include <net/rtnetlink.h>
13#include <net/genetlink.h>
14#include "hsr_main.h"
15#include "hsr_device.h"
16#include "hsr_framereg.h"
17
18static const struct nla_policy hsr_policy[IFLA_HSR_MAX + 1] = {
19 [IFLA_HSR_SLAVE1] = { .type = NLA_U32 },
20 [IFLA_HSR_SLAVE2] = { .type = NLA_U32 },
21 [IFLA_HSR_MULTICAST_SPEC] = { .type = NLA_U8 },
ee1c2797 22 [IFLA_HSR_VERSION] = { .type = NLA_U8 },
f9375729 23 [IFLA_HSR_SUPERVISION_ADDR] = { .len = ETH_ALEN },
98bf8362 24 [IFLA_HSR_SEQ_NR] = { .type = NLA_U16 },
8f4c0e01 25 [IFLA_HSR_PROTOCOL] = { .type = NLA_U8 },
5055cccf 26 [IFLA_HSR_INTERLINK] = { .type = NLA_U32 },
f421436a
AB
27};
28
f421436a
AB
29/* Here, it seems a netdevice has already been allocated for us, and the
30 * hsr_dev_setup routine has been executed. Nice!
31 */
32static int hsr_newlink(struct net *src_net, struct net_device *dev,
7a3f4a18
MS
33 struct nlattr *tb[], struct nlattr *data[],
34 struct netlink_ext_ack *extack)
f421436a 35{
8f4c0e01
MK
36 enum hsr_version proto_version;
37 unsigned char multicast_spec;
38 u8 proto = HSR_PROTOCOL_HSR;
f421436a 39
5055cccf 40 struct net_device *link[2], *interlink = NULL;
a718dcc5 41 if (!data) {
13eeb5fe 42 NL_SET_ERR_MSG_MOD(extack, "No slave devices specified");
a718dcc5
AB
43 return -EINVAL;
44 }
f421436a 45 if (!data[IFLA_HSR_SLAVE1]) {
13eeb5fe 46 NL_SET_ERR_MSG_MOD(extack, "Slave1 device not specified");
f421436a
AB
47 return -EINVAL;
48 }
d595b85a
MK
49 link[0] = __dev_get_by_index(src_net,
50 nla_get_u32(data[IFLA_HSR_SLAVE1]));
13eeb5fe
TY
51 if (!link[0]) {
52 NL_SET_ERR_MSG_MOD(extack, "Slave1 does not exist");
53 return -EINVAL;
54 }
f421436a 55 if (!data[IFLA_HSR_SLAVE2]) {
13eeb5fe 56 NL_SET_ERR_MSG_MOD(extack, "Slave2 device not specified");
f421436a
AB
57 return -EINVAL;
58 }
d595b85a
MK
59 link[1] = __dev_get_by_index(src_net,
60 nla_get_u32(data[IFLA_HSR_SLAVE2]));
13eeb5fe
TY
61 if (!link[1]) {
62 NL_SET_ERR_MSG_MOD(extack, "Slave2 does not exist");
63 return -EINVAL;
64 }
f421436a 65
13eeb5fe
TY
66 if (link[0] == link[1]) {
67 NL_SET_ERR_MSG_MOD(extack, "Slave1 and Slave2 are same");
f421436a 68 return -EINVAL;
13eeb5fe 69 }
f421436a 70
5055cccf
LM
71 if (data[IFLA_HSR_INTERLINK])
72 interlink = __dev_get_by_index(src_net,
73 nla_get_u32(data[IFLA_HSR_INTERLINK]));
74
75 if (interlink && interlink == link[0]) {
76 NL_SET_ERR_MSG_MOD(extack, "Interlink and Slave1 are the same");
77 return -EINVAL;
78 }
79
80 if (interlink && interlink == link[1]) {
81 NL_SET_ERR_MSG_MOD(extack, "Interlink and Slave2 are the same");
82 return -EINVAL;
83 }
84
f421436a
AB
85 if (!data[IFLA_HSR_MULTICAST_SPEC])
86 multicast_spec = 0;
87 else
88 multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]);
89
8f4c0e01
MK
90 if (data[IFLA_HSR_PROTOCOL])
91 proto = nla_get_u8(data[IFLA_HSR_PROTOCOL]);
92
93 if (proto >= HSR_PROTOCOL_MAX) {
b87f9fe1 94 NL_SET_ERR_MSG_MOD(extack, "Unsupported protocol");
8f4c0e01
MK
95 return -EINVAL;
96 }
97
4faab8c4 98 if (!data[IFLA_HSR_VERSION]) {
8f4c0e01 99 proto_version = HSR_V0;
4faab8c4 100 } else {
8f4c0e01 101 if (proto == HSR_PROTOCOL_PRP) {
b87f9fe1 102 NL_SET_ERR_MSG_MOD(extack, "PRP version unsupported");
8f4c0e01
MK
103 return -EINVAL;
104 }
105
106 proto_version = nla_get_u8(data[IFLA_HSR_VERSION]);
107 if (proto_version > HSR_V1) {
4faab8c4 108 NL_SET_ERR_MSG_MOD(extack,
b87f9fe1 109 "Only HSR version 0/1 supported");
4faab8c4
TY
110 return -EINVAL;
111 }
112 }
ee1c2797 113
5055cccf 114 if (proto == HSR_PROTOCOL_PRP) {
8f4c0e01 115 proto_version = PRP_V1;
5055cccf
LM
116 if (interlink) {
117 NL_SET_ERR_MSG_MOD(extack,
118 "Interlink only works with HSR");
119 return -EINVAL;
120 }
121 }
8f4c0e01 122
5055cccf
LM
123 return hsr_dev_finalize(dev, link, interlink, multicast_spec,
124 proto_version, extack);
f421436a
AB
125}
126
de0083c7
TY
127static void hsr_dellink(struct net_device *dev, struct list_head *head)
128{
129 struct hsr_priv *hsr = netdev_priv(dev);
130
131 del_timer_sync(&hsr->prune_timer);
5055cccf 132 del_timer_sync(&hsr->prune_proxy_timer);
de0083c7
TY
133 del_timer_sync(&hsr->announce_timer);
134
135 hsr_debugfs_term(hsr);
136 hsr_del_ports(hsr);
137
138 hsr_del_self_node(hsr);
e012764c 139 hsr_del_nodes(&hsr->node_db);
5055cccf 140 hsr_del_nodes(&hsr->proxy_node_db);
de0083c7
TY
141
142 unregister_netdevice_queue(dev, head);
143}
144
98bf8362
AB
145static int hsr_fill_info(struct sk_buff *skb, const struct net_device *dev)
146{
81390d0c 147 struct hsr_priv *hsr = netdev_priv(dev);
8f4c0e01 148 u8 proto = HSR_PROTOCOL_HSR;
c5a75911 149 struct hsr_port *port;
98bf8362 150
c5a75911 151 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
81390d0c
TY
152 if (port) {
153 if (nla_put_u32(skb, IFLA_HSR_SLAVE1, port->dev->ifindex))
154 goto nla_put_failure;
155 }
51f3c605 156
c5a75911 157 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
81390d0c
TY
158 if (port) {
159 if (nla_put_u32(skb, IFLA_HSR_SLAVE2, port->dev->ifindex))
160 goto nla_put_failure;
161 }
98bf8362
AB
162
163 if (nla_put(skb, IFLA_HSR_SUPERVISION_ADDR, ETH_ALEN,
70ebe4a4
AB
164 hsr->sup_multicast_addr) ||
165 nla_put_u16(skb, IFLA_HSR_SEQ_NR, hsr->sequence_nr))
98bf8362 166 goto nla_put_failure;
8f4c0e01
MK
167 if (hsr->prot_version == PRP_V1)
168 proto = HSR_PROTOCOL_PRP;
169 if (nla_put_u8(skb, IFLA_HSR_PROTOCOL, proto))
170 goto nla_put_failure;
98bf8362
AB
171
172 return 0;
173
174nla_put_failure:
175 return -EMSGSIZE;
176}
177
f421436a
AB
178static struct rtnl_link_ops hsr_link_ops __read_mostly = {
179 .kind = "hsr",
180 .maxtype = IFLA_HSR_MAX,
181 .policy = hsr_policy,
182 .priv_size = sizeof(struct hsr_priv),
183 .setup = hsr_dev_setup,
184 .newlink = hsr_newlink,
de0083c7 185 .dellink = hsr_dellink,
98bf8362 186 .fill_info = hsr_fill_info,
f421436a
AB
187};
188
f421436a 189/* attribute policy */
f421436a 190static const struct nla_policy hsr_genl_policy[HSR_A_MAX + 1] = {
f9375729
PH
191 [HSR_A_NODE_ADDR] = { .len = ETH_ALEN },
192 [HSR_A_NODE_ADDR_B] = { .len = ETH_ALEN },
f421436a
AB
193 [HSR_A_IFINDEX] = { .type = NLA_U32 },
194 [HSR_A_IF1_AGE] = { .type = NLA_U32 },
195 [HSR_A_IF2_AGE] = { .type = NLA_U32 },
196 [HSR_A_IF1_SEQ] = { .type = NLA_U16 },
197 [HSR_A_IF2_SEQ] = { .type = NLA_U16 },
198};
199
489111e5 200static struct genl_family hsr_genl_family;
f421436a 201
2a94fe48
JB
202static const struct genl_multicast_group hsr_mcgrps[] = {
203 { .name = "hsr-network", },
f421436a
AB
204};
205
f421436a
AB
206/* This is called if for some node with MAC address addr, we only get frames
207 * over one of the slave interfaces. This would indicate an open network ring
208 * (i.e. a link has failed somewhere).
209 */
70ebe4a4 210void hsr_nl_ringerror(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN],
c5a75911 211 struct hsr_port *port)
f421436a
AB
212{
213 struct sk_buff *skb;
214 void *msg_head;
c5a75911 215 struct hsr_port *master;
f421436a 216 int res;
f421436a
AB
217
218 skb = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
219 if (!skb)
220 goto fail;
221
d595b85a
MK
222 msg_head = genlmsg_put(skb, 0, 0, &hsr_genl_family, 0,
223 HSR_C_RING_ERROR);
f421436a
AB
224 if (!msg_head)
225 goto nla_put_failure;
226
227 res = nla_put(skb, HSR_A_NODE_ADDR, ETH_ALEN, addr);
228 if (res < 0)
229 goto nla_put_failure;
230
c5a75911 231 res = nla_put_u32(skb, HSR_A_IFINDEX, port->dev->ifindex);
f421436a
AB
232 if (res < 0)
233 goto nla_put_failure;
234
235 genlmsg_end(skb, msg_head);
2a94fe48 236 genlmsg_multicast(&hsr_genl_family, skb, 0, 0, GFP_ATOMIC);
f421436a
AB
237
238 return;
239
240nla_put_failure:
241 kfree_skb(skb);
242
243fail:
c5a75911
AB
244 rcu_read_lock();
245 master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
246 netdev_warn(master->dev, "Could not send HSR ring error message\n");
247 rcu_read_unlock();
f421436a
AB
248}
249
250/* This is called when we haven't heard from the node with MAC address addr for
251 * some time (just before the node is removed from the node table/list).
252 */
70ebe4a4 253void hsr_nl_nodedown(struct hsr_priv *hsr, unsigned char addr[ETH_ALEN])
f421436a
AB
254{
255 struct sk_buff *skb;
256 void *msg_head;
c5a75911 257 struct hsr_port *master;
f421436a
AB
258 int res;
259
260 skb = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
261 if (!skb)
262 goto fail;
263
264 msg_head = genlmsg_put(skb, 0, 0, &hsr_genl_family, 0, HSR_C_NODE_DOWN);
265 if (!msg_head)
266 goto nla_put_failure;
267
f421436a
AB
268 res = nla_put(skb, HSR_A_NODE_ADDR, ETH_ALEN, addr);
269 if (res < 0)
270 goto nla_put_failure;
271
272 genlmsg_end(skb, msg_head);
2a94fe48 273 genlmsg_multicast(&hsr_genl_family, skb, 0, 0, GFP_ATOMIC);
f421436a
AB
274
275 return;
276
277nla_put_failure:
278 kfree_skb(skb);
279
280fail:
c5a75911
AB
281 rcu_read_lock();
282 master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
283 netdev_warn(master->dev, "Could not send HSR node down\n");
284 rcu_read_unlock();
f421436a
AB
285}
286
f421436a
AB
287/* HSR_C_GET_NODE_STATUS lets userspace query the internal HSR node table
288 * about the status of a specific node in the network, defined by its MAC
289 * address.
290 *
291 * Input: hsr ifindex, node mac address
292 * Output: hsr ifindex, node mac address (copied from request),
293 * age of latest frame from node over slave 1, slave 2 [ms]
294 */
295static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
296{
297 /* For receiving */
298 struct nlattr *na;
c5a75911 299 struct net_device *hsr_dev;
f421436a
AB
300
301 /* For sending */
302 struct sk_buff *skb_out;
303 void *msg_head;
70ebe4a4 304 struct hsr_priv *hsr;
c5a75911 305 struct hsr_port *port;
f421436a
AB
306 unsigned char hsr_node_addr_b[ETH_ALEN];
307 int hsr_node_if1_age;
308 u16 hsr_node_if1_seq;
309 int hsr_node_if2_age;
310 u16 hsr_node_if2_seq;
311 int addr_b_ifindex;
312 int res;
313
314 if (!info)
315 goto invalid;
316
317 na = info->attrs[HSR_A_IFINDEX];
318 if (!na)
319 goto invalid;
320 na = info->attrs[HSR_A_NODE_ADDR];
321 if (!na)
322 goto invalid;
323
173756b8
TY
324 rcu_read_lock();
325 hsr_dev = dev_get_by_index_rcu(genl_info_net(info),
326 nla_get_u32(info->attrs[HSR_A_IFINDEX]));
f421436a 327 if (!hsr_dev)
173756b8 328 goto rcu_unlock;
f421436a 329 if (!is_hsr_master(hsr_dev))
173756b8 330 goto rcu_unlock;
f421436a 331
f421436a 332 /* Send reply */
173756b8 333 skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
f421436a
AB
334 if (!skb_out) {
335 res = -ENOMEM;
336 goto fail;
337 }
338
339 msg_head = genlmsg_put(skb_out, NETLINK_CB(skb_in).portid,
4fe25bd8
MK
340 info->snd_seq, &hsr_genl_family, 0,
341 HSR_C_SET_NODE_STATUS);
f421436a
AB
342 if (!msg_head) {
343 res = -ENOMEM;
344 goto nla_put_failure;
345 }
346
347 res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex);
348 if (res < 0)
349 goto nla_put_failure;
350
70ebe4a4
AB
351 hsr = netdev_priv(hsr_dev);
352 res = hsr_get_node_data(hsr,
d595b85a
MK
353 (unsigned char *)
354 nla_data(info->attrs[HSR_A_NODE_ADDR]),
355 hsr_node_addr_b,
356 &addr_b_ifindex,
357 &hsr_node_if1_age,
358 &hsr_node_if1_seq,
359 &hsr_node_if2_age,
360 &hsr_node_if2_seq);
f421436a 361 if (res < 0)
84a035f6 362 goto nla_put_failure;
f421436a
AB
363
364 res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN,
4fe25bd8 365 nla_data(info->attrs[HSR_A_NODE_ADDR]));
f421436a
AB
366 if (res < 0)
367 goto nla_put_failure;
368
369 if (addr_b_ifindex > -1) {
370 res = nla_put(skb_out, HSR_A_NODE_ADDR_B, ETH_ALEN,
d595b85a 371 hsr_node_addr_b);
f421436a
AB
372 if (res < 0)
373 goto nla_put_failure;
374
d595b85a
MK
375 res = nla_put_u32(skb_out, HSR_A_ADDR_B_IFINDEX,
376 addr_b_ifindex);
f421436a
AB
377 if (res < 0)
378 goto nla_put_failure;
379 }
380
381 res = nla_put_u32(skb_out, HSR_A_IF1_AGE, hsr_node_if1_age);
382 if (res < 0)
383 goto nla_put_failure;
384 res = nla_put_u16(skb_out, HSR_A_IF1_SEQ, hsr_node_if1_seq);
385 if (res < 0)
386 goto nla_put_failure;
c5a75911
AB
387 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
388 if (port)
389 res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX,
390 port->dev->ifindex);
f421436a
AB
391 if (res < 0)
392 goto nla_put_failure;
393
394 res = nla_put_u32(skb_out, HSR_A_IF2_AGE, hsr_node_if2_age);
395 if (res < 0)
396 goto nla_put_failure;
397 res = nla_put_u16(skb_out, HSR_A_IF2_SEQ, hsr_node_if2_seq);
398 if (res < 0)
399 goto nla_put_failure;
c5a75911
AB
400 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
401 if (port)
402 res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX,
403 port->dev->ifindex);
51f3c605
AB
404 if (res < 0)
405 goto nla_put_failure;
f421436a 406
173756b8
TY
407 rcu_read_unlock();
408
f421436a
AB
409 genlmsg_end(skb_out, msg_head);
410 genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid);
411
412 return 0;
413
173756b8
TY
414rcu_unlock:
415 rcu_read_unlock();
f421436a 416invalid:
2d4bc933 417 netlink_ack(skb_in, nlmsg_hdr(skb_in), -EINVAL, NULL);
f421436a
AB
418 return 0;
419
420nla_put_failure:
421 kfree_skb(skb_out);
422 /* Fall through */
423
424fail:
173756b8 425 rcu_read_unlock();
f421436a
AB
426 return res;
427}
428
f266a683 429/* Get a list of MacAddressA of all nodes known to this node (including self).
f421436a
AB
430 */
431static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
432{
ca19c70f 433 unsigned char addr[ETH_ALEN];
f421436a 434 struct net_device *hsr_dev;
f421436a 435 struct sk_buff *skb_out;
70ebe4a4 436 struct hsr_priv *hsr;
ca19c70f
TY
437 bool restart = false;
438 struct nlattr *na;
439 void *pos = NULL;
440 void *msg_head;
f421436a
AB
441 int res;
442
443 if (!info)
444 goto invalid;
445
446 na = info->attrs[HSR_A_IFINDEX];
447 if (!na)
448 goto invalid;
449
173756b8
TY
450 rcu_read_lock();
451 hsr_dev = dev_get_by_index_rcu(genl_info_net(info),
452 nla_get_u32(info->attrs[HSR_A_IFINDEX]));
f421436a 453 if (!hsr_dev)
173756b8 454 goto rcu_unlock;
f421436a 455 if (!is_hsr_master(hsr_dev))
173756b8 456 goto rcu_unlock;
f421436a 457
ca19c70f 458restart:
f421436a 459 /* Send reply */
ca19c70f 460 skb_out = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC);
f421436a
AB
461 if (!skb_out) {
462 res = -ENOMEM;
463 goto fail;
464 }
465
466 msg_head = genlmsg_put(skb_out, NETLINK_CB(skb_in).portid,
4fe25bd8
MK
467 info->snd_seq, &hsr_genl_family, 0,
468 HSR_C_SET_NODE_LIST);
f421436a
AB
469 if (!msg_head) {
470 res = -ENOMEM;
471 goto nla_put_failure;
472 }
473
ca19c70f
TY
474 if (!restart) {
475 res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex);
476 if (res < 0)
477 goto nla_put_failure;
478 }
f421436a 479
70ebe4a4 480 hsr = netdev_priv(hsr_dev);
f421436a 481
ca19c70f
TY
482 if (!pos)
483 pos = hsr_get_next_node(hsr, NULL, addr);
f421436a
AB
484 while (pos) {
485 res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr);
486 if (res < 0) {
ca19c70f
TY
487 if (res == -EMSGSIZE) {
488 genlmsg_end(skb_out, msg_head);
489 genlmsg_unicast(genl_info_net(info), skb_out,
490 info->snd_portid);
491 restart = true;
492 goto restart;
493 }
f421436a
AB
494 goto nla_put_failure;
495 }
70ebe4a4 496 pos = hsr_get_next_node(hsr, pos, addr);
f421436a
AB
497 }
498 rcu_read_unlock();
499
500 genlmsg_end(skb_out, msg_head);
501 genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid);
502
503 return 0;
504
173756b8
TY
505rcu_unlock:
506 rcu_read_unlock();
f421436a 507invalid:
2d4bc933 508 netlink_ack(skb_in, nlmsg_hdr(skb_in), -EINVAL, NULL);
f421436a
AB
509 return 0;
510
511nla_put_failure:
ca19c70f 512 nlmsg_free(skb_out);
f421436a
AB
513 /* Fall through */
514
515fail:
173756b8 516 rcu_read_unlock();
f421436a
AB
517 return res;
518}
519
66a9b928 520static const struct genl_small_ops hsr_ops[] = {
9504b3ee
JB
521 {
522 .cmd = HSR_C_GET_NODE_STATUS,
ef6243ac 523 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
9504b3ee 524 .flags = 0,
9504b3ee
JB
525 .doit = hsr_get_node_status,
526 .dumpit = NULL,
527 },
528 {
529 .cmd = HSR_C_GET_NODE_LIST,
ef6243ac 530 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
9504b3ee 531 .flags = 0,
9504b3ee
JB
532 .doit = hsr_get_node_list,
533 .dumpit = NULL,
534 },
f421436a
AB
535};
536
56989f6d 537static struct genl_family hsr_genl_family __ro_after_init = {
489111e5
JB
538 .hdrsize = 0,
539 .name = "HSR",
540 .version = 1,
541 .maxattr = HSR_A_MAX,
3b0f31f2 542 .policy = hsr_genl_policy,
09e91dbe 543 .netnsok = true,
489111e5 544 .module = THIS_MODULE,
66a9b928
JK
545 .small_ops = hsr_ops,
546 .n_small_ops = ARRAY_SIZE(hsr_ops),
9c5d03d3 547 .resv_start_op = HSR_C_SET_NODE_LIST + 1,
489111e5
JB
548 .mcgrps = hsr_mcgrps,
549 .n_mcgrps = ARRAY_SIZE(hsr_mcgrps),
550};
551
f421436a
AB
552int __init hsr_netlink_init(void)
553{
554 int rc;
555
556 rc = rtnl_link_register(&hsr_link_ops);
557 if (rc)
558 goto fail_rtnl_link_register;
559
489111e5 560 rc = genl_register_family(&hsr_genl_family);
f421436a
AB
561 if (rc)
562 goto fail_genl_register_family;
563
c6c4ccd7 564 hsr_debugfs_create_root();
f421436a
AB
565 return 0;
566
f421436a
AB
567fail_genl_register_family:
568 rtnl_link_unregister(&hsr_link_ops);
569fail_rtnl_link_register:
570
571 return rc;
572}
573
574void __exit hsr_netlink_exit(void)
575{
f421436a 576 genl_unregister_family(&hsr_genl_family);
f421436a
AB
577 rtnl_link_unregister(&hsr_link_ops);
578}
579
580MODULE_ALIAS_RTNL_LINK("hsr");