Skip to contentSkip to conversation

net: hsr: avoid learning nodes from ordinary PRP SAN traffic

PATCH In review Ao Zhou 6 participants 7 messages Apr 2 – Apr 21 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ao Zhou

author
#1 lore raw

PATCH 1/1 net: hsr: avoid learning nodes from ordinary PRP SAN traffic

From: Haoze Xie <[email protected]>

PRP slave ports accept ordinary SAN traffic and forward it to the master device without needing a persistent node entry. Creating one node per previously unseen SAN source lets arbitrary source MAC floods grow node_db until the prune timer catches up.

Keep the receive path for ordinary PRP SAN traffic, but stop learning a new node when the frame is untagged and does not carry a PRP trailer. Continue to deliver the frame locally and only keep node state for actual HSR/PRP senders or nodes that have already been learned.

Fixes 451d8123f897 ("net: prp: add packet handling support")
---
 net/hsr/hsr_forward.c  | 14 ++++++++++----
 net/hsr/hsr_framereg.c | 16 +++++++++++++---
 2 files changed, 23 insertions(+), 7 deletions(-)
net/hsr/hsr_forward.c +10 -4
index aefc9b6936ba..5fbfc42997d2 100644
@@ -403,7 +403,8 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 	int res, recv_len;
 
 	was_multicast_frame = (skb->pkt_type == PACKET_MULTICAST);
-	hsr_addr_subst_source(node_src, skb);
+	if (node_src)
+		hsr_addr_subst_source(node_src, skb);
 	skb_pull(skb, ETH_HLEN);
 	recv_len = skb->len;
 	res = netif_rx(skb);
@@ -699,8 +700,12 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 
 	frame->node_src = hsr_get_node(port, n_db, skb,
 				       frame->is_supervision, port->type);
-	if (!frame->node_src)
-		return -1; /* Unknown node and !is_supervision, or no mem */
+	if (IS_ERR(frame->node_src)) {
+		ret = PTR_ERR(frame->node_src);
+		if (ret != -ENOENT)
+			return ret;
+		frame->node_src = NULL;
+	}
 
 	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 	frame->is_vlan = false;
@@ -739,7 +744,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 	if (fill_frame_info(&frame, skb, port) < 0)
 		goto out_drop;
 
-	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
+	if (frame.node_src)
+		hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
 	hsr_forward_do(&frame);
 	rcu_read_unlock();
 	/* Gets called for ingress frames as well as egress from master port.
net/hsr/hsr_framereg.c +13 -3
index 50996f4de7f9..13e1a0484879 100644
@@ -230,7 +230,7 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 	bool san = false;
 
 	if (!skb_mac_header_was_set(skb))
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 
@@ -263,14 +263,24 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 	    ethhdr->h_proto == htons(ETH_P_HSR)) {
 		/* Check if skb contains hsr_ethhdr */
 		if (skb->mac_len < sizeof(struct hsr_ethhdr))
-			return NULL;
+			return ERR_PTR(-EINVAL);
 	} else {
 		rct = skb_get_PRP_rct(skb);
 		if (!rct && rx_port != HSR_PT_MASTER)
 			san = true;
 	}
 
-	return hsr_add_node(hsr, node_db, ethhdr->h_source, san, rx_port);
+	/* PRP accepts ordinary SAN traffic on slave ports without learning a
+	 * persistent node entry.
+	 */
+	if (hsr->prot_version == PRP_V1 && san)
+		return ERR_PTR(-ENOENT);
+
+	node = hsr_add_node(hsr, node_db, ethhdr->h_source, san, rx_port);
+	if (!node)
+		return ERR_PTR(-ENOMEM);
+
+	return node;
 }
 
 static bool hsr_seq_block_is_old(struct hsr_seq_block *block)
Signature · 1 line
2.53.0
maintainer
#2 lore raw
Quoted 11 lines · Ao Zhou

From: Haoze Xie <[email protected]>

PRP slave ports accept ordinary SAN traffic and forward it to the master device without needing a persistent node entry. Creating one node per previously unseen SAN source lets arbitrary source MAC floods grow node_db until the prune timer catches up.

Keep the receive path for ordinary PRP SAN traffic, but stop learning a new node when the frame is untagged and does not carry a PRP trailer. Continue to deliver the frame locally and only keep node state for actual HSR/PRP senders or nodes that have already been learned.

