selftests: mlxsw: devlink_trap_tunnel_ipip: Remove code duplication

As part of adding same test for GRE tunnel with IPv6 underlay, an
optional improvement was found - call ipip_payload_get from
ecn_payload_get, so do not duplicate the code which creates the payload.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Amit Cohen 2021-10-08 16:12:40 +03:00 committed by David S. Miller
parent c473f723f9
commit 8bb0ebd522

View File

@ -116,12 +116,16 @@ cleanup()
forwarding_restore
}
ecn_payload_get()
ipip_payload_get()
{
local flags=$1; shift
local key=$1; shift
p=$(:
)"0"$( : GRE flags
)"$flags"$( : GRE flags
)"0:00:"$( : Reserved + version
)"08:00:"$( : ETH protocol type
)"$key"$( : Key
)"4"$( : IP version
)"5:"$( : IHL
)"00:"$( : IP TOS
@ -137,6 +141,11 @@ ecn_payload_get()
echo $p
}
ecn_payload_get()
{
echo $(ipip_payload_get "0")
}
ecn_decap_test()
{
local trap_name="decap_error"
@ -171,31 +180,6 @@ ecn_decap_test()
tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower
}
ipip_payload_get()
{
local flags=$1; shift
local key=$1; shift
p=$(:
)"$flags"$( : GRE flags
)"0:00:"$( : Reserved + version
)"08:00:"$( : ETH protocol type
)"$key"$( : Key
)"4"$( : IP version
)"5:"$( : IHL
)"00:"$( : IP TOS
)"00:14:"$( : IP total length
)"00:00:"$( : IP identification
)"20:00:"$( : IP flags + frag off
)"30:"$( : IP TTL
)"01:"$( : IP proto
)"E7:E6:"$( : IP header csum
)"C0:00:01:01:"$( : IP saddr : 192.0.1.1
)"C0:00:02:01:"$( : IP daddr : 192.0.2.1
)
echo $p
}
no_matching_tunnel_test()
{
local trap_name="decap_error"