go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/l3plugin/vppcalls/vpp2106/vrf_vppcalls.go (about)

     1  //  Copyright (c) 2021 Cisco and/or its affiliates.
     2  //
     3  //  Licensed under the Apache License, Version 2.0 (the "License");
     4  //  you may not use this file except in compliance with the License.
     5  //  You may obtain a copy of the License at:
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  //  Unless required by applicable law or agreed to in writing, software
    10  //  distributed under the License is distributed on an "AS IS" BASIS,
    11  //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  //  See the License for the specific language governing permissions and
    13  //  limitations under the License.
    14  
    15  package vpp2106
    16  
    17  import (
    18  	vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/ip"
    19  	l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3"
    20  )
    21  
    22  // AddVrfTable adds new VRF table.
    23  func (h *VrfTableHandler) AddVrfTable(table *l3.VrfTable) error {
    24  	return h.addDelVrfTable(table, true)
    25  }
    26  
    27  // DelVrfTable deletes existing VRF table.
    28  func (h *VrfTableHandler) DelVrfTable(table *l3.VrfTable) error {
    29  	return h.addDelVrfTable(table, false)
    30  }
    31  
    32  func (h *VrfTableHandler) addDelVrfTable(table *l3.VrfTable, isAdd bool) error {
    33  	req := &vpp_ip.IPTableAddDel{
    34  		Table: vpp_ip.IPTable{
    35  			TableID: table.Id,
    36  			IsIP6:   table.GetProtocol() == l3.VrfTable_IPV6,
    37  			Name:    table.Label,
    38  		},
    39  		IsAdd: isAdd,
    40  	}
    41  	reply := &vpp_ip.IPTableAddDelReply{}
    42  
    43  	if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil {
    44  		return err
    45  	}
    46  
    47  	return nil
    48  }
    49  
    50  // SetVrfFlowHashSettings sets IP flow hash settings for a VRF table.
    51  func (h *VrfTableHandler) SetVrfFlowHashSettings(vrfID uint32, isIPv6 bool, hashFields *l3.VrfTable_FlowHashSettings) error {
    52  	req := &vpp_ip.SetIPFlowHash{
    53  		VrfID:     vrfID,
    54  		IsIPv6:    isIPv6,
    55  		Src:       hashFields.UseSrcIp,
    56  		Dst:       hashFields.UseDstIp,
    57  		Sport:     hashFields.UseSrcPort,
    58  		Dport:     hashFields.UseDstPort,
    59  		Proto:     hashFields.UseProtocol,
    60  		Reverse:   hashFields.Reverse,
    61  		Symmetric: hashFields.Symmetric,
    62  	}
    63  	reply := &vpp_ip.SetIPFlowHashReply{}
    64  
    65  	err := h.callsChannel.SendRequest(req).ReceiveReply(reply)
    66  	return err
    67  }