+++ /dev/null
-#!/usr/bin/env bash
-
-# Copyright (c) 2021 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Recompile DPDK l3fwd sample app with patching.
-
-set -exuo pipefail
-
-# Assumptions:
-# + There is a directory holding CSIT code to use (this script is there).
-# + At least one of the following is true:
-# ++ JOB_NAME environment variable is set,
-# ++ or this entry script has access to arguments.
-# Consequences (and specific assumptions) are multiple,
-# examine tree of functions for current description.
-
-# FIXME: Define API contract (as opposed to just help) for bootstrap.
-
-# "set -eu" handles failures from the following two lines.
-BASH_ENTRY_DIR="$(dirname $(readlink -e "${BASH_SOURCE[0]}"))"
-BASH_FUNCTION_DIR="$(readlink -e "${BASH_ENTRY_DIR}/../function")"
-source "${BASH_FUNCTION_DIR}/common.sh" || {
- echo "Source failed." >&2
- exit 1
-}
-source "${BASH_FUNCTION_DIR}/dpdk.sh" || die "Source failed."
-common_dirs || die
-dpdk_l3fwd_compile "${@}" || die
+++ /dev/null
-#!/bin/sh
-
-patch --ignore-whitespace --forward main.c <<"_EOF"
-204,205c204,205
-< {RTE_IPV4(198, 18, 0, 0), 24, 0},
-< {RTE_IPV4(198, 18, 1, 0), 24, 1},
----
-> {RTE_IPV4(198, 18, 0, 0), 24, 1},
-> {RTE_IPV4(198, 18, 1, 0), 24, 0},
-_EOF
from resources.libraries.python.Constants import Constants
from resources.libraries.python.CpuUtils import CpuUtils
from resources.libraries.python.DpdkUtil import DpdkUtil
-from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd
+from resources.libraries.python.ssh import exec_cmd_no_error
from resources.libraries.python.topology import NodeType, Topology
NB_PORTS = 2
)
command = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\
- f"/entry/run_l3fwd.sh \"{l3fwd_args} -P -L -p 0x3\""
+ f"/entry/run_l3fwd.sh \"{l3fwd_args} -P -L -p 0x3"\
+ f" --rule_ipv4={Constants.REMOTE_FW_DIR}/rule_ipv4.cfg\""
message = f"Failed to execute l3fwd test at node {node['host']}"
exec_cmd_no_error(node, command, timeout=1800, message=message)
# If DUT and TG not reordered -> flip
# Detect which is the port 0.
+ direction = 0
dut_flip = if_pci0 > if_pci1
if dut_flip:
if_key0, if_key1 = if_key1, if_key0
if tg_flip:
- L3fwdTest.patch_l3fwd(node, "patch_l3fwd_flip_routes")
+ direction = 1
elif not tg_flip:
- L3fwdTest.patch_l3fwd(node, "patch_l3fwd_flip_routes")
+ direction = 1
+
+ L3fwdTest.create_routes(node, direction=direction)
adj_node0, adj_if_key0 = Topology.get_adjacent_node_and_interface(
nodes, node, if_key0
return adj_mac0, adj_mac1, if_pci0, if_pci1
@staticmethod
- def patch_l3fwd(node, patch):
+ def create_routes(node, direction=0):
"""
- Patch l3fwd application and recompile.
+ Create route file for l3fwd application.
+
+ R<dst_ip><src_ip><dst_port><src_port><protocol><output_port_number>
:param node: DUT node.
- :param patch: Patch to apply.
+ :param direction: Route appearence order.
:type node: dict
- :type patch: str
- :raises RuntimeError: Patching of l3fwd failed.
+ :type direction: str
+ :raises RuntimeError: Create route file failed.
"""
- command = f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\
- f"/entry/patch_l3fwd.sh " \
- f"{Constants.REMOTE_FW_DIR}/{Constants.RESOURCES_LIB_SH}"\
- f"/entry/{patch}"
- message = f"Failed to patch l3fwd at node {node['host']}"
- ret_code, stdout, _ = exec_cmd(node, command, timeout=1800)
- if ret_code != 0 and "Skipping patch." not in stdout:
- raise RuntimeError(message)
+ filename = f"{Constants.REMOTE_FW_DIR}/rule_ipv4.cfg"
+ if not direction:
+ rule_ipv4 = (
+ "R198.18.0.0/24 0\n"
+ "R198.18.1.0/24 1\n"
+ )
+ else:
+ rule_ipv4 = (
+ "R198.18.0.0/24 1\n"
+ "R198.18.1.0/24 0\n"
+ )
+ cmd = f"echo \"{rule_ipv4}\" | sudo tee {filename}"
+ exec_cmd_no_error(node, cmd, message="Writing config file failed!")
\ No newline at end of file