hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/802/mrp.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * IEEE 802.1Q Multiple Registration Protocol (MRP)
34 *
....@@ -5,10 +6,6 @@
56 *
67 * Adapted from code in net/802/garp.c
78 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU General Public License
11
- * version 2 as published by the Free Software Foundation.
129 */
1310 #include <linux/kernel.h>
1411 #include <linux/timer.h>
....@@ -539,7 +536,7 @@
539536 struct mrp_attr *attr;
540537
541538 if (sizeof(struct mrp_skb_cb) + len >
542
- FIELD_SIZEOF(struct sk_buff, cb))
539
+ sizeof_field(struct sk_buff, cb))
543540 return -ENOMEM;
544541
545542 spin_lock_bh(&app->lock);
....@@ -564,7 +561,7 @@
564561 struct mrp_attr *attr;
565562
566563 if (sizeof(struct mrp_skb_cb) + len >
567
- FIELD_SIZEOF(struct sk_buff, cb))
564
+ sizeof_field(struct sk_buff, cb))
568565 return;
569566
570567 spin_lock_bh(&app->lock);
....@@ -609,7 +606,10 @@
609606 spin_unlock(&app->lock);
610607
611608 mrp_queue_xmit(app);
612
- mrp_join_timer_arm(app);
609
+ spin_lock(&app->lock);
610
+ if (likely(app->active))
611
+ mrp_join_timer_arm(app);
612
+ spin_unlock(&app->lock);
613613 }
614614
615615 static void mrp_periodic_timer_arm(struct mrp_applicant *app)
....@@ -623,11 +623,12 @@
623623 struct mrp_applicant *app = from_timer(app, t, periodic_timer);
624624
625625 spin_lock(&app->lock);
626
- mrp_mad_event(app, MRP_EVENT_PERIODIC);
627
- mrp_pdu_queue(app);
626
+ if (likely(app->active)) {
627
+ mrp_mad_event(app, MRP_EVENT_PERIODIC);
628
+ mrp_pdu_queue(app);
629
+ mrp_periodic_timer_arm(app);
630
+ }
628631 spin_unlock(&app->lock);
629
-
630
- mrp_periodic_timer_arm(app);
631632 }
632633
633634 static int mrp_pdu_parse_end_mark(struct sk_buff *skb, int *offset)
....@@ -708,7 +709,7 @@
708709 * advance to the next event in its Vector.
709710 */
710711 if (sizeof(struct mrp_skb_cb) + mrp_cb(skb)->mh->attrlen >
711
- FIELD_SIZEOF(struct sk_buff, cb))
712
+ sizeof_field(struct sk_buff, cb))
712713 return -1;
713714 if (skb_copy_bits(skb, *offset, mrp_cb(skb)->attrvalue,
714715 mrp_cb(skb)->mh->attrlen) < 0)
....@@ -875,6 +876,7 @@
875876 app->dev = dev;
876877 app->app = appl;
877878 app->mad = RB_ROOT;
879
+ app->active = true;
878880 spin_lock_init(&app->lock);
879881 skb_queue_head_init(&app->queue);
880882 rcu_assign_pointer(dev->mrp_port->applicants[appl->type], app);
....@@ -903,6 +905,9 @@
903905
904906 RCU_INIT_POINTER(port->applicants[appl->type], NULL);
905907
908
+ spin_lock_bh(&app->lock);
909
+ app->active = false;
910
+ spin_unlock_bh(&app->lock);
906911 /* Delete timer and generate a final TX event to flush out
907912 * all pending messages before the applicant is gone.
908913 */