From b96960805e154a43c595f2fb62f845b24b2e3877 Mon Sep 17 00:00:00 2001 From: hedi bouattour Date: Wed, 16 Aug 2023 15:08:16 +0000 Subject: [PATCH] add redirect to host rules for dns issue in kind A dns issue showed in kind cluster, due to specific iptables rules added by docker. This commit addresses that by adding a feature allowing to redirect some traffic to host, to get it pass through iptables. This is applied to coredns pods. We use some new user config to specify rulesfor this feature. A tag "host" is added to cnat snat poliy feature and we use it for our vpptap0 to disable snat on traffic outgoing through it. --- calico-vpp-agent/cni/cni_server.go | 82 + calico-vpp-agent/cni/network_vpp.go | 6 + config/config.go | 9 + docs/developper_guide.md | 7 + vpp-manager/utils/utils.go | 6 + vpp-manager/vpp_runner.go | 15 +- vpplink/classify.go | 138 + vpplink/cnat.go | 8 + .../bindings/classify/classify.ba.go | 2285 +++++++++++++++++ .../bindings/classify/classify_rpc.ba.go | 346 +++ vpplink/generated/bindings/cnat/cnat.ba.go | 9 +- .../ip_session_redirect.ba.go | 482 ++++ .../ip_session_redirect_rpc.ba.go | 51 + vpplink/generated/gen.go | 2 +- vpplink/generated/generate.log | 6 +- vpplink/generated/vpp_clone_current.sh | 1 + vpplink/redirect.go | 66 + vpplink/types/classify.go | 374 +++ vpplink/types/ip_types.go | 12 + vpplink/types/redirect.go | 39 + yaml/overlays/dev/kustomize.sh | 9 +- 21 files changed, 3938 insertions(+), 15 deletions(-) create mode 100644 vpplink/classify.go create mode 100644 vpplink/generated/bindings/classify/classify.ba.go create mode 100644 vpplink/generated/bindings/classify/classify_rpc.ba.go create mode 100644 vpplink/generated/bindings/ip_session_redirect/ip_session_redirect.ba.go create mode 100644 vpplink/generated/bindings/ip_session_redirect/ip_session_redirect_rpc.ba.go create mode 100644 vpplink/redirect.go create mode 100644 vpplink/types/classify.go create mode 100644 vpplink/types/redirect.go diff --git a/calico-vpp-agent/cni/cni_server.go b/calico-vpp-agent/cni/cni_server.go index a33f7205..416f9df6 100644 --- a/calico-vpp-agent/cni/cni_server.go +++ b/calico-vpp-agent/cni/cni_server.go @@ -38,6 +38,7 @@ import ( "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/common" "github.com/projectcalico/vpp-dataplane/v3/calico-vpp-agent/watchers" "github.com/projectcalico/vpp-dataplane/v3/config" + "github.com/projectcalico/vpp-dataplane/v3/vpp-manager/utils" "github.com/projectcalico/vpp-dataplane/v3/vpplink" "github.com/projectcalico/vpp-dataplane/v3/vpplink/types" ) @@ -61,6 +62,8 @@ type Server struct { availableBuffers uint64 + RedirectToHostClassifyTableIndex uint32 + networkDefinitions sync.Map cniMultinetEventChan chan common.CalicoVppEvent nodeBGPSpec *common.LocalNodeSpec @@ -245,6 +248,12 @@ func (s *Server) Add(ctx context.Context, request *cniproto.AddRequest) (*cnipro ErrorMessage: err.Error(), }, nil } + if len(config.GetCalicoVppInitialConfig().RedirectToHostRules) != 0 && podSpec.NetworkName == "" { + err := s.AddRedirectToHostToInterface(podSpec.TunTapSwIfIndex) + if err != nil { + return nil, err + } + } s.podInterfaceMap[podSpec.Key()] = *podSpec cniServerStateFile := fmt.Sprintf("%s%d", config.CniServerStateFile, storage.CniServerStateFileVersion) @@ -315,6 +324,34 @@ func (s *Server) rescanState() { default: s.log.Errorf("Interface add failed %s : %v", podSpecCopy.String(), err) } + if len(config.GetCalicoVppInitialConfig().RedirectToHostRules) != 0 && podSpecCopy.NetworkName == "" { + err := s.AddRedirectToHostToInterface(podSpecCopy.TunTapSwIfIndex) + if err != nil { + s.log.Error(err) + } + } + } +} + +func (s *Server) DelRedirectToHostOnInterface(swIfIndex uint32) error { + err := s.vpp.SetClassifyInputInterfaceTables(swIfIndex, s.RedirectToHostClassifyTableIndex, types.InvalidTableId, types.InvalidTableId, false /*isAdd*/) + if err != nil { + return errors.Wrapf(err, "Error deleting classify input table from interface") + } else { + s.log.Infof("pod(del) delete input acl table %d from interface %d successfully", s.RedirectToHostClassifyTableIndex, swIfIndex) + return nil + } +} + +func (s *Server) AddRedirectToHostToInterface(swIfIndex uint32) error { + s.log.Infof("Setting classify input acl table %d on interface %d", s.RedirectToHostClassifyTableIndex, swIfIndex) + err := s.vpp.SetClassifyInputInterfaceTables(swIfIndex, s.RedirectToHostClassifyTableIndex, types.InvalidTableId, types.InvalidTableId, true) + if err != nil { + s.log.Warnf("Error setting classify input table: %s, retrying...", err) + return errors.Errorf("could not set input acl table %d for interface %d", s.RedirectToHostClassifyTableIndex, swIfIndex) + } else { + s.log.Infof("set input acl table %d for interface %d successfully", s.RedirectToHostClassifyTableIndex, swIfIndex) + return nil } } @@ -442,6 +479,47 @@ forloop: return nil } +func (s *Server) getMainTap0Info() (tapSwIfIndex uint32, address net.IP) { + for _, i := range common.VppManagerInfo.UplinkStatuses { + if i.IsMain { + tapSwIfIndex = i.TapSwIfIndex + break + } + } + address = utils.FakeVppNextHopIP4 + return +} + +func (s *Server) createRedirectToHostRules() (uint32, error) { + var maxNumEntries uint32 + if len(config.GetCalicoVppInitialConfig().RedirectToHostRules) != 0 { + maxNumEntries = uint32(2 * len(config.GetCalicoVppInitialConfig().RedirectToHostRules)) + } else { + maxNumEntries = 1 + } + index, err := s.vpp.AddClassifyTable(&types.ClassifyTable{ + Mask: types.DstThreeTupleMask, + NextTableIndex: types.InvalidID, + MaxNumEntries: maxNumEntries, + MissNextIndex: ^uint32(0), + }) + if err != nil { + return types.InvalidID, err + } + tap0swifindex, tap0nexthop := s.getMainTap0Info() + for _, rule := range config.GetCalicoVppInitialConfig().RedirectToHostRules { + err = s.vpp.AddSessionRedirect(&types.SessionRedirect{ + FiveTuple: types.NewDst3Tuple(rule.Proto, net.ParseIP(rule.Ip), rule.Port), + TableIndex: index, + }, &types.RoutePath{Gw: tap0nexthop, SwIfIndex: tap0swifindex}) + if err != nil { + return types.InvalidID, err + } + } + + return index, nil +} + func (s *Server) ServeCNI(t *tomb.Tomb) error { err := syscall.Unlink(config.CNIServerSocket) if err != nil && !gerrors.Is(err, os.ErrNotExist) { @@ -453,6 +531,10 @@ func (s *Server) ServeCNI(t *tomb.Tomb) error { return errors.Wrapf(err, "failed to listen on %s", config.CNIServerSocket) } + s.RedirectToHostClassifyTableIndex, err = s.createRedirectToHostRules() + if err != nil { + return err + } cniproto.RegisterCniDataplaneServer(s.grpcServer, s) if *config.GetCalicoVppFeatureGates().MultinetEnabled { diff --git a/calico-vpp-agent/cni/network_vpp.go b/calico-vpp-agent/cni/network_vpp.go index 14b88e89..e9315b58 100644 --- a/calico-vpp-agent/cni/network_vpp.go +++ b/calico-vpp-agent/cni/network_vpp.go @@ -277,6 +277,12 @@ err: // CleanUpVPPNamespace deletes the devices in the network namespace. func (s *Server) DelVppInterface(podSpec *storage.LocalPodSpec) { + if len(config.GetCalicoVppInitialConfig().RedirectToHostRules) != 0 && podSpec.NetworkName == "" { + err := s.DelRedirectToHostOnInterface(podSpec.TunTapSwIfIndex) + if err != nil { + s.log.Error(err) + } + } err := ns.IsNSorErr(podSpec.NetnsName) if err != nil { s.log.Infof("pod(del) netns '%s' doesn't exist, skipping", podSpec.NetnsName) diff --git a/config/config.go b/config/config.go index 0a2744c3..a73b61c2 100644 --- a/config/config.go +++ b/config/config.go @@ -252,6 +252,13 @@ func (u *UplinkInterfaceSpec) String() string { return string(b) } +type RedirectToHostRulesConfigType struct { + Port uint16 `json:"port,omitempty"` + Ip string `json:"ip,omitempty"` + /* "tcp", "udp",... */ + Proto types.IPProto `json:"proto,omitempty"` +} + type CalicoVppDebugConfigType struct { PoliciesEnabled *bool `json:"policiesEnabled,omitempty"` ServicesEnabled *bool `json:"servicesEnabled,omitempty"` @@ -401,6 +408,8 @@ type CalicoVppInitialConfigConfigType struct { //out of agent and vppmanager IfConfigSavePath string `json:"ifConfigSavePath"` /* Comma separated list of IPs to be configured in VPP as default GW */ DefaultGWs string `json:"defaultGWs"` + /* List of rules for redirecting traffic to host */ + RedirectToHostRules []RedirectToHostRulesConfigType `json:"redirectToHostRules"` } func (self *CalicoVppInitialConfigConfigType) Validate() (err error) { return nil } diff --git a/docs/developper_guide.md b/docs/developper_guide.md index 846d54ef..9e065ea1 100644 --- a/docs/developper_guide.md +++ b/docs/developper_guide.md @@ -61,6 +61,13 @@ export CALICO_ENCAPSULATION_V4=IPIP export CALICO_ENCAPSULATION_V6=None export CALICO_NAT_OUTGOING=Enabled ```` +To add a redirection to host rule: +````bash +# --------------- redirect ---------------- +export CALICOVPP_REDIRECT_PROTO="\"udp\"" +export CALICOVPP_REDIRECT_PORT=53 +export CALICOVPP_REDIRECT_IP="\"172.18.0.1\"" +```` To run with hugepages on: ````bash diff --git a/vpp-manager/utils/utils.go b/vpp-manager/utils/utils.go index 902c30fa..bf210a02 100644 --- a/vpp-manager/utils/utils.go +++ b/vpp-manager/utils/utils.go @@ -47,6 +47,12 @@ import ( "github.com/projectcalico/vpp-dataplane/v3/vpplink" ) +var ( + FakeVppNextHopIP4 = net.ParseIP("169.254.0.1") + FakeVppNextHopIP6 = net.ParseIP("fc00:ffff:ffff:ffff:ca11:c000:fd10:fffe") + VppSideMac, _ = net.ParseMAC("02:ca:11:c0:fd:10") +) + func IsDriverLoaded(driver string) (bool, error) { _, err := os.Stat("/sys/bus/pci/drivers/" + driver) if err == nil { diff --git a/vpp-manager/vpp_runner.go b/vpp-manager/vpp_runner.go index a3dd00e9..62f131ca 100644 --- a/vpp-manager/vpp_runner.go +++ b/vpp-manager/vpp_runner.go @@ -45,12 +45,6 @@ import ( const DefaultPhysicalNetworkName = "" -var ( - fakeVppNextHopIP4 = net.ParseIP("169.254.0.1") - fakeVppNextHopIP6 = net.ParseIP("fc00:ffff:ffff:ffff:ca11:c000:fd10:fffe") - vppSideMac, _ = net.ParseMAC("02:ca:11:c0:fd:10") -) - type VppRunner struct { params *config.VppManagerParams conf []*config.LinuxInterfaceState @@ -147,7 +141,7 @@ func (v *VppRunner) configureGlobalPunt() (err error) { } func (v *VppRunner) configurePunt(tapSwIfIndex uint32, ifState config.LinuxInterfaceState) (err error) { - for _, neigh := range []net.IP{fakeVppNextHopIP4, fakeVppNextHopIP6} { + for _, neigh := range []net.IP{utils.FakeVppNextHopIP4, utils.FakeVppNextHopIP6} { err = v.vpp.AddNeighbor(&types.Neighbor{ SwIfIndex: tapSwIfIndex, IP: neigh, @@ -550,7 +544,7 @@ func (v *VppRunner) configureVppUplinkInterface( HostInterfaceName: ifSpec.InterfaceName, RxQueueSize: config.GetCalicoVppInterfaces().VppHostTapSpec.RxQueueSize, TxQueueSize: config.GetCalicoVppInterfaces().VppHostTapSpec.TxQueueSize, - HardwareAddr: vppSideMac, + HardwareAddr: utils.VppSideMac, }, HostNamespace: "pid:1", // create tap in root netns Tag: "host-" + ifSpec.InterfaceName, @@ -625,6 +619,11 @@ func (v *VppRunner) configureVppUplinkInterface( return errors.Wrap(err, "error configuring vpptap0 as pod intf") } + err = v.vpp.RegisterHostInterface(tapSwIfIndex) + if err != nil { + return errors.Wrap(err, "error configuring vpptap0 as host intf") + } + // Linux side tap setup link, err := netlink.LinkByName(ifSpec.InterfaceName) if err != nil { diff --git a/vpplink/classify.go b/vpplink/classify.go new file mode 100644 index 00000000..0f6b9541 --- /dev/null +++ b/vpplink/classify.go @@ -0,0 +1,138 @@ +// Copyright (C) 2023 Cisco Systems Inc. +// +// 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. + +package vpplink + +import ( + "fmt" + + "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/classify" + "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/interface_types" + "github.com/projectcalico/vpp-dataplane/v3/vpplink/types" +) + +func (v *VppLink) addDelClassifyTable(table *types.ClassifyTable, action types.ClassifyAction) (uint32, error) { + client := classify.NewServiceClient(v.GetConnection()) + + isAdd, delChain := false, false + currentDataFlags := uint8(0) + tableIndex := types.InvalidTableId + switch action { + case types.AddAbsolute: + isAdd = true + case types.AddRelative: + isAdd = true + currentDataFlags = uint8(1) + case types.Del: + tableIndex = table.TableIndex + case types.DelChain: + tableIndex = table.TableIndex + delChain = true + } + + mask := ExtendToVector(table.Mask) + + matchNVectors := table.MatchNVectors + if matchNVectors == 0 { + matchNVectors = uint32(len(mask)) / types.VectorSize + } + + nBuckets := table.NBuckets + if nBuckets == 0 { + // We provide as many buckets as the max number of entries we expect in the table + nBuckets = table.MaxNumEntries + } + + memorySize := table.MemorySize + if memorySize == 0 { + /* memory needed for the table: + * - each entry has a size of (32-bytes + mask vectors) + * - up to 2 entries per page for collision resolution + * - double for margin + */ + memorySize = table.MaxNumEntries * (32 + matchNVectors*types.VectorSize) * 2 * 2 + } + + response, err := client.ClassifyAddDelTable(v.GetContext(), &classify.ClassifyAddDelTable{ + IsAdd: isAdd, + DelChain: delChain, + TableIndex: tableIndex, + Nbuckets: nBuckets, + MemorySize: memorySize, + SkipNVectors: table.SkipNVectors, + MatchNVectors: matchNVectors, + NextTableIndex: table.NextTableIndex, + MissNextIndex: table.MissNextIndex, + CurrentDataFlag: currentDataFlags, + CurrentDataOffset: table.CurrentDataOffset, + MaskLen: uint32(len(mask)), + Mask: mask, + }) + + if err != nil { + return types.InvalidID, fmt.Errorf("Failed to %s the classify table: %w", map[bool]string{true: "add", false: "del"}[isAdd], err) + } + + return response.NewTableIndex, nil +} + +func (v *VppLink) AddClassifyTable(table *types.ClassifyTable) (uint32, error) { + return v.addDelClassifyTable(table, types.AddRelative) +} + +func (v *VppLink) DelClassifyTable(tableIndex uint32) error { + _, err := v.addDelClassifyTable(&types.ClassifyTable{TableIndex: tableIndex}, types.Del) + return err +} + +func ExtendToVector(match []byte) []byte { + n := len(match) % types.VectorSize + if n != 0 { + match = match[:len(match)+types.VectorSize-n] + } + return match +} + +func (v *VppLink) SetClassifyInputInterfaceTables(swIfIndex uint32, ip4TableIndex uint32, ip6TableIndex uint32, l2TableIndex uint32, isAdd bool) error { + client := classify.NewServiceClient(v.GetConnection()) + + _, err := client.InputACLSetInterface(v.GetContext(), &classify.InputACLSetInterface{ + IsAdd: isAdd, + SwIfIndex: interface_types.InterfaceIndex(swIfIndex), + IP4TableIndex: ip4TableIndex, + IP6TableIndex: ip6TableIndex, + L2TableIndex: l2TableIndex, + }) + if err != nil { + return fmt.Errorf("failed to set input acl tables for this interface: %w", err) + } + return nil +} + +func (v *VppLink) SetClassifyOutputInterfaceTables(swIfIndex uint32, ip4TableIndex uint32, ip6TableIndex uint32, l2TableIndex uint32, isAdd bool) error { + client := classify.NewServiceClient(v.GetConnection()) + + _, err := client.OutputACLSetInterface(v.GetContext(), &classify.OutputACLSetInterface{ + IsAdd: isAdd, + SwIfIndex: interface_types.InterfaceIndex(swIfIndex), + IP4TableIndex: ip4TableIndex, + IP6TableIndex: ip6TableIndex, + L2TableIndex: l2TableIndex, + }) + if err != nil { + return fmt.Errorf("failed to set input acl tables for this interface: %w", err) + } + return nil +} diff --git a/vpplink/cnat.go b/vpplink/cnat.go index 772f7252..ef77de69 100644 --- a/vpplink/cnat.go +++ b/vpplink/cnat.go @@ -157,6 +157,14 @@ func (v *VppLink) RemovePodInterface(swIfIndex uint32) (err error) { return v.cnatSnatPolicyAddDelPodInterface(swIfIndex, false /* isAdd */, cnat.CNAT_POLICY_POD) } +func (v *VppLink) RegisterHostInterface(swIfIndex uint32) (err error) { + return v.cnatSnatPolicyAddDelPodInterface(swIfIndex, true /* isAdd */, cnat.CNAT_POLICY_HOST) +} + +func (v *VppLink) RemoveHostInterface(swIfIndex uint32) (err error) { + return v.cnatSnatPolicyAddDelPodInterface(swIfIndex, false /* isAdd */, cnat.CNAT_POLICY_HOST) +} + func (v *VppLink) EnableDisableCnatSNAT(swIfIndex uint32, isIp6 bool, isEnable bool) (err error) { if isEnable { return v.enableCnatSNAT(swIfIndex, isIp6) diff --git a/vpplink/generated/bindings/classify/classify.ba.go b/vpplink/generated/bindings/classify/classify.ba.go new file mode 100644 index 00000000..dbff2ca9 --- /dev/null +++ b/vpplink/generated/bindings/classify/classify.ba.go @@ -0,0 +1,2285 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +// Package classify contains generated bindings for API file classify.api. +// +// Contents: +// - 3 enums +// - 44 messages +package classify + +import ( + "strconv" + + interface_types "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/interface_types" + api "go.fd.io/govpp/api" + codec "go.fd.io/govpp/codec" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the GoVPP api package it is being compiled against. +// A compilation error at this line likely means your copy of the +// GoVPP api package needs to be updated. +const _ = api.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "classify" + APIVersion = "3.1.0" + VersionCrc = 0x92a4f2c8 +) + +// ClassifyAction defines enum 'classify_action'. +type ClassifyAction uint8 + +const ( + CLASSIFY_API_ACTION_NONE ClassifyAction = 0 + CLASSIFY_API_ACTION_SET_IP4_FIB_INDEX ClassifyAction = 1 + CLASSIFY_API_ACTION_SET_IP6_FIB_INDEX ClassifyAction = 2 + CLASSIFY_API_ACTION_SET_METADATA ClassifyAction = 3 +) + +var ( + ClassifyAction_name = map[uint8]string{ + 0: "CLASSIFY_API_ACTION_NONE", + 1: "CLASSIFY_API_ACTION_SET_IP4_FIB_INDEX", + 2: "CLASSIFY_API_ACTION_SET_IP6_FIB_INDEX", + 3: "CLASSIFY_API_ACTION_SET_METADATA", + } + ClassifyAction_value = map[string]uint8{ + "CLASSIFY_API_ACTION_NONE": 0, + "CLASSIFY_API_ACTION_SET_IP4_FIB_INDEX": 1, + "CLASSIFY_API_ACTION_SET_IP6_FIB_INDEX": 2, + "CLASSIFY_API_ACTION_SET_METADATA": 3, + } +) + +func (x ClassifyAction) String() string { + s, ok := ClassifyAction_name[uint8(x)] + if ok { + return s + } + return "ClassifyAction(" + strconv.Itoa(int(x)) + ")" +} + +// FlowClassifyTable defines enum 'flow_classify_table'. +type FlowClassifyTable uint8 + +const ( + FLOW_CLASSIFY_API_TABLE_IP4 FlowClassifyTable = 0 + FLOW_CLASSIFY_API_TABLE_IP6 FlowClassifyTable = 1 +) + +var ( + FlowClassifyTable_name = map[uint8]string{ + 0: "FLOW_CLASSIFY_API_TABLE_IP4", + 1: "FLOW_CLASSIFY_API_TABLE_IP6", + } + FlowClassifyTable_value = map[string]uint8{ + "FLOW_CLASSIFY_API_TABLE_IP4": 0, + "FLOW_CLASSIFY_API_TABLE_IP6": 1, + } +) + +func (x FlowClassifyTable) String() string { + s, ok := FlowClassifyTable_name[uint8(x)] + if ok { + return s + } + return "FlowClassifyTable(" + strconv.Itoa(int(x)) + ")" +} + +// PolicerClassifyTable defines enum 'policer_classify_table'. +type PolicerClassifyTable uint8 + +const ( + POLICER_CLASSIFY_API_TABLE_IP4 PolicerClassifyTable = 0 + POLICER_CLASSIFY_API_TABLE_IP6 PolicerClassifyTable = 1 + POLICER_CLASSIFY_API_TABLE_L2 PolicerClassifyTable = 2 +) + +var ( + PolicerClassifyTable_name = map[uint8]string{ + 0: "POLICER_CLASSIFY_API_TABLE_IP4", + 1: "POLICER_CLASSIFY_API_TABLE_IP6", + 2: "POLICER_CLASSIFY_API_TABLE_L2", + } + PolicerClassifyTable_value = map[string]uint8{ + "POLICER_CLASSIFY_API_TABLE_IP4": 0, + "POLICER_CLASSIFY_API_TABLE_IP6": 1, + "POLICER_CLASSIFY_API_TABLE_L2": 2, + } +) + +func (x PolicerClassifyTable) String() string { + s, ok := PolicerClassifyTable_name[uint8(x)] + if ok { + return s + } + return "PolicerClassifyTable(" + strconv.Itoa(int(x)) + ")" +} + +// Classify add / del session request +// - is_add - add session if non-zero, else delete +// - table_index - index of the table to add/del the session, required +// - hit_next_index - for add, hit_next_index of new session, required +// - opaque_index - for add, opaque_index of new session +// - advance -for add, advance value for session +// - action - +// 0: no action (by default) +// metadata is not used. +// 1: Classified IP packets will be looked up from the +// specified ipv4 fib table (configured by metadata as VRF id). +// Only valid for L3 input ACL node +// 2: Classified IP packets will be looked up from the +// specified ipv6 fib table (configured by metadata as VRF id). +// Only valid for L3 input ACL node +// 3: Classified packet will be steered to source routing policy +// of given index (in metadata). +// This is only valid for IPv6 packets redirected to a source +// routing node. +// - metadata - valid only if action != 0 +// VRF id if action is 1 or 2. +// sr policy index if action is 3. +// - match_len - length of match, should be equal to skip_n_vectors plus match_n_vectors +// of target table times sizeof (u32x4) +// - match - for add, match value for session, required, +// needs to include bytes in front +// with length of skip_n_vectors of target table times sizeof (u32x4) +// (values of those bytes will be ignored) +// +// ClassifyAddDelSession defines message 'classify_add_del_session'. +type ClassifyAddDelSession struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + HitNextIndex uint32 `binapi:"u32,name=hit_next_index,default=4294967295" json:"hit_next_index,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index,default=4294967295" json:"opaque_index,omitempty"` + Advance int32 `binapi:"i32,name=advance,default=0" json:"advance,omitempty"` + Action ClassifyAction `binapi:"classify_action,name=action,default=0" json:"action,omitempty"` + Metadata uint32 `binapi:"u32,name=metadata,default=0" json:"metadata,omitempty"` + MatchLen uint32 `binapi:"u32,name=match_len" json:"-"` + Match []byte `binapi:"u8[match_len],name=match" json:"match,omitempty"` +} + +func (m *ClassifyAddDelSession) Reset() { *m = ClassifyAddDelSession{} } +func (*ClassifyAddDelSession) GetMessageName() string { return "classify_add_del_session" } +func (*ClassifyAddDelSession) GetCrcString() string { return "f20879f0" } +func (*ClassifyAddDelSession) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyAddDelSession) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 4 // m.TableIndex + size += 4 // m.HitNextIndex + size += 4 // m.OpaqueIndex + size += 4 // m.Advance + size += 1 // m.Action + size += 4 // m.Metadata + size += 4 // m.MatchLen + size += 1 * len(m.Match) // m.Match + return size +} +func (m *ClassifyAddDelSession) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint32(m.HitNextIndex) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeInt32(m.Advance) + buf.EncodeUint8(uint8(m.Action)) + buf.EncodeUint32(m.Metadata) + buf.EncodeUint32(uint32(len(m.Match))) + buf.EncodeBytes(m.Match, 0) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelSession) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.TableIndex = buf.DecodeUint32() + m.HitNextIndex = buf.DecodeUint32() + m.OpaqueIndex = buf.DecodeUint32() + m.Advance = buf.DecodeInt32() + m.Action = ClassifyAction(buf.DecodeUint8()) + m.Metadata = buf.DecodeUint32() + m.MatchLen = buf.DecodeUint32() + m.Match = make([]byte, m.MatchLen) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + return nil +} + +// ClassifyAddDelSessionReply defines message 'classify_add_del_session_reply'. +type ClassifyAddDelSessionReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ClassifyAddDelSessionReply) Reset() { *m = ClassifyAddDelSessionReply{} } +func (*ClassifyAddDelSessionReply) GetMessageName() string { return "classify_add_del_session_reply" } +func (*ClassifyAddDelSessionReply) GetCrcString() string { return "e8d4e804" } +func (*ClassifyAddDelSessionReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyAddDelSessionReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ClassifyAddDelSessionReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelSessionReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/Delete classification table request +// - is_add- if non-zero add the table, else delete it +// - del_chain - if non-zero delete the whole chain of tables +// - table_index - if add, returns index of the created table, else specifies the table to delete +// - nbuckets - number of buckets when adding a table +// - memory_size - memory size when adding a table +// - match_n_vectors - number of match vectors +// - next_table_index - index of next table +// - miss_next_index - index of miss table +// - current_data_flag - option to use current node's packet payload +// as the starting point from where packets are classified, +// This option is only valid for L2/L3 input ACL for now. +// 0: by default, classify data from the buffer's start location +// 1: classify packets from VPP node’s current data pointer +// - current_data_offset - a signed value to shift the start location of +// the packet to be classified +// For example, if input IP ACL node is used, L2 header’s first byte +// can be accessible by configuring current_data_offset to -14 +// if there is no vlan tag. +// This is valid only if current_data_flag is set to 1. +// - mask_len - length of match mask, should be equal to match_n_vectors * sizeof (u32x4) +// - mask - match mask +// +// ClassifyAddDelTable defines message 'classify_add_del_table'. +type ClassifyAddDelTable struct { + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` + DelChain bool `binapi:"bool,name=del_chain" json:"del_chain,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index,default=4294967295" json:"table_index,omitempty"` + Nbuckets uint32 `binapi:"u32,name=nbuckets,default=2" json:"nbuckets,omitempty"` + MemorySize uint32 `binapi:"u32,name=memory_size,default=2097152" json:"memory_size,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors,default=0" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors,default=1" json:"match_n_vectors,omitempty"` + NextTableIndex uint32 `binapi:"u32,name=next_table_index,default=4294967295" json:"next_table_index,omitempty"` + MissNextIndex uint32 `binapi:"u32,name=miss_next_index,default=4294967295" json:"miss_next_index,omitempty"` + CurrentDataFlag uint8 `binapi:"u8,name=current_data_flag,default=0" json:"current_data_flag,omitempty"` + CurrentDataOffset int16 `binapi:"i16,name=current_data_offset,default=0" json:"current_data_offset,omitempty"` + MaskLen uint32 `binapi:"u32,name=mask_len" json:"-"` + Mask []byte `binapi:"u8[mask_len],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyAddDelTable) Reset() { *m = ClassifyAddDelTable{} } +func (*ClassifyAddDelTable) GetMessageName() string { return "classify_add_del_table" } +func (*ClassifyAddDelTable) GetCrcString() string { return "6849e39e" } +func (*ClassifyAddDelTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyAddDelTable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsAdd + size += 1 // m.DelChain + size += 4 // m.TableIndex + size += 4 // m.Nbuckets + size += 4 // m.MemorySize + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + size += 4 // m.NextTableIndex + size += 4 // m.MissNextIndex + size += 1 // m.CurrentDataFlag + size += 2 // m.CurrentDataOffset + size += 4 // m.MaskLen + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyAddDelTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsAdd) + buf.EncodeBool(m.DelChain) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint32(m.Nbuckets) + buf.EncodeUint32(m.MemorySize) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(m.NextTableIndex) + buf.EncodeUint32(m.MissNextIndex) + buf.EncodeUint8(m.CurrentDataFlag) + buf.EncodeInt16(m.CurrentDataOffset) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsAdd = buf.DecodeBool() + m.DelChain = buf.DecodeBool() + m.TableIndex = buf.DecodeUint32() + m.Nbuckets = buf.DecodeUint32() + m.MemorySize = buf.DecodeUint32() + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.NextTableIndex = buf.DecodeUint32() + m.MissNextIndex = buf.DecodeUint32() + m.CurrentDataFlag = buf.DecodeUint8() + m.CurrentDataOffset = buf.DecodeInt16() + m.MaskLen = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLen) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Add/Delete classification table response +// - retval - return code for the table add/del request +// - new_table_index - for add, returned index of the new table +// - skip_n_vectors - for add, returned value of skip_n_vectors in table +// - match_n_vectors -for add, returned value of match_n_vectors in table +// +// ClassifyAddDelTableReply defines message 'classify_add_del_table_reply'. +type ClassifyAddDelTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + NewTableIndex uint32 `binapi:"u32,name=new_table_index" json:"new_table_index,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors" json:"match_n_vectors,omitempty"` +} + +func (m *ClassifyAddDelTableReply) Reset() { *m = ClassifyAddDelTableReply{} } +func (*ClassifyAddDelTableReply) GetMessageName() string { return "classify_add_del_table_reply" } +func (*ClassifyAddDelTableReply) GetCrcString() string { return "05486349" } +func (*ClassifyAddDelTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyAddDelTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.NewTableIndex + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + return size +} +func (m *ClassifyAddDelTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.NewTableIndex) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + return buf.Bytes(), nil +} +func (m *ClassifyAddDelTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.NewTableIndex = buf.DecodeUint32() + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + return nil +} + +// Classify get the PCAP table indices for an interface +// ClassifyPcapGetTables defines message 'classify_pcap_get_tables'. +type ClassifyPcapGetTables struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *ClassifyPcapGetTables) Reset() { *m = ClassifyPcapGetTables{} } +func (*ClassifyPcapGetTables) GetMessageName() string { return "classify_pcap_get_tables" } +func (*ClassifyPcapGetTables) GetCrcString() string { return "f9e6675e" } +func (*ClassifyPcapGetTables) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyPcapGetTables) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *ClassifyPcapGetTables) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *ClassifyPcapGetTables) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Classify get a PCAP tables response +// - retval - return code for the request +// - count - number of ids returned in response +// - indices - array of classify table indices +// +// ClassifyPcapGetTablesReply defines message 'classify_pcap_get_tables_reply'. +type ClassifyPcapGetTablesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Indices []uint32 `binapi:"u32[count],name=indices" json:"indices,omitempty"` +} + +func (m *ClassifyPcapGetTablesReply) Reset() { *m = ClassifyPcapGetTablesReply{} } +func (*ClassifyPcapGetTablesReply) GetMessageName() string { return "classify_pcap_get_tables_reply" } +func (*ClassifyPcapGetTablesReply) GetCrcString() string { return "5f5bc9e6" } +func (*ClassifyPcapGetTablesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyPcapGetTablesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Indices) // m.Indices + return size +} +func (m *ClassifyPcapGetTablesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Indices))) + for i := 0; i < len(m.Indices); i++ { + var x uint32 + if i < len(m.Indices) { + x = uint32(m.Indices[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ClassifyPcapGetTablesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Indices = make([]uint32, m.Count) + for i := 0; i < len(m.Indices); i++ { + m.Indices[i] = buf.DecodeUint32() + } + return nil +} + +// Find a compatible Classify table in a PCAP chain +// - sw_if_index - interface whose chain will be searched, 0==system-wide +// - skip_n_vectors - number of u32x4 skip vectors +// - match_n_vectors - number of u32x4 vectors, 1..5 +// - mask_len - length of mask, match_n_vectors * sizeof(u32x4) +// - mask - match mask +// +// ClassifyPcapLookupTable defines message 'classify_pcap_lookup_table'. +type ClassifyPcapLookupTable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors,default=0" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors,default=1" json:"match_n_vectors,omitempty"` + MaskLen uint32 `binapi:"u32,name=mask_len" json:"-"` + Mask []byte `binapi:"u8[mask_len],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyPcapLookupTable) Reset() { *m = ClassifyPcapLookupTable{} } +func (*ClassifyPcapLookupTable) GetMessageName() string { return "classify_pcap_lookup_table" } +func (*ClassifyPcapLookupTable) GetCrcString() string { return "e1b4cc6b" } +func (*ClassifyPcapLookupTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyPcapLookupTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + size += 4 // m.MaskLen + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyPcapLookupTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyPcapLookupTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.MaskLen = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLen) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Classify pcap table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the found table, or ~0 +// +// ClassifyPcapLookupTableReply defines message 'classify_pcap_lookup_table_reply'. +type ClassifyPcapLookupTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyPcapLookupTableReply) Reset() { *m = ClassifyPcapLookupTableReply{} } +func (*ClassifyPcapLookupTableReply) GetMessageName() string { + return "classify_pcap_lookup_table_reply" +} +func (*ClassifyPcapLookupTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyPcapLookupTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyPcapLookupTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyPcapLookupTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyPcapLookupTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Add a Classify table into a PCAP chain on an interface +// - sw_if_index - interface whose chain will be searched, 0==system-wide +// - table_index - Classify table to be added +// - sort_masks - 1=sort masks into most-to-least specific order +// +// ClassifyPcapSetTable defines message 'classify_pcap_set_table'. +type ClassifyPcapSetTable struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index,default=4294967295" json:"table_index,omitempty"` + SortMasks bool `binapi:"bool,name=sort_masks,default=0" json:"sort_masks,omitempty"` +} + +func (m *ClassifyPcapSetTable) Reset() { *m = ClassifyPcapSetTable{} } +func (*ClassifyPcapSetTable) GetMessageName() string { return "classify_pcap_set_table" } +func (*ClassifyPcapSetTable) GetCrcString() string { return "006051b3" } +func (*ClassifyPcapSetTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyPcapSetTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + size += 1 // m.SortMasks + return size +} +func (m *ClassifyPcapSetTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + buf.EncodeBool(m.SortMasks) + return buf.Bytes(), nil +} +func (m *ClassifyPcapSetTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + m.SortMasks = buf.DecodeBool() + return nil +} + +// Classify pcap table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the sorted table chain +// +// ClassifyPcapSetTableReply defines message 'classify_pcap_set_table_reply'. +type ClassifyPcapSetTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyPcapSetTableReply) Reset() { *m = ClassifyPcapSetTableReply{} } +func (*ClassifyPcapSetTableReply) GetMessageName() string { return "classify_pcap_set_table_reply" } +func (*ClassifyPcapSetTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyPcapSetTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyPcapSetTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyPcapSetTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyPcapSetTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Reply for classify table session dump request +// - count - number of ids returned in response +// - table_id - classify table index +// - hit_next_index - hit_next_index of session +// - opaque_index - for add, opaque_index of session +// - advance - advance value of session +// - match[] - match value for session +// +// ClassifySessionDetails defines message 'classify_session_details'. +type ClassifySessionDetails struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + HitNextIndex uint32 `binapi:"u32,name=hit_next_index" json:"hit_next_index,omitempty"` + Advance int32 `binapi:"i32,name=advance" json:"advance,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index" json:"opaque_index,omitempty"` + MatchLength uint32 `binapi:"u32,name=match_length" json:"-"` + Match []byte `binapi:"u8[match_length],name=match" json:"match,omitempty"` +} + +func (m *ClassifySessionDetails) Reset() { *m = ClassifySessionDetails{} } +func (*ClassifySessionDetails) GetMessageName() string { return "classify_session_details" } +func (*ClassifySessionDetails) GetCrcString() string { return "60e3ef94" } +func (*ClassifySessionDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifySessionDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableID + size += 4 // m.HitNextIndex + size += 4 // m.Advance + size += 4 // m.OpaqueIndex + size += 4 // m.MatchLength + size += 1 * len(m.Match) // m.Match + return size +} +func (m *ClassifySessionDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(m.HitNextIndex) + buf.EncodeInt32(m.Advance) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeUint32(uint32(len(m.Match))) + buf.EncodeBytes(m.Match, 0) + return buf.Bytes(), nil +} +func (m *ClassifySessionDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableID = buf.DecodeUint32() + m.HitNextIndex = buf.DecodeUint32() + m.Advance = buf.DecodeInt32() + m.OpaqueIndex = buf.DecodeUint32() + m.MatchLength = buf.DecodeUint32() + m.Match = make([]byte, m.MatchLength) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + return nil +} + +// Classify sessions dump request +// - table_id - classify table index +// +// ClassifySessionDump defines message 'classify_session_dump'. +type ClassifySessionDump struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` +} + +func (m *ClassifySessionDump) Reset() { *m = ClassifySessionDump{} } +func (*ClassifySessionDump) GetMessageName() string { return "classify_session_dump" } +func (*ClassifySessionDump) GetCrcString() string { return "0cca2cd9" } +func (*ClassifySessionDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifySessionDump) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + return size +} +func (m *ClassifySessionDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + return buf.Bytes(), nil +} +func (m *ClassifySessionDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + return nil +} + +// Set/unset the classification table for an interface request +// - is_ipv6 - ipv6 if non-zero, else ipv4 +// - sw_if_index - interface to associate with the table +// - table_index - index of the table, if ~0 unset the table +// +// ClassifySetInterfaceIPTable defines message 'classify_set_interface_ip_table'. +type ClassifySetInterfaceIPTable struct { + IsIPv6 bool `binapi:"bool,name=is_ipv6" json:"is_ipv6,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifySetInterfaceIPTable) Reset() { *m = ClassifySetInterfaceIPTable{} } +func (*ClassifySetInterfaceIPTable) GetMessageName() string { return "classify_set_interface_ip_table" } +func (*ClassifySetInterfaceIPTable) GetCrcString() string { return "e0b097c7" } +func (*ClassifySetInterfaceIPTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifySetInterfaceIPTable) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.IsIPv6 + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + return size +} +func (m *ClassifySetInterfaceIPTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeBool(m.IsIPv6) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceIPTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IsIPv6 = buf.DecodeBool() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + return nil +} + +// ClassifySetInterfaceIPTableReply defines message 'classify_set_interface_ip_table_reply'. +type ClassifySetInterfaceIPTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ClassifySetInterfaceIPTableReply) Reset() { *m = ClassifySetInterfaceIPTableReply{} } +func (*ClassifySetInterfaceIPTableReply) GetMessageName() string { + return "classify_set_interface_ip_table_reply" +} +func (*ClassifySetInterfaceIPTableReply) GetCrcString() string { return "e8d4e804" } +func (*ClassifySetInterfaceIPTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifySetInterfaceIPTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ClassifySetInterfaceIPTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceIPTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set/unset l2 classification tables for an interface request +// - sw_if_index - interface to set/unset tables for +// - ip4_table_index - ip4 index, use ~0 for all 3 indexes to unset +// - ip6_table_index - ip6 index +// - other_table_index - other index +// +// ClassifySetInterfaceL2Tables defines message 'classify_set_interface_l2_tables'. +type ClassifySetInterfaceL2Tables struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + OtherTableIndex uint32 `binapi:"u32,name=other_table_index" json:"other_table_index,omitempty"` + IsInput bool `binapi:"bool,name=is_input" json:"is_input,omitempty"` +} + +func (m *ClassifySetInterfaceL2Tables) Reset() { *m = ClassifySetInterfaceL2Tables{} } +func (*ClassifySetInterfaceL2Tables) GetMessageName() string { + return "classify_set_interface_l2_tables" +} +func (*ClassifySetInterfaceL2Tables) GetCrcString() string { return "5a6ddf65" } +func (*ClassifySetInterfaceL2Tables) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifySetInterfaceL2Tables) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.OtherTableIndex + size += 1 // m.IsInput + return size +} +func (m *ClassifySetInterfaceL2Tables) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.OtherTableIndex) + buf.EncodeBool(m.IsInput) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceL2Tables) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.OtherTableIndex = buf.DecodeUint32() + m.IsInput = buf.DecodeBool() + return nil +} + +// ClassifySetInterfaceL2TablesReply defines message 'classify_set_interface_l2_tables_reply'. +type ClassifySetInterfaceL2TablesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *ClassifySetInterfaceL2TablesReply) Reset() { *m = ClassifySetInterfaceL2TablesReply{} } +func (*ClassifySetInterfaceL2TablesReply) GetMessageName() string { + return "classify_set_interface_l2_tables_reply" +} +func (*ClassifySetInterfaceL2TablesReply) GetCrcString() string { return "e8d4e804" } +func (*ClassifySetInterfaceL2TablesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifySetInterfaceL2TablesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *ClassifySetInterfaceL2TablesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *ClassifySetInterfaceL2TablesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Classify table ids by interface index request +// - sw_if_index - index of the interface +// +// ClassifyTableByInterface defines message 'classify_table_by_interface'. +type ClassifyTableByInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *ClassifyTableByInterface) Reset() { *m = ClassifyTableByInterface{} } +func (*ClassifyTableByInterface) GetMessageName() string { return "classify_table_by_interface" } +func (*ClassifyTableByInterface) GetCrcString() string { return "f9e6675e" } +func (*ClassifyTableByInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTableByInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + return size +} +func (m *ClassifyTableByInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *ClassifyTableByInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Reply for classify table id by interface index request +// - count - number of ids returned in response +// - sw_if_index - index of the interface +// - l2_table_id - l2 classify table index +// - ip4_table_id - ip4 classify table index +// - ip6_table_id - ip6 classify table index +// +// ClassifyTableByInterfaceReply defines message 'classify_table_by_interface_reply'. +type ClassifyTableByInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + L2TableID uint32 `binapi:"u32,name=l2_table_id" json:"l2_table_id,omitempty"` + IP4TableID uint32 `binapi:"u32,name=ip4_table_id" json:"ip4_table_id,omitempty"` + IP6TableID uint32 `binapi:"u32,name=ip6_table_id" json:"ip6_table_id,omitempty"` +} + +func (m *ClassifyTableByInterfaceReply) Reset() { *m = ClassifyTableByInterfaceReply{} } +func (*ClassifyTableByInterfaceReply) GetMessageName() string { + return "classify_table_by_interface_reply" +} +func (*ClassifyTableByInterfaceReply) GetCrcString() string { return "ed4197db" } +func (*ClassifyTableByInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTableByInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.SwIfIndex + size += 4 // m.L2TableID + size += 4 // m.IP4TableID + size += 4 // m.IP6TableID + return size +} +func (m *ClassifyTableByInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.L2TableID) + buf.EncodeUint32(m.IP4TableID) + buf.EncodeUint32(m.IP6TableID) + return buf.Bytes(), nil +} +func (m *ClassifyTableByInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.L2TableID = buf.DecodeUint32() + m.IP4TableID = buf.DecodeUint32() + m.IP6TableID = buf.DecodeUint32() + return nil +} + +// Classify get table IDs request +// ClassifyTableIds defines message 'classify_table_ids'. +type ClassifyTableIds struct{} + +func (m *ClassifyTableIds) Reset() { *m = ClassifyTableIds{} } +func (*ClassifyTableIds) GetMessageName() string { return "classify_table_ids" } +func (*ClassifyTableIds) GetCrcString() string { return "51077d14" } +func (*ClassifyTableIds) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTableIds) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ClassifyTableIds) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ClassifyTableIds) Unmarshal(b []byte) error { + return nil +} + +// Reply for classify get table IDs request +// - count - number of ids returned in response +// - ids - array of classify table ids +// +// ClassifyTableIdsReply defines message 'classify_table_ids_reply'. +type ClassifyTableIdsReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Ids []uint32 `binapi:"u32[count],name=ids" json:"ids,omitempty"` +} + +func (m *ClassifyTableIdsReply) Reset() { *m = ClassifyTableIdsReply{} } +func (*ClassifyTableIdsReply) GetMessageName() string { return "classify_table_ids_reply" } +func (*ClassifyTableIdsReply) GetCrcString() string { return "d1d20e1d" } +func (*ClassifyTableIdsReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTableIdsReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Ids) // m.Ids + return size +} +func (m *ClassifyTableIdsReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Ids))) + for i := 0; i < len(m.Ids); i++ { + var x uint32 + if i < len(m.Ids) { + x = uint32(m.Ids[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ClassifyTableIdsReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Ids = make([]uint32, m.Count) + for i := 0; i < len(m.Ids); i++ { + m.Ids[i] = buf.DecodeUint32() + } + return nil +} + +// Classify table info +// - table_id - classify table index +// +// ClassifyTableInfo defines message 'classify_table_info'. +type ClassifyTableInfo struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` +} + +func (m *ClassifyTableInfo) Reset() { *m = ClassifyTableInfo{} } +func (*ClassifyTableInfo) GetMessageName() string { return "classify_table_info" } +func (*ClassifyTableInfo) GetCrcString() string { return "0cca2cd9" } +func (*ClassifyTableInfo) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTableInfo) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableID + return size +} +func (m *ClassifyTableInfo) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableID) + return buf.Bytes(), nil +} +func (m *ClassifyTableInfo) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableID = buf.DecodeUint32() + return nil +} + +// Reply for classify table info request +// - count - number of ids returned in response +// - table_id - classify table index +// - nbuckets - number of buckets when adding a table +// - match_n_vectors - number of match vectors +// - skip_n_vectors - number of skip_n_vectors +// - active_sessions - number of sessions (active entries) +// - next_table_index - index of next table +// - miss_next_index - index of miss table +// - mask[] - match mask +// +// ClassifyTableInfoReply defines message 'classify_table_info_reply'. +type ClassifyTableInfoReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Nbuckets uint32 `binapi:"u32,name=nbuckets" json:"nbuckets,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors" json:"match_n_vectors,omitempty"` + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors" json:"skip_n_vectors,omitempty"` + ActiveSessions uint32 `binapi:"u32,name=active_sessions" json:"active_sessions,omitempty"` + NextTableIndex uint32 `binapi:"u32,name=next_table_index" json:"next_table_index,omitempty"` + MissNextIndex uint32 `binapi:"u32,name=miss_next_index" json:"miss_next_index,omitempty"` + MaskLength uint32 `binapi:"u32,name=mask_length" json:"-"` + Mask []byte `binapi:"u8[mask_length],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyTableInfoReply) Reset() { *m = ClassifyTableInfoReply{} } +func (*ClassifyTableInfoReply) GetMessageName() string { return "classify_table_info_reply" } +func (*ClassifyTableInfoReply) GetCrcString() string { return "4a573c0e" } +func (*ClassifyTableInfoReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTableInfoReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableID + size += 4 // m.Nbuckets + size += 4 // m.MatchNVectors + size += 4 // m.SkipNVectors + size += 4 // m.ActiveSessions + size += 4 // m.NextTableIndex + size += 4 // m.MissNextIndex + size += 4 // m.MaskLength + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyTableInfoReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableID) + buf.EncodeUint32(m.Nbuckets) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.ActiveSessions) + buf.EncodeUint32(m.NextTableIndex) + buf.EncodeUint32(m.MissNextIndex) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyTableInfoReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableID = buf.DecodeUint32() + m.Nbuckets = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.SkipNVectors = buf.DecodeUint32() + m.ActiveSessions = buf.DecodeUint32() + m.NextTableIndex = buf.DecodeUint32() + m.MissNextIndex = buf.DecodeUint32() + m.MaskLength = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLength) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Classify get the Trace table indices +// ClassifyTraceGetTables defines message 'classify_trace_get_tables'. +type ClassifyTraceGetTables struct{} + +func (m *ClassifyTraceGetTables) Reset() { *m = ClassifyTraceGetTables{} } +func (*ClassifyTraceGetTables) GetMessageName() string { return "classify_trace_get_tables" } +func (*ClassifyTraceGetTables) GetCrcString() string { return "51077d14" } +func (*ClassifyTraceGetTables) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTraceGetTables) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *ClassifyTraceGetTables) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *ClassifyTraceGetTables) Unmarshal(b []byte) error { + return nil +} + +// Classify get the Trace tables response +// - retval - return code for the request +// - count - number of ids returned in response +// - indices - array of classify table indices +// +// ClassifyTraceGetTablesReply defines message 'classify_trace_get_tables_reply'. +type ClassifyTraceGetTablesReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Count uint32 `binapi:"u32,name=count" json:"-"` + Indices []uint32 `binapi:"u32[count],name=indices" json:"indices,omitempty"` +} + +func (m *ClassifyTraceGetTablesReply) Reset() { *m = ClassifyTraceGetTablesReply{} } +func (*ClassifyTraceGetTablesReply) GetMessageName() string { return "classify_trace_get_tables_reply" } +func (*ClassifyTraceGetTablesReply) GetCrcString() string { return "5f5bc9e6" } +func (*ClassifyTraceGetTablesReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTraceGetTablesReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.Count + size += 4 * len(m.Indices) // m.Indices + return size +} +func (m *ClassifyTraceGetTablesReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(uint32(len(m.Indices))) + for i := 0; i < len(m.Indices); i++ { + var x uint32 + if i < len(m.Indices) { + x = uint32(m.Indices[i]) + } + buf.EncodeUint32(x) + } + return buf.Bytes(), nil +} +func (m *ClassifyTraceGetTablesReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.Count = buf.DecodeUint32() + m.Indices = make([]uint32, m.Count) + for i := 0; i < len(m.Indices); i++ { + m.Indices[i] = buf.DecodeUint32() + } + return nil +} + +// Find a mask-compatible Classify table in the Trace chain +// - skip_n_vectors - number of u32x4 skip vectors +// - match_n_vectors - number of u32x4 vectors, 1..5 +// - mask_len - length of mask, match_n_vectors * sizeof(u32x4) +// - mask - match mask +// +// ClassifyTraceLookupTable defines message 'classify_trace_lookup_table'. +type ClassifyTraceLookupTable struct { + SkipNVectors uint32 `binapi:"u32,name=skip_n_vectors,default=0" json:"skip_n_vectors,omitempty"` + MatchNVectors uint32 `binapi:"u32,name=match_n_vectors,default=1" json:"match_n_vectors,omitempty"` + MaskLen uint32 `binapi:"u32,name=mask_len" json:"-"` + Mask []byte `binapi:"u8[mask_len],name=mask" json:"mask,omitempty"` +} + +func (m *ClassifyTraceLookupTable) Reset() { *m = ClassifyTraceLookupTable{} } +func (*ClassifyTraceLookupTable) GetMessageName() string { return "classify_trace_lookup_table" } +func (*ClassifyTraceLookupTable) GetCrcString() string { return "3f7b72e4" } +func (*ClassifyTraceLookupTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTraceLookupTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SkipNVectors + size += 4 // m.MatchNVectors + size += 4 // m.MaskLen + size += 1 * len(m.Mask) // m.Mask + return size +} +func (m *ClassifyTraceLookupTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.SkipNVectors) + buf.EncodeUint32(m.MatchNVectors) + buf.EncodeUint32(uint32(len(m.Mask))) + buf.EncodeBytes(m.Mask, 0) + return buf.Bytes(), nil +} +func (m *ClassifyTraceLookupTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SkipNVectors = buf.DecodeUint32() + m.MatchNVectors = buf.DecodeUint32() + m.MaskLen = buf.DecodeUint32() + m.Mask = make([]byte, m.MaskLen) + copy(m.Mask, buf.DecodeBytes(len(m.Mask))) + return nil +} + +// Classify trace table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the found table, or ~0 +// +// ClassifyTraceLookupTableReply defines message 'classify_trace_lookup_table_reply'. +type ClassifyTraceLookupTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyTraceLookupTableReply) Reset() { *m = ClassifyTraceLookupTableReply{} } +func (*ClassifyTraceLookupTableReply) GetMessageName() string { + return "classify_trace_lookup_table_reply" +} +func (*ClassifyTraceLookupTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyTraceLookupTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTraceLookupTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyTraceLookupTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyTraceLookupTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Add a Classify table into the Trace chain +// - table_index - Classify table to be added +// - sort_masks - 1=sort masks into most-to-least specific order +// +// ClassifyTraceSetTable defines message 'classify_trace_set_table'. +type ClassifyTraceSetTable struct { + TableIndex uint32 `binapi:"u32,name=table_index,default=4294967295" json:"table_index,omitempty"` + SortMasks bool `binapi:"bool,name=sort_masks,default=0" json:"sort_masks,omitempty"` +} + +func (m *ClassifyTraceSetTable) Reset() { *m = ClassifyTraceSetTable{} } +func (*ClassifyTraceSetTable) GetMessageName() string { return "classify_trace_set_table" } +func (*ClassifyTraceSetTable) GetCrcString() string { return "3909b55a" } +func (*ClassifyTraceSetTable) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *ClassifyTraceSetTable) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 1 // m.SortMasks + return size +} +func (m *ClassifyTraceSetTable) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeBool(m.SortMasks) + return buf.Bytes(), nil +} +func (m *ClassifyTraceSetTable) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.SortMasks = buf.DecodeBool() + return nil +} + +// Classify Trace table lookup response +// - retval - return code for the table lookup request +// - table_index - returned index of the sorted table chain +// +// ClassifyTraceSetTableReply defines message 'classify_trace_set_table_reply'. +type ClassifyTraceSetTableReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *ClassifyTraceSetTableReply) Reset() { *m = ClassifyTraceSetTableReply{} } +func (*ClassifyTraceSetTableReply) GetMessageName() string { return "classify_trace_set_table_reply" } +func (*ClassifyTraceSetTableReply) GetCrcString() string { return "9c6c6773" } +func (*ClassifyTraceSetTableReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *ClassifyTraceSetTableReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.TableIndex + return size +} +func (m *ClassifyTraceSetTableReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *ClassifyTraceSetTableReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Flow classify operational state response. +// - sw_if_index - software interface index +// - table_index - classify table index +// +// FlowClassifyDetails defines message 'flow_classify_details'. +type FlowClassifyDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *FlowClassifyDetails) Reset() { *m = FlowClassifyDetails{} } +func (*FlowClassifyDetails) GetMessageName() string { return "flow_classify_details" } +func (*FlowClassifyDetails) GetCrcString() string { return "dfd08765" } +func (*FlowClassifyDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FlowClassifyDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + return size +} +func (m *FlowClassifyDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *FlowClassifyDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Get list of flow classify interfaces and tables +// - type - flow classify table type +// - sw_if_index - filter on sw_if_index +// +// FlowClassifyDump defines message 'flow_classify_dump'. +type FlowClassifyDump struct { + Type FlowClassifyTable `binapi:"flow_classify_table,name=type" json:"type,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *FlowClassifyDump) Reset() { *m = FlowClassifyDump{} } +func (*FlowClassifyDump) GetMessageName() string { return "flow_classify_dump" } +func (*FlowClassifyDump) GetCrcString() string { return "25dd3e4c" } +func (*FlowClassifyDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FlowClassifyDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Type + size += 4 // m.SwIfIndex + return size +} +func (m *FlowClassifyDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *FlowClassifyDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Type = FlowClassifyTable(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Set/unset flow classify interface +// - sw_if_index - interface to set/unset flow classify +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// FlowClassifySetInterface defines message 'flow_classify_set_interface'. +type FlowClassifySetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *FlowClassifySetInterface) Reset() { *m = FlowClassifySetInterface{} } +func (*FlowClassifySetInterface) GetMessageName() string { return "flow_classify_set_interface" } +func (*FlowClassifySetInterface) GetCrcString() string { return "b6192f1c" } +func (*FlowClassifySetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *FlowClassifySetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 1 // m.IsAdd + return size +} +func (m *FlowClassifySetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *FlowClassifySetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// FlowClassifySetInterfaceReply defines message 'flow_classify_set_interface_reply'. +type FlowClassifySetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *FlowClassifySetInterfaceReply) Reset() { *m = FlowClassifySetInterfaceReply{} } +func (*FlowClassifySetInterfaceReply) GetMessageName() string { + return "flow_classify_set_interface_reply" +} +func (*FlowClassifySetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*FlowClassifySetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *FlowClassifySetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *FlowClassifySetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *FlowClassifySetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set/unset input ACL interface +// - sw_if_index - interface to set/unset input ACL +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set input ACL if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// InputACLSetInterface defines message 'input_acl_set_interface'. +type InputACLSetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + L2TableIndex uint32 `binapi:"u32,name=l2_table_index" json:"l2_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *InputACLSetInterface) Reset() { *m = InputACLSetInterface{} } +func (*InputACLSetInterface) GetMessageName() string { return "input_acl_set_interface" } +func (*InputACLSetInterface) GetCrcString() string { return "de7ad708" } +func (*InputACLSetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *InputACLSetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.L2TableIndex + size += 1 // m.IsAdd + return size +} +func (m *InputACLSetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.L2TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *InputACLSetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.L2TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// InputACLSetInterfaceReply defines message 'input_acl_set_interface_reply'. +type InputACLSetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *InputACLSetInterfaceReply) Reset() { *m = InputACLSetInterfaceReply{} } +func (*InputACLSetInterfaceReply) GetMessageName() string { return "input_acl_set_interface_reply" } +func (*InputACLSetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*InputACLSetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *InputACLSetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *InputACLSetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *InputACLSetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Set/unset output ACL interface +// - sw_if_index - interface to set/unset output ACL +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set output ACL if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// OutputACLSetInterface defines message 'output_acl_set_interface'. +type OutputACLSetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + L2TableIndex uint32 `binapi:"u32,name=l2_table_index" json:"l2_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *OutputACLSetInterface) Reset() { *m = OutputACLSetInterface{} } +func (*OutputACLSetInterface) GetMessageName() string { return "output_acl_set_interface" } +func (*OutputACLSetInterface) GetCrcString() string { return "de7ad708" } +func (*OutputACLSetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *OutputACLSetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.L2TableIndex + size += 1 // m.IsAdd + return size +} +func (m *OutputACLSetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.L2TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *OutputACLSetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.L2TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// OutputACLSetInterfaceReply defines message 'output_acl_set_interface_reply'. +type OutputACLSetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *OutputACLSetInterfaceReply) Reset() { *m = OutputACLSetInterfaceReply{} } +func (*OutputACLSetInterfaceReply) GetMessageName() string { return "output_acl_set_interface_reply" } +func (*OutputACLSetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*OutputACLSetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *OutputACLSetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *OutputACLSetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *OutputACLSetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Policer classify operational state response. +// - sw_if_index - software interface index +// - table_index - classify table index +// +// PolicerClassifyDetails defines message 'policer_classify_details'. +type PolicerClassifyDetails struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` +} + +func (m *PolicerClassifyDetails) Reset() { *m = PolicerClassifyDetails{} } +func (*PolicerClassifyDetails) GetMessageName() string { return "policer_classify_details" } +func (*PolicerClassifyDetails) GetCrcString() string { return "dfd08765" } +func (*PolicerClassifyDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerClassifyDetails) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.TableIndex + return size +} +func (m *PolicerClassifyDetails) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.TableIndex) + return buf.Bytes(), nil +} +func (m *PolicerClassifyDetails) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.TableIndex = buf.DecodeUint32() + return nil +} + +// Get list of policer classify interfaces and tables +// - type - classify table type +// - sw_if_index - filter on sw_if_index +// +// PolicerClassifyDump defines message 'policer_classify_dump'. +type PolicerClassifyDump struct { + Type PolicerClassifyTable `binapi:"policer_classify_table,name=type" json:"type,omitempty"` + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` +} + +func (m *PolicerClassifyDump) Reset() { *m = PolicerClassifyDump{} } +func (*PolicerClassifyDump) GetMessageName() string { return "policer_classify_dump" } +func (*PolicerClassifyDump) GetCrcString() string { return "56cbb5fb" } +func (*PolicerClassifyDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerClassifyDump) Size() (size int) { + if m == nil { + return 0 + } + size += 1 // m.Type + size += 4 // m.SwIfIndex + return size +} +func (m *PolicerClassifyDump) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint8(uint8(m.Type)) + buf.EncodeUint32(uint32(m.SwIfIndex)) + return buf.Bytes(), nil +} +func (m *PolicerClassifyDump) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Type = PolicerClassifyTable(buf.DecodeUint8()) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + return nil +} + +// Set/unset policer classify interface +// - sw_if_index - interface to set/unset policer classify +// - ip4_table_index - ip4 classify table index (~0 for skip) +// - ip6_table_index - ip6 classify table index (~0 for skip) +// - l2_table_index - l2 classify table index (~0 for skip) +// - is_add - Set if non-zero, else unset +// Note: User is recommended to use just one valid table_index per call. +// (ip4_table_index, ip6_table_index, or l2_table_index) +// +// PolicerClassifySetInterface defines message 'policer_classify_set_interface'. +type PolicerClassifySetInterface struct { + SwIfIndex interface_types.InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` + L2TableIndex uint32 `binapi:"u32,name=l2_table_index" json:"l2_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add" json:"is_add,omitempty"` +} + +func (m *PolicerClassifySetInterface) Reset() { *m = PolicerClassifySetInterface{} } +func (*PolicerClassifySetInterface) GetMessageName() string { return "policer_classify_set_interface" } +func (*PolicerClassifySetInterface) GetCrcString() string { return "de7ad708" } +func (*PolicerClassifySetInterface) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PolicerClassifySetInterface) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.SwIfIndex + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 4 // m.L2TableIndex + size += 1 // m.IsAdd + return size +} +func (m *PolicerClassifySetInterface) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(uint32(m.SwIfIndex)) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeUint32(m.L2TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *PolicerClassifySetInterface) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.SwIfIndex = interface_types.InterfaceIndex(buf.DecodeUint32()) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.L2TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// PolicerClassifySetInterfaceReply defines message 'policer_classify_set_interface_reply'. +type PolicerClassifySetInterfaceReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PolicerClassifySetInterfaceReply) Reset() { *m = PolicerClassifySetInterfaceReply{} } +func (*PolicerClassifySetInterfaceReply) GetMessageName() string { + return "policer_classify_set_interface_reply" +} +func (*PolicerClassifySetInterfaceReply) GetCrcString() string { return "e8d4e804" } +func (*PolicerClassifySetInterfaceReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PolicerClassifySetInterfaceReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PolicerClassifySetInterfaceReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PolicerClassifySetInterfaceReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add/del punt ACL +// - ip4_table_index - ip4 punt classify table index (~0 for skip) +// - ip6_table_index - ip6 punt classify table index (~0 for skip) +// - is_add - add punt ACL if non-zero, else delete +// +// PuntACLAddDel defines message 'punt_acl_add_del'. +type PuntACLAddDel struct { + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index,default=4294967295" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index,default=4294967295" json:"ip6_table_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` +} + +func (m *PuntACLAddDel) Reset() { *m = PuntACLAddDel{} } +func (*PuntACLAddDel) GetMessageName() string { return "punt_acl_add_del" } +func (*PuntACLAddDel) GetCrcString() string { return "a93bf3a0" } +func (*PuntACLAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntACLAddDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + size += 1 // m.IsAdd + return size +} +func (m *PuntACLAddDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + buf.EncodeBool(m.IsAdd) + return buf.Bytes(), nil +} +func (m *PuntACLAddDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + m.IsAdd = buf.DecodeBool() + return nil +} + +// PuntACLAddDelReply defines message 'punt_acl_add_del_reply'. +type PuntACLAddDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *PuntACLAddDelReply) Reset() { *m = PuntACLAddDelReply{} } +func (*PuntACLAddDelReply) GetMessageName() string { return "punt_acl_add_del_reply" } +func (*PuntACLAddDelReply) GetCrcString() string { return "e8d4e804" } +func (*PuntACLAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntACLAddDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *PuntACLAddDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *PuntACLAddDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Get classify table ids configured for punt ACL +// PuntACLGet defines message 'punt_acl_get'. +type PuntACLGet struct{} + +func (m *PuntACLGet) Reset() { *m = PuntACLGet{} } +func (*PuntACLGet) GetMessageName() string { return "punt_acl_get" } +func (*PuntACLGet) GetCrcString() string { return "51077d14" } +func (*PuntACLGet) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *PuntACLGet) Size() (size int) { + if m == nil { + return 0 + } + return size +} +func (m *PuntACLGet) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + return buf.Bytes(), nil +} +func (m *PuntACLGet) Unmarshal(b []byte) error { + return nil +} + +// Reply for punt_acl_get +// - retval - return value (0 for success) +// - ip4_table_index - ip4 punt classify table index (~0 for none) +// - ip6_table_index - ip6 punt classify table index (~0 for none) +// +// PuntACLGetReply defines message 'punt_acl_get_reply'. +type PuntACLGetReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + IP4TableIndex uint32 `binapi:"u32,name=ip4_table_index" json:"ip4_table_index,omitempty"` + IP6TableIndex uint32 `binapi:"u32,name=ip6_table_index" json:"ip6_table_index,omitempty"` +} + +func (m *PuntACLGetReply) Reset() { *m = PuntACLGetReply{} } +func (*PuntACLGetReply) GetMessageName() string { return "punt_acl_get_reply" } +func (*PuntACLGetReply) GetCrcString() string { return "8409b9dd" } +func (*PuntACLGetReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *PuntACLGetReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + size += 4 // m.IP4TableIndex + size += 4 // m.IP6TableIndex + return size +} +func (m *PuntACLGetReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + buf.EncodeUint32(m.IP4TableIndex) + buf.EncodeUint32(m.IP6TableIndex) + return buf.Bytes(), nil +} +func (m *PuntACLGetReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + m.IP4TableIndex = buf.DecodeUint32() + m.IP6TableIndex = buf.DecodeUint32() + return nil +} + +func init() { file_classify_binapi_init() } +func file_classify_binapi_init() { + api.RegisterMessage((*ClassifyAddDelSession)(nil), "classify_add_del_session_f20879f0") + api.RegisterMessage((*ClassifyAddDelSessionReply)(nil), "classify_add_del_session_reply_e8d4e804") + api.RegisterMessage((*ClassifyAddDelTable)(nil), "classify_add_del_table_6849e39e") + api.RegisterMessage((*ClassifyAddDelTableReply)(nil), "classify_add_del_table_reply_05486349") + api.RegisterMessage((*ClassifyPcapGetTables)(nil), "classify_pcap_get_tables_f9e6675e") + api.RegisterMessage((*ClassifyPcapGetTablesReply)(nil), "classify_pcap_get_tables_reply_5f5bc9e6") + api.RegisterMessage((*ClassifyPcapLookupTable)(nil), "classify_pcap_lookup_table_e1b4cc6b") + api.RegisterMessage((*ClassifyPcapLookupTableReply)(nil), "classify_pcap_lookup_table_reply_9c6c6773") + api.RegisterMessage((*ClassifyPcapSetTable)(nil), "classify_pcap_set_table_006051b3") + api.RegisterMessage((*ClassifyPcapSetTableReply)(nil), "classify_pcap_set_table_reply_9c6c6773") + api.RegisterMessage((*ClassifySessionDetails)(nil), "classify_session_details_60e3ef94") + api.RegisterMessage((*ClassifySessionDump)(nil), "classify_session_dump_0cca2cd9") + api.RegisterMessage((*ClassifySetInterfaceIPTable)(nil), "classify_set_interface_ip_table_e0b097c7") + api.RegisterMessage((*ClassifySetInterfaceIPTableReply)(nil), "classify_set_interface_ip_table_reply_e8d4e804") + api.RegisterMessage((*ClassifySetInterfaceL2Tables)(nil), "classify_set_interface_l2_tables_5a6ddf65") + api.RegisterMessage((*ClassifySetInterfaceL2TablesReply)(nil), "classify_set_interface_l2_tables_reply_e8d4e804") + api.RegisterMessage((*ClassifyTableByInterface)(nil), "classify_table_by_interface_f9e6675e") + api.RegisterMessage((*ClassifyTableByInterfaceReply)(nil), "classify_table_by_interface_reply_ed4197db") + api.RegisterMessage((*ClassifyTableIds)(nil), "classify_table_ids_51077d14") + api.RegisterMessage((*ClassifyTableIdsReply)(nil), "classify_table_ids_reply_d1d20e1d") + api.RegisterMessage((*ClassifyTableInfo)(nil), "classify_table_info_0cca2cd9") + api.RegisterMessage((*ClassifyTableInfoReply)(nil), "classify_table_info_reply_4a573c0e") + api.RegisterMessage((*ClassifyTraceGetTables)(nil), "classify_trace_get_tables_51077d14") + api.RegisterMessage((*ClassifyTraceGetTablesReply)(nil), "classify_trace_get_tables_reply_5f5bc9e6") + api.RegisterMessage((*ClassifyTraceLookupTable)(nil), "classify_trace_lookup_table_3f7b72e4") + api.RegisterMessage((*ClassifyTraceLookupTableReply)(nil), "classify_trace_lookup_table_reply_9c6c6773") + api.RegisterMessage((*ClassifyTraceSetTable)(nil), "classify_trace_set_table_3909b55a") + api.RegisterMessage((*ClassifyTraceSetTableReply)(nil), "classify_trace_set_table_reply_9c6c6773") + api.RegisterMessage((*FlowClassifyDetails)(nil), "flow_classify_details_dfd08765") + api.RegisterMessage((*FlowClassifyDump)(nil), "flow_classify_dump_25dd3e4c") + api.RegisterMessage((*FlowClassifySetInterface)(nil), "flow_classify_set_interface_b6192f1c") + api.RegisterMessage((*FlowClassifySetInterfaceReply)(nil), "flow_classify_set_interface_reply_e8d4e804") + api.RegisterMessage((*InputACLSetInterface)(nil), "input_acl_set_interface_de7ad708") + api.RegisterMessage((*InputACLSetInterfaceReply)(nil), "input_acl_set_interface_reply_e8d4e804") + api.RegisterMessage((*OutputACLSetInterface)(nil), "output_acl_set_interface_de7ad708") + api.RegisterMessage((*OutputACLSetInterfaceReply)(nil), "output_acl_set_interface_reply_e8d4e804") + api.RegisterMessage((*PolicerClassifyDetails)(nil), "policer_classify_details_dfd08765") + api.RegisterMessage((*PolicerClassifyDump)(nil), "policer_classify_dump_56cbb5fb") + api.RegisterMessage((*PolicerClassifySetInterface)(nil), "policer_classify_set_interface_de7ad708") + api.RegisterMessage((*PolicerClassifySetInterfaceReply)(nil), "policer_classify_set_interface_reply_e8d4e804") + api.RegisterMessage((*PuntACLAddDel)(nil), "punt_acl_add_del_a93bf3a0") + api.RegisterMessage((*PuntACLAddDelReply)(nil), "punt_acl_add_del_reply_e8d4e804") + api.RegisterMessage((*PuntACLGet)(nil), "punt_acl_get_51077d14") + api.RegisterMessage((*PuntACLGetReply)(nil), "punt_acl_get_reply_8409b9dd") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*ClassifyAddDelSession)(nil), + (*ClassifyAddDelSessionReply)(nil), + (*ClassifyAddDelTable)(nil), + (*ClassifyAddDelTableReply)(nil), + (*ClassifyPcapGetTables)(nil), + (*ClassifyPcapGetTablesReply)(nil), + (*ClassifyPcapLookupTable)(nil), + (*ClassifyPcapLookupTableReply)(nil), + (*ClassifyPcapSetTable)(nil), + (*ClassifyPcapSetTableReply)(nil), + (*ClassifySessionDetails)(nil), + (*ClassifySessionDump)(nil), + (*ClassifySetInterfaceIPTable)(nil), + (*ClassifySetInterfaceIPTableReply)(nil), + (*ClassifySetInterfaceL2Tables)(nil), + (*ClassifySetInterfaceL2TablesReply)(nil), + (*ClassifyTableByInterface)(nil), + (*ClassifyTableByInterfaceReply)(nil), + (*ClassifyTableIds)(nil), + (*ClassifyTableIdsReply)(nil), + (*ClassifyTableInfo)(nil), + (*ClassifyTableInfoReply)(nil), + (*ClassifyTraceGetTables)(nil), + (*ClassifyTraceGetTablesReply)(nil), + (*ClassifyTraceLookupTable)(nil), + (*ClassifyTraceLookupTableReply)(nil), + (*ClassifyTraceSetTable)(nil), + (*ClassifyTraceSetTableReply)(nil), + (*FlowClassifyDetails)(nil), + (*FlowClassifyDump)(nil), + (*FlowClassifySetInterface)(nil), + (*FlowClassifySetInterfaceReply)(nil), + (*InputACLSetInterface)(nil), + (*InputACLSetInterfaceReply)(nil), + (*OutputACLSetInterface)(nil), + (*OutputACLSetInterfaceReply)(nil), + (*PolicerClassifyDetails)(nil), + (*PolicerClassifyDump)(nil), + (*PolicerClassifySetInterface)(nil), + (*PolicerClassifySetInterfaceReply)(nil), + (*PuntACLAddDel)(nil), + (*PuntACLAddDelReply)(nil), + (*PuntACLGet)(nil), + (*PuntACLGetReply)(nil), + } +} diff --git a/vpplink/generated/bindings/classify/classify_rpc.ba.go b/vpplink/generated/bindings/classify/classify_rpc.ba.go new file mode 100644 index 00000000..71b2b163 --- /dev/null +++ b/vpplink/generated/bindings/classify/classify_rpc.ba.go @@ -0,0 +1,346 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package classify + +import ( + "context" + "fmt" + "io" + + memclnt "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/memclnt" + api "go.fd.io/govpp/api" +) + +// RPCService defines RPC service classify. +type RPCService interface { + ClassifyAddDelSession(ctx context.Context, in *ClassifyAddDelSession) (*ClassifyAddDelSessionReply, error) + ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) + ClassifyPcapGetTables(ctx context.Context, in *ClassifyPcapGetTables) (*ClassifyPcapGetTablesReply, error) + ClassifyPcapLookupTable(ctx context.Context, in *ClassifyPcapLookupTable) (*ClassifyPcapLookupTableReply, error) + ClassifyPcapSetTable(ctx context.Context, in *ClassifyPcapSetTable) (*ClassifyPcapSetTableReply, error) + ClassifySessionDump(ctx context.Context, in *ClassifySessionDump) (RPCService_ClassifySessionDumpClient, error) + ClassifySetInterfaceIPTable(ctx context.Context, in *ClassifySetInterfaceIPTable) (*ClassifySetInterfaceIPTableReply, error) + ClassifySetInterfaceL2Tables(ctx context.Context, in *ClassifySetInterfaceL2Tables) (*ClassifySetInterfaceL2TablesReply, error) + ClassifyTableByInterface(ctx context.Context, in *ClassifyTableByInterface) (*ClassifyTableByInterfaceReply, error) + ClassifyTableIds(ctx context.Context, in *ClassifyTableIds) (*ClassifyTableIdsReply, error) + ClassifyTableInfo(ctx context.Context, in *ClassifyTableInfo) (*ClassifyTableInfoReply, error) + ClassifyTraceGetTables(ctx context.Context, in *ClassifyTraceGetTables) (*ClassifyTraceGetTablesReply, error) + ClassifyTraceLookupTable(ctx context.Context, in *ClassifyTraceLookupTable) (*ClassifyTraceLookupTableReply, error) + ClassifyTraceSetTable(ctx context.Context, in *ClassifyTraceSetTable) (*ClassifyTraceSetTableReply, error) + FlowClassifyDump(ctx context.Context, in *FlowClassifyDump) (RPCService_FlowClassifyDumpClient, error) + FlowClassifySetInterface(ctx context.Context, in *FlowClassifySetInterface) (*FlowClassifySetInterfaceReply, error) + InputACLSetInterface(ctx context.Context, in *InputACLSetInterface) (*InputACLSetInterfaceReply, error) + OutputACLSetInterface(ctx context.Context, in *OutputACLSetInterface) (*OutputACLSetInterfaceReply, error) + PolicerClassifyDump(ctx context.Context, in *PolicerClassifyDump) (RPCService_PolicerClassifyDumpClient, error) + PolicerClassifySetInterface(ctx context.Context, in *PolicerClassifySetInterface) (*PolicerClassifySetInterfaceReply, error) + PuntACLAddDel(ctx context.Context, in *PuntACLAddDel) (*PuntACLAddDelReply, error) + PuntACLGet(ctx context.Context, in *PuntACLGet) (*PuntACLGetReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) ClassifyAddDelSession(ctx context.Context, in *ClassifyAddDelSession) (*ClassifyAddDelSessionReply, error) { + out := new(ClassifyAddDelSessionReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyAddDelTable(ctx context.Context, in *ClassifyAddDelTable) (*ClassifyAddDelTableReply, error) { + out := new(ClassifyAddDelTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyPcapGetTables(ctx context.Context, in *ClassifyPcapGetTables) (*ClassifyPcapGetTablesReply, error) { + out := new(ClassifyPcapGetTablesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyPcapLookupTable(ctx context.Context, in *ClassifyPcapLookupTable) (*ClassifyPcapLookupTableReply, error) { + out := new(ClassifyPcapLookupTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyPcapSetTable(ctx context.Context, in *ClassifyPcapSetTable) (*ClassifyPcapSetTableReply, error) { + out := new(ClassifyPcapSetTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifySessionDump(ctx context.Context, in *ClassifySessionDump) (RPCService_ClassifySessionDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_ClassifySessionDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_ClassifySessionDumpClient interface { + Recv() (*ClassifySessionDetails, error) + api.Stream +} + +type serviceClient_ClassifySessionDumpClient struct { + api.Stream +} + +func (c *serviceClient_ClassifySessionDumpClient) Recv() (*ClassifySessionDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *ClassifySessionDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) ClassifySetInterfaceIPTable(ctx context.Context, in *ClassifySetInterfaceIPTable) (*ClassifySetInterfaceIPTableReply, error) { + out := new(ClassifySetInterfaceIPTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifySetInterfaceL2Tables(ctx context.Context, in *ClassifySetInterfaceL2Tables) (*ClassifySetInterfaceL2TablesReply, error) { + out := new(ClassifySetInterfaceL2TablesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTableByInterface(ctx context.Context, in *ClassifyTableByInterface) (*ClassifyTableByInterfaceReply, error) { + out := new(ClassifyTableByInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTableIds(ctx context.Context, in *ClassifyTableIds) (*ClassifyTableIdsReply, error) { + out := new(ClassifyTableIdsReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTableInfo(ctx context.Context, in *ClassifyTableInfo) (*ClassifyTableInfoReply, error) { + out := new(ClassifyTableInfoReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTraceGetTables(ctx context.Context, in *ClassifyTraceGetTables) (*ClassifyTraceGetTablesReply, error) { + out := new(ClassifyTraceGetTablesReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTraceLookupTable(ctx context.Context, in *ClassifyTraceLookupTable) (*ClassifyTraceLookupTableReply, error) { + out := new(ClassifyTraceLookupTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) ClassifyTraceSetTable(ctx context.Context, in *ClassifyTraceSetTable) (*ClassifyTraceSetTableReply, error) { + out := new(ClassifyTraceSetTableReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) FlowClassifyDump(ctx context.Context, in *FlowClassifyDump) (RPCService_FlowClassifyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_FlowClassifyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_FlowClassifyDumpClient interface { + Recv() (*FlowClassifyDetails, error) + api.Stream +} + +type serviceClient_FlowClassifyDumpClient struct { + api.Stream +} + +func (c *serviceClient_FlowClassifyDumpClient) Recv() (*FlowClassifyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *FlowClassifyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) FlowClassifySetInterface(ctx context.Context, in *FlowClassifySetInterface) (*FlowClassifySetInterfaceReply, error) { + out := new(FlowClassifySetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) InputACLSetInterface(ctx context.Context, in *InputACLSetInterface) (*InputACLSetInterfaceReply, error) { + out := new(InputACLSetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) OutputACLSetInterface(ctx context.Context, in *OutputACLSetInterface) (*OutputACLSetInterfaceReply, error) { + out := new(OutputACLSetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PolicerClassifyDump(ctx context.Context, in *PolicerClassifyDump) (RPCService_PolicerClassifyDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_PolicerClassifyDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_PolicerClassifyDumpClient interface { + Recv() (*PolicerClassifyDetails, error) + api.Stream +} + +type serviceClient_PolicerClassifyDumpClient struct { + api.Stream +} + +func (c *serviceClient_PolicerClassifyDumpClient) Recv() (*PolicerClassifyDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *PolicerClassifyDetails: + return m, nil + case *memclnt.ControlPingReply: + err = c.Stream.Close() + if err != nil { + return nil, err + } + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + +func (c *serviceClient) PolicerClassifySetInterface(ctx context.Context, in *PolicerClassifySetInterface) (*PolicerClassifySetInterfaceReply, error) { + out := new(PolicerClassifySetInterfaceReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PuntACLAddDel(ctx context.Context, in *PuntACLAddDel) (*PuntACLAddDelReply, error) { + out := new(PuntACLAddDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) PuntACLGet(ctx context.Context, in *PuntACLGet) (*PuntACLGetReply, error) { + out := new(PuntACLGetReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/vpplink/generated/bindings/cnat/cnat.ba.go b/vpplink/generated/bindings/cnat/cnat.ba.go index a9b0a8a4..eae47fd2 100644 --- a/vpplink/generated/bindings/cnat/cnat.ba.go +++ b/vpplink/generated/bindings/cnat/cnat.ba.go @@ -27,7 +27,7 @@ const _ = api.GoVppAPIPackageIsVersion2 const ( APIFile = "cnat" APIVersion = "0.2.0" - VersionCrc = 0xfd05573b + VersionCrc = 0x8e6b2e7b ) // CnatEndpointTupleFlags defines enum 'cnat_endpoint_tuple_flags'. @@ -137,6 +137,7 @@ const ( CNAT_POLICY_INCLUDE_V4 CnatSnatPolicyTable = 0 CNAT_POLICY_INCLUDE_V6 CnatSnatPolicyTable = 1 CNAT_POLICY_POD CnatSnatPolicyTable = 2 + CNAT_POLICY_HOST CnatSnatPolicyTable = 3 ) var ( @@ -144,11 +145,13 @@ var ( 0: "CNAT_POLICY_INCLUDE_V4", 1: "CNAT_POLICY_INCLUDE_V6", 2: "CNAT_POLICY_POD", + 3: "CNAT_POLICY_HOST", } CnatSnatPolicyTable_value = map[string]uint8{ "CNAT_POLICY_INCLUDE_V4": 0, "CNAT_POLICY_INCLUDE_V6": 1, "CNAT_POLICY_POD": 2, + "CNAT_POLICY_HOST": 3, } ) @@ -717,7 +720,7 @@ type CnatSnatPolicyAddDelIf struct { func (m *CnatSnatPolicyAddDelIf) Reset() { *m = CnatSnatPolicyAddDelIf{} } func (*CnatSnatPolicyAddDelIf) GetMessageName() string { return "cnat_snat_policy_add_del_if" } -func (*CnatSnatPolicyAddDelIf) GetCrcString() string { return "6828deca" } +func (*CnatSnatPolicyAddDelIf) GetCrcString() string { return "4ebb8d02" } func (*CnatSnatPolicyAddDelIf) GetMessageType() api.MessageType { return api.RequestMessage } @@ -1156,7 +1159,7 @@ func file_cnat_binapi_init() { api.RegisterMessage((*CnatSetSnatPolicyReply)(nil), "cnat_set_snat_policy_reply_e8d4e804") api.RegisterMessage((*CnatSnatPolicyAddDelExcludePfx)(nil), "cnat_snat_policy_add_del_exclude_pfx_e26dd79a") api.RegisterMessage((*CnatSnatPolicyAddDelExcludePfxReply)(nil), "cnat_snat_policy_add_del_exclude_pfx_reply_e8d4e804") - api.RegisterMessage((*CnatSnatPolicyAddDelIf)(nil), "cnat_snat_policy_add_del_if_6828deca") + api.RegisterMessage((*CnatSnatPolicyAddDelIf)(nil), "cnat_snat_policy_add_del_if_4ebb8d02") api.RegisterMessage((*CnatSnatPolicyAddDelIfReply)(nil), "cnat_snat_policy_add_del_if_reply_e8d4e804") api.RegisterMessage((*CnatTranslationDel)(nil), "cnat_translation_del_3a91bde5") api.RegisterMessage((*CnatTranslationDelReply)(nil), "cnat_translation_del_reply_e8d4e804") diff --git a/vpplink/generated/bindings/ip_session_redirect/ip_session_redirect.ba.go b/vpplink/generated/bindings/ip_session_redirect/ip_session_redirect.ba.go new file mode 100644 index 00000000..d93f7513 --- /dev/null +++ b/vpplink/generated/bindings/ip_session_redirect/ip_session_redirect.ba.go @@ -0,0 +1,482 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +// Package ip_session_redirect contains generated bindings for API file ip_session_redirect.api. +// +// Contents: +// - 6 messages +package ip_session_redirect + +import ( + fib_types "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/fib_types" + _ "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/interface_types" + _ "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/ip_types" + api "go.fd.io/govpp/api" + codec "go.fd.io/govpp/codec" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the GoVPP api package it is being compiled against. +// A compilation error at this line likely means your copy of the +// GoVPP api package needs to be updated. +const _ = api.GoVppAPIPackageIsVersion2 + +const ( + APIFile = "ip_session_redirect" + APIVersion = "0.3.0" + VersionCrc = 0xf174f8ba +) + +// Add or update a session redirection +// - table_index - classifier table index +// - opaque_index - classifier session opaque index +// - match_len - classifier session match length in bytes (max is 80-bytes) +// - match - classifier session match +// - is_punt - true = punted traffic, false = forwarded traffic +// - n_paths - number of paths +// - paths - the paths of the redirect +// +// IPSessionRedirectAdd defines message 'ip_session_redirect_add'. +// Deprecated: the message will be removed in the future versions +type IPSessionRedirectAdd struct { + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + MatchLen uint8 `binapi:"u8,name=match_len" json:"match_len,omitempty"` + Match []byte `binapi:"u8[80],name=match" json:"match,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index,default=4294967295" json:"opaque_index,omitempty"` + IsPunt bool `binapi:"bool,name=is_punt" json:"is_punt,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"-"` + Paths []fib_types.FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` +} + +func (m *IPSessionRedirectAdd) Reset() { *m = IPSessionRedirectAdd{} } +func (*IPSessionRedirectAdd) GetMessageName() string { return "ip_session_redirect_add" } +func (*IPSessionRedirectAdd) GetCrcString() string { return "2f78ffda" } +func (*IPSessionRedirectAdd) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPSessionRedirectAdd) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 1 // m.MatchLen + size += 1 * 80 // m.Match + size += 4 // m.OpaqueIndex + size += 1 // m.IsPunt + size += 1 // m.NPaths + for j1 := 0; j1 < len(m.Paths); j1++ { + var s1 fib_types.FibPath + _ = s1 + if j1 < len(m.Paths) { + s1 = m.Paths[j1] + } + size += 4 // s1.SwIfIndex + size += 4 // s1.TableID + size += 4 // s1.RpfID + size += 1 // s1.Weight + size += 1 // s1.Preference + size += 4 // s1.Type + size += 4 // s1.Flags + size += 4 // s1.Proto + size += 1 * 16 // s1.Nh.Address + size += 4 // s1.Nh.ViaLabel + size += 4 // s1.Nh.ObjID + size += 4 // s1.Nh.ClassifyTableIndex + size += 1 // s1.NLabels + for j2 := 0; j2 < 16; j2++ { + size += 1 // s1.LabelStack[j2].IsUniform + size += 4 // s1.LabelStack[j2].Label + size += 1 // s1.LabelStack[j2].TTL + size += 1 // s1.LabelStack[j2].Exp + } + } + return size +} +func (m *IPSessionRedirectAdd) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint8(m.MatchLen) + buf.EncodeBytes(m.Match, 80) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeBool(m.IsPunt) + buf.EncodeUint8(uint8(len(m.Paths))) + for j0 := 0; j0 < len(m.Paths); j0++ { + var v0 fib_types.FibPath // Paths + if j0 < len(m.Paths) { + v0 = m.Paths[j0] + } + buf.EncodeUint32(v0.SwIfIndex) + buf.EncodeUint32(v0.TableID) + buf.EncodeUint32(v0.RpfID) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(v0.Preference) + buf.EncodeUint32(uint32(v0.Type)) + buf.EncodeUint32(uint32(v0.Flags)) + buf.EncodeUint32(uint32(v0.Proto)) + buf.EncodeBytes(v0.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v0.Nh.ViaLabel) + buf.EncodeUint32(v0.Nh.ObjID) + buf.EncodeUint32(v0.Nh.ClassifyTableIndex) + buf.EncodeUint8(v0.NLabels) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeUint8(v0.LabelStack[j1].IsUniform) + buf.EncodeUint32(v0.LabelStack[j1].Label) + buf.EncodeUint8(v0.LabelStack[j1].TTL) + buf.EncodeUint8(v0.LabelStack[j1].Exp) + } + } + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAdd) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.MatchLen = buf.DecodeUint8() + m.Match = make([]byte, 80) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + m.OpaqueIndex = buf.DecodeUint32() + m.IsPunt = buf.DecodeBool() + m.NPaths = buf.DecodeUint8() + m.Paths = make([]fib_types.FibPath, m.NPaths) + for j0 := 0; j0 < len(m.Paths); j0++ { + m.Paths[j0].SwIfIndex = buf.DecodeUint32() + m.Paths[j0].TableID = buf.DecodeUint32() + m.Paths[j0].RpfID = buf.DecodeUint32() + m.Paths[j0].Weight = buf.DecodeUint8() + m.Paths[j0].Preference = buf.DecodeUint8() + m.Paths[j0].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.Paths[j0].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.Paths[j0].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.Paths[j0].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Paths[j0].Nh.ViaLabel = buf.DecodeUint32() + m.Paths[j0].Nh.ObjID = buf.DecodeUint32() + m.Paths[j0].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.Paths[j0].NLabels = buf.DecodeUint8() + for j1 := 0; j1 < 16; j1++ { + m.Paths[j0].LabelStack[j1].IsUniform = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Label = buf.DecodeUint32() + m.Paths[j0].LabelStack[j1].TTL = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Exp = buf.DecodeUint8() + } + } + return nil +} + +// IPSessionRedirectAddReply defines message 'ip_session_redirect_add_reply'. +// Deprecated: the message will be removed in the future versions +type IPSessionRedirectAddReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPSessionRedirectAddReply) Reset() { *m = IPSessionRedirectAddReply{} } +func (*IPSessionRedirectAddReply) GetMessageName() string { return "ip_session_redirect_add_reply" } +func (*IPSessionRedirectAddReply) GetCrcString() string { return "e8d4e804" } +func (*IPSessionRedirectAddReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPSessionRedirectAddReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPSessionRedirectAddReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAddReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Add or update a session redirection - version 2 +// - table_index - classifier table index +// - opaque_index - classifier session opaque index +// - proto - protocol of forwarded packets (default autodetect from path nh) +// - is_punt - true = punted traffic, false = forwarded traffic +// - match_len - classifier session match length in bytes (max is 80-bytes) +// - match - classifier session match +// - n_paths - number of paths +// - paths - the paths of the redirect +// +// IPSessionRedirectAddV2 defines message 'ip_session_redirect_add_v2'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectAddV2 struct { + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + OpaqueIndex uint32 `binapi:"u32,name=opaque_index,default=4294967295" json:"opaque_index,omitempty"` + Proto fib_types.FibPathNhProto `binapi:"fib_path_nh_proto,name=proto,default=4294967295" json:"proto,omitempty"` + IsPunt bool `binapi:"bool,name=is_punt" json:"is_punt,omitempty"` + MatchLen uint8 `binapi:"u8,name=match_len" json:"match_len,omitempty"` + Match []byte `binapi:"u8[80],name=match" json:"match,omitempty"` + NPaths uint8 `binapi:"u8,name=n_paths" json:"-"` + Paths []fib_types.FibPath `binapi:"fib_path[n_paths],name=paths" json:"paths,omitempty"` +} + +func (m *IPSessionRedirectAddV2) Reset() { *m = IPSessionRedirectAddV2{} } +func (*IPSessionRedirectAddV2) GetMessageName() string { return "ip_session_redirect_add_v2" } +func (*IPSessionRedirectAddV2) GetCrcString() string { return "0765f51f" } +func (*IPSessionRedirectAddV2) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPSessionRedirectAddV2) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 4 // m.OpaqueIndex + size += 4 // m.Proto + size += 1 // m.IsPunt + size += 1 // m.MatchLen + size += 1 * 80 // m.Match + size += 1 // m.NPaths + for j1 := 0; j1 < len(m.Paths); j1++ { + var s1 fib_types.FibPath + _ = s1 + if j1 < len(m.Paths) { + s1 = m.Paths[j1] + } + size += 4 // s1.SwIfIndex + size += 4 // s1.TableID + size += 4 // s1.RpfID + size += 1 // s1.Weight + size += 1 // s1.Preference + size += 4 // s1.Type + size += 4 // s1.Flags + size += 4 // s1.Proto + size += 1 * 16 // s1.Nh.Address + size += 4 // s1.Nh.ViaLabel + size += 4 // s1.Nh.ObjID + size += 4 // s1.Nh.ClassifyTableIndex + size += 1 // s1.NLabels + for j2 := 0; j2 < 16; j2++ { + size += 1 // s1.LabelStack[j2].IsUniform + size += 4 // s1.LabelStack[j2].Label + size += 1 // s1.LabelStack[j2].TTL + size += 1 // s1.LabelStack[j2].Exp + } + } + return size +} +func (m *IPSessionRedirectAddV2) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint32(m.OpaqueIndex) + buf.EncodeUint32(uint32(m.Proto)) + buf.EncodeBool(m.IsPunt) + buf.EncodeUint8(m.MatchLen) + buf.EncodeBytes(m.Match, 80) + buf.EncodeUint8(uint8(len(m.Paths))) + for j0 := 0; j0 < len(m.Paths); j0++ { + var v0 fib_types.FibPath // Paths + if j0 < len(m.Paths) { + v0 = m.Paths[j0] + } + buf.EncodeUint32(v0.SwIfIndex) + buf.EncodeUint32(v0.TableID) + buf.EncodeUint32(v0.RpfID) + buf.EncodeUint8(v0.Weight) + buf.EncodeUint8(v0.Preference) + buf.EncodeUint32(uint32(v0.Type)) + buf.EncodeUint32(uint32(v0.Flags)) + buf.EncodeUint32(uint32(v0.Proto)) + buf.EncodeBytes(v0.Nh.Address.XXX_UnionData[:], 16) + buf.EncodeUint32(v0.Nh.ViaLabel) + buf.EncodeUint32(v0.Nh.ObjID) + buf.EncodeUint32(v0.Nh.ClassifyTableIndex) + buf.EncodeUint8(v0.NLabels) + for j1 := 0; j1 < 16; j1++ { + buf.EncodeUint8(v0.LabelStack[j1].IsUniform) + buf.EncodeUint32(v0.LabelStack[j1].Label) + buf.EncodeUint8(v0.LabelStack[j1].TTL) + buf.EncodeUint8(v0.LabelStack[j1].Exp) + } + } + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAddV2) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.OpaqueIndex = buf.DecodeUint32() + m.Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + m.IsPunt = buf.DecodeBool() + m.MatchLen = buf.DecodeUint8() + m.Match = make([]byte, 80) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + m.NPaths = buf.DecodeUint8() + m.Paths = make([]fib_types.FibPath, m.NPaths) + for j0 := 0; j0 < len(m.Paths); j0++ { + m.Paths[j0].SwIfIndex = buf.DecodeUint32() + m.Paths[j0].TableID = buf.DecodeUint32() + m.Paths[j0].RpfID = buf.DecodeUint32() + m.Paths[j0].Weight = buf.DecodeUint8() + m.Paths[j0].Preference = buf.DecodeUint8() + m.Paths[j0].Type = fib_types.FibPathType(buf.DecodeUint32()) + m.Paths[j0].Flags = fib_types.FibPathFlags(buf.DecodeUint32()) + m.Paths[j0].Proto = fib_types.FibPathNhProto(buf.DecodeUint32()) + copy(m.Paths[j0].Nh.Address.XXX_UnionData[:], buf.DecodeBytes(16)) + m.Paths[j0].Nh.ViaLabel = buf.DecodeUint32() + m.Paths[j0].Nh.ObjID = buf.DecodeUint32() + m.Paths[j0].Nh.ClassifyTableIndex = buf.DecodeUint32() + m.Paths[j0].NLabels = buf.DecodeUint8() + for j1 := 0; j1 < 16; j1++ { + m.Paths[j0].LabelStack[j1].IsUniform = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Label = buf.DecodeUint32() + m.Paths[j0].LabelStack[j1].TTL = buf.DecodeUint8() + m.Paths[j0].LabelStack[j1].Exp = buf.DecodeUint8() + } + } + return nil +} + +// IPSessionRedirectAddV2Reply defines message 'ip_session_redirect_add_v2_reply'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectAddV2Reply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPSessionRedirectAddV2Reply) Reset() { *m = IPSessionRedirectAddV2Reply{} } +func (*IPSessionRedirectAddV2Reply) GetMessageName() string { + return "ip_session_redirect_add_v2_reply" +} +func (*IPSessionRedirectAddV2Reply) GetCrcString() string { return "e8d4e804" } +func (*IPSessionRedirectAddV2Reply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPSessionRedirectAddV2Reply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPSessionRedirectAddV2Reply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectAddV2Reply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +// Delete a session redirection +// - table_index - classifier table index +// - match_len - classifier session match length in bytes (max is 80-bytes) +// - match - classifier session match +// +// IPSessionRedirectDel defines message 'ip_session_redirect_del'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectDel struct { + TableIndex uint32 `binapi:"u32,name=table_index" json:"table_index,omitempty"` + MatchLen uint8 `binapi:"u8,name=match_len" json:"-"` + Match []byte `binapi:"u8[match_len],name=match" json:"match,omitempty"` +} + +func (m *IPSessionRedirectDel) Reset() { *m = IPSessionRedirectDel{} } +func (*IPSessionRedirectDel) GetMessageName() string { return "ip_session_redirect_del" } +func (*IPSessionRedirectDel) GetCrcString() string { return "fb643388" } +func (*IPSessionRedirectDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +func (m *IPSessionRedirectDel) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.TableIndex + size += 1 // m.MatchLen + size += 1 * len(m.Match) // m.Match + return size +} +func (m *IPSessionRedirectDel) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeUint32(m.TableIndex) + buf.EncodeUint8(uint8(len(m.Match))) + buf.EncodeBytes(m.Match, 0) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectDel) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.TableIndex = buf.DecodeUint32() + m.MatchLen = buf.DecodeUint8() + m.Match = make([]byte, m.MatchLen) + copy(m.Match, buf.DecodeBytes(len(m.Match))) + return nil +} + +// IPSessionRedirectDelReply defines message 'ip_session_redirect_del_reply'. +// InProgress: the message form may change in the future versions +type IPSessionRedirectDelReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *IPSessionRedirectDelReply) Reset() { *m = IPSessionRedirectDelReply{} } +func (*IPSessionRedirectDelReply) GetMessageName() string { return "ip_session_redirect_del_reply" } +func (*IPSessionRedirectDelReply) GetCrcString() string { return "e8d4e804" } +func (*IPSessionRedirectDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +func (m *IPSessionRedirectDelReply) Size() (size int) { + if m == nil { + return 0 + } + size += 4 // m.Retval + return size +} +func (m *IPSessionRedirectDelReply) Marshal(b []byte) ([]byte, error) { + if b == nil { + b = make([]byte, m.Size()) + } + buf := codec.NewBuffer(b) + buf.EncodeInt32(m.Retval) + return buf.Bytes(), nil +} +func (m *IPSessionRedirectDelReply) Unmarshal(b []byte) error { + buf := codec.NewBuffer(b) + m.Retval = buf.DecodeInt32() + return nil +} + +func init() { file_ip_session_redirect_binapi_init() } +func file_ip_session_redirect_binapi_init() { + api.RegisterMessage((*IPSessionRedirectAdd)(nil), "ip_session_redirect_add_2f78ffda") + api.RegisterMessage((*IPSessionRedirectAddReply)(nil), "ip_session_redirect_add_reply_e8d4e804") + api.RegisterMessage((*IPSessionRedirectAddV2)(nil), "ip_session_redirect_add_v2_0765f51f") + api.RegisterMessage((*IPSessionRedirectAddV2Reply)(nil), "ip_session_redirect_add_v2_reply_e8d4e804") + api.RegisterMessage((*IPSessionRedirectDel)(nil), "ip_session_redirect_del_fb643388") + api.RegisterMessage((*IPSessionRedirectDelReply)(nil), "ip_session_redirect_del_reply_e8d4e804") +} + +// Messages returns list of all messages in this module. +func AllMessages() []api.Message { + return []api.Message{ + (*IPSessionRedirectAdd)(nil), + (*IPSessionRedirectAddReply)(nil), + (*IPSessionRedirectAddV2)(nil), + (*IPSessionRedirectAddV2Reply)(nil), + (*IPSessionRedirectDel)(nil), + (*IPSessionRedirectDelReply)(nil), + } +} diff --git a/vpplink/generated/bindings/ip_session_redirect/ip_session_redirect_rpc.ba.go b/vpplink/generated/bindings/ip_session_redirect/ip_session_redirect_rpc.ba.go new file mode 100644 index 00000000..9c58288d --- /dev/null +++ b/vpplink/generated/bindings/ip_session_redirect/ip_session_redirect_rpc.ba.go @@ -0,0 +1,51 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. + +package ip_session_redirect + +import ( + "context" + + api "go.fd.io/govpp/api" +) + +// RPCService defines RPC service ip_session_redirect. +type RPCService interface { + IPSessionRedirectAdd(ctx context.Context, in *IPSessionRedirectAdd) (*IPSessionRedirectAddReply, error) + IPSessionRedirectAddV2(ctx context.Context, in *IPSessionRedirectAddV2) (*IPSessionRedirectAddV2Reply, error) + IPSessionRedirectDel(ctx context.Context, in *IPSessionRedirectDel) (*IPSessionRedirectDelReply, error) +} + +type serviceClient struct { + conn api.Connection +} + +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} +} + +func (c *serviceClient) IPSessionRedirectAdd(ctx context.Context, in *IPSessionRedirectAdd) (*IPSessionRedirectAddReply, error) { + out := new(IPSessionRedirectAddReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPSessionRedirectAddV2(ctx context.Context, in *IPSessionRedirectAddV2) (*IPSessionRedirectAddV2Reply, error) { + out := new(IPSessionRedirectAddV2Reply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} + +func (c *serviceClient) IPSessionRedirectDel(ctx context.Context, in *IPSessionRedirectDel) (*IPSessionRedirectDelReply, error) { + out := new(IPSessionRedirectDelReply) + err := c.conn.Invoke(ctx, in, out) + if err != nil { + return nil, err + } + return out, api.RetvalToVPPApiError(out.Retval) +} diff --git a/vpplink/generated/gen.go b/vpplink/generated/gen.go index 916ab60c..20cd0237 100644 --- a/vpplink/generated/gen.go +++ b/vpplink/generated/gen.go @@ -8,4 +8,4 @@ import ( ) //go:generate go build -buildmode=plugin -o ./.bin/vpplink_plugin.so github.com/calico-vpp/vpplink/pkg -//go:generate go run go.fd.io/govpp/cmd/binapi-generator --no-version-info --no-source-path-info --gen rpc,./.bin/vpplink_plugin.so -o ./bindings --input $VPP_DIR ikev2 gso arp interface ip ipip ipsec ip_neighbor tapv2 nat44_ed cnat af_packet feature ip6_nd punt vxlan af_xdp vlib virtio avf wireguard capo memif acl abf crypto_sw_scheduler sr rdma vmxnet3 pbl memclnt session vpe urpf +//go:generate go run go.fd.io/govpp/cmd/binapi-generator --no-version-info --no-source-path-info --gen rpc,./.bin/vpplink_plugin.so -o ./bindings --input $VPP_DIR ikev2 gso arp interface ip ipip ipsec ip_neighbor tapv2 nat44_ed cnat af_packet feature ip6_nd punt vxlan af_xdp vlib virtio avf wireguard capo memif acl abf crypto_sw_scheduler sr rdma vmxnet3 pbl memclnt session vpe urpf classify ip_session_redirect diff --git a/vpplink/generated/generate.log b/vpplink/generated/generate.log index 93063473..7cc8602b 100755 --- a/vpplink/generated/generate.log +++ b/vpplink/generated/generate.log @@ -1,11 +1,13 @@ -VPP Version : 23.10-rc0~6-g892b7bce0 +VPP Version : 23.10-rc0~8-gb811f2187 Binapi-generator version : v0.8.0-dev -VPP Base commit : 03304d1c6 gerrit:34726/3 interface: add buffer stats api +VPP Base commit : 32203ce45 gerrit:34726/3 interface: add buffer stats api ------------------ Cherry picked commits -------------------- interface: Fix interface.api endianness capo: Calico Policies plugin acl: acl-plugin custom policies cnat: [WIP] no k8s maglev from pods pbl: Port based balancer +gerrit:39387/5 cnat: add host tag to bitmap in cnat snat +gerrit:31449/13 cnat: Support offloaded check sums gerrit:34726/3 interface: add buffer stats api ------------------------------------------------------------- diff --git a/vpplink/generated/vpp_clone_current.sh b/vpplink/generated/vpp_clone_current.sh index 0ac610a8..8dfbb434 100755 --- a/vpplink/generated/vpp_clone_current.sh +++ b/vpplink/generated/vpp_clone_current.sh @@ -96,6 +96,7 @@ git_clone_cd_and_reset "$1" a7dd04d73bf5abed944fb77a5e957bbad24e2750 # misc: Ini git_cherry_pick refs/changes/26/34726/3 # 34726: interface: add buffer stats api | https://gerrit.fd.io/r/c/vpp/+/34726 git_cherry_pick refs/changes/49/31449/13 # 31449: cnat: Support offloaded check sums | https://gerrit.fd.io/r/c/vpp/+/31449/13 +git_cherry_pick refs/changes/87/39387/5 # 39387: cnat: add host tag to bitmap in cnat snat | https://gerrit.fd.io/r/c/vpp/+/39387/2 # --------------- private plugins --------------- # Generated with 'git format-patch --zero-commit -o ./patches/ HEAD^^^' diff --git a/vpplink/redirect.go b/vpplink/redirect.go new file mode 100644 index 00000000..bbf3fba1 --- /dev/null +++ b/vpplink/redirect.go @@ -0,0 +1,66 @@ +// Copyright (C) 2023 Cisco Systems Inc. +// +// 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. + +package vpplink + +import ( + "fmt" + + fib_types "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/fib_types" + "github.com/projectcalico/vpp-dataplane/v3/vpplink/generated/bindings/ip_session_redirect" + "github.com/projectcalico/vpp-dataplane/v3/vpplink/types" +) + +func (v *VppLink) AddSessionRedirect(redirect *types.SessionRedirect, paths ...*types.RoutePath) (err error) { + client := ip_session_redirect.NewServiceClient(v.GetConnection()) + + fibPaths := make([]fib_types.FibPath, 0, len(paths)) + for _, routePath := range paths { + fibPaths = append(fibPaths, routePath.ToFibPath(false)) + } + match, err := redirect.GetMatch() + if err != nil { + return err + } + _, err = client.IPSessionRedirectAddV2(v.GetContext(), &ip_session_redirect.IPSessionRedirectAddV2{ + TableIndex: redirect.TableIndex, + MatchLen: uint8(len(match)), + Match: match, + NPaths: uint8(len(fibPaths)), + Paths: fibPaths, + }) + if err != nil { + return fmt.Errorf("failed to add ip session redirect: %w", err) + } + return nil +} + +func (v *VppLink) DelSessionRedirect(redirect *types.SessionRedirect) error { + client := ip_session_redirect.NewServiceClient(v.GetConnection()) + + match, err := redirect.GetMatch() + if err != nil { + return err + } + _, err = client.IPSessionRedirectDel(v.GetContext(), &ip_session_redirect.IPSessionRedirectDel{ + TableIndex: redirect.TableIndex, + MatchLen: uint8(len(match)), + Match: match, + }) + if err != nil { + return fmt.Errorf("failed to del ip session redirect: %w", err) + } + return nil +} diff --git a/vpplink/types/classify.go b/vpplink/types/classify.go new file mode 100644 index 00000000..a86c8786 --- /dev/null +++ b/vpplink/types/classify.go @@ -0,0 +1,374 @@ +// Copyright (C) 2023 Cisco Systems Inc. +// +// 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. + +package types + +import ( + "bytes" + "encoding/binary" + "fmt" + "net" + "net/netip" + "strings" +) + +const InvalidTableId = ^uint32(0) + +type IPv4Header struct { + VersionIHL uint8 + Tos uint8 + TotLen uint16 + Id uint16 + FragOff uint16 + Ttl uint8 + Protocol uint8 + Csum uint16 + Saddr [4]byte + Daddr [4]byte +} + +type UDPHeader struct { + Sport uint16 + Dport uint16 + Len uint16 + Csum uint16 +} + +type GeneveHeader struct { + VersionOptLen uint8 + Flags uint8 + ProtocolType uint16 + Vni uint32 + Options []byte +} + +func (h GeneveHeader) FixedBytes() []byte { + buf := make([]byte, 0, 8) + buf = append(buf, h.VersionOptLen, h.Flags) + buf = binary.BigEndian.AppendUint16(buf, h.ProtocolType) + buf = binary.BigEndian.AppendUint32(buf, h.Vni) + return buf +} + +type UDPv4Header struct { + IP IPv4Header + UDP UDPHeader +} + +func NewUDPv4Header(buffer []byte) (*UDPv4Header, error) { + udpHdr := UDPv4Header{} + reader := bytes.NewReader(buffer) + err := binary.Read(reader, binary.BigEndian, &udpHdr) + return &udpHdr, err +} + +func (h UDPv4Header) Bytes() ([]byte, error) { + var buf bytes.Buffer + err := binary.Write(&buf, binary.BigEndian, h) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +type GeneveV4Header struct { + UDPv4Header + GeneveHeader +} + +func (h GeneveV4Header) Bytes() ([]byte, error) { + var buf bytes.Buffer + err := binary.Write(&buf, binary.BigEndian, h.UDPv4Header) + if err != nil { + return nil, err + } + buf.Write(h.FixedBytes()) + buf.Write(h.Options) + return buf.Bytes(), nil +} + +type TCPPorts struct { + Sport uint16 + Dport uint16 +} + +type TCPv4Header struct { + IP IPv4Header + TCP TCPPorts +} + +func (h TCPv4Header) Bytes() ([]byte, error) { + var buf bytes.Buffer + err := binary.Write(&buf, binary.BigEndian, h) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +var ( + FiveTupleMask []byte + DstFourTupleMask []byte + DstThreeTupleMask []byte + SrcThreeTupleMask []byte + DstAddrMask []byte + SrcAddrMask []byte +) + +type DstThreeTuple struct { + Protocol IPProto + DstAddr netip.Addr + DstPort uint16 +} + +type FiveTuple struct { + Protocol IPProto + SrcAddr netip.Addr + SrcPort uint16 + DstAddr netip.Addr + DstPort uint16 +} + +func IPToAddr(a net.IP) netip.Addr { + if a == nil { + return netip.AddrFrom4([4]byte{0, 0, 0, 0}) + } + if a.To4() == nil { + addr, _ := netip.AddrFromSlice(a) + return addr + } + addr, _ := netip.AddrFromSlice(a) + return netip.AddrFrom4(addr.As4()) +} + +func New5Tuple(protocol IPProto, srcAddr net.IP, srcPort uint16, dstAddr net.IP, dstPort uint16) FiveTuple { + return FiveTuple{ + Protocol: protocol, + SrcPort: srcPort, DstPort: dstPort, + SrcAddr: IPToAddr(srcAddr), DstAddr: IPToAddr(dstAddr), + } +} + +func NewDst4Tuple(protocol IPProto, srcAddr net.IP, dstAddr net.IP, dstPort uint16) FiveTuple { + return New5Tuple(protocol, srcAddr, 0, dstAddr, dstPort) +} + +func NewDst3Tuple(protocol IPProto, dstAddr net.IP, dstPort uint16) FiveTuple { + return New5Tuple(protocol, net.IPv4zero, 0, dstAddr, dstPort) +} + +func NewSrc3Tuple(protocol IPProto, srcAddr net.IP, srcPort uint16) FiveTuple { + return New5Tuple(protocol, srcAddr, srcPort, net.IPv4zero, 0) +} + +func (tuple *FiveTuple) String() string { + return fmt.Sprintf("%s,%s:%d->%s:%d", tuple.Protocol.String(), + tuple.SrcAddr, tuple.SrcPort, tuple.DstAddr, tuple.DstPort) +} + +func (tuple *FiveTuple) GetMatch() ([]byte, error) { + var match UDPv4Header + match.IP.Protocol = uint8(tuple.Protocol) + match.IP.Saddr = tuple.SrcAddr.As4() + match.IP.Daddr = tuple.DstAddr.As4() + match.UDP.Sport = tuple.SrcPort + match.UDP.Dport = tuple.DstPort + matchBytes, err := match.Bytes() + if err != nil { + return nil, err + } + return matchBytes, nil +} + +func (tuple *FiveTuple) GetMask() ([]byte, error) { + var mask UDPv4Header + + if tuple.Protocol != IPProto(0) { + mask.IP.Protocol = 0xff + } + if !tuple.SrcAddr.IsUnspecified() && tuple.SrcAddr.IsValid() { + mask.IP.Saddr = [4]byte{0xff, 0xff, 0xff, 0xff} + } + if tuple.SrcPort != 0 { + mask.UDP.Sport = 0xffff + } + if !tuple.DstAddr.IsUnspecified() && tuple.DstAddr.IsValid() { + mask.IP.Daddr = [4]byte{0xff, 0xff, 0xff, 0xff} + } + if tuple.DstPort != 0 { + mask.UDP.Dport = 0xffff + } + maskBytes, err := mask.Bytes() + if err != nil { + return nil, err + } + return maskBytes, nil +} + +func (tuple *FiveTuple) GetBPF() string { + expressions := make([]string, 0, 4) + if !tuple.SrcAddr.IsUnspecified() && tuple.SrcAddr.IsValid() { + expressions = append(expressions, fmt.Sprintf("src host %s", tuple.SrcAddr)) + } + if !tuple.DstAddr.IsUnspecified() && tuple.DstAddr.IsValid() { + expressions = append(expressions, fmt.Sprintf("dst host %s", tuple.DstAddr)) + } + if tuple.SrcPort != 0 { + expressions = append(expressions, fmt.Sprintf("src port %d", tuple.SrcPort)) + } + if tuple.DstPort != 0 { + expressions = append(expressions, fmt.Sprintf("dst port %d", tuple.DstPort)) + } + return strings.Join(expressions, " and ") +} + +func NewGeneveHeader(outerFiveTuple FiveTuple, vni uint32) GeneveV4Header { + return GeneveV4Header{ + UDPv4Header{ + IP: IPv4Header{Protocol: uint8(UDP), Saddr: outerFiveTuple.SrcAddr.As4(), Daddr: outerFiveTuple.DstAddr.As4()}, + UDP: UDPHeader{Sport: outerFiveTuple.SrcPort, Dport: outerFiveTuple.DstPort}, + }, + GeneveHeader{ + Vni: vni << 8, + }, + } +} + +func (gnv *GeneveV4Header) GetMatch() ([]byte, error) { + matchBytes, err := gnv.Bytes() + if err != nil { + return nil, err + } + return matchBytes, nil +} + +func (gnv *GeneveV4Header) GetMask() ([]byte, error) { + var mask GeneveV4Header + srcIP := netip.AddrFrom4(gnv.IP.Saddr) + dstIP := netip.AddrFrom4(gnv.IP.Daddr) + + if gnv.IP.Protocol != 0 { + mask.IP.Protocol = 0xff + } + if !srcIP.IsUnspecified() && srcIP.IsValid() { + mask.IP.Saddr = [4]byte{0xff, 0xff, 0xff, 0xff} + } + if gnv.UDP.Sport != 0 { + mask.UDP.Sport = 0xffff + } + if !dstIP.IsUnspecified() && dstIP.IsValid() { + mask.IP.Daddr = [4]byte{0xff, 0xff, 0xff, 0xff} + } + if gnv.UDP.Dport != 0 { + mask.UDP.Dport = 0xffff + } + // if vni != INVALID_ID<<8 + if gnv.Vni != 0xffffff00 { + mask.Vni = 0xffffff00 + } + maskBytes, err := mask.Bytes() + if err != nil { + return nil, err + } + return maskBytes, nil +} + +func init() { + var err error + FiveTupleMask, err = (UDPv4Header{ + IP: IPv4Header{ + Protocol: 0xff, + Saddr: [4]byte{0xff, 0xff, 0xff, 0xff}, + Daddr: [4]byte{0xff, 0xff, 0xff, 0xff}, + }, + UDP: UDPHeader{ + Sport: 0xffff, + Dport: 0xffff, + }, + }).Bytes() + if err != nil { + panic(err) + } + + DstFourTupleMask, err = (UDPv4Header{ + IP: IPv4Header{ + Protocol: 0xff, + Saddr: [4]byte{0xff, 0xff, 0xff, 0xff}, + Daddr: [4]byte{0xff, 0xff, 0xff, 0xff}, + }, + UDP: UDPHeader{ + Dport: 0xffff, + }, + }).Bytes() + if err != nil { + panic(err) + } + + DstThreeTupleMask, err = (UDPv4Header{ + IP: IPv4Header{Protocol: 0xff, Daddr: [4]byte{0xff, 0xff, 0xff, 0xff}}, + UDP: UDPHeader{Dport: 0xffff}, + }).Bytes() + if err != nil { + panic(err) + } + + SrcThreeTupleMask, err = (UDPv4Header{ + IP: IPv4Header{Protocol: 0xff, Saddr: [4]byte{0xff, 0xff, 0xff, 0xff}}, + UDP: UDPHeader{Sport: 0xffff}, + }).Bytes() + if err != nil { + panic(err) + } + + DstAddrMask, err = (UDPv4Header{ + IP: IPv4Header{Daddr: [4]byte{0xff, 0xff, 0xff, 0xff}}, + }).Bytes() + if err != nil { + panic(err) + } + + SrcAddrMask, err = (UDPv4Header{ + IP: IPv4Header{Saddr: [4]byte{0xff, 0xff, 0xff, 0xff}}, + }).Bytes() + if err != nil { + panic(err) + } +} + +type ClassifyAction int + +const ( + AddAbsolute ClassifyAction = iota + AddRelative + Del + DelChain +) + +const ( + VectorSize = 16 +) + +type ClassifyTable struct { + TableIndex uint32 + NBuckets uint32 + MaxNumEntries uint32 + MatchNVectors uint32 + SkipNVectors uint32 + NextTableIndex uint32 + MissNextIndex uint32 + Mask []byte + MemorySize uint32 + CurrentDataOffset int16 +} diff --git a/vpplink/types/ip_types.go b/vpplink/types/ip_types.go index 75134026..20610dd8 100644 --- a/vpplink/types/ip_types.go +++ b/vpplink/types/ip_types.go @@ -37,6 +37,18 @@ const ( INVALID IPProto = IPProto(ip_types.IP_API_PROTO_RESERVED) ) +func (mode *IPProto) UnmarshalText(text []byte) error { + switch string(text) { + case "tcp": + *mode = TCP + case "udp": + *mode = UDP + default: + *mode = TCP + } + return nil +} + type IPFlowHash uint8 const ( diff --git a/vpplink/types/redirect.go b/vpplink/types/redirect.go new file mode 100644 index 00000000..78727820 --- /dev/null +++ b/vpplink/types/redirect.go @@ -0,0 +1,39 @@ +// Copyright (C) 2022 Cisco Systems Inc. +// +// 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. + +package types + +import ( + "fmt" +) + +type SessionRedirect struct { + FiveTuple + TableIndex uint32 + IsPunt bool + OpaqueIndex uint32 +} + +func (sr *SessionRedirect) String() string { + return fmt.Sprintf("[tbl:%d %s]", sr.TableIndex, sr.FiveTuple.String()) +} + +func (sr *SessionRedirect) VppString() string { + match, err := sr.GetMatch() + if err != nil { + return "" + } + return fmt.Sprintf("%x", match) +} diff --git a/yaml/overlays/dev/kustomize.sh b/yaml/overlays/dev/kustomize.sh index 172187a3..57c1c2d8 100755 --- a/yaml/overlays/dev/kustomize.sh +++ b/yaml/overlays/dev/kustomize.sh @@ -112,7 +112,14 @@ function get_initial_config () echo "{ \"vppStartupSleepSeconds\": ${CALICOVPP_VPP_STARTUP_SLEEP:-0}, \"corePattern\": \"${CALICOVPP_CORE_PATTERN:-/var/lib/vpp/vppcore.%e.%p}\", - \"defaultGWs\": \"${CALICOVPP_DEFAULT_GW}\" + \"defaultGWs\": \"${CALICOVPP_DEFAULT_GW}\", + \"redirectToHostRules\": [ + { + \"proto\": \"${CALICOVPP_REDIRECT_PROTO:-udp}\", + \"port\": ${CALICOVPP_REDIRECT_PORT:-53}, + \"ip\": \"${CALICOVPP_REDIRECT_IP:-172.18.0.1}\" + } + ] }" }