It's not clear to me what prevents the rouge sender from always including a valid PRP trailer, thus still causing the issue addressed here. Some rationale needs to be included, or possibly limit the amount of newly created nodes to some configurable maximum.

Quoted 44 lines
Fixes 451d8123f897 ("net: prp: add packet handling support")
---
 net/hsr/hsr_forward.c  | 14 ++++++++++----
 net/hsr/hsr_framereg.c | 16 +++++++++++++---
 2 files changed, 23 insertions(+), 7 deletions(-)
net/hsr/hsr_forward.c +8 -3
index aefc9b6936ba..5fbfc42997d2 100644
@@ -403,7 +403,8 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 	int res, recv_len;
 
 	was_multicast_frame = (skb->pkt_type == PACKET_MULTICAST);
-	hsr_addr_subst_source(node_src, skb);
+	if (node_src)
+		hsr_addr_subst_source(node_src, skb);
 	skb_pull(skb, ETH_HLEN);
 	recv_len = skb->len;
 	res = netif_rx(skb);
@@ -699,8 +700,12 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 
 	frame->node_src = hsr_get_node(port, n_db, skb,
 				       frame->is_supervision, port->type);
-	if (!frame->node_src)
-		return -1; /* Unknown node and !is_supervision, or no mem */
+	if (IS_ERR(frame->node_src)) {
+		ret = PTR_ERR(frame->node_src);
+		if (ret != -ENOENT)
+			return ret;
+		frame->node_src = NULL;
+	}
 
 	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 	frame->is_vlan = false;

net/hsr/hsr_forward.c void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) · line 749

Quoted 7 lines
net/hsr/hsr_forward.c +2 -1
@@ -739,7 +744,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 	if (fill_frame_info(&frame, skb, port) < 0)
 		goto out_drop;
 
-	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
+	if (frame.node_src)
+		hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
 	hsr_forward_do(&frame);

I *think* the hsr_forward_do() could unconditionally dereference node_src in:

hsr->proto_ops->register_frame_out -> {prp,hsr}_register_frame_out -> hsr_check_duplicate:

	node = frame->node_src;	
	if (WARN_ON_ONCE(port_type >= node->seq_port_cnt))

/P

author
#3 lore raw

PATCH v2 1/1 net: hsr: avoid learning unknown senders for local delivery

In reply to a message not in the archive

From: Haoze Xie <[email protected]>

Traffic that is directly addressed to the local HSR/PRP master can be delivered locally without creating a persistent node entry. Learning one node per previously unseen source MAC lets forged sender floods grow node_db until the prune timer catches up.

Determine whether a frame is locally exclusive before node lookup and skip learning for unknown senders in that case. When no node state exists, also skip duplicate discard checks that depend on it.

This keeps locally-destined traffic reachable while avoiding node table growth from source-MAC floods in both the PRP SAN path and the HSR/PRP tagged sender paths.

Fixes f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
Fixes 451d8123f897 ("net: prp: add packet handling support")

---
changes in v2:
- generalize the fix beyond PRP SAN traffic and cover HSR/PRP tagged sender floods
- decide whether learning is needed from local-exclusive delivery instead of protocol-specific SAN checks
- use the normal NULL return semantics from hsr_get_node() instead of ERR_PTR-based error plumbing
- skip duplicate-discard state checks when no node state exists

 net/hsr/hsr_forward.c  | 23 +++++++++++++----------
 net/hsr/hsr_framereg.c |  5 ++++-
 net/hsr/hsr_framereg.h |  2 +-
 3 files changed, 18 insertions(+), 12 deletions(-)
net/hsr/hsr_forward.c +13 -10
index aefc9b6936ba..15bd17b4ee17 100644
@@ -403,7 +403,8 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 	int res, recv_len;
 
 	was_multicast_frame = (skb->pkt_type == PACKET_MULTICAST);
-	hsr_addr_subst_source(node_src, skb);
+	if (node_src)
+		hsr_addr_subst_source(node_src, skb);
 	skb_pull(skb, ETH_HLEN);
 	recv_len = skb->len;
 	res = netif_rx(skb);
@@ -545,7 +546,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
 		/* Don't send frame over port where it has been sent before.
 		 * Also for SAN, this shouldn't be done.
 		 */
