• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
4# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
5# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
6
7virt_type="macsec"
8VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-100}
9IPSEC_MODE="transport"
10
11TST_NEEDS_TMPDIR=1
12TST_TESTFUNC=virt_netperf_msg_sizes
13TST_SETUP=macsec_lib_setup
14TST_CLEANUP=macsec_lib_cleanup
15TST_NEEDS_DRIVERS="macsec"
16. ipsec_lib.sh
17. virt_lib.sh
18
19# MACSEC_LIB_SETUP:
20# [ cipher { default | gcm-aes-128 } ] [ encrypt { on | off } ]
21# [ protect { on | off } ] [ replay { on | off } ] [ window WINDOW ]
22# [ validate { strict | check | disabled } ]
23macsec_lib_setup()
24{
25	local keyid0="01"
26	local keyid1="02"
27	local sa=0
28	local h0=$(tst_hwaddr)
29	local h1=$(tst_hwaddr rhost)
30	local cmd="ip macsec add ltp_v0"
31	local key0="01234567890123456789012345678901"
32	local key1="98765432109876543210987612343434"
33
34	ipsec_lib_setup
35
36	tst_res TINFO "setup IPsec $IPSEC_MODE/$IPSEC_PROTO $EALGO"
37	tst_ipsec lhost $(tst_ipaddr) $(tst_ipaddr rhost)
38	tst_ipsec rhost $(tst_ipaddr rhost) $(tst_ipaddr)
39
40	virt_setup "icvlen 16 encodingsa $sa $MACSEC_LIB_SETUP"
41
42	ROD $cmd tx sa $sa pn 100 on key $keyid0 $key0
43	ROD $cmd rx address $h1 port 1
44	ROD $cmd rx address $h1 port 1 sa $sa pn 100 on key $keyid1 $key1
45
46	tst_rhost_run -s -c "$cmd tx sa $sa pn 100 on key $keyid1 $key1"
47	tst_rhost_run -s -c "$cmd rx address $h0 port 1"
48	tst_rhost_run -s -c \
49		"$cmd rx address $h0 port 1 sa $sa pn 100 on key $keyid0 $key0"
50}
51
52macsec_lib_cleanup()
53{
54	virt_cleanup
55	tst_ipsec_cleanup
56}
57