net: hsr: fix mac_len checks
[ Upstream commit 48b491a5cc74333c4a6a82fe21cea42c055a3b0b ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
a6a0af3c90
commit
f6442ee08f
@@ -58,12 +58,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);
|
||||
|
||||
|
Reference in New Issue
Block a user