Commit af21b94b authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'hsr-supervisor-frames'

Sebastian Andrzej Siewior says:

====================
net: hsr: Properly parse HSRv1 supervisor frames.

this is a follow-up to
	https://lore.kernel.org/all/20230825153111.228768-1-lukma@denx.de/
replacing
	https://lore.kernel.org/all/20230914124731.1654059-1-lukma@denx.de/



by grabing/ adding tags and reposting with a commit message plus a
missing __packed to a struct (#2) plus extending the testsuite to sover
HSRv1 which is what broke here (#3-#5).

HSRv0 is (was) not affected.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6af28974 b0e9c3b5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -288,13 +288,13 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame)

	/* And leave the HSR tag. */
	if (ethhdr->h_proto == htons(ETH_P_HSR)) {
		pull_size = sizeof(struct ethhdr);
		pull_size = sizeof(struct hsr_tag);
		skb_pull(skb, pull_size);
		total_pull_size += pull_size;
	}

	/* And leave the HSR sup tag. */
	pull_size = sizeof(struct hsr_tag);
	pull_size = sizeof(struct hsr_sup_tag);
	skb_pull(skb, pull_size);
	total_pull_size += pull_size;

+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ struct hsr_vlan_ethhdr {
struct hsr_sup_tlv {
	u8		HSR_TLV_type;
	u8		HSR_TLV_length;
};
} __packed;

/* HSR/PRP Supervision Frame data types.
 * Field names as defined in the IEC:2010 standard for HSR.
+143 −123
Original line number Diff line number Diff line
@@ -41,61 +41,6 @@ cleanup()
	done
}

ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
	echo "SKIP: Could not run test without ip tool"
	exit $ksft_skip
fi

trap cleanup EXIT

for i in "$ns1" "$ns2" "$ns3" ;do
	ip netns add $i || exit $ksft_skip
	ip -net $i link set lo up
done

echo "INFO: preparing interfaces."
# Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
#
#    ns1eth1 ----- ns2eth1
#      hsr1         hsr2
#    ns1eth2       ns2eth2
#       |            |
#    ns3eth1      ns3eth2
#           \    /
#            hsr3
#
# Interfaces
ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
ip link add ns1eth2 netns "$ns1" type veth peer name ns3eth1 netns "$ns3"
ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2"

# HSRv0.
ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version 0 proto 0
ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version 0 proto 0
ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version 0 proto 0

# IP for HSR
ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1
ip -net "$ns1" addr add dead:beef:1::1/64 dev hsr1 nodad
ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2
ip -net "$ns2" addr add dead:beef:1::2/64 dev hsr2 nodad
ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3
ip -net "$ns3" addr add dead:beef:1::3/64 dev hsr3 nodad

# All Links up
ip -net "$ns1" link set ns1eth1 up
ip -net "$ns1" link set ns1eth2 up
ip -net "$ns1" link set hsr1 up

ip -net "$ns2" link set ns2eth1 up
ip -net "$ns2" link set ns2eth2 up
ip -net "$ns2" link set hsr2 up

ip -net "$ns3" link set ns3eth1 up
ip -net "$ns3" link set ns3eth2 up
ip -net "$ns3" link set hsr3 up

# $1: IP address
is_v6()
{
@@ -164,7 +109,8 @@ stop_if_error()
	fi
}


do_complete_ping_test()
{
	echo "INFO: Initial validation ping."
	# Each node has to be able each one.
	do_ping "$ns1" 100.64.0.2
@@ -197,7 +143,7 @@ do
			break
		fi
		sleep 1
	let WAIT = WAIT - 1
		let "WAIT = WAIT - 1"
	done

# Just a safety delay in case the above check didn't handle it.
@@ -253,4 +199,78 @@ do_ping_long "$ns3" 100.64.0.2
	stop_if_error "Failed with delay and packetloss."

	echo "INFO: All good."
}

setup_hsr_interfaces()
{
	local HSRv="$1"

	echo "INFO: preparing interfaces for HSRv${HSRv}."
# Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
#
#    ns1eth1 ----- ns2eth1
#      hsr1         hsr2
#    ns1eth2       ns2eth2
#       |            |
#    ns3eth1      ns3eth2
#           \    /
#            hsr3
#
	# Interfaces
	ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
	ip link add ns1eth2 netns "$ns1" type veth peer name ns3eth1 netns "$ns3"
	ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2"

	# HSRv0/1
	ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version $HSRv proto 0
	ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version $HSRv proto 0
	ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version $HSRv proto 0

	# IP for HSR
	ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1
	ip -net "$ns1" addr add dead:beef:1::1/64 dev hsr1 nodad
	ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2
	ip -net "$ns2" addr add dead:beef:1::2/64 dev hsr2 nodad
	ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3
	ip -net "$ns3" addr add dead:beef:1::3/64 dev hsr3 nodad

	# All Links up
	ip -net "$ns1" link set ns1eth1 up
	ip -net "$ns1" link set ns1eth2 up
	ip -net "$ns1" link set hsr1 up

	ip -net "$ns2" link set ns2eth1 up
	ip -net "$ns2" link set ns2eth2 up
	ip -net "$ns2" link set hsr2 up

	ip -net "$ns3" link set ns3eth1 up
	ip -net "$ns3" link set ns3eth2 up
	ip -net "$ns3" link set hsr3 up
}

ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
	echo "SKIP: Could not run test without ip tool"
	exit $ksft_skip
fi

trap cleanup EXIT

for i in "$ns1" "$ns2" "$ns3" ;do
	ip netns add $i || exit $ksft_skip
	ip -net $i link set lo up
done

setup_hsr_interfaces 0
do_complete_ping_test
cleanup

for i in "$ns1" "$ns2" "$ns3" ;do
	ip netns add $i || exit $ksft_skip
	ip -net $i link set lo up
done

setup_hsr_interfaces 1
do_complete_ping_test

exit $ret