1 // SPDX-License-Identifier: GPL-2.0-only
3 * IEEE 802.1D Generic Attribute Registration Protocol (GARP)
5 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
7 #include <linux/kernel.h>
8 #include <linux/timer.h>
9 #include <linux/skbuff.h>
10 #include <linux/netdevice.h>
11 #include <linux/etherdevice.h>
12 #include <linux/rtnetlink.h>
13 #include <linux/llc.h>
14 #include <linux/slab.h>
15 #include <linux/module.h>
17 #include <net/llc_pdu.h>
19 #include <linux/unaligned.h>
21 static unsigned int garp_join_time __read_mostly
= 200;
22 module_param(garp_join_time
, uint
, 0644);
23 MODULE_PARM_DESC(garp_join_time
, "Join time in ms (default 200ms)");
24 MODULE_DESCRIPTION("IEEE 802.1D Generic Attribute Registration Protocol (GARP)");
25 MODULE_LICENSE("GPL");
27 static const struct garp_state_trans
{
30 } garp_applicant_state_table
[GARP_APPLICANT_MAX
+ 1][GARP_EVENT_MAX
+ 1] = {
31 [GARP_APPLICANT_VA
] = {
32 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_AA
,
33 .action
= GARP_ACTION_S_JOIN_IN
},
34 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_AA
},
35 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VA
},
36 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VA
},
37 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VA
},
38 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
39 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_INVALID
},
40 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_LA
},
42 [GARP_APPLICANT_AA
] = {
43 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_QA
,
44 .action
= GARP_ACTION_S_JOIN_IN
},
45 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_QA
},
46 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VA
},
47 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VA
},
48 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VA
},
49 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
50 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_INVALID
},
51 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_LA
},
53 [GARP_APPLICANT_QA
] = {
54 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_INVALID
},
55 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_QA
},
56 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VA
},
57 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VA
},
58 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VP
},
59 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
60 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_INVALID
},
61 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_LA
},
63 [GARP_APPLICANT_LA
] = {
64 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_VO
,
65 .action
= GARP_ACTION_S_LEAVE_EMPTY
},
66 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_LA
},
67 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
68 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_LA
},
69 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_LA
},
70 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
71 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_VA
},
72 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_INVALID
},
74 [GARP_APPLICANT_VP
] = {
75 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_AA
,
76 .action
= GARP_ACTION_S_JOIN_IN
},
77 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_AP
},
78 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
79 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
80 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VP
},
81 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
82 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_INVALID
},
83 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_VO
},
85 [GARP_APPLICANT_AP
] = {
86 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_QA
,
87 .action
= GARP_ACTION_S_JOIN_IN
},
88 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_QP
},
89 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
90 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
91 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VP
},
92 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
93 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_INVALID
},
94 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_AO
},
96 [GARP_APPLICANT_QP
] = {
97 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_INVALID
},
98 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_QP
},
99 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
100 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
101 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VP
},
102 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VP
},
103 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_INVALID
},
104 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_QO
},
106 [GARP_APPLICANT_VO
] = {
107 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_INVALID
},
108 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_AO
},
109 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
110 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
111 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VO
},
112 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
113 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_VP
},
114 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_INVALID
},
116 [GARP_APPLICANT_AO
] = {
117 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_INVALID
},
118 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_QO
},
119 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
120 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
121 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VO
},
122 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
123 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_AP
},
124 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_INVALID
},
126 [GARP_APPLICANT_QO
] = {
127 [GARP_EVENT_TRANSMIT_PDU
] = { .state
= GARP_APPLICANT_INVALID
},
128 [GARP_EVENT_R_JOIN_IN
] = { .state
= GARP_APPLICANT_QO
},
129 [GARP_EVENT_R_JOIN_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
130 [GARP_EVENT_R_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
131 [GARP_EVENT_R_LEAVE_IN
] = { .state
= GARP_APPLICANT_VO
},
132 [GARP_EVENT_R_LEAVE_EMPTY
] = { .state
= GARP_APPLICANT_VO
},
133 [GARP_EVENT_REQ_JOIN
] = { .state
= GARP_APPLICANT_QP
},
134 [GARP_EVENT_REQ_LEAVE
] = { .state
= GARP_APPLICANT_INVALID
},
138 static int garp_attr_cmp(const struct garp_attr
*attr
,
139 const void *data
, u8 len
, u8 type
)
141 if (attr
->type
!= type
)
142 return attr
->type
- type
;
143 if (attr
->dlen
!= len
)
144 return attr
->dlen
- len
;
145 return memcmp(attr
->data
, data
, len
);
148 static struct garp_attr
*garp_attr_lookup(const struct garp_applicant
*app
,
149 const void *data
, u8 len
, u8 type
)
151 struct rb_node
*parent
= app
->gid
.rb_node
;
152 struct garp_attr
*attr
;
156 attr
= rb_entry(parent
, struct garp_attr
, node
);
157 d
= garp_attr_cmp(attr
, data
, len
, type
);
159 parent
= parent
->rb_left
;
161 parent
= parent
->rb_right
;
168 static struct garp_attr
*garp_attr_create(struct garp_applicant
*app
,
169 const void *data
, u8 len
, u8 type
)
171 struct rb_node
*parent
= NULL
, **p
= &app
->gid
.rb_node
;
172 struct garp_attr
*attr
;
177 attr
= rb_entry(parent
, struct garp_attr
, node
);
178 d
= garp_attr_cmp(attr
, data
, len
, type
);
180 p
= &parent
->rb_left
;
182 p
= &parent
->rb_right
;
184 /* The attribute already exists; re-use it. */
188 attr
= kmalloc(sizeof(*attr
) + len
, GFP_ATOMIC
);
191 attr
->state
= GARP_APPLICANT_VO
;
194 memcpy(attr
->data
, data
, len
);
196 rb_link_node(&attr
->node
, parent
, p
);
197 rb_insert_color(&attr
->node
, &app
->gid
);
201 static void garp_attr_destroy(struct garp_applicant
*app
, struct garp_attr
*attr
)
203 rb_erase(&attr
->node
, &app
->gid
);
207 static void garp_attr_destroy_all(struct garp_applicant
*app
)
209 struct rb_node
*node
, *next
;
210 struct garp_attr
*attr
;
212 for (node
= rb_first(&app
->gid
);
213 next
= node
? rb_next(node
) : NULL
, node
!= NULL
;
215 attr
= rb_entry(node
, struct garp_attr
, node
);
216 garp_attr_destroy(app
, attr
);
220 static int garp_pdu_init(struct garp_applicant
*app
)
223 struct garp_pdu_hdr
*gp
;
225 #define LLC_RESERVE sizeof(struct llc_pdu_un)
226 skb
= alloc_skb(app
->dev
->mtu
+ LL_RESERVED_SPACE(app
->dev
),
232 skb
->protocol
= htons(ETH_P_802_2
);
233 skb_reserve(skb
, LL_RESERVED_SPACE(app
->dev
) + LLC_RESERVE
);
235 gp
= __skb_put(skb
, sizeof(*gp
));
236 put_unaligned(htons(GARP_PROTOCOL_ID
), &gp
->protocol
);
242 static int garp_pdu_append_end_mark(struct garp_applicant
*app
)
244 if (skb_tailroom(app
->pdu
) < sizeof(u8
))
246 __skb_put_u8(app
->pdu
, GARP_END_MARK
);
250 static void garp_pdu_queue(struct garp_applicant
*app
)
255 garp_pdu_append_end_mark(app
);
256 garp_pdu_append_end_mark(app
);
258 llc_pdu_header_init(app
->pdu
, LLC_PDU_TYPE_U
, LLC_SAP_BSPAN
,
259 LLC_SAP_BSPAN
, LLC_PDU_CMD
);
260 llc_pdu_init_as_ui_cmd(app
->pdu
);
261 llc_mac_hdr_init(app
->pdu
, app
->dev
->dev_addr
,
262 app
->app
->proto
.group_address
);
264 skb_queue_tail(&app
->queue
, app
->pdu
);
268 static void garp_queue_xmit(struct garp_applicant
*app
)
272 while ((skb
= skb_dequeue(&app
->queue
)))
276 static int garp_pdu_append_msg(struct garp_applicant
*app
, u8 attrtype
)
278 struct garp_msg_hdr
*gm
;
280 if (skb_tailroom(app
->pdu
) < sizeof(*gm
))
282 gm
= __skb_put(app
->pdu
, sizeof(*gm
));
283 gm
->attrtype
= attrtype
;
284 garp_cb(app
->pdu
)->cur_type
= attrtype
;
288 static int garp_pdu_append_attr(struct garp_applicant
*app
,
289 const struct garp_attr
*attr
,
290 enum garp_attr_event event
)
292 struct garp_attr_hdr
*ga
;
297 err
= garp_pdu_init(app
);
302 if (garp_cb(app
->pdu
)->cur_type
!= attr
->type
) {
303 if (garp_cb(app
->pdu
)->cur_type
&&
304 garp_pdu_append_end_mark(app
) < 0)
306 if (garp_pdu_append_msg(app
, attr
->type
) < 0)
310 len
= sizeof(*ga
) + attr
->dlen
;
311 if (skb_tailroom(app
->pdu
) < len
)
313 ga
= __skb_put(app
->pdu
, len
);
316 memcpy(ga
->data
, attr
->data
, attr
->dlen
);
324 static void garp_attr_event(struct garp_applicant
*app
,
325 struct garp_attr
*attr
, enum garp_event event
)
327 enum garp_applicant_state state
;
329 state
= garp_applicant_state_table
[attr
->state
][event
].state
;
330 if (state
== GARP_APPLICANT_INVALID
)
333 switch (garp_applicant_state_table
[attr
->state
][event
].action
) {
334 case GARP_ACTION_NONE
:
336 case GARP_ACTION_S_JOIN_IN
:
337 /* When appending the attribute fails, don't update state in
338 * order to retry on next TRANSMIT_PDU event. */
339 if (garp_pdu_append_attr(app
, attr
, GARP_JOIN_IN
) < 0)
342 case GARP_ACTION_S_LEAVE_EMPTY
:
343 garp_pdu_append_attr(app
, attr
, GARP_LEAVE_EMPTY
);
344 /* As a pure applicant, sending a leave message implies that
345 * the attribute was unregistered and can be destroyed. */
346 garp_attr_destroy(app
, attr
);
355 int garp_request_join(const struct net_device
*dev
,
356 const struct garp_application
*appl
,
357 const void *data
, u8 len
, u8 type
)
359 struct garp_port
*port
= rtnl_dereference(dev
->garp_port
);
360 struct garp_applicant
*app
= rtnl_dereference(port
->applicants
[appl
->type
]);
361 struct garp_attr
*attr
;
363 spin_lock_bh(&app
->lock
);
364 attr
= garp_attr_create(app
, data
, len
, type
);
366 spin_unlock_bh(&app
->lock
);
369 garp_attr_event(app
, attr
, GARP_EVENT_REQ_JOIN
);
370 spin_unlock_bh(&app
->lock
);
373 EXPORT_SYMBOL_GPL(garp_request_join
);
375 void garp_request_leave(const struct net_device
*dev
,
376 const struct garp_application
*appl
,
377 const void *data
, u8 len
, u8 type
)
379 struct garp_port
*port
= rtnl_dereference(dev
->garp_port
);
380 struct garp_applicant
*app
= rtnl_dereference(port
->applicants
[appl
->type
]);
381 struct garp_attr
*attr
;
383 spin_lock_bh(&app
->lock
);
384 attr
= garp_attr_lookup(app
, data
, len
, type
);
386 spin_unlock_bh(&app
->lock
);
389 garp_attr_event(app
, attr
, GARP_EVENT_REQ_LEAVE
);
390 spin_unlock_bh(&app
->lock
);
392 EXPORT_SYMBOL_GPL(garp_request_leave
);
394 static void garp_gid_event(struct garp_applicant
*app
, enum garp_event event
)
396 struct rb_node
*node
, *next
;
397 struct garp_attr
*attr
;
399 for (node
= rb_first(&app
->gid
);
400 next
= node
? rb_next(node
) : NULL
, node
!= NULL
;
402 attr
= rb_entry(node
, struct garp_attr
, node
);
403 garp_attr_event(app
, attr
, event
);
407 static void garp_join_timer_arm(struct garp_applicant
*app
)
411 delay
= get_random_u32_below(msecs_to_jiffies(garp_join_time
));
412 mod_timer(&app
->join_timer
, jiffies
+ delay
);
415 static void garp_join_timer(struct timer_list
*t
)
417 struct garp_applicant
*app
= from_timer(app
, t
, join_timer
);
419 spin_lock(&app
->lock
);
420 garp_gid_event(app
, GARP_EVENT_TRANSMIT_PDU
);
422 spin_unlock(&app
->lock
);
424 garp_queue_xmit(app
);
425 garp_join_timer_arm(app
);
428 static int garp_pdu_parse_end_mark(struct sk_buff
*skb
)
430 if (!pskb_may_pull(skb
, sizeof(u8
)))
432 if (*skb
->data
== GARP_END_MARK
) {
433 skb_pull(skb
, sizeof(u8
));
439 static int garp_pdu_parse_attr(struct garp_applicant
*app
, struct sk_buff
*skb
,
442 const struct garp_attr_hdr
*ga
;
443 struct garp_attr
*attr
;
444 enum garp_event event
;
447 if (!pskb_may_pull(skb
, sizeof(*ga
)))
449 ga
= (struct garp_attr_hdr
*)skb
->data
;
450 if (ga
->len
< sizeof(*ga
))
453 if (!pskb_may_pull(skb
, ga
->len
))
455 skb_pull(skb
, ga
->len
);
456 dlen
= sizeof(*ga
) - ga
->len
;
458 if (attrtype
> app
->app
->maxattr
)
465 garp_gid_event(app
, GARP_EVENT_R_LEAVE_EMPTY
);
467 case GARP_JOIN_EMPTY
:
468 event
= GARP_EVENT_R_JOIN_EMPTY
;
471 event
= GARP_EVENT_R_JOIN_IN
;
473 case GARP_LEAVE_EMPTY
:
474 event
= GARP_EVENT_R_LEAVE_EMPTY
;
477 event
= GARP_EVENT_R_EMPTY
;
485 attr
= garp_attr_lookup(app
, ga
->data
, dlen
, attrtype
);
488 garp_attr_event(app
, attr
, event
);
492 static int garp_pdu_parse_msg(struct garp_applicant
*app
, struct sk_buff
*skb
)
494 const struct garp_msg_hdr
*gm
;
496 if (!pskb_may_pull(skb
, sizeof(*gm
)))
498 gm
= (struct garp_msg_hdr
*)skb
->data
;
499 if (gm
->attrtype
== 0)
501 skb_pull(skb
, sizeof(*gm
));
503 while (skb
->len
> 0) {
504 if (garp_pdu_parse_attr(app
, skb
, gm
->attrtype
) < 0)
506 if (garp_pdu_parse_end_mark(skb
) < 0)
512 static void garp_pdu_rcv(const struct stp_proto
*proto
, struct sk_buff
*skb
,
513 struct net_device
*dev
)
515 struct garp_application
*appl
= proto
->data
;
516 struct garp_port
*port
;
517 struct garp_applicant
*app
;
518 const struct garp_pdu_hdr
*gp
;
520 port
= rcu_dereference(dev
->garp_port
);
523 app
= rcu_dereference(port
->applicants
[appl
->type
]);
527 if (!pskb_may_pull(skb
, sizeof(*gp
)))
529 gp
= (struct garp_pdu_hdr
*)skb
->data
;
530 if (get_unaligned(&gp
->protocol
) != htons(GARP_PROTOCOL_ID
))
532 skb_pull(skb
, sizeof(*gp
));
534 spin_lock(&app
->lock
);
535 while (skb
->len
> 0) {
536 if (garp_pdu_parse_msg(app
, skb
) < 0)
538 if (garp_pdu_parse_end_mark(skb
) < 0)
541 spin_unlock(&app
->lock
);
546 static int garp_init_port(struct net_device
*dev
)
548 struct garp_port
*port
;
550 port
= kzalloc(sizeof(*port
), GFP_KERNEL
);
553 rcu_assign_pointer(dev
->garp_port
, port
);
557 static void garp_release_port(struct net_device
*dev
)
559 struct garp_port
*port
= rtnl_dereference(dev
->garp_port
);
562 for (i
= 0; i
<= GARP_APPLICATION_MAX
; i
++) {
563 if (rtnl_dereference(port
->applicants
[i
]))
566 RCU_INIT_POINTER(dev
->garp_port
, NULL
);
567 kfree_rcu(port
, rcu
);
570 int garp_init_applicant(struct net_device
*dev
, struct garp_application
*appl
)
572 struct garp_applicant
*app
;
577 if (!rtnl_dereference(dev
->garp_port
)) {
578 err
= garp_init_port(dev
);
584 app
= kzalloc(sizeof(*app
), GFP_KERNEL
);
588 err
= dev_mc_add(dev
, appl
->proto
.group_address
);
595 spin_lock_init(&app
->lock
);
596 skb_queue_head_init(&app
->queue
);
597 rcu_assign_pointer(dev
->garp_port
->applicants
[appl
->type
], app
);
598 timer_setup(&app
->join_timer
, garp_join_timer
, 0);
599 garp_join_timer_arm(app
);
605 garp_release_port(dev
);
609 EXPORT_SYMBOL_GPL(garp_init_applicant
);
611 void garp_uninit_applicant(struct net_device
*dev
, struct garp_application
*appl
)
613 struct garp_port
*port
= rtnl_dereference(dev
->garp_port
);
614 struct garp_applicant
*app
= rtnl_dereference(port
->applicants
[appl
->type
]);
618 RCU_INIT_POINTER(port
->applicants
[appl
->type
], NULL
);
620 /* Delete timer and generate a final TRANSMIT_PDU event to flush out
621 * all pending messages before the applicant is gone. */
622 timer_shutdown_sync(&app
->join_timer
);
624 spin_lock_bh(&app
->lock
);
625 garp_gid_event(app
, GARP_EVENT_TRANSMIT_PDU
);
626 garp_attr_destroy_all(app
);
628 spin_unlock_bh(&app
->lock
);
630 garp_queue_xmit(app
);
632 dev_mc_del(dev
, appl
->proto
.group_address
);
634 garp_release_port(dev
);
636 EXPORT_SYMBOL_GPL(garp_uninit_applicant
);
638 int garp_register_application(struct garp_application
*appl
)
640 appl
->proto
.rcv
= garp_pdu_rcv
;
641 appl
->proto
.data
= appl
;
642 return stp_proto_register(&appl
->proto
);
644 EXPORT_SYMBOL_GPL(garp_register_application
);
646 void garp_unregister_application(struct garp_application
*appl
)
648 stp_proto_unregister(&appl
->proto
);
650 EXPORT_SYMBOL_GPL(garp_unregister_application
);