#!/usr/bin/env bash # Copyright (c) 2018 AT&T Corporation # All Rights Reserved. # # 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. help_msg="Incorrect arguments supplied!! Aborting....\nUsage: 1. VLANs to VF mirroring: $0 <'vlan_mirror'> <'add'|'rem'> \nUsage: 2. VF to VF mirroring: $0 <'ingress_mirror'|'egress_mirror'> <'add'|'rem'> " (($#!=5)) && { echo -e ${help_msg} && exit 1; } if [ -f /sys/class/net/${1}/device/sriov/${2}/${3} ] then echo ${4} ${5} > /sys/class/net/${1}/device/sriov/${2}/${3} else echo "Invalid sysfs path: /sys/class/net/${1}/device/sriov/${2}/${3}" exit 1 fi