-		if (!frame->is_from_san &&
+		if (frame->node_src && !frame->is_from_san &&
 		    hsr->proto_ops->register_frame_out &&
 		    hsr->proto_ops->register_frame_out(port, frame))
 			continue;
@@ -688,21 +689,25 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 		return -EINVAL;
 
 	memset(frame, 0, sizeof(*frame));
+	frame->port_rcv = port;
 	frame->is_supervision = is_supervision_frame(port->hsr, skb);
 	if (frame->is_supervision && hsr->redbox)
 		frame->is_proxy_supervision =
 			is_proxy_supervision_frame(port->hsr, skb);
 
+	ethhdr = (struct ethhdr *)skb_mac_header(skb);
+	check_local_dest(port->hsr, skb, frame);
+
 	n_db = &hsr->node_db;
 	if (port->type == HSR_PT_INTERLINK)
 		n_db = &hsr->proxy_node_db;
 
 	frame->node_src = hsr_get_node(port, n_db, skb,
-				       frame->is_supervision, port->type);
-	if (!frame->node_src)
-		return -1; /* Unknown node and !is_supervision, or no mem */
+				       frame->is_supervision, port->type,
+				       !frame->is_local_exclusive);
+	if (!frame->node_src && !frame->is_local_exclusive)
+		return -1;
 
-	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 	frame->is_vlan = false;
 	proto = ethhdr->h_proto;
 
@@ -720,13 +725,10 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 	}
 
 	frame->is_from_san = false;
-	frame->port_rcv = port;
 	ret = hsr->proto_ops->fill_frame_info(proto, skb, frame);
 	if (ret)
 		return ret;
 
-	check_local_dest(port->hsr, skb, frame);
-
 	return 0;
 }
 
@@ -739,7 +741,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 	if (fill_frame_info(&frame, skb, port) < 0)
 		goto out_drop;
 
-	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
+	if (frame.node_src)
+		hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
 	hsr_forward_do(&frame);
 	rcu_read_unlock();
 	/* Gets called for ingress frames as well as egress from master port.
net/hsr/hsr_framereg.c +4 -1
index 50996f4de7f9..2bc6f8f154c2 100644
@@ -221,7 +221,7 @@ void prp_update_san_info(struct hsr_node *node, bool is_sup)
  */
 struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			      struct sk_buff *skb, bool is_sup,
-			      enum hsr_port_type rx_port)
+			      enum hsr_port_type rx_port, bool learn)
 {
 	struct hsr_priv *hsr = port->hsr;
 	struct hsr_node *node;
@@ -270,6 +270,9 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			san = true;
 	}
 
+	if (!learn)
+		return NULL;
+
 	return hsr_add_node(hsr, node_db, ethhdr->h_source, san, rx_port);
 }
 
net/hsr/hsr_framereg.h +1 -1
index c65ecb925734..3d9c88e83090 100644
@@ -33,7 +33,7 @@ void hsr_del_self_node(struct hsr_priv *hsr);
 void hsr_del_nodes(struct list_head *node_db);
 struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			      struct sk_buff *skb, bool is_sup,
-			      enum hsr_port_type rx_port);
+			      enum hsr_port_type rx_port, bool learn);
 void hsr_handle_sup_frame(struct hsr_frame_info *frame);
 bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
 bool hsr_addr_is_redbox(struct hsr_priv *hsr, unsigned char *addr);
Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH net v2 1/1] net: hsr: avoid learning unknown senders for local delivery

Quoted 7 lines · Ao Zhou

From: Haoze Xie <[email protected]>

Traffic that is directly addressed to the local HSR/PRP master can be delivered locally without creating a persistent node entry. Learning one node per previously unseen source MAC lets forged sender floods grow node_db until the prune timer catches up.

Quoted 7 lines

Determine whether a frame is locally exclusive before node lookup and skip learning for unknown senders in that case. When no node state exists, also skip duplicate discard checks that depend on it.

This keeps locally-destined traffic reachable while avoiding node table growth from source-MAC floods in both the PRP SAN path and the HSR/PRP tagged sender paths.

I see the problem you are trying to solve here, but I don't think this patch provides a significant improvement over the current situation. Yes, this will disable learning of new nodes from regular traffic (and thereby completely prevent the duplicate discard algorithm from working). New nodes would only be learned from supervision frames. But nothing prevents a malicious host in the network from spoofing tons of supervision frames.

HSR and PRP are supposed to be used in pretty restricted network environments, so the whole protocol design doesn't really expect malicious actors in the network and doesn't provide good options to safeguard against misuse.

