Skip to content

Commit 94909c5

Browse files
author
Paolo Abeni
committed
Merge branch 'hsr-send-correct-hsrv0-supervision-frames'
Felix Maurer says: ==================== hsr: Send correct HSRv0 supervision frames Hangbin recently reported that the hsr selftests were failing and noted that the entries in the node table were not merged, i.e., had 00:00:00:00:00:00 as MacAddressB forever [1]. This failure only occured with HSRv0 because it was not sending supervision frames anymore. While debugging this I found that we were not really following the HSRv0 standard for the supervision frames we sent, so I additionally made a few changes to get closer to the standard and restore a more correct behavior we had a while ago. The selftests can still fail because they take a while and run into the timeout. I did not include a change of the timeout because I have more improvements to the selftests mostly ready that change the test duration but are net-next material. [1]: https://lore.kernel.org/netdev/aMONxDXkzBZZRfE5@fedora/ ==================== Link: https://patch.msgid.link/cover.1762876095.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 0eff2ea + b2c26c8 commit 94909c5

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

net/hsr/hsr_device.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ static void send_hsr_supervision_frame(struct hsr_port *port,
320320
}
321321

322322
hsr_stag = skb_put(skb, sizeof(struct hsr_sup_tag));
323+
skb_set_network_header(skb, ETH_HLEN + HSR_HLEN);
324+
skb_reset_mac_len(skb);
325+
323326
set_hsr_stag_path(hsr_stag, (hsr->prot_version ? 0x0 : 0xf));
324327
set_hsr_stag_HSR_ver(hsr_stag, hsr->prot_version);
325328

@@ -334,7 +337,7 @@ static void send_hsr_supervision_frame(struct hsr_port *port,
334337
}
335338

336339
hsr_stag->tlv.HSR_TLV_type = type;
337-
/* TODO: Why 12 in HSRv0? */
340+
/* HSRv0 has 6 unused bytes after the MAC */
338341
hsr_stag->tlv.HSR_TLV_length = hsr->prot_version ?
339342
sizeof(struct hsr_sup_payload) : 12;
340343

net/hsr/hsr_forward.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,23 @@ static struct sk_buff *prp_fill_rct(struct sk_buff *skb,
262262
return skb;
263263
}
264264

265-
static void hsr_set_path_id(struct hsr_ethhdr *hsr_ethhdr,
265+
static void hsr_set_path_id(struct hsr_frame_info *frame,
266+
struct hsr_ethhdr *hsr_ethhdr,
266267
struct hsr_port *port)
267268
{
268269
int path_id;
269270

270-
if (port->type == HSR_PT_SLAVE_A)
271-
path_id = 0;
272-
else
273-
path_id = 1;
271+
if (port->hsr->prot_version) {
272+
if (port->type == HSR_PT_SLAVE_A)
273+
path_id = 0;
274+
else
275+
path_id = 1;
276+
} else {
277+
if (frame->is_supervision)
278+
path_id = 0xf;
279+
else
280+
path_id = 1;
281+
}
274282

275283
set_hsr_tag_path(&hsr_ethhdr->hsr_tag, path_id);
276284
}
@@ -304,7 +312,7 @@ static struct sk_buff *hsr_fill_tag(struct sk_buff *skb,
304312
else
305313
hsr_ethhdr = (struct hsr_ethhdr *)pc;
306314

307-
hsr_set_path_id(hsr_ethhdr, port);
315+
hsr_set_path_id(frame, hsr_ethhdr, port);
308316
set_hsr_tag_LSDU_size(&hsr_ethhdr->hsr_tag, lsdu_size);
309317
hsr_ethhdr->hsr_tag.sequence_nr = htons(frame->sequence_nr);
310318
hsr_ethhdr->hsr_tag.encap_proto = hsr_ethhdr->ethhdr.h_proto;
@@ -330,7 +338,7 @@ struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame,
330338
(struct hsr_ethhdr *)skb_mac_header(frame->skb_hsr);
331339

332340
/* set the lane id properly */
333-
hsr_set_path_id(hsr_ethhdr, port);
341+
hsr_set_path_id(frame, hsr_ethhdr, port);
334342
return skb_clone(frame->skb_hsr, GFP_ATOMIC);
335343
} else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) {
336344
return skb_clone(frame->skb_std, GFP_ATOMIC);

0 commit comments

Comments
 (0)