hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/net/hsr/hsr_forward.c
....@@ -186,6 +186,7 @@
186186 set_prp_LSDU_size(trailer, lsdu_size);
187187 trailer->sequence_nr = htons(frame->sequence_nr);
188188 trailer->PRP_suffix = htons(ETH_P_PRP);
189
+ skb->protocol = eth_hdr(skb)->h_proto;
189190
190191 return skb;
191192 }
....@@ -226,6 +227,7 @@
226227 hsr_ethhdr->hsr_tag.encap_proto = hsr_ethhdr->ethhdr.h_proto;
227228 hsr_ethhdr->ethhdr.h_proto = htons(proto_version ?
228229 ETH_P_HSR : ETH_P_PRP);
230
+ skb->protocol = hsr_ethhdr->ethhdr.h_proto;
229231
230232 return skb;
231233 }
....@@ -435,7 +437,6 @@
435437 {
436438 struct hsr_port *port = frame->port_rcv;
437439 struct hsr_priv *hsr = port->hsr;
438
- unsigned long irqflags;
439440
440441 frame->skb_hsr = NULL;
441442 frame->skb_prp = NULL;
....@@ -445,17 +446,20 @@
445446 frame->is_from_san = true;
446447 } else {
447448 /* Sequence nr for the master node */
448
- spin_lock_irqsave(&hsr->seqnr_lock, irqflags);
449
+ lockdep_assert_held(&hsr->seqnr_lock);
449450 frame->sequence_nr = hsr->sequence_nr;
450451 hsr->sequence_nr++;
451
- spin_unlock_irqrestore(&hsr->seqnr_lock, irqflags);
452452 }
453453 }
454454
455455 int hsr_fill_frame_info(__be16 proto, struct sk_buff *skb,
456456 struct hsr_frame_info *frame)
457457 {
458
- if (proto == htons(ETH_P_PRP) ||
458
+ struct hsr_port *port = frame->port_rcv;
459
+ struct hsr_priv *hsr = port->hsr;
460
+
461
+ /* HSRv0 supervisory frames double as a tag so treat them as tagged. */
462
+ if ((!hsr->prot_version && proto == htons(ETH_P_PRP)) ||
459463 proto == htons(ETH_P_HSR)) {
460464 /* Check if skb contains hsr_ethhdr */
461465 if (skb->mac_len < sizeof(struct hsr_ethhdr))
....@@ -527,6 +531,7 @@
527531 proto = vlan_hdr->vlanhdr.h_vlan_encapsulated_proto;
528532 /* FIXME: */
529533 netdev_warn_once(skb->dev, "VLAN not yet supported");
534
+ return -EINVAL;
530535 }
531536
532537 frame->is_from_san = false;
....@@ -545,11 +550,13 @@
545550 {
546551 struct hsr_frame_info frame;
547552
553
+ rcu_read_lock();
548554 if (fill_frame_info(&frame, skb, port) < 0)
549555 goto out_drop;
550556
551557 hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
552558 hsr_forward_do(&frame);
559
+ rcu_read_unlock();
553560 /* Gets called for ingress frames as well as egress from master port.
554561 * So check and increment stats for master port only here.
555562 */
....@@ -564,6 +571,7 @@
564571 return;
565572
566573 out_drop:
574
+ rcu_read_unlock();
567575 port->dev->stats.tx_dropped++;
568576 kfree_skb(skb);
569577 }