IMHO, the only real way to prevent excessive resource use on our side is to put a limit on these resources. In this case, limit the size of the node table (bonus: make that limit configurable as Paolo suggested).

Thanks,
Felix

Quoted 138 lines
Fixes f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
Fixes 451d8123f897 ("net: prp: add packet handling support")

---
changes in v2:
- generalize the fix beyond PRP SAN traffic and cover HSR/PRP tagged sender floods
- decide whether learning is needed from local-exclusive delivery instead of protocol-specific SAN checks
- use the normal NULL return semantics from hsr_get_node() instead of ERR_PTR-based error plumbing
- skip duplicate-discard state checks when no node state exists

 net/hsr/hsr_forward.c  | 23 +++++++++++++----------
 net/hsr/hsr_framereg.c |  5 ++++-
 net/hsr/hsr_framereg.h |  2 +-
 3 files changed, 18 insertions(+), 12 deletions(-)
net/hsr/hsr_forward.c +13 -10
index aefc9b6936ba..15bd17b4ee17 100644
@@ -403,7 +403,8 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 	int res, recv_len;
 
 	was_multicast_frame = (skb->pkt_type == PACKET_MULTICAST);
-	hsr_addr_subst_source(node_src, skb);
+	if (node_src)
+		hsr_addr_subst_source(node_src, skb);
 	skb_pull(skb, ETH_HLEN);
 	recv_len = skb->len;
 	res = netif_rx(skb);
@@ -545,7 +546,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
 		/* Don't send frame over port where it has been sent before.
 		 * Also for SAN, this shouldn't be done.
 		 */
-		if (!frame->is_from_san &&
+		if (frame->node_src && !frame->is_from_san &&
 		    hsr->proto_ops->register_frame_out &&
 		    hsr->proto_ops->register_frame_out(port, frame))
 			continue;
@@ -688,21 +689,25 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 		return -EINVAL;
 
 	memset(frame, 0, sizeof(*frame));
+	frame->port_rcv = port;
 	frame->is_supervision = is_supervision_frame(port->hsr, skb);
 	if (frame->is_supervision && hsr->redbox)
 		frame->is_proxy_supervision =
 			is_proxy_supervision_frame(port->hsr, skb);
 
+	ethhdr = (struct ethhdr *)skb_mac_header(skb);
+	check_local_dest(port->hsr, skb, frame);
+
 	n_db = &hsr->node_db;
 	if (port->type == HSR_PT_INTERLINK)
 		n_db = &hsr->proxy_node_db;
 
 	frame->node_src = hsr_get_node(port, n_db, skb,
-				       frame->is_supervision, port->type);
-	if (!frame->node_src)
-		return -1; /* Unknown node and !is_supervision, or no mem */
+				       frame->is_supervision, port->type,
+				       !frame->is_local_exclusive);
+	if (!frame->node_src && !frame->is_local_exclusive)
+		return -1;
 
-	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 	frame->is_vlan = false;
 	proto = ethhdr->h_proto;
 
@@ -720,13 +725,10 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 	}
 
 	frame->is_from_san = false;
-	frame->port_rcv = port;
 	ret = hsr->proto_ops->fill_frame_info(proto, skb, frame);
 	if (ret)
 		return ret;
 
-	check_local_dest(port->hsr, skb, frame);
-
 	return 0;
 }
 
@@ -739,7 +741,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 	if (fill_frame_info(&frame, skb, port) < 0)
 		goto out_drop;
 
-	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
+	if (frame.node_src)
+		hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
 	hsr_forward_do(&frame);
 	rcu_read_unlock();
 	/* Gets called for ingress frames as well as egress from master port.
net/hsr/hsr_framereg.c +4 -1
index 50996f4de7f9..2bc6f8f154c2 100644
@@ -221,7 +221,7 @@ void prp_update_san_info(struct hsr_node *node, bool is_sup)
  */
 struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			      struct sk_buff *skb, bool is_sup,
-			      enum hsr_port_type rx_port)
+			      enum hsr_port_type rx_port, bool learn)
 {
 	struct hsr_priv *hsr = port->hsr;
 	struct hsr_node *node;
@@ -270,6 +270,9 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			san = true;
 	}
 
+	if (!learn)
+		return NULL;
+
 	return hsr_add_node(hsr, node_db, ethhdr->h_source, san, rx_port);
 }
 
