summaryrefslogtreecommitdiff
path: root/net/hsr/hsr_slave.c
diff options
context:
space:
mode:
authorGeorge McCollister <george.mccollister@gmail.com>2021-05-24 21:50:54 +0300
committerDavid S. Miller <davem@davemloft.net>2021-05-25 00:10:28 +0300
commit48b491a5cc74333c4a6a82fe21cea42c055a3b0b (patch)
tree26ea4fa3badf5fbf8bd12d290a8c81a75250a25e /net/hsr/hsr_slave.c
parenta4dd4fc6105e54393d637450a11d4cddb5fabc4f (diff)
downloadlinux-48b491a5cc74333c4a6a82fe21cea42c055a3b0b.tar.xz
net: hsr: fix mac_len checks
Commit 2e9f60932a2c ("net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info") added the following which resulted in -EINVAL always being returned: if (skb->mac_len < sizeof(struct hsr_ethhdr)) return -EINVAL; mac_len was not being set correctly so this check completely broke HSR/PRP since it was always 14, not 20. Set mac_len correctly and modify the mac_len checks to test in the correct places since sometimes it is legitimately 14. Fixes: 2e9f60932a2c ("net: hsr: check skb can contain struct hsr_ethhdr in fill_frame_info") Signed-off-by: George McCollister <george.mccollister@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/hsr/hsr_slave.c')
-rw-r--r--net/hsr/hsr_slave.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
index c5227d42faf5..b70e6bbf6021 100644
--- a/net/hsr/hsr_slave.c
+++ b/net/hsr/hsr_slave.c
@@ -60,12 +60,11 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb)
goto finish_pass;
skb_push(skb, ETH_HLEN);
-
- if (skb_mac_header(skb) != skb->data) {
- WARN_ONCE(1, "%s:%d: Malformed frame at source port %s)\n",
- __func__, __LINE__, port->dev->name);
- goto finish_consume;
- }
+ skb_reset_mac_header(skb);
+ if ((!hsr->prot_version && protocol == htons(ETH_P_PRP)) ||
+ protocol == htons(ETH_P_HSR))
+ skb_set_network_header(skb, ETH_HLEN + HSR_HLEN);
+ skb_reset_mac_len(skb);
hsr_forward_skb(skb, port);