net/hsr/hsr_framereg.h +1 -2
index c65ecb925734..3d9c88e83090 100644
@@ -33,7 +33,7 @@ void hsr_del_self_node(struct hsr_priv *hsr);
 void hsr_del_nodes(struct list_head *node_db);
 struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			      struct sk_buff *skb, bool is_sup,
-			      enum hsr_port_type rx_port);
+			      enum hsr_port_type rx_port, bool learn);
 void hsr_handle_sup_frame(struct hsr_frame_info *frame);
 bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
 bool hsr_addr_is_redbox(struct hsr_priv *hsr, unsigned char *addr);
--

2.53.0

#5 lore raw

Re: [PATCH net v2 1/1] net: hsr: avoid learning unknown senders for local delivery

Quoted 3 lines · Felix Maurer

IMHO, the only real way to prevent excessive resource use on our side is to put a limit on these resources. In this case, limit the size of the node table (bonus: make that limit configurable as Paolo suggested).

I am slowly catching up. There was no follow-up on this one, right?

Quoted 2 lines

Thanks,
Felix

Sebastian

#6 lore raw

Re: [PATCH net v2 1/1] net: hsr: avoid learning unknown senders for local delivery

Quoted 5 lines · Sebastian Andrzej Siewior
Quoted 3 lines · Felix Maurer

IMHO, the only real way to prevent excessive resource use on our side is to put a limit on these resources. In this case, limit the size of the node table (bonus: make that limit configurable as Paolo suggested).

I am slowly catching up. There was no follow-up on this one, right?

Hi,

Thank you for checking in. Please excuse the delay as we are only able to work on this part-time.

We are still refining the fix approach based on the recent feedback to ensure the fix is suitable and robust.

Thanks for your patience.

Best,

Yuan

Quoted 3 lines
Quoted 2 lines

Thanks,
Felix

Sebastian

#7 lore raw

Re: [PATCH net v2 1/1] net: hsr: avoid learning unknown senders for local delivery

In reply to Felix Maurer
Quoted 29 lines · Felix Maurer
Quoted 7 lines · Ao Zhou

From: Haoze Xie <[email protected]>

Traffic that is directly addressed to the local HSR/PRP master can be delivered locally without creating a persistent node entry. Learning one node per previously unseen source MAC lets forged sender floods grow node_db until the prune timer catches up.

Quoted 7 lines

Determine whether a frame is locally exclusive before node lookup and skip learning for unknown senders in that case. When no node state exists, also skip duplicate discard checks that depend on it.

This keeps locally-destined traffic reachable while avoiding node table growth from source-MAC floods in both the PRP SAN path and the HSR/PRP tagged sender paths.

I see the problem you are trying to solve here, but I don't think this patch provides a significant improvement over the current situation. Yes, this will disable learning of new nodes from regular traffic (and thereby completely prevent the duplicate discard algorithm from working). New nodes would only be learned from supervision frames. But nothing prevents a malicious host in the network from spoofing tons of supervision frames.

HSR and PRP are supposed to be used in pretty restricted network environments, so the whole protocol design doesn't really expect malicious actors in the network and doesn't provide good options to safeguard against misuse.

Quoted 7 lines

IMHO, the only real way to prevent excessive resource use on our side is to put a limit on these resources. In this case, limit the size of the node table (bonus: make that limit configurable as Paolo suggested).

Thanks,
Felix

I agree and therefore dropped the v2 learning-suppression approach and reworked the fix toward directly bounding node-table growth in v3 patch.

If the node-table-limit approach in v3 looks acceptable, I can also follow up later with refinements such as per-device configurability and better visibility when the table is saturated.

Best regards,
Haoze Xie

Quoted 140 lines
Quoted 139 lines
Fixes f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
Fixes 451d8123f897 ("net: prp: add packet handling support")

---
changes in v2:
- generalize the fix beyond PRP SAN traffic and cover HSR/PRP tagged sender floods
- decide whether learning is needed from local-exclusive delivery instead of protocol-specific SAN checks
- use the normal NULL return semantics from hsr_get_node() instead of ERR_PTR-based error plumbing
- skip duplicate-discard state checks when no node state exists

 net/hsr/hsr_forward.c  | 23 +++++++++++++----------
 net/hsr/hsr_framereg.c |  5 ++++-
 net/hsr/hsr_framereg.h |  2 +-
 3 files changed, 18 insertions(+), 12 deletions(-)
net/hsr/hsr_forward.c +13 -10
index aefc9b6936ba..15bd17b4ee17 100644
@@ -403,7 +403,8 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 	int res, recv_len;
 
 	was_multicast_frame = (skb->pkt_type == PACKET_MULTICAST);
-	hsr_addr_subst_source(node_src, skb);
+	if (node_src)
+		hsr_addr_subst_source(node_src, skb);
 	skb_pull(skb, ETH_HLEN);
 	recv_len = skb->len;
 	res = netif_rx(skb);
@@ -545,7 +546,7 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
 		/* Don't send frame over port where it has been sent before.
 		 * Also for SAN, this shouldn't be done.
 		 */
-		if (!frame->is_from_san &&
+		if (frame->node_src && !frame->is_from_san &&
 		    hsr->proto_ops->register_frame_out &&
 		    hsr->proto_ops->register_frame_out(port, frame))
 			continue;
@@ -688,21 +689,25 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 		return -EINVAL;
 
 	memset(frame, 0, sizeof(*frame));
+	frame->port_rcv = port;
 	frame->is_supervision = is_supervision_frame(port->hsr, skb);
 	if (frame->is_supervision && hsr->redbox)
 		frame->is_proxy_supervision =
 			is_proxy_supervision_frame(port->hsr, skb);
 
+	ethhdr = (struct ethhdr *)skb_mac_header(skb);
+	check_local_dest(port->hsr, skb, frame);
+
 	n_db = &hsr->node_db;
 	if (port->type == HSR_PT_INTERLINK)
 		n_db = &hsr->proxy_node_db;
 
 	frame->node_src = hsr_get_node(port, n_db, skb,
-				       frame->is_supervision, port->type);
-	if (!frame->node_src)
-		return -1; /* Unknown node and !is_supervision, or no mem */
+				       frame->is_supervision, port->type,
+				       !frame->is_local_exclusive);
+	if (!frame->node_src && !frame->is_local_exclusive)
+		return -1;
 
-	ethhdr = (struct ethhdr *)skb_mac_header(skb);
 	frame->is_vlan = false;
 	proto = ethhdr->h_proto;
 
@@ -720,13 +725,10 @@ static int fill_frame_info(struct hsr_frame_info *frame,
 	}
 
 	frame->is_from_san = false;
-	frame->port_rcv = port;
 	ret = hsr->proto_ops->fill_frame_info(proto, skb, frame);
 	if (ret)
 		return ret;
 
-	check_local_dest(port->hsr, skb, frame);
-
 	return 0;
 }
 
@@ -739,7 +741,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 	if (fill_frame_info(&frame, skb, port) < 0)
 		goto out_drop;
 
-	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
+	if (frame.node_src)
+		hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
 	hsr_forward_do(&frame);
 	rcu_read_unlock();
 	/* Gets called for ingress frames as well as egress from master port.
net/hsr/hsr_framereg.c +4 -1
index 50996f4de7f9..2bc6f8f154c2 100644
@@ -221,7 +221,7 @@ void prp_update_san_info(struct hsr_node *node, bool is_sup)
  */
 struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			      struct sk_buff *skb, bool is_sup,
-			      enum hsr_port_type rx_port)
+			      enum hsr_port_type rx_port, bool learn)
 {
 	struct hsr_priv *hsr = port->hsr;
 	struct hsr_node *node;
@@ -270,6 +270,9 @@ struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			san = true;
 	}
 
+	if (!learn)
+		return NULL;
+
 	return hsr_add_node(hsr, node_db, ethhdr->h_source, san, rx_port);
 }
 
net/hsr/hsr_framereg.h +1 -2
index c65ecb925734..3d9c88e83090 100644
@@ -33,7 +33,7 @@ void hsr_del_self_node(struct hsr_priv *hsr);
 void hsr_del_nodes(struct list_head *node_db);
 struct hsr_node *hsr_get_node(struct hsr_port *port, struct list_head *node_db,
 			      struct sk_buff *skb, bool is_sup,
-			      enum hsr_port_type rx_port);
+			      enum hsr_port_type rx_port, bool learn);
 void hsr_handle_sup_frame(struct hsr_frame_info *frame);
 bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr);
 bool hsr_addr_is_redbox(struct hsr_priv *hsr, unsigned char *addr);
--

2.53.0