From 24927c823cdefb91b14e50521d9f92df07f7e80c Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Thu, 4 Jul 2019 11:08:57 +0200 Subject: [PATCH 1/9] update abf plugin Signed-off-by: Vladimir Lavor --- .../vppcalls/vpp1908/abf_vppcalls.go | 56 ++- .../vppcalls/vpp1908/abf_vppcalls_test.go | 8 +- .../vppcalls/vpp1908/dump_abf_vppcalls.go | 24 +- plugins/vpp/binapi/vpp1908/abf/abf.ba.go | 331 ++++++++++++++++-- 4 files changed, 369 insertions(+), 50 deletions(-) diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go index 00026a9ecb..d177dae455 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go @@ -24,6 +24,16 @@ import ( "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/abf" ) +const ( + // NextHopViaLabelUnset constant has to be assigned into the field next hop via label + // in abf_policy_add_del binary message if next hop via label is not defined. + NextHopViaLabelUnset uint32 = 0xfffff + 1 + + // ClassifyTableIndexUnset is a default value for field classify_table_index + // in abf_policy_add_del binary message. + ClassifyTableIndexUnset = ^uint32(0) +) + // GetAbfVersion retrieves version of the VPP ABF plugin func (h *ABFVppHandler) GetAbfVersion() (ver string, err error) { req := &abf.AbfPluginGetVersion{} @@ -126,26 +136,46 @@ func (h *ABFVppHandler) toFibPaths(abfPaths []*vpp_abf.ABF_ForwardingPath) (fibP SwIfIndex: ifData.SwIfIndex, Weight: uint8(abfPath.Weight), Preference: uint8(abfPath.Preference), - IsDvr: boolToUint(abfPath.Dvr), - } - - // next hop IP - nextHop := net.ParseIP(abfPath.NextHopIp) - if nextHop.To4() == nil { - nextHop = nextHop.To16() - fibPath.Afi = 1 - } else { - nextHop = nextHop.To4() - fibPath.Afi = 0 + Type: setFibPathType(abfPath.Dvr), } - fibPath.NextHop = nextHop - + fibPath.Nh, fibPath.Proto = setFibPathNhAndProto(abfPath.NextHopIp) fibPaths = append(fibPaths, fibPath) } return fibPaths } +// supported cases are DVR and normal +func setFibPathType(isDvr bool) abf.FibPathType { + if isDvr { + return abf.FIB_API_PATH_TYPE_DVR + } + return abf.FIB_API_PATH_TYPE_NORMAL +} + +// resolve IP address and return FIB path next hop (IP address) and IPv4/IPv6 version +func setFibPathNhAndProto(ipStr string) (nh abf.FibPathNh, proto abf.FibPathNhProto) { + netIP := net.ParseIP(ipStr) + if netIP == nil { + return + } + var ipData [16]byte + if netIP.To4() == nil { + proto = abf.FIB_API_PATH_NH_PROTO_IP6 + copy(ipData[:], netIP[:]) + } else { + proto = abf.FIB_API_PATH_NH_PROTO_IP4 + copy(ipData[:], netIP[12:]) + } + return abf.FibPathNh{ + Address: abf.AddressUnion{ + XXX_UnionData: ipData, + }, + ViaLabel: NextHopViaLabelUnset, + ClassifyTableIndex: ClassifyTableIndexUnset, + }, proto +} + func boolToUint(input bool) uint8 { if input { return 1 diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go index bc315416c0..ed37096cfc 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go @@ -75,9 +75,9 @@ func TestAddABFPolicy(t *testing.T) { Expect(req.Policy.ACLIndex).To(Equal(uint32(2))) Expect(req.Policy.NPaths).To(Equal(uint8(2))) Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5))) - Expect(req.Policy.Paths[0].NextHop[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) + Expect(req.Policy.Paths[0].Nh.Address.XXX_UnionData[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10))) - Expect(req.Policy.Paths[1].NextHop).To(BeEquivalentTo(net.ParseIP("ffff::").To16())) + Expect(req.Policy.Paths[1].Nh.Address.XXX_UnionData[:]).To(BeEquivalentTo(net.ParseIP("ffff::").To16())) } func TestAddABFPolicyError(t *testing.T) { @@ -124,9 +124,9 @@ func TestDeleteABFPolicy(t *testing.T) { Expect(req.Policy.PolicyID).To(Equal(uint32(1))) Expect(req.Policy.NPaths).To(Equal(uint8(2))) Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5))) - Expect(req.Policy.Paths[0].NextHop[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) + Expect(req.Policy.Paths[0].Nh.Address.XXX_UnionData[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10))) - Expect(req.Policy.Paths[1].NextHop).To(BeEquivalentTo(net.ParseIP("ffff::").To16())) + Expect(req.Policy.Paths[1].Nh.Address.XXX_UnionData[:]).To(BeEquivalentTo(net.ParseIP("ffff::").To16())) } func TestDeleteABFPolicyError(t *testing.T) { diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go index 95f2b7a252..1b998f95c1 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go @@ -122,13 +122,12 @@ func (h *ABFVppHandler) dumpABFPolicy() ([]*vppcalls.ABFDetails, error) { // base fields fwdPath := &vpp_abf.ABF_ForwardingPath{ - NextHopIp: parseNextHopToString(path.NextHop, path.Afi), + NextHopIp: parseNextHopToString(path.Nh, path.Proto), InterfaceName: ifName, Weight: uint32(path.Weight), Preference: uint32(path.Preference), - Dvr: uintToBool(path.IsDvr), + Dvr: isDvr(path.Type), } - fwdPaths = append(fwdPaths, fwdPath) } @@ -149,19 +148,28 @@ func (h *ABFVppHandler) dumpABFPolicy() ([]*vppcalls.ABFDetails, error) { return abfs, nil } -// Parses IP address to string. IP version is read from 'afi' where 1==IPv4 and 2==IPv6 -func parseNextHopToString(nh []byte, IPv uint8) string { - var nhIP net.IP = nh - if IPv == 1 { +// returns next hop IP address +func parseNextHopToString(nh abf.FibPathNh, proto abf.FibPathNhProto) string { + var nhIP net.IP = make([]byte, 16) + copy(nhIP[:], nh.Address.XXX_UnionData[:]) + if proto == abf.FIB_API_PATH_NH_PROTO_IP4 { return nhIP[:4].To4().String() } - if IPv == 2 { + if proto == abf.FIB_API_PATH_NH_PROTO_IP6 { return nhIP.To16().String() } return "" } +// abf fib currently supports only DVR or normal mode +func isDvr(pathType abf.FibPathType) (isDvr bool) { + if pathType == abf.FIB_API_PATH_TYPE_DVR { + return true + } + return false +} + func uintToBool(value uint8) bool { if value == 0 { return false diff --git a/plugins/vpp/binapi/vpp1908/abf/abf.ba.go b/plugins/vpp/binapi/vpp1908/abf/abf.ba.go index fcaa3ebc9c..af524a4b68 100644 --- a/plugins/vpp/binapi/vpp1908/abf/abf.ba.go +++ b/plugins/vpp/binapi/vpp1908/abf/abf.ba.go @@ -5,7 +5,10 @@ Package abf is a generated VPP binary API for 'abf' module. It consists of: - 4 types + 5 enums + 2 aliases + 10 types + 1 union 10 messages 5 services */ @@ -26,9 +29,190 @@ const ( // APIVersion is the API version of this module. APIVersion = "1.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x4caa3a59 + VersionCrc = 0x25b8fffd ) +// AddressFamily represents VPP binary API enum 'address_family'. +type AddressFamily uint32 + +const ( + ADDRESS_IP4 AddressFamily = 0 + ADDRESS_IP6 AddressFamily = 1 +) + +var AddressFamily_name = map[uint32]string{ + 0: "ADDRESS_IP4", + 1: "ADDRESS_IP6", +} + +var AddressFamily_value = map[string]uint32{ + "ADDRESS_IP4": 0, + "ADDRESS_IP6": 1, +} + +func (x AddressFamily) String() string { + s, ok := AddressFamily_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// FibPathFlags represents VPP binary API enum 'fib_path_flags'. +type FibPathFlags uint32 + +const ( + FIB_API_PATH_FLAG_NONE FibPathFlags = 0 + FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED FibPathFlags = 1 + FIB_API_PATH_FLAG_RESOLVE_VIA_HOST FibPathFlags = 2 +) + +var FibPathFlags_name = map[uint32]string{ + 0: "FIB_API_PATH_FLAG_NONE", + 1: "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED", + 2: "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST", +} + +var FibPathFlags_value = map[string]uint32{ + "FIB_API_PATH_FLAG_NONE": 0, + "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED": 1, + "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST": 2, +} + +func (x FibPathFlags) String() string { + s, ok := FibPathFlags_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'. +type FibPathNhProto uint32 + +const ( + FIB_API_PATH_NH_PROTO_IP4 FibPathNhProto = 0 + FIB_API_PATH_NH_PROTO_IP6 FibPathNhProto = 1 + FIB_API_PATH_NH_PROTO_MPLS FibPathNhProto = 2 + FIB_API_PATH_NH_PROTO_ETHERNET FibPathNhProto = 3 + FIB_API_PATH_NH_PROTO_BIER FibPathNhProto = 4 +) + +var FibPathNhProto_name = map[uint32]string{ + 0: "FIB_API_PATH_NH_PROTO_IP4", + 1: "FIB_API_PATH_NH_PROTO_IP6", + 2: "FIB_API_PATH_NH_PROTO_MPLS", + 3: "FIB_API_PATH_NH_PROTO_ETHERNET", + 4: "FIB_API_PATH_NH_PROTO_BIER", +} + +var FibPathNhProto_value = map[string]uint32{ + "FIB_API_PATH_NH_PROTO_IP4": 0, + "FIB_API_PATH_NH_PROTO_IP6": 1, + "FIB_API_PATH_NH_PROTO_MPLS": 2, + "FIB_API_PATH_NH_PROTO_ETHERNET": 3, + "FIB_API_PATH_NH_PROTO_BIER": 4, +} + +func (x FibPathNhProto) String() string { + s, ok := FibPathNhProto_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// FibPathType represents VPP binary API enum 'fib_path_type'. +type FibPathType uint32 + +const ( + FIB_API_PATH_TYPE_NORMAL FibPathType = 0 + FIB_API_PATH_TYPE_LOCAL FibPathType = 1 + FIB_API_PATH_TYPE_DROP FibPathType = 2 + FIB_API_PATH_TYPE_UDP_ENCAP FibPathType = 3 + FIB_API_PATH_TYPE_BIER_IMP FibPathType = 4 + FIB_API_PATH_TYPE_ICMP_UNREACH FibPathType = 5 + FIB_API_PATH_TYPE_ICMP_PROHIBIT FibPathType = 6 + FIB_API_PATH_TYPE_SOURCE_LOOKUP FibPathType = 7 + FIB_API_PATH_TYPE_DVR FibPathType = 8 + FIB_API_PATH_TYPE_INTERFACE_RX FibPathType = 9 + FIB_API_PATH_TYPE_CLASSIFY FibPathType = 10 +) + +var FibPathType_name = map[uint32]string{ + 0: "FIB_API_PATH_TYPE_NORMAL", + 1: "FIB_API_PATH_TYPE_LOCAL", + 2: "FIB_API_PATH_TYPE_DROP", + 3: "FIB_API_PATH_TYPE_UDP_ENCAP", + 4: "FIB_API_PATH_TYPE_BIER_IMP", + 5: "FIB_API_PATH_TYPE_ICMP_UNREACH", + 6: "FIB_API_PATH_TYPE_ICMP_PROHIBIT", + 7: "FIB_API_PATH_TYPE_SOURCE_LOOKUP", + 8: "FIB_API_PATH_TYPE_DVR", + 9: "FIB_API_PATH_TYPE_INTERFACE_RX", + 10: "FIB_API_PATH_TYPE_CLASSIFY", +} + +var FibPathType_value = map[string]uint32{ + "FIB_API_PATH_TYPE_NORMAL": 0, + "FIB_API_PATH_TYPE_LOCAL": 1, + "FIB_API_PATH_TYPE_DROP": 2, + "FIB_API_PATH_TYPE_UDP_ENCAP": 3, + "FIB_API_PATH_TYPE_BIER_IMP": 4, + "FIB_API_PATH_TYPE_ICMP_UNREACH": 5, + "FIB_API_PATH_TYPE_ICMP_PROHIBIT": 6, + "FIB_API_PATH_TYPE_SOURCE_LOOKUP": 7, + "FIB_API_PATH_TYPE_DVR": 8, + "FIB_API_PATH_TYPE_INTERFACE_RX": 9, + "FIB_API_PATH_TYPE_CLASSIFY": 10, +} + +func (x FibPathType) String() string { + s, ok := FibPathType_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// IPProto represents VPP binary API enum 'ip_proto'. +type IPProto uint32 + +const ( + IP_API_PROTO_TCP IPProto = 6 + IP_API_PROTO_UDP IPProto = 17 + IP_API_PROTO_EIGRP IPProto = 88 + IP_API_PROTO_OSPF IPProto = 89 +) + +var IPProto_name = map[uint32]string{ + 6: "IP_API_PROTO_TCP", + 17: "IP_API_PROTO_UDP", + 88: "IP_API_PROTO_EIGRP", + 89: "IP_API_PROTO_OSPF", +} + +var IPProto_value = map[string]uint32{ + "IP_API_PROTO_TCP": 6, + "IP_API_PROTO_UDP": 17, + "IP_API_PROTO_EIGRP": 88, + "IP_API_PROTO_OSPF": 89, +} + +func (x IPProto) String() string { + s, ok := IPProto_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// IP4Address represents VPP binary API alias 'ip4_address'. +type IP4Address [4]uint8 + +// IP6Address represents VPP binary API alias 'ip6_address'. +type IP6Address [16]uint8 + // AbfItfAttach represents VPP binary API type 'abf_itf_attach'. type AbfItfAttach struct { PolicyID uint32 @@ -53,6 +237,16 @@ func (*AbfPolicy) GetTypeName() string { return "abf_policy" } +// Address represents VPP binary API type 'address'. +type Address struct { + Af AddressFamily + Un AddressUnion +} + +func (*Address) GetTypeName() string { + return "address" +} + // FibMplsLabel represents VPP binary API type 'fib_mpls_label'. type FibMplsLabel struct { IsUniform uint8 @@ -67,33 +261,120 @@ func (*FibMplsLabel) GetTypeName() string { // FibPath represents VPP binary API type 'fib_path'. type FibPath struct { - SwIfIndex uint32 - TableID uint32 - Weight uint8 - Preference uint8 - IsLocal uint8 - IsDrop uint8 - IsUDPEncap uint8 - IsUnreach uint8 - IsProhibit uint8 - IsResolveHost uint8 - IsResolveAttached uint8 - IsDvr uint8 - IsSourceLookup uint8 - IsInterfaceRx uint8 - Afi uint8 - NextHop []byte `struc:"[16]byte"` - NextHopID uint32 - RpfID uint32 - ViaLabel uint32 - NLabels uint8 `struc:"sizeof=LabelStack"` // MANUALLY FIXED - LabelStack []FibMplsLabel + SwIfIndex uint32 + TableID uint32 + RpfID uint32 + Weight uint8 + Preference uint8 + Type FibPathType + Flags FibPathFlags + Proto FibPathNhProto + Nh FibPathNh + NLabels uint8 `struc:"sizeof=LabelStack"` // MANUALLY FIXED + LabelStack []FibMplsLabel } func (*FibPath) GetTypeName() string { return "fib_path" } +// FibPathNh represents VPP binary API type 'fib_path_nh'. +type FibPathNh struct { + Address AddressUnion + ViaLabel uint32 + ObjID uint32 + ClassifyTableIndex uint32 +} + +func (*FibPathNh) GetTypeName() string { + return "fib_path_nh" +} + +// IP4Prefix represents VPP binary API type 'ip4_prefix'. +type IP4Prefix struct { + Address IP4Address + Len uint8 +} + +func (*IP4Prefix) GetTypeName() string { + return "ip4_prefix" +} + +// IP6Prefix represents VPP binary API type 'ip6_prefix'. +type IP6Prefix struct { + Address IP6Address + Len uint8 +} + +func (*IP6Prefix) GetTypeName() string { + return "ip6_prefix" +} + +// Mprefix represents VPP binary API type 'mprefix'. +type Mprefix struct { + Af AddressFamily + GrpAddressLength uint16 + GrpAddress AddressUnion + SrcAddress AddressUnion +} + +func (*Mprefix) GetTypeName() string { + return "mprefix" +} + +// Prefix represents VPP binary API type 'prefix'. +type Prefix struct { + Address Address + Len uint8 +} + +func (*Prefix) GetTypeName() string { + return "prefix" +} + +// AddressUnion represents VPP binary API union 'address_union'. +type AddressUnion struct { + XXX_UnionData [16]byte +} + +func (*AddressUnion) GetTypeName() string { + return "address_union" +} + +func AddressUnionIP4(a IP4Address) (u AddressUnion) { + u.SetIP4(a) + return +} +func (u *AddressUnion) SetIP4(a IP4Address) { + var b = new(bytes.Buffer) + if err := struc.Pack(b, &a); err != nil { + return + } + copy(u.XXX_UnionData[:], b.Bytes()) +} +func (u *AddressUnion) GetIP4() (a IP4Address) { + var b = bytes.NewReader(u.XXX_UnionData[:]) + struc.Unpack(b, &a) + return +} + +func AddressUnionIP6(a IP6Address) (u AddressUnion) { + u.SetIP6(a) + return +} +func (u *AddressUnion) SetIP6(a IP6Address) { + var b = new(bytes.Buffer) + if err := struc.Pack(b, &a); err != nil { + return + } + copy(u.XXX_UnionData[:], b.Bytes()) +} +func (u *AddressUnion) GetIP6() (a IP6Address) { + var b = bytes.NewReader(u.XXX_UnionData[:]) + struc.Unpack(b, &a) + return +} + // AbfItfAttachAddDel represents VPP binary API message 'abf_itf_attach_add_del'. type AbfItfAttachAddDel struct { IsAdd uint8 @@ -192,7 +473,7 @@ func (*AbfPolicyAddDel) GetMessageName() string { return "abf_policy_add_del" } func (*AbfPolicyAddDel) GetCrcString() string { - return "60e0b539" + return "60b0000b" } func (*AbfPolicyAddDel) GetMessageType() api.MessageType { return api.RequestMessage @@ -222,7 +503,7 @@ func (*AbfPolicyDetails) GetMessageName() string { return "abf_policy_details" } func (*AbfPolicyDetails) GetCrcString() string { - return "0106eebd" + return "ed2091e2" } func (*AbfPolicyDetails) GetMessageType() api.MessageType { return api.ReplyMessage From a6823b058a405ebe3f3b588165c1130f09652fe5 Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Thu, 4 Jul 2019 11:11:52 +0200 Subject: [PATCH 2/9] update interface plugin Signed-off-by: Vladimir Lavor --- .../vppcalls/vpp1908/dump_interface_vppcalls.go | 8 +++++--- .../vppcalls/vpp1908/ip_container_vppcalls.go | 2 +- .../vpp1908/ip_container_vppcalls_test.go | 16 ++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go index 3d2edc6734..67bd9e53cb 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp1908/dump_interface_vppcalls.go @@ -426,10 +426,12 @@ func (h *InterfaceVppHandler) processIPDetails(ifs map[uint32]*vppcalls.Interfac } var ipAddr string - if ipDetails.IsIPv6 == 1 { - ipAddr = fmt.Sprintf("%s/%d", net.IP(ipDetails.IP).To16().String(), uint32(ipDetails.PrefixLength)) + ipByte := make([]byte, 16) + copy(ipByte[:], ipDetails.Prefix.Address.Un.XXX_UnionData[:]) + if ipDetails.Prefix.Address.Af == ip.ADDRESS_IP6 { + ipAddr = fmt.Sprintf("%s/%d", net.IP(ipByte).To16().String(), uint32(ipDetails.Prefix.Len)) } else { - ipAddr = fmt.Sprintf("%s/%d", net.IP(ipDetails.IP[:4]).To4().String(), uint32(ipDetails.PrefixLength)) + ipAddr = fmt.Sprintf("%s/%d", net.IP(ipByte[:4]).To4().String(), uint32(ipDetails.Prefix.Len)) } // skip IP addresses given by DHCP diff --git a/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls.go index f98beb3c56..4a3b4b0085 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls.go @@ -36,7 +36,7 @@ func (h *InterfaceVppHandler) sendAndLogMessageForVpp(ifIdx uint32, addr string, } prefix, _ := IPaddr.Mask.Size() - req.Pfx.AddressLength = byte(prefix) + req.Pfx.Len = byte(prefix) if isIPv6 { copy(req.Pfx.Address.Un.XXX_UnionData[:], IPaddr.IP.To16()) req.Pfx.Address.Af = ip.ADDRESS_IP6 diff --git a/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls_test.go index 0eadc0f87b..f070578ad0 100644 --- a/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls_test.go +++ b/plugins/vpp/ifplugin/vppcalls/vpp1908/ip_container_vppcalls_test.go @@ -44,8 +44,8 @@ func TestAddContainerIP(t *testing.T) { Expect(ok).To(BeTrue()) Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) Expect(vppMsg.Pfx).To(BeEquivalentTo(ip.Prefix{ - Address: ipToAddr("10.0.0.1"), - AddressLength: 24, + Address: ipToAddr("10.0.0.1"), + Len: 24, })) Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) } @@ -63,8 +63,8 @@ func TestAddContainerIPv6(t *testing.T) { Expect(ok).To(BeTrue()) Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) Expect(vppMsg.Pfx).To(BeEquivalentTo(ip.Prefix{ - Address: ipToAddr("2001:db8:0:1:1:1:1:1"), - AddressLength: 128, + Address: ipToAddr("2001:db8:0:1:1:1:1:1"), + Len: 128, })) Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) } @@ -117,8 +117,8 @@ func TestDelContainerIP(t *testing.T) { Expect(ok).To(BeTrue()) Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) Expect(vppMsg.Pfx).To(BeEquivalentTo(ip.Prefix{ - Address: ipToAddr("10.0.0.1"), - AddressLength: 24, + Address: ipToAddr("10.0.0.1"), + Len: 24, })) Expect(vppMsg.IsAdd).To(BeEquivalentTo(0)) } @@ -136,8 +136,8 @@ func TestDelContainerIPv6(t *testing.T) { Expect(ok).To(BeTrue()) Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) Expect(vppMsg.Pfx).To(BeEquivalentTo(ip.Prefix{ - Address: ipToAddr("2001:db8:0:1:1:1:1:1"), - AddressLength: 128, + Address: ipToAddr("2001:db8:0:1:1:1:1:1"), + Len: 128, })) Expect(vppMsg.IsAdd).To(BeEquivalentTo(0)) } From 959e804806d0627d9c7076b5b35c5ae31d7415d2 Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Thu, 4 Jul 2019 11:17:34 +0200 Subject: [PATCH 3/9] update l2 plugin Signed-off-by: Vladimir Lavor --- plugins/vpp/binapi/vpp1908/l2/l2.ba.go | 40 ++++++++------ .../vppcalls/vpp1908/arp_term_vppcalls.go | 19 ++++--- .../vpp1908/arp_term_vppcalls_test.go | 54 ++++++++++--------- .../vppcalls/vpp1908/dump_vppcalls.go | 25 ++++----- .../vppcalls/vpp1908/dump_vppcalls_test.go | 14 +++-- 5 files changed, 87 insertions(+), 65 deletions(-) diff --git a/plugins/vpp/binapi/vpp1908/l2/l2.ba.go b/plugins/vpp/binapi/vpp1908/l2/l2.ba.go index ee4f11cb9a..0cfa914515 100644 --- a/plugins/vpp/binapi/vpp1908/l2/l2.ba.go +++ b/plugins/vpp/binapi/vpp1908/l2/l2.ba.go @@ -7,7 +7,7 @@ Package l2 is a generated VPP binary API for 'l2' module. It consists of: 4 enums 3 aliases - 7 types + 8 types 1 union 51 messages 25 services @@ -29,7 +29,7 @@ const ( // APIVersion is the API version of this module. APIVersion = "2.2.2" // VersionCrc is the CRC of this module. - VersionCrc = 0x44c328e8 + VersionCrc = 0xbaafc7be ) // AddressFamily represents VPP binary API enum 'address_family'. @@ -179,6 +179,17 @@ func (*Address) GetTypeName() string { return "address" } +// BdIPMac represents VPP binary API type 'bd_ip_mac'. +type BdIPMac struct { + BdID uint32 + IP Address + Mac MacAddress +} + +func (*BdIPMac) GetTypeName() string { + return "bd_ip_mac" +} + // BridgeDomainSwIf represents VPP binary API type 'bridge_domain_sw_if'. type BridgeDomainSwIf struct { Context uint32 @@ -192,8 +203,8 @@ func (*BridgeDomainSwIf) GetTypeName() string { // IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { - Prefix IP4Address - Len uint8 + Address IP4Address + Len uint8 } func (*IP4Prefix) GetTypeName() string { @@ -202,8 +213,8 @@ func (*IP4Prefix) GetTypeName() string { // IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { - Prefix IP6Address - Len uint8 + Address IP6Address + Len uint8 } func (*IP6Prefix) GetTypeName() string { @@ -236,8 +247,8 @@ func (*Mprefix) GetTypeName() string { // Prefix represents VPP binary API type 'prefix'. type Prefix struct { - Address Address - AddressLength uint8 + Address Address + Len uint8 } func (*Prefix) GetTypeName() string { @@ -289,17 +300,15 @@ func (u *AddressUnion) GetIP6() (a IP6Address) { // BdIPMacAddDel represents VPP binary API message 'bd_ip_mac_add_del'. type BdIPMacAddDel struct { - BdID uint32 IsAdd uint8 - IP Address - Mac MacAddress + Entry BdIPMac } func (*BdIPMacAddDel) GetMessageName() string { return "bd_ip_mac_add_del" } func (*BdIPMacAddDel) GetCrcString() string { - return "1aabd078" + return "97367ad1" } func (*BdIPMacAddDel) GetMessageType() api.MessageType { return api.RequestMessage @@ -322,17 +331,14 @@ func (*BdIPMacAddDelReply) GetMessageType() api.MessageType { // BdIPMacDetails represents VPP binary API message 'bd_ip_mac_details'. type BdIPMacDetails struct { - BdID uint32 - IsIPv6 uint8 - IPAddress []byte `struc:"[16]byte"` - MacAddress MacAddress + Entry BdIPMac } func (*BdIPMacDetails) GetMessageName() string { return "bd_ip_mac_details" } func (*BdIPMacDetails) GetCrcString() string { - return "c05c27de" + return "3f1eb886" } func (*BdIPMacDetails) GetMessageType() api.MessageType { return api.ReplyMessage diff --git a/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls.go index b44b303977..6317efb4e3 100644 --- a/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls.go +++ b/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls.go @@ -21,20 +21,23 @@ import ( ) func (h *BridgeDomainVppHandler) callBdIPMacAddDel(isAdd bool, bdID uint32, mac string, ip string) error { - req := &l2ba.BdIPMacAddDel{ - BdID: bdID, - IsAdd: boolToUint(isAdd), + ipAddr, err := ipToAddress(ip) + if err != nil { + return err } - macAddr, err := net.ParseMAC(mac) if err != nil { return err } - copy(req.Mac[:], macAddr) + bdEntry := l2ba.BdIPMac{ + BdID: bdID, + IP: ipAddr, + } + copy(bdEntry.Mac[:], macAddr) - req.IP, err = ipToAddress(ip) - if err != nil { - return err + req := &l2ba.BdIPMacAddDel{ + IsAdd: boolToUint(isAdd), + Entry: bdEntry, } reply := &l2ba.BdIPMacAddDelReply{} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls_test.go index 7913068ab1..9ca53e8e12 100644 --- a/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls_test.go +++ b/plugins/vpp/l2plugin/vppcalls/vpp1908/arp_term_vppcalls_test.go @@ -32,15 +32,17 @@ func TestVppAddArpTerminationTableEntry(t *testing.T) { Expect(err).ShouldNot(HaveOccurred()) Expect(ctx.MockChannel.Msg).To(Equal(&l2ba.BdIPMacAddDel{ - BdID: 4, - IsAdd: 1, - IP: l2ba.Address{ - Af: l2ba.ADDRESS_IP4, - Un: l2ba.AddressUnionIP4( - l2ba.IP4Address{192, 168, 4, 4}, - ), + Entry: l2ba.BdIPMac{ + BdID: 4, + IP: l2ba.Address{ + Af: l2ba.ADDRESS_IP4, + Un: l2ba.AddressUnionIP4( + l2ba.IP4Address{192, 168, 4, 4}, + ), + }, + Mac: l2ba.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, }, - Mac: l2ba.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, + IsAdd: 1, })) } @@ -54,15 +56,17 @@ func TestVppAddArpTerminationTableEntryIPv6(t *testing.T) { Expect(err).ShouldNot(HaveOccurred()) Expect(ctx.MockChannel.Msg).To(Equal(&l2ba.BdIPMacAddDel{ - BdID: 4, - IsAdd: 1, - IP: l2ba.Address{ - Af: l2ba.ADDRESS_IP6, - Un: l2ba.AddressUnionIP6( - l2ba.IP6Address{32, 1, 13, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84}, - ), + Entry: l2ba.BdIPMac{ + BdID: 4, + IP: l2ba.Address{ + Af: l2ba.ADDRESS_IP6, + Un: l2ba.AddressUnionIP6( + l2ba.IP6Address{32, 1, 13, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84}, + ), + }, + Mac: l2ba.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, }, - Mac: l2ba.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, + IsAdd: 1, })) } @@ -76,15 +80,17 @@ func TestVppRemoveArpTerminationTableEntry(t *testing.T) { Expect(err).ShouldNot(HaveOccurred()) Expect(ctx.MockChannel.Msg).To(Equal(&l2ba.BdIPMacAddDel{ - BdID: 4, - IsAdd: 0, - IP: l2ba.Address{ - Af: l2ba.ADDRESS_IP4, - Un: l2ba.AddressUnionIP4( - l2ba.IP4Address{192, 168, 4, 4}, - ), + Entry: l2ba.BdIPMac{ + BdID: 4, + IP: l2ba.Address{ + Af: l2ba.ADDRESS_IP4, + Un: l2ba.AddressUnionIP4( + l2ba.IP4Address{192, 168, 4, 4}, + ), + }, + Mac: l2ba.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, }, - Mac: l2ba.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, + IsAdd: 0, })) } diff --git a/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls.go index 0d3d72bc02..f09a295b61 100644 --- a/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls.go +++ b/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls.go @@ -115,16 +115,11 @@ func (h *BridgeDomainVppHandler) dumpBridgeDomainMacTable() (map[uint32][]*l2nb. // Prepare ARP entry arpEntry := &l2nb.BridgeDomain_ArpTerminationEntry{} - var ipAddr net.IP = msg.IPAddress - if uintToBool(msg.IsIPv6) { - arpEntry.IpAddress = ipAddr.To16().String() - } else { - arpEntry.IpAddress = ipAddr[:4].To4().String() - } - arpEntry.PhysAddress = net.HardwareAddr(msg.MacAddress[:]).String() + arpEntry.IpAddress = parseAddressToString(msg.Entry.IP) + arpEntry.PhysAddress = net.HardwareAddr(msg.Entry.Mac[:]).String() // Add ARP entry to result map - bdArpTable[msg.BdID] = append(bdArpTable[msg.BdID], arpEntry) + bdArpTable[msg.Entry.BdID] = append(bdArpTable[msg.Entry.BdID], arpEntry) } return bdArpTable, nil @@ -234,9 +229,15 @@ func (h *XConnectVppHandler) DumpXConnectPairs() (map[uint32]*vppcalls.XConnectD return xpairs, nil } -func uintToBool(value uint8) bool { - if value == 0 { - return false +func parseAddressToString(address l2ba.Address) string { + var nhIP net.IP = make([]byte, 16) + copy(nhIP[:], address.Un.XXX_UnionData[:]) + if address.Af == l2ba.ADDRESS_IP4 { + return nhIP[:4].To4().String() } - return true + if address.Af == l2ba.ADDRESS_IP6 { + return nhIP.To16().String() + } + + return "" } diff --git a/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls_test.go index 5e4ec87bc0..1c00012f96 100644 --- a/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls_test.go +++ b/plugins/vpp/l2plugin/vppcalls/vpp1908/dump_vppcalls_test.go @@ -143,10 +143,16 @@ func TestDumpBridgeDomainsWithARP(t *testing.T) { Name: (&l2ba.BdIPMacDump{}).GetMessageName(), Ping: true, Message: &l2ba.BdIPMacDetails{ - BdID: 5, - IsIPv6: 0, - IPAddress: []byte{192, 168, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - MacAddress: l2ba.MacAddress{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}, + Entry: l2ba.BdIPMac{ + BdID: 5, + IP: l2ba.Address{ + Af: l2ba.ADDRESS_IP4, + Un: l2ba.AddressUnionIP4( + l2ba.IP4Address{192, 168, 0, 1}, + ), + }, + Mac: l2ba.MacAddress{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}, + }, }, }, { From c2aefc1f3b94b6795920b08df1b913bffc100d2a Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Thu, 4 Jul 2019 14:26:09 +0200 Subject: [PATCH 4/9] update L3 plugin Signed-off-by: Vladimir Lavor --- cmd/vpp-agent-ctl/data/ifplugin.go | 1 + cmd/vpp-agent-ctl/data/l3plugins.go | 25 + cmd/vpp-agent-ctl/main.go | 4 + plugins/vpp/binapi/vpp1908/ip/ip.ba.go | 896 +++++++++++------- plugins/vpp/binapi/vpp1908/ipsec/ipsec.ba.go | 186 +++- plugins/vpp/binapi/vpp1908/nat/nat.ba.go | 18 +- plugins/vpp/binapi/vpp1908/punt/punt.ba.go | 14 +- plugins/vpp/binapi/vpp1908/tapv2/tapv2.ba.go | 11 +- .../l3plugin/vppcalls/vpp1908/route_dump.go | 98 +- .../vppcalls/vpp1908/route_dump_test.go | 41 +- .../vppcalls/vpp1908/route_vppcalls.go | 115 ++- .../vppcalls/vpp1908/route_vppcalls_test.go | 10 +- .../vpp/l3plugin/vppcalls/vpp1908/vrf_dump.go | 52 +- .../vppcalls/vpp1908/vrf_dump_test.go | 48 +- .../l3plugin/vppcalls/vpp1908/vrf_vppcalls.go | 10 +- .../vppcalls/vpp1908/vrf_vppcalls_test.go | 38 +- vpp.env | 2 +- 17 files changed, 985 insertions(+), 584 deletions(-) diff --git a/cmd/vpp-agent-ctl/data/ifplugin.go b/cmd/vpp-agent-ctl/data/ifplugin.go index 27a4a00cf7..d61ec5f90c 100644 --- a/cmd/vpp-agent-ctl/data/ifplugin.go +++ b/cmd/vpp-agent-ctl/data/ifplugin.go @@ -110,6 +110,7 @@ func (ctl *VppAgentCtlImpl) PutTap() error { Link: &interfaces.Interface_Tap{ Tap: &interfaces.TapLink{ HostIfName: "tap-host", + Version: 2, }, }, } diff --git a/cmd/vpp-agent-ctl/data/l3plugins.go b/cmd/vpp-agent-ctl/data/l3plugins.go index 0d9cf1e572..763e279139 100644 --- a/cmd/vpp-agent-ctl/data/l3plugins.go +++ b/cmd/vpp-agent-ctl/data/l3plugins.go @@ -53,6 +53,10 @@ type L3Ctl interface { SetIPScanNeigh() error // UnsetIPScanNeigh removes VPP IP scan neighbor configuration from the ETCD UnsetIPScanNeigh() error + // PutVrf puts VPP VRF to the ETCD + PutVrf() error + // UnsetVrf removes VPP VRF configuration from the ETCD + DeleteVrf() error // CreateLinuxArp puts linux ARP entry configuration to the ETCD PutLinuxArp() error // DeleteLinuxArp removes Linux ARP entry configuration from the ETCD @@ -243,6 +247,27 @@ func (ctl *VppAgentCtlImpl) UnsetIPScanNeigh() error { return err } +// PutVrf puts VPP VRF to the ETCD +func (ctl *VppAgentCtlImpl) PutVrf() error { + vrf := &l3.VrfTable{ + Label: "vrf1", + Id: 1, + Protocol: l3.VrfTable_IPV4, + } + + ctl.Log.Info("VRF set") + return ctl.broker.Put(l3.VrfTableKey(vrf.Id, vrf.Protocol), vrf) +} + +// DeleteVrf removes VPP VRF configuration from the ETCD +func (ctl *VppAgentCtlImpl) DeleteVrf() error { + vrf := l3.VrfTableKey(1, l3.VrfTable_IPV4) + + ctl.Log.Info("VRF unset") + _, err := ctl.broker.Delete(vrf) + return err +} + // PutLinuxArp puts linux ARP entry configuration to the ETCD func (ctl *VppAgentCtlImpl) PutLinuxArp() error { linuxArp := &linuxL3.ARPEntry{ diff --git a/cmd/vpp-agent-ctl/main.go b/cmd/vpp-agent-ctl/main.go index d008c77059..d2bf41cdc4 100644 --- a/cmd/vpp-agent-ctl/main.go +++ b/cmd/vpp-agent-ctl/main.go @@ -207,6 +207,10 @@ func do(ctl data.VppAgentCtl) { err = ctl.SetIPScanNeigh() case "-ipscand": err = ctl.UnsetIPScanNeigh() + case "-vrf": + err = ctl.PutVrf() + case "-vrfd": + err = ctl.DeleteVrf() // Linux L3 plugin case "-lroute": err = ctl.PutLinuxRoute() diff --git a/plugins/vpp/binapi/vpp1908/ip/ip.ba.go b/plugins/vpp/binapi/vpp1908/ip/ip.ba.go index 4f2322984c..3426f811ba 100644 --- a/plugins/vpp/binapi/vpp1908/ip/ip.ba.go +++ b/plugins/vpp/binapi/vpp1908/ip/ip.ba.go @@ -5,12 +5,12 @@ Package ip is a generated VPP binary API for 'ip' module. It consists of: - 3 enums + 7 enums 3 aliases - 12 types + 16 types 1 union - 91 messages - 44 services + 93 messages + 45 services */ package ip @@ -27,9 +27,9 @@ const ( // ModuleName is the name of this module. ModuleName = "ip" // APIVersion is the API version of this module. - APIVersion = "2.0.1" + APIVersion = "3.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x75d994fe + VersionCrc = 0x66000d59 ) // AddressFamily represents VPP binary API enum 'address_family'. @@ -58,6 +58,123 @@ func (x AddressFamily) String() string { return strconv.Itoa(int(x)) } +// FibPathFlags represents VPP binary API enum 'fib_path_flags'. +type FibPathFlags uint32 + +const ( + FIB_API_PATH_FLAG_NONE FibPathFlags = 0 + FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED FibPathFlags = 1 + FIB_API_PATH_FLAG_RESOLVE_VIA_HOST FibPathFlags = 2 +) + +var FibPathFlags_name = map[uint32]string{ + 0: "FIB_API_PATH_FLAG_NONE", + 1: "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED", + 2: "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST", +} + +var FibPathFlags_value = map[string]uint32{ + "FIB_API_PATH_FLAG_NONE": 0, + "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED": 1, + "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST": 2, +} + +func (x FibPathFlags) String() string { + s, ok := FibPathFlags_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'. +type FibPathNhProto uint32 + +const ( + FIB_API_PATH_NH_PROTO_IP4 FibPathNhProto = 0 + FIB_API_PATH_NH_PROTO_IP6 FibPathNhProto = 1 + FIB_API_PATH_NH_PROTO_MPLS FibPathNhProto = 2 + FIB_API_PATH_NH_PROTO_ETHERNET FibPathNhProto = 3 + FIB_API_PATH_NH_PROTO_BIER FibPathNhProto = 4 +) + +var FibPathNhProto_name = map[uint32]string{ + 0: "FIB_API_PATH_NH_PROTO_IP4", + 1: "FIB_API_PATH_NH_PROTO_IP6", + 2: "FIB_API_PATH_NH_PROTO_MPLS", + 3: "FIB_API_PATH_NH_PROTO_ETHERNET", + 4: "FIB_API_PATH_NH_PROTO_BIER", +} + +var FibPathNhProto_value = map[string]uint32{ + "FIB_API_PATH_NH_PROTO_IP4": 0, + "FIB_API_PATH_NH_PROTO_IP6": 1, + "FIB_API_PATH_NH_PROTO_MPLS": 2, + "FIB_API_PATH_NH_PROTO_ETHERNET": 3, + "FIB_API_PATH_NH_PROTO_BIER": 4, +} + +func (x FibPathNhProto) String() string { + s, ok := FibPathNhProto_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + +// FibPathType represents VPP binary API enum 'fib_path_type'. +type FibPathType uint32 + +const ( + FIB_API_PATH_TYPE_NORMAL FibPathType = 0 + FIB_API_PATH_TYPE_LOCAL FibPathType = 1 + FIB_API_PATH_TYPE_DROP FibPathType = 2 + FIB_API_PATH_TYPE_UDP_ENCAP FibPathType = 3 + FIB_API_PATH_TYPE_BIER_IMP FibPathType = 4 + FIB_API_PATH_TYPE_ICMP_UNREACH FibPathType = 5 + FIB_API_PATH_TYPE_ICMP_PROHIBIT FibPathType = 6 + FIB_API_PATH_TYPE_SOURCE_LOOKUP FibPathType = 7 + FIB_API_PATH_TYPE_DVR FibPathType = 8 + FIB_API_PATH_TYPE_INTERFACE_RX FibPathType = 9 + FIB_API_PATH_TYPE_CLASSIFY FibPathType = 10 +) + +var FibPathType_name = map[uint32]string{ + 0: "FIB_API_PATH_TYPE_NORMAL", + 1: "FIB_API_PATH_TYPE_LOCAL", + 2: "FIB_API_PATH_TYPE_DROP", + 3: "FIB_API_PATH_TYPE_UDP_ENCAP", + 4: "FIB_API_PATH_TYPE_BIER_IMP", + 5: "FIB_API_PATH_TYPE_ICMP_UNREACH", + 6: "FIB_API_PATH_TYPE_ICMP_PROHIBIT", + 7: "FIB_API_PATH_TYPE_SOURCE_LOOKUP", + 8: "FIB_API_PATH_TYPE_DVR", + 9: "FIB_API_PATH_TYPE_INTERFACE_RX", + 10: "FIB_API_PATH_TYPE_CLASSIFY", +} + +var FibPathType_value = map[string]uint32{ + "FIB_API_PATH_TYPE_NORMAL": 0, + "FIB_API_PATH_TYPE_LOCAL": 1, + "FIB_API_PATH_TYPE_DROP": 2, + "FIB_API_PATH_TYPE_UDP_ENCAP": 3, + "FIB_API_PATH_TYPE_BIER_IMP": 4, + "FIB_API_PATH_TYPE_ICMP_UNREACH": 5, + "FIB_API_PATH_TYPE_ICMP_PROHIBIT": 6, + "FIB_API_PATH_TYPE_SOURCE_LOOKUP": 7, + "FIB_API_PATH_TYPE_DVR": 8, + "FIB_API_PATH_TYPE_INTERFACE_RX": 9, + "FIB_API_PATH_TYPE_CLASSIFY": 10, +} + +func (x FibPathType) String() string { + s, ok := FibPathType_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + // IPNeighborFlags represents VPP binary API enum 'ip_neighbor_flags'. type IPNeighborFlags uint32 @@ -119,6 +236,44 @@ func (x IPProto) String() string { return strconv.Itoa(int(x)) } +// MfibItfFlags represents VPP binary API enum 'mfib_itf_flags'. +type MfibItfFlags uint32 + +const ( + MFIB_API_ITF_FLAG_NONE MfibItfFlags = 0 + MFIB_API_ITF_FLAG_NEGATE_SIGNAL MfibItfFlags = 1 + MFIB_API_ITF_FLAG_ACCEPT MfibItfFlags = 2 + MFIB_API_ITF_FLAG_FORWARD MfibItfFlags = 4 + MFIB_API_ITF_FLAG_SIGNAL_PRESENT MfibItfFlags = 8 + MFIB_API_ITF_FLAG_DONT_PRESERVE MfibItfFlags = 16 +) + +var MfibItfFlags_name = map[uint32]string{ + 0: "MFIB_API_ITF_FLAG_NONE", + 1: "MFIB_API_ITF_FLAG_NEGATE_SIGNAL", + 2: "MFIB_API_ITF_FLAG_ACCEPT", + 4: "MFIB_API_ITF_FLAG_FORWARD", + 8: "MFIB_API_ITF_FLAG_SIGNAL_PRESENT", + 16: "MFIB_API_ITF_FLAG_DONT_PRESERVE", +} + +var MfibItfFlags_value = map[string]uint32{ + "MFIB_API_ITF_FLAG_NONE": 0, + "MFIB_API_ITF_FLAG_NEGATE_SIGNAL": 1, + "MFIB_API_ITF_FLAG_ACCEPT": 2, + "MFIB_API_ITF_FLAG_FORWARD": 4, + "MFIB_API_ITF_FLAG_SIGNAL_PRESENT": 8, + "MFIB_API_ITF_FLAG_DONT_PRESERVE": 16, +} + +func (x MfibItfFlags) String() string { + s, ok := MfibItfFlags_name[uint32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} + // IP4Address represents VPP binary API alias 'ip4_address'. type IP4Address [4]uint8 @@ -152,37 +307,39 @@ func (*FibMplsLabel) GetTypeName() string { // FibPath represents VPP binary API type 'fib_path'. type FibPath struct { - SwIfIndex uint32 - TableID uint32 - Weight uint8 - Preference uint8 - IsLocal uint8 - IsDrop uint8 - IsUDPEncap uint8 - IsUnreach uint8 - IsProhibit uint8 - IsResolveHost uint8 - IsResolveAttached uint8 - IsDvr uint8 - IsSourceLookup uint8 - IsInterfaceRx uint8 - Afi uint8 - NextHop []byte `struc:"[16]byte"` - NextHopID uint32 - RpfID uint32 - ViaLabel uint32 - NLabels uint8 `struc:"sizeof=LabelStack"` // MANUALLY FIXED, see https://jira.fd.io/browse/VPP-1261 - LabelStack []FibMplsLabel + SwIfIndex uint32 + TableID uint32 + RpfID uint32 + Weight uint8 + Preference uint8 + Type FibPathType + Flags FibPathFlags + Proto FibPathNhProto + Nh FibPathNh + NLabels uint8 `struc:"sizeof=LabelStack"` // MANUALLY FIXED, see https://jira.fd.io/browse/VPP-1261 + LabelStack []FibMplsLabel } func (*FibPath) GetTypeName() string { return "fib_path" } +// FibPathNh represents VPP binary API type 'fib_path_nh'. +type FibPathNh struct { + Address AddressUnion + ViaLabel uint32 + ObjID uint32 + ClassifyTableIndex uint32 +} + +func (*FibPathNh) GetTypeName() string { + return "fib_path_nh" +} + // IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { - Prefix IP4Address - Len uint8 + Address IP4Address + Len uint8 } func (*IP4Prefix) GetTypeName() string { @@ -191,8 +348,8 @@ func (*IP4Prefix) GetTypeName() string { // IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { - Prefix IP6Address - Len uint8 + Address IP6Address + Len uint8 } func (*IP6Prefix) GetTypeName() string { @@ -211,6 +368,20 @@ func (*IP6RaPrefixInfo) GetTypeName() string { return "ip6_ra_prefix_info" } +// IPMroute represents VPP binary API type 'ip_mroute'. +type IPMroute struct { + TableID uint32 + EntryFlags uint32 + RpfID uint32 + Prefix Mprefix + NPaths uint8 `struc:"sizeof=Paths"` + Paths []MfibPath +} + +func (*IPMroute) GetTypeName() string { + return "ip_mroute" +} + // IPNeighbor represents VPP binary API type 'ip_neighbor'. type IPNeighbor struct { SwIfIndex uint32 @@ -223,10 +394,34 @@ func (*IPNeighbor) GetTypeName() string { return "ip_neighbor" } +// IPRoute represents VPP binary API type 'ip_route'. +type IPRoute struct { + TableID uint32 + StatsIndex uint32 + Prefix Prefix + NPaths uint8 `struc:"sizeof=Paths"` + Paths []FibPath +} + +func (*IPRoute) GetTypeName() string { + return "ip_route" +} + +// IPTable represents VPP binary API type 'ip_table'. +type IPTable struct { + TableID uint32 + IsIP6 uint8 + Name []byte `struc:"[64]byte"` +} + +func (*IPTable) GetTypeName() string { + return "ip_table" +} + // MfibPath represents VPP binary API type 'mfib_path'. type MfibPath struct { + ItfFlags MfibItfFlags Path FibPath - ItfFlags uint32 } func (*MfibPath) GetTypeName() string { @@ -247,8 +442,8 @@ func (*Mprefix) GetTypeName() string { // Prefix represents VPP binary API type 'prefix'. type Prefix struct { - Address Address - AddressLength uint8 + Address Address + Len uint8 } func (*Prefix) GetTypeName() string { @@ -404,73 +599,6 @@ func (*IP4ArpEvent) GetMessageType() api.MessageType { return api.EventMessage } -// IP6FibDetails represents VPP binary API message 'ip6_fib_details'. -type IP6FibDetails struct { - TableID uint32 - TableName []byte `struc:"[64]byte"` - AddressLength uint8 - Address []byte `struc:"[16]byte"` - Count uint32 `struc:"sizeof=Path"` - StatsIndex uint32 - Path []FibPath -} - -func (*IP6FibDetails) GetMessageName() string { - return "ip6_fib_details" -} -func (*IP6FibDetails) GetCrcString() string { - return "c49b0e40" -} -func (*IP6FibDetails) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// IP6FibDump represents VPP binary API message 'ip6_fib_dump'. -type IP6FibDump struct{} - -func (*IP6FibDump) GetMessageName() string { - return "ip6_fib_dump" -} -func (*IP6FibDump) GetCrcString() string { - return "51077d14" -} -func (*IP6FibDump) GetMessageType() api.MessageType { - return api.RequestMessage -} - -// IP6MfibDetails represents VPP binary API message 'ip6_mfib_details'. -type IP6MfibDetails struct { - TableID uint32 - AddressLength uint8 - GrpAddress []byte `struc:"[16]byte"` - SrcAddress []byte `struc:"[16]byte"` - Count uint32 `struc:"sizeof=Path"` - Path []MfibPath -} - -func (*IP6MfibDetails) GetMessageName() string { - return "ip6_mfib_details" -} -func (*IP6MfibDetails) GetCrcString() string { - return "dd805dd8" -} -func (*IP6MfibDetails) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// IP6MfibDump represents VPP binary API message 'ip6_mfib_dump'. -type IP6MfibDump struct{} - -func (*IP6MfibDump) GetMessageName() string { - return "ip6_mfib_dump" -} -func (*IP6MfibDump) GetCrcString() string { - return "51077d14" -} -func (*IP6MfibDump) GetMessageType() api.MessageType { - return api.RequestMessage -} - // IP6NdEvent represents VPP binary API message 'ip6_nd_event'. type IP6NdEvent struct { PID uint32 @@ -508,7 +636,7 @@ func (*IP6RaEvent) GetMessageName() string { return "ip6_ra_event" } func (*IP6RaEvent) GetCrcString() string { - return "de28fe01" + return "34c9ddac" } func (*IP6RaEvent) GetMessageType() api.MessageType { return api.EventMessage @@ -610,76 +738,17 @@ func (*IP6ndSendRouterSolicitationReply) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPAddDelRoute represents VPP binary API message 'ip_add_del_route'. -type IPAddDelRoute struct { - NextHopSwIfIndex uint32 - TableID uint32 - ClassifyTableIndex uint32 - NextHopTableID uint32 - NextHopID uint32 - IsAdd uint8 - IsDrop uint8 - IsUnreach uint8 - IsProhibit uint8 - IsIPv6 uint8 - IsLocal uint8 - IsClassify uint8 - IsMultipath uint8 - IsResolveHost uint8 - IsResolveAttached uint8 - IsDvr uint8 - IsSourceLookup uint8 - IsUDPEncap uint8 - NextHopWeight uint8 - NextHopPreference uint8 - NextHopProto uint8 - DstAddressLength uint8 - DstAddress []byte `struc:"[16]byte"` - NextHopAddress []byte `struc:"[16]byte"` - NextHopNOutLabels uint8 `struc:"sizeof=NextHopOutLabelStack"` - NextHopViaLabel uint32 - NextHopOutLabelStack []FibMplsLabel -} - -func (*IPAddDelRoute) GetMessageName() string { - return "ip_add_del_route" -} -func (*IPAddDelRoute) GetCrcString() string { - return "4065b585" -} -func (*IPAddDelRoute) GetMessageType() api.MessageType { - return api.RequestMessage -} - -// IPAddDelRouteReply represents VPP binary API message 'ip_add_del_route_reply'. -type IPAddDelRouteReply struct { - Retval int32 - StatsIndex uint32 -} - -func (*IPAddDelRouteReply) GetMessageName() string { - return "ip_add_del_route_reply" -} -func (*IPAddDelRouteReply) GetCrcString() string { - return "1992deab" -} -func (*IPAddDelRouteReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - // IPAddressDetails represents VPP binary API message 'ip_address_details'. type IPAddressDetails struct { - IP []byte `struc:"[16]byte"` - PrefixLength uint8 - SwIfIndex uint32 - IsIPv6 uint8 + SwIfIndex uint32 + Prefix Prefix } func (*IPAddressDetails) GetMessageName() string { return "ip_address_details" } func (*IPAddressDetails) GetCrcString() string { - return "9bc25966" + return "2f1dbc7d" } func (*IPAddressDetails) GetMessageType() api.MessageType { return api.ReplyMessage @@ -712,7 +781,7 @@ func (*IPContainerProxyAddDel) GetMessageName() string { return "ip_container_proxy_add_del" } func (*IPContainerProxyAddDel) GetCrcString() string { - return "5a631dec" + return "5ba831f3" } func (*IPContainerProxyAddDel) GetMessageType() api.MessageType { return api.RequestMessage @@ -743,7 +812,7 @@ func (*IPContainerProxyDetails) GetMessageName() string { return "ip_container_proxy_details" } func (*IPContainerProxyDetails) GetCrcString() string { - return "46e69b7c" + return "2f1dbc7d" } func (*IPContainerProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage @@ -793,118 +862,95 @@ func (*IPDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPFibDetails represents VPP binary API message 'ip_fib_details'. -type IPFibDetails struct { - TableID uint32 - TableName []byte `struc:"[64]byte"` - AddressLength uint8 - Address []byte `struc:"[4]byte"` - Count uint32 `struc:"sizeof=Path"` - StatsIndex uint32 - Path []FibPath +// IPMrouteAddDel represents VPP binary API message 'ip_mroute_add_del'. +type IPMrouteAddDel struct { + IsAdd uint8 + IsMultipath uint8 + Route IPMroute } -func (*IPFibDetails) GetMessageName() string { - return "ip_fib_details" +func (*IPMrouteAddDel) GetMessageName() string { + return "ip_mroute_add_del" } -func (*IPFibDetails) GetCrcString() string { - return "e4d5591d" +func (*IPMrouteAddDel) GetCrcString() string { + return "997baab2" } -func (*IPFibDetails) GetMessageType() api.MessageType { - return api.ReplyMessage +func (*IPMrouteAddDel) GetMessageType() api.MessageType { + return api.RequestMessage } -// IPFibDump represents VPP binary API message 'ip_fib_dump'. -type IPFibDump struct{} +// IPMrouteAddDelReply represents VPP binary API message 'ip_mroute_add_del_reply'. +type IPMrouteAddDelReply struct { + Retval int32 + StatsIndex uint32 +} -func (*IPFibDump) GetMessageName() string { - return "ip_fib_dump" +func (*IPMrouteAddDelReply) GetMessageName() string { + return "ip_mroute_add_del_reply" } -func (*IPFibDump) GetCrcString() string { - return "51077d14" +func (*IPMrouteAddDelReply) GetCrcString() string { + return "1992deab" } -func (*IPFibDump) GetMessageType() api.MessageType { - return api.RequestMessage +func (*IPMrouteAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage } -// IPMfibDetails represents VPP binary API message 'ip_mfib_details'. -type IPMfibDetails struct { - TableID uint32 - EntryFlags uint32 - RpfID uint32 - AddressLength uint8 - GrpAddress []byte `struc:"[4]byte"` - SrcAddress []byte `struc:"[4]byte"` - Count uint32 `struc:"sizeof=Path"` - StatsIndex uint32 - Path []MfibPath +// IPMrouteDetails represents VPP binary API message 'ip_mroute_details'. +type IPMrouteDetails struct { + Route IPMroute } -func (*IPMfibDetails) GetMessageName() string { - return "ip_mfib_details" +func (*IPMrouteDetails) GetMessageName() string { + return "ip_mroute_details" } -func (*IPMfibDetails) GetCrcString() string { - return "f668185d" +func (*IPMrouteDetails) GetCrcString() string { + return "39405e5a" } -func (*IPMfibDetails) GetMessageType() api.MessageType { +func (*IPMrouteDetails) GetMessageType() api.MessageType { return api.ReplyMessage } -// IPMfibDump represents VPP binary API message 'ip_mfib_dump'. -type IPMfibDump struct{} +// IPMrouteDump represents VPP binary API message 'ip_mroute_dump'. +type IPMrouteDump struct { + Table IPTable +} -func (*IPMfibDump) GetMessageName() string { - return "ip_mfib_dump" +func (*IPMrouteDump) GetMessageName() string { + return "ip_mroute_dump" } -func (*IPMfibDump) GetCrcString() string { - return "51077d14" +func (*IPMrouteDump) GetCrcString() string { + return "f5ad78e8" } -func (*IPMfibDump) GetMessageType() api.MessageType { +func (*IPMrouteDump) GetMessageType() api.MessageType { return api.RequestMessage } -// IPMrouteAddDel represents VPP binary API message 'ip_mroute_add_del'. -type IPMrouteAddDel struct { - NextHopSwIfIndex uint32 - TableID uint32 - EntryFlags uint32 - ItfFlags uint32 - RpfID uint32 - BierImp uint32 - GrpAddressLength uint16 - NextHopAfi uint8 - IsAdd uint8 - IsIPv6 uint8 - IsLocal uint8 - GrpAddress []byte `struc:"[16]byte"` - SrcAddress []byte `struc:"[16]byte"` - NhAddress []byte `struc:"[16]byte"` +// IPMtableDetails represents VPP binary API message 'ip_mtable_details'. +type IPMtableDetails struct { + Table IPTable } -func (*IPMrouteAddDel) GetMessageName() string { - return "ip_mroute_add_del" +func (*IPMtableDetails) GetMessageName() string { + return "ip_mtable_details" } -func (*IPMrouteAddDel) GetCrcString() string { - return "f44c17b1" +func (*IPMtableDetails) GetCrcString() string { + return "f5ad78e8" } -func (*IPMrouteAddDel) GetMessageType() api.MessageType { +func (*IPMtableDetails) GetMessageType() api.MessageType { return api.RequestMessage } -// IPMrouteAddDelReply represents VPP binary API message 'ip_mroute_add_del_reply'. -type IPMrouteAddDelReply struct { - Retval int32 - StatsIndex uint32 -} +// IPMtableDump represents VPP binary API message 'ip_mtable_dump'. +type IPMtableDump struct{} -func (*IPMrouteAddDelReply) GetMessageName() string { - return "ip_mroute_add_del_reply" +func (*IPMtableDump) GetMessageName() string { + return "ip_mtable_dump" } -func (*IPMrouteAddDelReply) GetCrcString() string { - return "1992deab" +func (*IPMtableDump) GetCrcString() string { + return "51077d14" } -func (*IPMrouteAddDelReply) GetMessageType() api.MessageType { - return api.ReplyMessage +func (*IPMtableDump) GetMessageType() api.MessageType { + return api.RequestMessage } // IPNeighborAddDel represents VPP binary API message 'ip_neighbor_add_del'. @@ -1196,6 +1242,69 @@ func (*IPReassemblySetReply) GetMessageType() api.MessageType { return api.ReplyMessage } +// IPRouteAddDel represents VPP binary API message 'ip_route_add_del'. +type IPRouteAddDel struct { + IsAdd uint8 + IsMultipath uint8 + Route IPRoute +} + +func (*IPRouteAddDel) GetMessageName() string { + return "ip_route_add_del" +} +func (*IPRouteAddDel) GetCrcString() string { + return "83e086ce" +} +func (*IPRouteAddDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +// IPRouteAddDelReply represents VPP binary API message 'ip_route_add_del_reply'. +type IPRouteAddDelReply struct { + Retval int32 + StatsIndex uint32 +} + +func (*IPRouteAddDelReply) GetMessageName() string { + return "ip_route_add_del_reply" +} +func (*IPRouteAddDelReply) GetCrcString() string { + return "1992deab" +} +func (*IPRouteAddDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +// IPRouteDetails represents VPP binary API message 'ip_route_details'. +type IPRouteDetails struct { + Route IPRoute +} + +func (*IPRouteDetails) GetMessageName() string { + return "ip_route_details" +} +func (*IPRouteDetails) GetCrcString() string { + return "acdee858" +} +func (*IPRouteDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +// IPRouteDump represents VPP binary API message 'ip_route_dump'. +type IPRouteDump struct { + Table IPTable +} + +func (*IPRouteDump) GetMessageName() string { + return "ip_route_dump" +} +func (*IPRouteDump) GetCrcString() string { + return "f5ad78e8" +} +func (*IPRouteDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + // IPScanNeighborEnableDisable represents VPP binary API message 'ip_scan_neighbor_enable_disable'. type IPScanNeighborEnableDisable struct { Mode uint8 @@ -1245,7 +1354,7 @@ func (*IPSourceAndPortRangeCheckAddDel) GetMessageName() string { return "ip_source_and_port_range_check_add_del" } func (*IPSourceAndPortRangeCheckAddDel) GetCrcString() string { - return "7fb73e64" + return "b50ed159" } func (*IPSourceAndPortRangeCheckAddDel) GetMessageType() api.MessageType { return api.RequestMessage @@ -1335,17 +1444,15 @@ func (*IPSourceCheckInterfaceAddDelReply) GetMessageType() api.MessageType { // IPTableAddDel represents VPP binary API message 'ip_table_add_del'. type IPTableAddDel struct { - TableID uint32 - IsIPv6 uint8 - IsAdd uint8 - Name []byte `struc:"[64]byte"` + IsAdd uint8 + Table IPTable } func (*IPTableAddDel) GetMessageName() string { return "ip_table_add_del" } func (*IPTableAddDel) GetCrcString() string { - return "0240c89d" + return "e5d378f2" } func (*IPTableAddDel) GetMessageType() api.MessageType { return api.RequestMessage @@ -1366,6 +1473,34 @@ func (*IPTableAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } +// IPTableDetails represents VPP binary API message 'ip_table_details'. +type IPTableDetails struct { + Table IPTable +} + +func (*IPTableDetails) GetMessageName() string { + return "ip_table_details" +} +func (*IPTableDetails) GetCrcString() string { + return "4d251961" +} +func (*IPTableDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +// IPTableDump represents VPP binary API message 'ip_table_dump'. +type IPTableDump struct{} + +func (*IPTableDump) GetMessageName() string { + return "ip_table_dump" +} +func (*IPTableDump) GetCrcString() string { + return "51077d14" +} +func (*IPTableDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + // IPUnnumberedDetails represents VPP binary API message 'ip_unnumbered_details'. type IPUnnumberedDetails struct { SwIfIndex uint32 @@ -1399,20 +1534,18 @@ func (*IPUnnumberedDump) GetMessageType() api.MessageType { // MfibSignalDetails represents VPP binary API message 'mfib_signal_details'. type MfibSignalDetails struct { - SwIfIndex uint32 - TableID uint32 - GrpAddressLen uint16 - GrpAddress []byte `struc:"[16]byte"` - SrcAddress []byte `struc:"[16]byte"` - IPPacketLen uint16 - IPPacketData []byte `struc:"[256]byte"` + SwIfIndex uint32 + TableID uint32 + Prefix Mprefix + IPPacketLen uint16 + IPPacketData []byte `struc:"[256]byte"` } func (*MfibSignalDetails) GetMessageName() string { return "mfib_signal_details" } func (*MfibSignalDetails) GetCrcString() string { - return "3f5f03f5" + return "cd461bfa" } func (*MfibSignalDetails) GetMessageType() api.MessageType { return api.ReplyMessage @@ -1680,6 +1813,37 @@ func (*SwInterfaceIP6EnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } +// SwInterfaceIP6SetLinkLocalAddress represents VPP binary API message 'sw_interface_ip6_set_link_local_address'. +type SwInterfaceIP6SetLinkLocalAddress struct { + SwIfIndex uint32 + Address []byte `struc:"[16]byte"` +} + +func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageName() string { + return "sw_interface_ip6_set_link_local_address" +} +func (*SwInterfaceIP6SetLinkLocalAddress) GetCrcString() string { + return "d73bf1ab" +} +func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageType() api.MessageType { + return api.RequestMessage +} + +// SwInterfaceIP6SetLinkLocalAddressReply represents VPP binary API message 'sw_interface_ip6_set_link_local_address_reply'. +type SwInterfaceIP6SetLinkLocalAddressReply struct { + Retval int32 +} + +func (*SwInterfaceIP6SetLinkLocalAddressReply) GetMessageName() string { + return "sw_interface_ip6_set_link_local_address_reply" +} +func (*SwInterfaceIP6SetLinkLocalAddressReply) GetCrcString() string { + return "e8d4e804" +} +func (*SwInterfaceIP6SetLinkLocalAddressReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + // SwInterfaceIP6ndRaConfig represents VPP binary API message 'sw_interface_ip6nd_ra_config'. type SwInterfaceIP6ndRaConfig struct { SwIfIndex uint32 @@ -1741,7 +1905,7 @@ func (*SwInterfaceIP6ndRaPrefix) GetMessageName() string { return "sw_interface_ip6nd_ra_prefix" } func (*SwInterfaceIP6ndRaPrefix) GetCrcString() string { - return "e67af1ef" + return "0f759f82" } func (*SwInterfaceIP6ndRaPrefix) GetMessageType() api.MessageType { return api.RequestMessage @@ -1863,10 +2027,6 @@ func init() { api.RegisterMessage((*IoamEnable)(nil), "ip.IoamEnable") api.RegisterMessage((*IoamEnableReply)(nil), "ip.IoamEnableReply") api.RegisterMessage((*IP4ArpEvent)(nil), "ip.IP4ArpEvent") - api.RegisterMessage((*IP6FibDetails)(nil), "ip.IP6FibDetails") - api.RegisterMessage((*IP6FibDump)(nil), "ip.IP6FibDump") - api.RegisterMessage((*IP6MfibDetails)(nil), "ip.IP6MfibDetails") - api.RegisterMessage((*IP6MfibDump)(nil), "ip.IP6MfibDump") api.RegisterMessage((*IP6NdEvent)(nil), "ip.IP6NdEvent") api.RegisterMessage((*IP6RaEvent)(nil), "ip.IP6RaEvent") api.RegisterMessage((*IP6ndProxyAddDel)(nil), "ip.IP6ndProxyAddDel") @@ -1875,8 +2035,6 @@ func init() { api.RegisterMessage((*IP6ndProxyDump)(nil), "ip.IP6ndProxyDump") api.RegisterMessage((*IP6ndSendRouterSolicitation)(nil), "ip.IP6ndSendRouterSolicitation") api.RegisterMessage((*IP6ndSendRouterSolicitationReply)(nil), "ip.IP6ndSendRouterSolicitationReply") - api.RegisterMessage((*IPAddDelRoute)(nil), "ip.IPAddDelRoute") - api.RegisterMessage((*IPAddDelRouteReply)(nil), "ip.IPAddDelRouteReply") api.RegisterMessage((*IPAddressDetails)(nil), "ip.IPAddressDetails") api.RegisterMessage((*IPAddressDump)(nil), "ip.IPAddressDump") api.RegisterMessage((*IPContainerProxyAddDel)(nil), "ip.IPContainerProxyAddDel") @@ -1885,12 +2043,12 @@ func init() { api.RegisterMessage((*IPContainerProxyDump)(nil), "ip.IPContainerProxyDump") api.RegisterMessage((*IPDetails)(nil), "ip.IPDetails") api.RegisterMessage((*IPDump)(nil), "ip.IPDump") - api.RegisterMessage((*IPFibDetails)(nil), "ip.IPFibDetails") - api.RegisterMessage((*IPFibDump)(nil), "ip.IPFibDump") - api.RegisterMessage((*IPMfibDetails)(nil), "ip.IPMfibDetails") - api.RegisterMessage((*IPMfibDump)(nil), "ip.IPMfibDump") api.RegisterMessage((*IPMrouteAddDel)(nil), "ip.IPMrouteAddDel") api.RegisterMessage((*IPMrouteAddDelReply)(nil), "ip.IPMrouteAddDelReply") + api.RegisterMessage((*IPMrouteDetails)(nil), "ip.IPMrouteDetails") + api.RegisterMessage((*IPMrouteDump)(nil), "ip.IPMrouteDump") + api.RegisterMessage((*IPMtableDetails)(nil), "ip.IPMtableDetails") + api.RegisterMessage((*IPMtableDump)(nil), "ip.IPMtableDump") api.RegisterMessage((*IPNeighborAddDel)(nil), "ip.IPNeighborAddDel") api.RegisterMessage((*IPNeighborAddDelReply)(nil), "ip.IPNeighborAddDelReply") api.RegisterMessage((*IPNeighborDetails)(nil), "ip.IPNeighborDetails") @@ -1909,6 +2067,10 @@ func init() { api.RegisterMessage((*IPReassemblyGetReply)(nil), "ip.IPReassemblyGetReply") api.RegisterMessage((*IPReassemblySet)(nil), "ip.IPReassemblySet") api.RegisterMessage((*IPReassemblySetReply)(nil), "ip.IPReassemblySetReply") + api.RegisterMessage((*IPRouteAddDel)(nil), "ip.IPRouteAddDel") + api.RegisterMessage((*IPRouteAddDelReply)(nil), "ip.IPRouteAddDelReply") + api.RegisterMessage((*IPRouteDetails)(nil), "ip.IPRouteDetails") + api.RegisterMessage((*IPRouteDump)(nil), "ip.IPRouteDump") api.RegisterMessage((*IPScanNeighborEnableDisable)(nil), "ip.IPScanNeighborEnableDisable") api.RegisterMessage((*IPScanNeighborEnableDisableReply)(nil), "ip.IPScanNeighborEnableDisableReply") api.RegisterMessage((*IPSourceAndPortRangeCheckAddDel)(nil), "ip.IPSourceAndPortRangeCheckAddDel") @@ -1919,6 +2081,8 @@ func init() { api.RegisterMessage((*IPSourceCheckInterfaceAddDelReply)(nil), "ip.IPSourceCheckInterfaceAddDelReply") api.RegisterMessage((*IPTableAddDel)(nil), "ip.IPTableAddDel") api.RegisterMessage((*IPTableAddDelReply)(nil), "ip.IPTableAddDelReply") + api.RegisterMessage((*IPTableDetails)(nil), "ip.IPTableDetails") + api.RegisterMessage((*IPTableDump)(nil), "ip.IPTableDump") api.RegisterMessage((*IPUnnumberedDetails)(nil), "ip.IPUnnumberedDetails") api.RegisterMessage((*IPUnnumberedDump)(nil), "ip.IPUnnumberedDump") api.RegisterMessage((*MfibSignalDetails)(nil), "ip.MfibSignalDetails") @@ -1939,6 +2103,8 @@ func init() { api.RegisterMessage((*SetIPFlowHashReply)(nil), "ip.SetIPFlowHashReply") api.RegisterMessage((*SwInterfaceIP6EnableDisable)(nil), "ip.SwInterfaceIP6EnableDisable") api.RegisterMessage((*SwInterfaceIP6EnableDisableReply)(nil), "ip.SwInterfaceIP6EnableDisableReply") + api.RegisterMessage((*SwInterfaceIP6SetLinkLocalAddress)(nil), "ip.SwInterfaceIP6SetLinkLocalAddress") + api.RegisterMessage((*SwInterfaceIP6SetLinkLocalAddressReply)(nil), "ip.SwInterfaceIP6SetLinkLocalAddressReply") api.RegisterMessage((*SwInterfaceIP6ndRaConfig)(nil), "ip.SwInterfaceIP6ndRaConfig") api.RegisterMessage((*SwInterfaceIP6ndRaConfigReply)(nil), "ip.SwInterfaceIP6ndRaConfigReply") api.RegisterMessage((*SwInterfaceIP6ndRaPrefix)(nil), "ip.SwInterfaceIP6ndRaPrefix") @@ -1959,10 +2125,6 @@ func AllMessages() []api.Message { (*IoamEnable)(nil), (*IoamEnableReply)(nil), (*IP4ArpEvent)(nil), - (*IP6FibDetails)(nil), - (*IP6FibDump)(nil), - (*IP6MfibDetails)(nil), - (*IP6MfibDump)(nil), (*IP6NdEvent)(nil), (*IP6RaEvent)(nil), (*IP6ndProxyAddDel)(nil), @@ -1971,8 +2133,6 @@ func AllMessages() []api.Message { (*IP6ndProxyDump)(nil), (*IP6ndSendRouterSolicitation)(nil), (*IP6ndSendRouterSolicitationReply)(nil), - (*IPAddDelRoute)(nil), - (*IPAddDelRouteReply)(nil), (*IPAddressDetails)(nil), (*IPAddressDump)(nil), (*IPContainerProxyAddDel)(nil), @@ -1981,12 +2141,12 @@ func AllMessages() []api.Message { (*IPContainerProxyDump)(nil), (*IPDetails)(nil), (*IPDump)(nil), - (*IPFibDetails)(nil), - (*IPFibDump)(nil), - (*IPMfibDetails)(nil), - (*IPMfibDump)(nil), (*IPMrouteAddDel)(nil), (*IPMrouteAddDelReply)(nil), + (*IPMrouteDetails)(nil), + (*IPMrouteDump)(nil), + (*IPMtableDetails)(nil), + (*IPMtableDump)(nil), (*IPNeighborAddDel)(nil), (*IPNeighborAddDelReply)(nil), (*IPNeighborDetails)(nil), @@ -2005,6 +2165,10 @@ func AllMessages() []api.Message { (*IPReassemblyGetReply)(nil), (*IPReassemblySet)(nil), (*IPReassemblySetReply)(nil), + (*IPRouteAddDel)(nil), + (*IPRouteAddDelReply)(nil), + (*IPRouteDetails)(nil), + (*IPRouteDump)(nil), (*IPScanNeighborEnableDisable)(nil), (*IPScanNeighborEnableDisableReply)(nil), (*IPSourceAndPortRangeCheckAddDel)(nil), @@ -2015,6 +2179,8 @@ func AllMessages() []api.Message { (*IPSourceCheckInterfaceAddDelReply)(nil), (*IPTableAddDel)(nil), (*IPTableAddDelReply)(nil), + (*IPTableDetails)(nil), + (*IPTableDump)(nil), (*IPUnnumberedDetails)(nil), (*IPUnnumberedDump)(nil), (*MfibSignalDetails)(nil), @@ -2035,6 +2201,8 @@ func AllMessages() []api.Message { (*SetIPFlowHashReply)(nil), (*SwInterfaceIP6EnableDisable)(nil), (*SwInterfaceIP6EnableDisableReply)(nil), + (*SwInterfaceIP6SetLinkLocalAddress)(nil), + (*SwInterfaceIP6SetLinkLocalAddressReply)(nil), (*SwInterfaceIP6ndRaConfig)(nil), (*SwInterfaceIP6ndRaConfigReply)(nil), (*SwInterfaceIP6ndRaPrefix)(nil), @@ -2050,16 +2218,16 @@ func AllMessages() []api.Message { // RPCService represents RPC service API for ip module. type RPCService interface { - DumpIP6Fib(ctx context.Context, in *IP6FibDump) (RPCService_DumpIP6FibClient, error) - DumpIP6Mfib(ctx context.Context, in *IP6MfibDump) (RPCService_DumpIP6MfibClient, error) DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) (RPCService_DumpIP6ndProxyClient, error) DumpIPAddress(ctx context.Context, in *IPAddressDump) (RPCService_DumpIPAddressClient, error) DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) (RPCService_DumpIPContainerProxyClient, error) DumpIP(ctx context.Context, in *IPDump) (RPCService_DumpIPClient, error) - DumpIPFib(ctx context.Context, in *IPFibDump) (RPCService_DumpIPFibClient, error) - DumpIPMfib(ctx context.Context, in *IPMfibDump) (RPCService_DumpIPMfibClient, error) + DumpIPMroute(ctx context.Context, in *IPMrouteDump) (RPCService_DumpIPMrouteClient, error) + DumpIPMtable(ctx context.Context, in *IPMtableDump) (RPCService_DumpIPMtableClient, error) DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) (RPCService_DumpIPNeighborClient, error) DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) (RPCService_DumpIPPuntRedirectClient, error) + DumpIPRoute(ctx context.Context, in *IPRouteDump) (RPCService_DumpIPRouteClient, error) + DumpIPTable(ctx context.Context, in *IPTableDump) (RPCService_DumpIPTableClient, error) DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) (RPCService_DumpIPUnnumberedClient, error) DumpMfibSignal(ctx context.Context, in *MfibSignalDump) (RPCService_DumpMfibSignalClient, error) DumpProxyArp(ctx context.Context, in *ProxyArpDump) (RPCService_DumpProxyArpClient, error) @@ -2068,7 +2236,6 @@ type RPCService interface { IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) - IPAddDelRoute(ctx context.Context, in *IPAddDelRoute) (*IPAddDelRouteReply, error) IPContainerProxyAddDel(ctx context.Context, in *IPContainerProxyAddDel) (*IPContainerProxyAddDelReply, error) IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) (*IPMrouteAddDelReply, error) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) @@ -2078,6 +2245,7 @@ type RPCService interface { IPReassemblyEnableDisable(ctx context.Context, in *IPReassemblyEnableDisable) (*IPReassemblyEnableDisableReply, error) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) + IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (*IPRouteAddDelReply, error) IPScanNeighborEnableDisable(ctx context.Context, in *IPScanNeighborEnableDisable) (*IPScanNeighborEnableDisableReply, error) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) @@ -2089,6 +2257,7 @@ type RPCService interface { SetArpNeighborLimit(ctx context.Context, in *SetArpNeighborLimit) (*SetArpNeighborLimitReply, error) SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (*SetIPFlowHashReply, error) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfaceIP6EnableDisable) (*SwInterfaceIP6EnableDisableReply, error) + SwInterfaceIP6SetLinkLocalAddress(ctx context.Context, in *SwInterfaceIP6SetLinkLocalAddress) (*SwInterfaceIP6SetLinkLocalAddressReply, error) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) WantIP4ArpEvents(ctx context.Context, in *WantIP4ArpEvents) (*WantIP4ArpEventsReply, error) @@ -2104,58 +2273,6 @@ func NewServiceClient(ch api.Channel) RPCService { return &serviceClient{ch} } -func (c *serviceClient) DumpIP6Fib(ctx context.Context, in *IP6FibDump) (RPCService_DumpIP6FibClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIP6FibClient{stream} - return x, nil -} - -type RPCService_DumpIP6FibClient interface { - Recv() (*IP6FibDetails, error) -} - -type serviceClient_DumpIP6FibClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIP6FibClient) Recv() (*IP6FibDetails, error) { - m := new(IP6FibDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIP6Mfib(ctx context.Context, in *IP6MfibDump) (RPCService_DumpIP6MfibClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIP6MfibClient{stream} - return x, nil -} - -type RPCService_DumpIP6MfibClient interface { - Recv() (*IP6MfibDetails, error) -} - -type serviceClient_DumpIP6MfibClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIP6MfibClient) Recv() (*IP6MfibDetails, error) { - m := new(IP6MfibDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - func (c *serviceClient) DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) (RPCService_DumpIP6ndProxyClient, error) { stream := c.ch.SendMultiRequest(in) x := &serviceClient_DumpIP6ndProxyClient{stream} @@ -2260,22 +2377,22 @@ func (c *serviceClient_DumpIPClient) Recv() (*IPDetails, error) { return m, nil } -func (c *serviceClient) DumpIPFib(ctx context.Context, in *IPFibDump) (RPCService_DumpIPFibClient, error) { +func (c *serviceClient) DumpIPMroute(ctx context.Context, in *IPMrouteDump) (RPCService_DumpIPMrouteClient, error) { stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPFibClient{stream} + x := &serviceClient_DumpIPMrouteClient{stream} return x, nil } -type RPCService_DumpIPFibClient interface { - Recv() (*IPFibDetails, error) +type RPCService_DumpIPMrouteClient interface { + Recv() (*IPMrouteDetails, error) } -type serviceClient_DumpIPFibClient struct { +type serviceClient_DumpIPMrouteClient struct { api.MultiRequestCtx } -func (c *serviceClient_DumpIPFibClient) Recv() (*IPFibDetails, error) { - m := new(IPFibDetails) +func (c *serviceClient_DumpIPMrouteClient) Recv() (*IPMrouteDetails, error) { + m := new(IPMrouteDetails) stop, err := c.MultiRequestCtx.ReceiveReply(m) if err != nil { return nil, err @@ -2286,22 +2403,22 @@ func (c *serviceClient_DumpIPFibClient) Recv() (*IPFibDetails, error) { return m, nil } -func (c *serviceClient) DumpIPMfib(ctx context.Context, in *IPMfibDump) (RPCService_DumpIPMfibClient, error) { +func (c *serviceClient) DumpIPMtable(ctx context.Context, in *IPMtableDump) (RPCService_DumpIPMtableClient, error) { stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPMfibClient{stream} + x := &serviceClient_DumpIPMtableClient{stream} return x, nil } -type RPCService_DumpIPMfibClient interface { - Recv() (*IPMfibDetails, error) +type RPCService_DumpIPMtableClient interface { + Recv() (*IPMtableDetails, error) } -type serviceClient_DumpIPMfibClient struct { +type serviceClient_DumpIPMtableClient struct { api.MultiRequestCtx } -func (c *serviceClient_DumpIPMfibClient) Recv() (*IPMfibDetails, error) { - m := new(IPMfibDetails) +func (c *serviceClient_DumpIPMtableClient) Recv() (*IPMtableDetails, error) { + m := new(IPMtableDetails) stop, err := c.MultiRequestCtx.ReceiveReply(m) if err != nil { return nil, err @@ -2364,6 +2481,58 @@ func (c *serviceClient_DumpIPPuntRedirectClient) Recv() (*IPPuntRedirectDetails, return m, nil } +func (c *serviceClient) DumpIPRoute(ctx context.Context, in *IPRouteDump) (RPCService_DumpIPRouteClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPRouteClient{stream} + return x, nil +} + +type RPCService_DumpIPRouteClient interface { + Recv() (*IPRouteDetails, error) +} + +type serviceClient_DumpIPRouteClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPRouteClient) Recv() (*IPRouteDetails, error) { + m := new(IPRouteDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + +func (c *serviceClient) DumpIPTable(ctx context.Context, in *IPTableDump) (RPCService_DumpIPTableClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIPTableClient{stream} + return x, nil +} + +type RPCService_DumpIPTableClient interface { + Recv() (*IPTableDetails, error) +} + +type serviceClient_DumpIPTableClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIPTableClient) Recv() (*IPTableDetails, error) { + m := new(IPTableDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + func (c *serviceClient) DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) (RPCService_DumpIPUnnumberedClient, error) { stream := c.ch.SendMultiRequest(in) x := &serviceClient_DumpIPUnnumberedClient{stream} @@ -2504,15 +2673,6 @@ func (c *serviceClient) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6 return out, nil } -func (c *serviceClient) IPAddDelRoute(ctx context.Context, in *IPAddDelRoute) (*IPAddDelRouteReply, error) { - out := new(IPAddDelRouteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - func (c *serviceClient) IPContainerProxyAddDel(ctx context.Context, in *IPContainerProxyAddDel) (*IPContainerProxyAddDelReply, error) { out := new(IPContainerProxyAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) @@ -2594,6 +2754,15 @@ func (c *serviceClient) IPReassemblySet(ctx context.Context, in *IPReassemblySet return out, nil } +func (c *serviceClient) IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (*IPRouteAddDelReply, error) { + out := new(IPRouteAddDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + func (c *serviceClient) IPScanNeighborEnableDisable(ctx context.Context, in *IPScanNeighborEnableDisable) (*IPScanNeighborEnableDisableReply, error) { out := new(IPScanNeighborEnableDisableReply) err := c.ch.SendRequest(in).ReceiveReply(out) @@ -2693,6 +2862,15 @@ func (c *serviceClient) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwI return out, nil } +func (c *serviceClient) SwInterfaceIP6SetLinkLocalAddress(ctx context.Context, in *SwInterfaceIP6SetLinkLocalAddress) (*SwInterfaceIP6SetLinkLocalAddressReply, error) { + out := new(SwInterfaceIP6SetLinkLocalAddressReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + func (c *serviceClient) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) { out := new(SwInterfaceIP6ndRaConfigReply) err := c.ch.SendRequest(in).ReceiveReply(out) diff --git a/plugins/vpp/binapi/vpp1908/ipsec/ipsec.ba.go b/plugins/vpp/binapi/vpp1908/ipsec/ipsec.ba.go index aad72b609e..55af4dd7ac 100644 --- a/plugins/vpp/binapi/vpp1908/ipsec/ipsec.ba.go +++ b/plugins/vpp/binapi/vpp1908/ipsec/ipsec.ba.go @@ -6,11 +6,11 @@ Package ipsec is a generated VPP binary API for 'ipsec' module. It consists of: 7 enums - 2 aliases - 8 types + 3 aliases + 9 types 1 union - 24 messages - 12 services + 30 messages + 15 services */ package ipsec @@ -29,7 +29,7 @@ const ( // APIVersion is the API version of this module. APIVersion = "3.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0xaee12632 + VersionCrc = 0xfc13e31d ) // AddressFamily represents VPP binary API enum 'address_family'. @@ -283,6 +283,9 @@ func (x IpsecSpdAction) String() string { return strconv.Itoa(int(x)) } +// InterfaceIndex represents VPP binary API alias 'interface_index'. +type InterfaceIndex uint32 + // IP4Address represents VPP binary API alias 'ip4_address'. type IP4Address [4]uint8 @@ -301,8 +304,8 @@ func (*Address) GetTypeName() string { // IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { - Prefix IP4Address - Len uint8 + Address IP4Address + Len uint8 } func (*IP4Prefix) GetTypeName() string { @@ -311,8 +314,8 @@ func (*IP4Prefix) GetTypeName() string { // IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { - Prefix IP6Address - Len uint8 + Address IP6Address + Len uint8 } func (*IP6Prefix) GetTypeName() string { @@ -361,6 +364,18 @@ func (*IpsecSpdEntry) GetTypeName() string { return "ipsec_spd_entry" } +// IpsecTunnelProtect represents VPP binary API type 'ipsec_tunnel_protect'. +type IpsecTunnelProtect struct { + SwIfIndex InterfaceIndex + SaOut uint32 + NSaIn uint8 `struc:"sizeof=SaIn"` + SaIn []uint32 +} + +func (*IpsecTunnelProtect) GetTypeName() string { + return "ipsec_tunnel_protect" +} + // Key represents VPP binary API type 'key'. type Key struct { Length uint8 @@ -385,8 +400,8 @@ func (*Mprefix) GetTypeName() string { // Prefix represents VPP binary API type 'prefix'. type Prefix struct { - Address Address - AddressLength uint8 + Address Address + Len uint8 } func (*Prefix) GetTypeName() string { @@ -837,6 +852,96 @@ func (*IpsecTunnelIfSetSaReply) GetMessageType() api.MessageType { return api.ReplyMessage } +// IpsecTunnelProtectDel represents VPP binary API message 'ipsec_tunnel_protect_del'. +type IpsecTunnelProtectDel struct { + SwIfIndex InterfaceIndex +} + +func (*IpsecTunnelProtectDel) GetMessageName() string { + return "ipsec_tunnel_protect_del" +} +func (*IpsecTunnelProtectDel) GetCrcString() string { + return "d85aab0d" +} +func (*IpsecTunnelProtectDel) GetMessageType() api.MessageType { + return api.RequestMessage +} + +// IpsecTunnelProtectDelReply represents VPP binary API message 'ipsec_tunnel_protect_del_reply'. +type IpsecTunnelProtectDelReply struct { + Retval int32 +} + +func (*IpsecTunnelProtectDelReply) GetMessageName() string { + return "ipsec_tunnel_protect_del_reply" +} +func (*IpsecTunnelProtectDelReply) GetCrcString() string { + return "e8d4e804" +} +func (*IpsecTunnelProtectDelReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +// IpsecTunnelProtectDetails represents VPP binary API message 'ipsec_tunnel_protect_details'. +type IpsecTunnelProtectDetails struct { + Tun IpsecTunnelProtect +} + +func (*IpsecTunnelProtectDetails) GetMessageName() string { + return "ipsec_tunnel_protect_details" +} +func (*IpsecTunnelProtectDetails) GetCrcString() string { + return "f724bc50" +} +func (*IpsecTunnelProtectDetails) GetMessageType() api.MessageType { + return api.ReplyMessage +} + +// IpsecTunnelProtectDump represents VPP binary API message 'ipsec_tunnel_protect_dump'. +type IpsecTunnelProtectDump struct { + SwIfIndex InterfaceIndex +} + +func (*IpsecTunnelProtectDump) GetMessageName() string { + return "ipsec_tunnel_protect_dump" +} +func (*IpsecTunnelProtectDump) GetCrcString() string { + return "d85aab0d" +} +func (*IpsecTunnelProtectDump) GetMessageType() api.MessageType { + return api.RequestMessage +} + +// IpsecTunnelProtectUpdate represents VPP binary API message 'ipsec_tunnel_protect_update'. +type IpsecTunnelProtectUpdate struct { + Tunnel IpsecTunnelProtect +} + +func (*IpsecTunnelProtectUpdate) GetMessageName() string { + return "ipsec_tunnel_protect_update" +} +func (*IpsecTunnelProtectUpdate) GetCrcString() string { + return "316dab99" +} +func (*IpsecTunnelProtectUpdate) GetMessageType() api.MessageType { + return api.RequestMessage +} + +// IpsecTunnelProtectUpdateReply represents VPP binary API message 'ipsec_tunnel_protect_update_reply'. +type IpsecTunnelProtectUpdateReply struct { + Retval int32 +} + +func (*IpsecTunnelProtectUpdateReply) GetMessageName() string { + return "ipsec_tunnel_protect_update_reply" +} +func (*IpsecTunnelProtectUpdateReply) GetCrcString() string { + return "e8d4e804" +} +func (*IpsecTunnelProtectUpdateReply) GetMessageType() api.MessageType { + return api.ReplyMessage +} + func init() { api.RegisterMessage((*IpsecBackendDetails)(nil), "ipsec.IpsecBackendDetails") api.RegisterMessage((*IpsecBackendDump)(nil), "ipsec.IpsecBackendDump") @@ -862,6 +967,12 @@ func init() { api.RegisterMessage((*IpsecTunnelIfAddDelReply)(nil), "ipsec.IpsecTunnelIfAddDelReply") api.RegisterMessage((*IpsecTunnelIfSetSa)(nil), "ipsec.IpsecTunnelIfSetSa") api.RegisterMessage((*IpsecTunnelIfSetSaReply)(nil), "ipsec.IpsecTunnelIfSetSaReply") + api.RegisterMessage((*IpsecTunnelProtectDel)(nil), "ipsec.IpsecTunnelProtectDel") + api.RegisterMessage((*IpsecTunnelProtectDelReply)(nil), "ipsec.IpsecTunnelProtectDelReply") + api.RegisterMessage((*IpsecTunnelProtectDetails)(nil), "ipsec.IpsecTunnelProtectDetails") + api.RegisterMessage((*IpsecTunnelProtectDump)(nil), "ipsec.IpsecTunnelProtectDump") + api.RegisterMessage((*IpsecTunnelProtectUpdate)(nil), "ipsec.IpsecTunnelProtectUpdate") + api.RegisterMessage((*IpsecTunnelProtectUpdateReply)(nil), "ipsec.IpsecTunnelProtectUpdateReply") } // Messages returns list of all messages in this module. @@ -891,6 +1002,12 @@ func AllMessages() []api.Message { (*IpsecTunnelIfAddDelReply)(nil), (*IpsecTunnelIfSetSa)(nil), (*IpsecTunnelIfSetSaReply)(nil), + (*IpsecTunnelProtectDel)(nil), + (*IpsecTunnelProtectDelReply)(nil), + (*IpsecTunnelProtectDetails)(nil), + (*IpsecTunnelProtectDump)(nil), + (*IpsecTunnelProtectUpdate)(nil), + (*IpsecTunnelProtectUpdateReply)(nil), } } @@ -901,6 +1018,7 @@ type RPCService interface { DumpIpsecSpd(ctx context.Context, in *IpsecSpdDump) (RPCService_DumpIpsecSpdClient, error) DumpIpsecSpdInterface(ctx context.Context, in *IpsecSpdInterfaceDump) (RPCService_DumpIpsecSpdInterfaceClient, error) DumpIpsecSpds(ctx context.Context, in *IpsecSpdsDump) (RPCService_DumpIpsecSpdsClient, error) + DumpIpsecTunnelProtect(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_DumpIpsecTunnelProtectClient, error) IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) IpsecSadEntryAddDel(ctx context.Context, in *IpsecSadEntryAddDel) (*IpsecSadEntryAddDelReply, error) IpsecSelectBackend(ctx context.Context, in *IpsecSelectBackend) (*IpsecSelectBackendReply, error) @@ -908,6 +1026,8 @@ type RPCService interface { IpsecSpdEntryAddDel(ctx context.Context, in *IpsecSpdEntryAddDel) (*IpsecSpdEntryAddDelReply, error) IpsecTunnelIfAddDel(ctx context.Context, in *IpsecTunnelIfAddDel) (*IpsecTunnelIfAddDelReply, error) IpsecTunnelIfSetSa(ctx context.Context, in *IpsecTunnelIfSetSa) (*IpsecTunnelIfSetSaReply, error) + IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) + IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecTunnelProtectUpdate) (*IpsecTunnelProtectUpdateReply, error) } type serviceClient struct { @@ -1048,6 +1168,32 @@ func (c *serviceClient_DumpIpsecSpdsClient) Recv() (*IpsecSpdsDetails, error) { return m, nil } +func (c *serviceClient) DumpIpsecTunnelProtect(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_DumpIpsecTunnelProtectClient, error) { + stream := c.ch.SendMultiRequest(in) + x := &serviceClient_DumpIpsecTunnelProtectClient{stream} + return x, nil +} + +type RPCService_DumpIpsecTunnelProtectClient interface { + Recv() (*IpsecTunnelProtectDetails, error) +} + +type serviceClient_DumpIpsecTunnelProtectClient struct { + api.MultiRequestCtx +} + +func (c *serviceClient_DumpIpsecTunnelProtectClient) Recv() (*IpsecTunnelProtectDetails, error) { + m := new(IpsecTunnelProtectDetails) + stop, err := c.MultiRequestCtx.ReceiveReply(m) + if err != nil { + return nil, err + } + if stop { + return nil, io.EOF + } + return m, nil +} + func (c *serviceClient) IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) { out := new(IpsecInterfaceAddDelSpdReply) err := c.ch.SendRequest(in).ReceiveReply(out) @@ -1111,6 +1257,24 @@ func (c *serviceClient) IpsecTunnelIfSetSa(ctx context.Context, in *IpsecTunnelI return out, nil } +func (c *serviceClient) IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) { + out := new(IpsecTunnelProtectDelReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecTunnelProtectUpdate) (*IpsecTunnelProtectUpdateReply, error) { + out := new(IpsecTunnelProtectUpdateReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + // 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 diff --git a/plugins/vpp/binapi/vpp1908/nat/nat.ba.go b/plugins/vpp/binapi/vpp1908/nat/nat.ba.go index 1629f18889..6e60fe7d59 100644 --- a/plugins/vpp/binapi/vpp1908/nat/nat.ba.go +++ b/plugins/vpp/binapi/vpp1908/nat/nat.ba.go @@ -29,7 +29,7 @@ const ( // APIVersion is the API version of this module. APIVersion = "5.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0xa3356fd6 + VersionCrc = 0x7cd9bbbc ) // AddressFamily represents VPP binary API enum 'address_family'. @@ -158,8 +158,8 @@ func (*Address) GetTypeName() string { // IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { - Prefix IP4Address - Len uint8 + Address IP4Address + Len uint8 } func (*IP4Prefix) GetTypeName() string { @@ -168,8 +168,8 @@ func (*IP4Prefix) GetTypeName() string { // IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { - Prefix IP6Address - Len uint8 + Address IP6Address + Len uint8 } func (*IP6Prefix) GetTypeName() string { @@ -202,8 +202,8 @@ func (*Nat44LbAddrPort) GetTypeName() string { // Prefix represents VPP binary API type 'prefix'. type Prefix struct { - Address Address - AddressLength uint8 + Address Address + Len uint8 } func (*Prefix) GetTypeName() string { @@ -1216,7 +1216,7 @@ func (*Nat64AddDelPrefix) GetMessageName() string { return "nat64_add_del_prefix" } func (*Nat64AddDelPrefix) GetCrcString() string { - return "5d4919d7" + return "f1c54efa" } func (*Nat64AddDelPrefix) GetMessageType() api.MessageType { return api.RequestMessage @@ -1378,7 +1378,7 @@ func (*Nat64PrefixDetails) GetMessageName() string { return "nat64_prefix_details" } func (*Nat64PrefixDetails) GetCrcString() string { - return "276b9191" + return "6e0088d7" } func (*Nat64PrefixDetails) GetMessageType() api.MessageType { return api.ReplyMessage diff --git a/plugins/vpp/binapi/vpp1908/punt/punt.ba.go b/plugins/vpp/binapi/vpp1908/punt/punt.ba.go index 53034d2380..335d504e37 100644 --- a/plugins/vpp/binapi/vpp1908/punt/punt.ba.go +++ b/plugins/vpp/binapi/vpp1908/punt/punt.ba.go @@ -29,7 +29,7 @@ const ( // APIVersion is the API version of this module. APIVersion = "2.1.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x7cb64da0 + VersionCrc = 0xf01c2fb8 ) // AddressFamily represents VPP binary API enum 'address_family'. @@ -137,8 +137,8 @@ func (*Address) GetTypeName() string { // IP4Prefix represents VPP binary API type 'ip4_prefix'. type IP4Prefix struct { - Prefix IP4Address - Len uint8 + Address IP4Address + Len uint8 } func (*IP4Prefix) GetTypeName() string { @@ -147,8 +147,8 @@ func (*IP4Prefix) GetTypeName() string { // IP6Prefix represents VPP binary API type 'ip6_prefix'. type IP6Prefix struct { - Prefix IP6Address - Len uint8 + Address IP6Address + Len uint8 } func (*IP6Prefix) GetTypeName() string { @@ -169,8 +169,8 @@ func (*Mprefix) GetTypeName() string { // Prefix represents VPP binary API type 'prefix'. type Prefix struct { - Address Address - AddressLength uint8 + Address Address + Len uint8 } func (*Prefix) GetTypeName() string { diff --git a/plugins/vpp/binapi/vpp1908/tapv2/tapv2.ba.go b/plugins/vpp/binapi/vpp1908/tapv2/tapv2.ba.go index d572e71da1..8e6da266dc 100644 --- a/plugins/vpp/binapi/vpp1908/tapv2/tapv2.ba.go +++ b/plugins/vpp/binapi/vpp1908/tapv2/tapv2.ba.go @@ -23,9 +23,9 @@ const ( // ModuleName is the name of this module. ModuleName = "tapv2" // APIVersion is the API version of this module. - APIVersion = "2.0.0" + APIVersion = "2.1.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x588529f + VersionCrc = 0x25beb6c0 ) // SwInterfaceTapV2Details represents VPP binary API message 'sw_interface_tap_v2_details'. @@ -43,6 +43,7 @@ type SwInterfaceTapV2Details struct { HostIP4PrefixLen uint8 HostIP6Addr []byte `struc:"[16]byte"` HostIP6PrefixLen uint8 + HostMtuSize uint32 TapFlags uint32 } @@ -50,7 +51,7 @@ func (*SwInterfaceTapV2Details) GetMessageName() string { return "sw_interface_tap_v2_details" } func (*SwInterfaceTapV2Details) GetCrcString() string { - return "73dbc2d2" + return "5ee87a5f" } func (*SwInterfaceTapV2Details) GetMessageType() api.MessageType { return api.ReplyMessage @@ -94,6 +95,8 @@ type TapCreateV2 struct { HostIP4Gw []byte `struc:"[4]byte"` HostIP6GwSet uint8 HostIP6Gw []byte `struc:"[16]byte"` + HostMtuSet uint8 + HostMtuSize uint32 Tag []byte `struc:"[64]byte"` TapFlags uint32 } @@ -102,7 +105,7 @@ func (*TapCreateV2) GetMessageName() string { return "tap_create_v2" } func (*TapCreateV2) GetCrcString() string { - return "eabede03" + return "8fa99320" } func (*TapCreateV2) GetMessageType() api.MessageType { return api.RequestMessage diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go index e54a1ef5a6..9afe186f48 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go @@ -15,10 +15,11 @@ package vpp1908 import ( - "bytes" "fmt" "net" + "github.com/ligato/cn-infra/logging" + l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" l3binapi "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/ip" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" @@ -28,9 +29,9 @@ import ( func (h *RouteHandler) DumpRoutes() ([]*vppcalls.RouteDetails, error) { var routes []*vppcalls.RouteDetails // Dump IPv4 l3 FIB. - reqCtx := h.callsChannel.SendMultiRequest(&l3binapi.IPFibDump{}) + reqCtx := h.callsChannel.SendMultiRequest(&l3binapi.IPRouteDump{}) for { - fibDetails := &l3binapi.IPFibDetails{} + fibDetails := &l3binapi.IPRouteDetails{} stop, err := reqCtx.ReceiveReply(fibDetails) if stop { break @@ -38,72 +39,51 @@ func (h *RouteHandler) DumpRoutes() ([]*vppcalls.RouteDetails, error) { if err != nil { return nil, err } - ipv4Route, err := h.dumpRouteIPv4Details(fibDetails) + ipv4Route, err := h.dumpRouteIPDetails(fibDetails.Route) if err != nil { return nil, err } routes = append(routes, ipv4Route...) } - // Dump IPv6 l3 FIB. - reqCtx = h.callsChannel.SendMultiRequest(&l3binapi.IP6FibDump{}) - for { - fibDetails := &l3binapi.IP6FibDetails{} - stop, err := reqCtx.ReceiveReply(fibDetails) - if stop { - break - } - if err != nil { - return nil, err - } - ipv6Route, err := h.dumpRouteIPv6Details(fibDetails) - if err != nil { - return nil, err - } - routes = append(routes, ipv6Route...) - } - return routes, nil } -func (h *RouteHandler) dumpRouteIPv4Details(fibDetails *l3binapi.IPFibDetails) ([]*vppcalls.RouteDetails, error) { - return h.dumpRouteIPDetails(fibDetails.TableID, fibDetails.TableName, fibDetails.Address, fibDetails.AddressLength, fibDetails.Path, false) -} - -func (h *RouteHandler) dumpRouteIPv6Details(fibDetails *l3binapi.IP6FibDetails) ([]*vppcalls.RouteDetails, error) { - return h.dumpRouteIPDetails(fibDetails.TableID, fibDetails.TableName, fibDetails.Address, fibDetails.AddressLength, fibDetails.Path, true) -} - // dumpRouteIPDetails processes static route details and returns a route objects. Number of routes returned // depends on size of path list. -func (h *RouteHandler) dumpRouteIPDetails(tableID uint32, tableName []byte, address []byte, prefixLen uint8, paths []l3binapi.FibPath, ipv6 bool) ([]*vppcalls.RouteDetails, error) { +func (h *RouteHandler) dumpRouteIPDetails(ipRoute l3binapi.IPRoute) ([]*vppcalls.RouteDetails, error) { // Common fields for every route path (destination IP, VRF) var dstIP string - if ipv6 { - dstIP = fmt.Sprintf("%s/%d", net.IP(address).To16().String(), uint32(prefixLen)) + netIP := make([]byte, 16) + copy(netIP[:], ipRoute.Prefix.Address.Un.XXX_UnionData[:]) + if ipRoute.Prefix.Address.Af == l3binapi.ADDRESS_IP6 { + dstIP = fmt.Sprintf("%s/%d", net.IP(netIP).To16().String(), uint32(ipRoute.Prefix.Len)) } else { - dstIP = fmt.Sprintf("%s/%d", net.IP(address[:4]).To4().String(), uint32(prefixLen)) + dstIP = fmt.Sprintf("%s/%d", net.IP(netIP[:4]).To4().String(), uint32(ipRoute.Prefix.Len)) } var routeDetails []*vppcalls.RouteDetails // Paths - if len(paths) > 0 { - for _, path := range paths { + if ipRoute.NPaths > 0 { + for _, path := range ipRoute.Paths { // Next hop IP address var nextHopIP string - if ipv6 { - nextHopIP = fmt.Sprintf("%s", net.IP(path.NextHop).To16().String()) + netIP := make([]byte, 16) + copy(netIP[:], path.Nh.Address.XXX_UnionData[:]) + logging.DefaultLogger.Warnf("netip: %v, proto %v", path.Nh.Address.XXX_UnionData, path.Proto) + if path.Proto == l3binapi.FIB_API_PATH_NH_PROTO_IP6 { + nextHopIP = fmt.Sprintf("%s", net.IP(netIP).To16().String()) } else { - nextHopIP = fmt.Sprintf("%s", net.IP(path.NextHop[:4]).To4().String()) + nextHopIP = fmt.Sprintf("%s", net.IP(netIP[:4]).To4().String()) } // Route type (if via VRF is used) var routeType l3.Route_RouteType var viaVrfID uint32 - if uintToBool(path.IsDrop) { + if path.Type == l3binapi.FIB_API_PATH_TYPE_DROP { routeType = l3.Route_DROP - } else if path.SwIfIndex == NextHopOutgoingIfUnset && path.TableID != tableID { + } else if path.SwIfIndex == NextHopOutgoingIfUnset && path.TableID != ipRoute.TableID { // outgoing interface not specified and path table is not equal to route table id = inter-VRF route routeType = l3.Route_INTER_VRF viaVrfID = path.TableID @@ -127,7 +107,7 @@ func (h *RouteHandler) dumpRouteIPDetails(tableID uint32, tableName []byte, addr // Route configuration route := &l3.Route{ Type: routeType, - VrfId: tableID, + VrfId: ipRoute.TableID, DstNetwork: dstIP, NextHopAddr: nextHopIP, OutgoingInterface: ifName, @@ -148,21 +128,9 @@ func (h *RouteHandler) dumpRouteIPDetails(tableID uint32, tableName []byte, addr // Route metadata meta := &vppcalls.RouteMeta{ - TableName: bytesToString(tableName), - OutgoingIfIdx: ifIdx, - NextHopID: path.NextHopID, - IsIPv6: ipv6, - RpfID: path.RpfID, - Afi: path.Afi, - IsLocal: uintToBool(path.IsLocal), - IsUDPEncap: uintToBool(path.IsUDPEncap), - IsDvr: uintToBool(path.IsDvr), - IsProhibit: uintToBool(path.IsProhibit), - IsResolveAttached: uintToBool(path.IsResolveAttached), - IsResolveHost: uintToBool(path.IsResolveHost), - IsSourceLookup: uintToBool(path.IsSourceLookup), - IsUnreach: uintToBool(path.IsUnreach), - LabelStack: labelStack, + OutgoingIfIdx: ifIdx, + RpfID: path.RpfID, + LabelStack: labelStack, } routeDetails = append(routeDetails, &vppcalls.RouteDetails{ @@ -172,18 +140,12 @@ func (h *RouteHandler) dumpRouteIPDetails(tableID uint32, tableName []byte, addr } } else { // Return route without path fields, but this is not a valid configuration - h.log.Warnf("Route with destination IP %s (VRF %d) has no path specified", dstIP, tableID) - route := &l3.Route{ - Type: l3.Route_INTRA_VRF, // default - VrfId: tableID, - DstNetwork: dstIP, - } - meta := &vppcalls.RouteMeta{ - TableName: string(bytes.SplitN(tableName, []byte{0x00}, 2)[0]), - } routeDetails = append(routeDetails, &vppcalls.RouteDetails{ - Route: route, - Meta: meta, + Route: &l3.Route{ + Type: l3.Route_INTRA_VRF, // default + VrfId: ipRoute.TableID, + DstNetwork: dstIP, + }, }) } diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go index d9927811c0..b8e42c64ae 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go @@ -35,13 +35,40 @@ func TestDumpStaticRoutes(t *testing.T) { ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - ctx.MockVpp.MockReply(&ip.IPFibDetails{ - Path: []ip.FibPath{{SwIfIndex: 2}}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - ctx.MockVpp.MockReply(&ip.IP6FibDetails{ - Path: []ip.FibPath{{SwIfIndex: 1}}, - }) + ctx.MockVpp.MockReply(&ip.IPRouteDetails{ + Route: ip.IPRoute{ + Prefix: ip.Prefix{ + Address: ip.Address{ + Af: ip.ADDRESS_IP4, + Un: ip.AddressUnion{ + XXX_UnionData: [16]byte{10, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + }, + }, + }, + Paths: []ip.FibPath{ + { + SwIfIndex: 2, + }, + }, + }, + }, + &ip.IPRouteDetails{ + Route: ip.IPRoute{ + Prefix: ip.Prefix{ + Address: ip.Address{ + Af: ip.ADDRESS_IP6, + Un: ip.AddressUnion{ + XXX_UnionData: [16]byte{255, 255, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + }, + }, + }, + Paths: []ip.FibPath{ + { + SwIfIndex: 1, + }, + }, + }, + }) ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) rtDetails, err := l3handler.DumpRoutes() diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go index 03d2cd62d1..a64f931972 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go @@ -17,7 +17,10 @@ package vpp1908 import ( "net" + "github.com/ligato/cn-infra/logging" + "github.com/ligato/cn-infra/utils/addrs" + vpp_l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/ip" "github.com/pkg/errors" @@ -39,54 +42,50 @@ const ( // vppAddDelRoute adds or removes route, according to provided input. Every route has to contain VRF ID (default is 0). func (h *RouteHandler) vppAddDelRoute(route *vpp_l3.Route, rtIfIdx uint32, delete bool) error { - req := &ip.IPAddDelRoute{} + req := &ip.IPRouteAddDel{ + // Multi path is always true + IsMultipath: 1, + } if delete { req.IsAdd = 0 } else { req.IsAdd = 1 } - // Destination address (route set identifier) - parsedDstIP, isIpv6, err := addrs.ParseIPWithPrefix(route.DstNetwork) - if err != nil { - return err - } - parsedNextHopIP := net.ParseIP(route.NextHopAddr) - prefix, _ := parsedDstIP.Mask.Size() - if isIpv6 { - req.IsIPv6 = 1 - req.DstAddress = []byte(parsedDstIP.IP.To16()) - req.NextHopAddress = []byte(parsedNextHopIP.To16()) - } else { - req.IsIPv6 = 0 - req.DstAddress = []byte(parsedDstIP.IP.To4()) - req.NextHopAddress = []byte(parsedNextHopIP.To4()) - } - req.DstAddressLength = byte(prefix) - // Common route parameters - req.NextHopWeight = uint8(route.Weight) - req.NextHopPreference = uint8(route.Preference) - req.NextHopViaLabel = NextHopViaLabelUnset - req.ClassifyTableIndex = ClassifyTableIndexUnset + fibPath := ip.FibPath{ + Weight: uint8(route.Weight), + Preference: uint8(route.Preference), + } + fibPath.Nh, fibPath.Proto = setFibPathNhAndProto(route.NextHopAddr) // VRF/Other route parameters based on type - req.TableID = route.VrfId if route.Type == vpp_l3.Route_INTER_VRF { - req.NextHopSwIfIndex = rtIfIdx - req.NextHopTableID = route.ViaVrfId + fibPath.SwIfIndex = rtIfIdx + fibPath.TableID = route.ViaVrfId } else if route.Type == vpp_l3.Route_DROP { - req.IsDrop = 1 + fibPath.Type = ip.FIB_API_PATH_TYPE_DROP } else { - req.NextHopSwIfIndex = rtIfIdx - req.NextHopTableID = route.VrfId + fibPath.SwIfIndex = rtIfIdx + fibPath.TableID = route.VrfId + } + // Destination address + prefix, err := setRoutePrefix(route.DstNetwork) + if err != nil { + return err } - // Multi path is always true - req.IsMultipath = 1 + req.Route = ip.IPRoute{ + TableID: route.VrfId, + Prefix: prefix, + NPaths: 1, + Paths: []ip.FibPath{fibPath}, + } + + logging.DefaultLogger.Warnf("route: %v, vrf %v/%v", req.Route, req.Route.TableID, route.VrfId) // Send message - reply := &ip.IPAddDelRouteReply{} + reply := &ip.IPRouteAddDelReply{} if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { return err } @@ -114,6 +113,56 @@ func (h *RouteHandler) VppDelRoute(route *vpp_l3.Route) error { return h.vppAddDelRoute(route, swIfIdx, true) } +func setFibPathNhAndProto(ipStr string) (nh ip.FibPathNh, proto ip.FibPathNhProto) { + netIP := net.ParseIP(ipStr) + if netIP == nil { + return + } + var ipData [16]byte + if netIP.To4() == nil { + proto = ip.FIB_API_PATH_NH_PROTO_IP6 + copy(ipData[:], netIP[:]) + } else { + proto = ip.FIB_API_PATH_NH_PROTO_IP4 + copy(ipData[:], netIP[12:]) + } + return ip.FibPathNh{ + Address: ip.AddressUnion{ + XXX_UnionData: ipData, + }, + ViaLabel: NextHopViaLabelUnset, + ClassifyTableIndex: ClassifyTableIndexUnset, + }, proto +} + +func setRoutePrefix(dstNetwork string) (ip.Prefix, error) { + addr, isIPv6, err := addrs.ParseIPWithPrefix(dstNetwork) + if err != nil { + return ip.Prefix{}, err + } + mask, _ := addr.Mask.Size() + return ip.Prefix{ + Address: ip.Address{ + Af: func(isIPv6 bool) ip.AddressFamily { + if isIPv6 { + return ip.ADDRESS_IP6 + } + return ip.ADDRESS_IP4 + }(isIPv6), + Un: func(ipAddr []byte) ip.AddressUnion { + var addrUnion ip.AddressUnion + if isIPv6 { + copy(addrUnion.XXX_UnionData[:], ipAddr[:]) + } else { + copy(addrUnion.XXX_UnionData[:], ipAddr[12:]) + } + return addrUnion + }(addr.IP), + }, + Len: uint8(mask), + }, nil +} + func (h *RouteHandler) getRouteSwIfIndex(ifName string) (swIfIdx uint32, err error) { swIfIdx = NextHopOutgoingIfUnset if ifName != "" { @@ -124,4 +173,4 @@ func (h *RouteHandler) getRouteSwIfIndex(ifName string) (swIfIdx uint32, err err swIfIdx = meta.SwIfIndex } return -} \ No newline at end of file +} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls_test.go index 56a6271642..8a66f667c4 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls_test.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls_test.go @@ -54,11 +54,11 @@ func TestAddRoute(t *testing.T) { ctx, _, rtHandler := routeTestSetup(t) defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&ip.IPAddDelRouteReply{}) + ctx.MockVpp.MockReply(&ip.IPRouteAddDelReply{}) err := rtHandler.VppAddRoute(routes[0]) Expect(err).To(Succeed()) - ctx.MockVpp.MockReply(&ip.IPAddDelRouteReply{}) + ctx.MockVpp.MockReply(&ip.IPRouteAddDelReply{}) err = rtHandler.VppAddRoute(routes[2]) Expect(err).To(Not(BeNil())) // unknown interface } @@ -68,15 +68,15 @@ func TestDeleteRoute(t *testing.T) { ctx, _, rtHandler := routeTestSetup(t) defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&ip.IPAddDelRouteReply{}) + ctx.MockVpp.MockReply(&ip.IPRouteAddDelReply{}) err := rtHandler.VppDelRoute(routes[0]) Expect(err).To(Succeed()) - ctx.MockVpp.MockReply(&ip.IPAddDelRouteReply{}) + ctx.MockVpp.MockReply(&ip.IPRouteAddDelReply{}) err = rtHandler.VppDelRoute(routes[1]) Expect(err).To(Succeed()) - ctx.MockVpp.MockReply(&ip.IPAddDelRouteReply{Retval: 1}) + ctx.MockVpp.MockReply(&ip.IPRouteAddDelReply{Retval: 1}) err = rtHandler.VppDelRoute(routes[0]) Expect(err).To(Not(BeNil())) } diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump.go index ddbfd5f034..7264f8a2d4 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump.go @@ -15,18 +15,18 @@ package vpp1908 import ( + "bytes" + l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/ip" - "bytes" ) // DumpVrfTables dumps all configured VRF tables. func (h *VrfTableHandler) DumpVrfTables() (tables []*l3.VrfTable, err error) { // dump IPv4 VRF tables - v4Tables := make(map[uint32]*l3.VrfTable) - reqCtx := h.callsChannel.SendMultiRequest(&ip.IPFibDump{}) + reqCtx := h.callsChannel.SendMultiRequest(&ip.IPTableDump{}) for { - fibDetails := &ip.IPFibDetails{} + fibDetails := &ip.IPTableDetails{} stop, err := reqCtx.ReceiveReply(fibDetails) if stop { break @@ -34,43 +34,21 @@ func (h *VrfTableHandler) DumpVrfTables() (tables []*l3.VrfTable, err error) { if err != nil { return nil, err } - if _, dumped := v4Tables[fibDetails.TableID]; !dumped { - v4Tables[fibDetails.TableID] = &l3.VrfTable{ - Id: fibDetails.TableID, - Protocol: l3.VrfTable_IPV4, - Label: bytesToString(fibDetails.TableName), - } - } + tables = append(tables, &l3.VrfTable{ + Id: fibDetails.Table.TableID, + Protocol: getTableProto(uintToBool(fibDetails.Table.IsIP6)), + Label: bytesToString(fibDetails.Table.Name), + }) } - // dump IPv6 VRF tables - v6Tables := make(map[uint32]*l3.VrfTable) - reqCtx = h.callsChannel.SendMultiRequest(&ip.IP6FibDump{}) - for { - fibDetails := &ip.IP6FibDetails{} - stop, err := reqCtx.ReceiveReply(fibDetails) - if stop { - break - } - if err != nil { - return nil, err - } - if _, dumped := v6Tables[fibDetails.TableID]; !dumped { - v6Tables[fibDetails.TableID] = &l3.VrfTable{ - Id: fibDetails.TableID, - Protocol: l3.VrfTable_IPV6, - Label: bytesToString(fibDetails.TableName), - } - } - } + return tables, nil +} - for _, table := range v4Tables { - tables = append(tables, table) +func getTableProto(isIPv6 bool) l3.VrfTable_Protocol { + if isIPv6 { + return l3.VrfTable_IPV6 } - for _, table := range v6Tables { - tables = append(tables, table) - } - return tables, nil + return l3.VrfTable_IPV4 } func bytesToString(b []byte) string { diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump_test.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump_test.go index fb9d7a99e7..2d2e583e5e 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump_test.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_dump_test.go @@ -31,27 +31,35 @@ func TestDumpVrfTables(t *testing.T) { vthandler := NewVrfTableVppHandler(ctx.MockChannel, logrus.DefaultLogger()) ctx.MockVpp.MockReply( - &ip.IPFibDetails{ - TableID: 3, - TableName: []byte("table3"), - Path: []ip.FibPath{{SwIfIndex: 2}, {SwIfIndex: 4}}, + &ip.IPTableDetails{ + Table: ip.IPTable{ + TableID: 1, + Name: []byte("table3"), + IsIP6: 0, + }, }, - &ip.IPFibDetails{ - TableID: 3, - TableName: []byte("table3"), - Path: []ip.FibPath{{SwIfIndex: 5}}, + &ip.IPTableDetails{ + Table: ip.IPTable{ + TableID: 2, + Name: []byte("table3"), + IsIP6: 0, + }, }, - &ip.IPFibDetails{ - TableID: 2, - TableName: []byte("table2"), - Path: []ip.FibPath{{SwIfIndex: 5}}, - }) + &ip.IPTableDetails{ + Table: ip.IPTable{ + TableID: 3, + Name: []byte("table2"), + IsIP6: 1, + }, + }, + ) ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) ctx.MockVpp.MockReply( - &ip.IP6FibDetails{ - TableID: 2, - TableName: []byte("table2"), - Path: []ip.FibPath{{SwIfIndex: 5}}, + &ip.IPRouteDetails{ + Route: ip.IPRoute{ + TableID: 2, + Paths: []ip.FibPath{{SwIfIndex: 5}}, + }, }) ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) @@ -62,8 +70,8 @@ func TestDumpVrfTables(t *testing.T) { Expect(vrfTables[1]).To(Equal(&l3.VrfTable{Id: 3, Protocol: l3.VrfTable_IPV4, Label: "table3"})) Expect(vrfTables[0]).To(Equal(&l3.VrfTable{Id: 2, Protocol: l3.VrfTable_IPV4, Label: "table2"})) } else { - Expect(vrfTables[0]).To(Equal(&l3.VrfTable{Id: 3, Protocol: l3.VrfTable_IPV4, Label: "table3"})) - Expect(vrfTables[1]).To(Equal(&l3.VrfTable{Id: 2, Protocol: l3.VrfTable_IPV4, Label: "table2"})) + Expect(vrfTables[0]).To(Equal(&l3.VrfTable{Id: 1, Protocol: l3.VrfTable_IPV4, Label: "table3"})) + Expect(vrfTables[1]).To(Equal(&l3.VrfTable{Id: 2, Protocol: l3.VrfTable_IPV4, Label: "table3"})) } - Expect(vrfTables[2]).To(Equal(&l3.VrfTable{Id: 2, Protocol: l3.VrfTable_IPV6, Label: "table2"})) + Expect(vrfTables[2]).To(Equal(&l3.VrfTable{Id: 3, Protocol: l3.VrfTable_IPV6, Label: "table2"})) } diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls.go index 1dcda87f2f..235966e804 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls.go @@ -31,10 +31,12 @@ func (h *VrfTableHandler) DelVrfTable(table *l3.VrfTable) error { func (h *VrfTableHandler) addDelVrfTable(table *l3.VrfTable, isAdd bool) error { req := &ip.IPTableAddDel{ - TableID: table.Id, - IsIPv6: boolToUint(table.GetProtocol() == l3.VrfTable_IPV6), - Name: []byte(table.Label), - IsAdd: boolToUint(isAdd), + Table: ip.IPTable{ + TableID: table.Id, + IsIP6: boolToUint(table.GetProtocol() == l3.VrfTable_IPV6), + Name: []byte(table.Label), + }, + IsAdd: boolToUint(isAdd), } reply := &ip.IPTableAddDelReply{} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls_test.go index cea2325d0e..c1edaddf59 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls_test.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/vrf_vppcalls_test.go @@ -55,10 +55,10 @@ func TestAddVrfTable(t *testing.T) { vppMsg, ok := ctx.MockChannel.Msg.(*ip.IPTableAddDel) Expect(ok).To(BeTrue()) - Expect(vppMsg.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(0)) + Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.IsIP6).To(BeEquivalentTo(0)) Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) - Expect(vppMsg.Name).To(BeEquivalentTo([]byte("table1"))) + Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) ctx.MockVpp.MockReply(&ip.IPTableAddDelReply{}) err = vtHandler.AddVrfTable(vrfTables[1]) @@ -66,10 +66,10 @@ func TestAddVrfTable(t *testing.T) { vppMsg, ok = ctx.MockChannel.Msg.(*ip.IPTableAddDel) Expect(ok).To(BeTrue()) - Expect(vppMsg.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.IsIP6).To(BeEquivalentTo(1)) Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) - Expect(vppMsg.Name).To(BeEquivalentTo([]byte("table1"))) + Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) ctx.MockVpp.MockReply(&ip.IPTableAddDelReply{}) err = vtHandler.AddVrfTable(vrfTables[2]) @@ -77,10 +77,10 @@ func TestAddVrfTable(t *testing.T) { vppMsg, ok = ctx.MockChannel.Msg.(*ip.IPTableAddDel) Expect(ok).To(BeTrue()) - Expect(vppMsg.TableID).To(BeEquivalentTo(2)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.TableID).To(BeEquivalentTo(2)) + Expect(vppMsg.Table.IsIP6).To(BeEquivalentTo(1)) Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) - Expect(vppMsg.Name).To(BeEquivalentTo([]byte("table2"))) + Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table2"))) ctx.MockVpp.MockReply(&ip.IPTableAddDelReply{Retval: 1}) err = vtHandler.AddVrfTable(vrfTables[0]) @@ -98,10 +98,10 @@ func TestDeleteVrfTable(t *testing.T) { vppMsg, ok := ctx.MockChannel.Msg.(*ip.IPTableAddDel) Expect(ok).To(BeTrue()) - Expect(vppMsg.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(0)) + Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.IsIP6).To(BeEquivalentTo(0)) Expect(vppMsg.IsAdd).To(BeEquivalentTo(0)) - Expect(vppMsg.Name).To(BeEquivalentTo([]byte("table1"))) + Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) ctx.MockVpp.MockReply(&ip.IPTableAddDelReply{}) err = vtHandler.DelVrfTable(vrfTables[1]) @@ -109,10 +109,10 @@ func TestDeleteVrfTable(t *testing.T) { vppMsg, ok = ctx.MockChannel.Msg.(*ip.IPTableAddDel) Expect(ok).To(BeTrue()) - Expect(vppMsg.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.IsIP6).To(BeEquivalentTo(1)) Expect(vppMsg.IsAdd).To(BeEquivalentTo(0)) - Expect(vppMsg.Name).To(BeEquivalentTo([]byte("table1"))) + Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) ctx.MockVpp.MockReply(&ip.IPTableAddDelReply{}) err = vtHandler.DelVrfTable(vrfTables[2]) @@ -120,10 +120,10 @@ func TestDeleteVrfTable(t *testing.T) { vppMsg, ok = ctx.MockChannel.Msg.(*ip.IPTableAddDel) Expect(ok).To(BeTrue()) - Expect(vppMsg.TableID).To(BeEquivalentTo(2)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(1)) + Expect(vppMsg.Table.TableID).To(BeEquivalentTo(2)) + Expect(vppMsg.Table.IsIP6).To(BeEquivalentTo(1)) Expect(vppMsg.IsAdd).To(BeEquivalentTo(0)) - Expect(vppMsg.Name).To(BeEquivalentTo([]byte("table2"))) + Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table2"))) ctx.MockVpp.MockReply(&ip.IPTableAddDelReply{Retval: 1}) err = vtHandler.DelVrfTable(vrfTables[0]) @@ -135,4 +135,4 @@ func vrfTableTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.VrfTableVpp log := logrus.NewLogger("test-log") vtHandler := vpp1908.NewVrfTableVppHandler(ctx.MockChannel, log) return ctx, vtHandler -} \ No newline at end of file +} diff --git a/vpp.env b/vpp.env index 2f1059a413..ec62eba68a 100644 --- a/vpp.env +++ b/vpp.env @@ -9,7 +9,7 @@ VPP_BINAPI_1901=plugins/vpp/binapi/vpp1901 VPP_IMG_1904=ligato/vpp-base:19.04 VPP_BINAPI_1904=plugins/vpp/binapi/vpp1904 # VPP 19.08-rc0 -VPP_IMG_1908=ligato/vpp-base:19.08-rc0.437-gc898a4f5b +VPP_IMG_1908=ligato/vpp-base:19.08-rc0.581-g3eea9de89 VPP_BINAPI_1908=plugins/vpp/binapi/vpp1908 # default VPP VPP_DEFAULT=1904 \ No newline at end of file From c1cde560882237fa26b561f049127d2d64026047 Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Mon, 8 Jul 2019 07:53:33 +0200 Subject: [PATCH 5/9] removed redundant log Signed-off-by: Vladimir Lavor --- plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go index a64f931972..91ec4fd83b 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go @@ -17,8 +17,6 @@ package vpp1908 import ( "net" - "github.com/ligato/cn-infra/logging" - "github.com/ligato/cn-infra/utils/addrs" vpp_l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" @@ -82,8 +80,6 @@ func (h *RouteHandler) vppAddDelRoute(route *vpp_l3.Route, rtIfIdx uint32, delet Paths: []ip.FibPath{fibPath}, } - logging.DefaultLogger.Warnf("route: %v, vrf %v/%v", req.Route, req.Route.TableID, route.VrfId) - // Send message reply := &ip.IPRouteAddDelReply{} if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { From ff65fc031c29e46a5990bcbf0de6a0aed87aecfd Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Mon, 8 Jul 2019 13:20:55 +0200 Subject: [PATCH 6/9] code improvements and cleanup Signed-off-by: Vladimir Lavor --- .../vpp/abfplugin/vppcalls/abf_vppcalls.go | 4 +-- .../vppcalls/vpp1901/abf_vppcalls_test.go | 2 +- .../vppcalls/vpp1901/vppcalls_handlers.go | 11 ++++--- .../vppcalls/vpp1904/abf_vppcalls_test.go | 2 +- .../vppcalls/vpp1904/vppcalls_handlers.go | 11 ++++--- .../vppcalls/vpp1908/abf_vppcalls.go | 27 +++++++++------- .../vppcalls/vpp1908/abf_vppcalls_test.go | 6 ++-- .../vppcalls/vpp1908/dump_abf_vppcalls.go | 9 +++--- .../vppcalls/vpp1908/vppcalls_handlers.go | 11 ++++--- .../l3plugin/vppcalls/vpp1908/route_dump.go | 3 -- .../vppcalls/vpp1908/route_dump_test.go | 8 ++--- .../vppcalls/vpp1908/route_vppcalls.go | 32 +------------------ .../vppcalls/vpp1908/vppcalls_handlers.go | 26 +++++++++++++++ 13 files changed, 77 insertions(+), 75 deletions(-) diff --git a/plugins/vpp/abfplugin/vppcalls/abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/abf_vppcalls.go index a5da05d4d7..20edffce86 100644 --- a/plugins/vpp/abfplugin/vppcalls/abf_vppcalls.go +++ b/plugins/vpp/abfplugin/vppcalls/abf_vppcalls.go @@ -63,7 +63,7 @@ var Versions = map[string]HandlerVersion{} type HandlerVersion struct { Msgs []govppapi.Message - New func(govppapi.Channel, aclidx.ACLMetadataIndex, ifaceidx.IfaceMetadataIndex) ABFVppAPI + New func(govppapi.Channel, aclidx.ACLMetadataIndex, ifaceidx.IfaceMetadataIndex, logging.Logger) ABFVppAPI } func CompatibleABFVppHandler(ch govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) ABFVppAPI { @@ -77,7 +77,7 @@ func CompatibleABFVppHandler(ch govppapi.Channel, aclIdx aclidx.ACLMetadataIndex continue } log.Debug("found compatible version:", ver) - return h.New(ch, aclIdx, ifIdx) + return h.New(ch, aclIdx, ifIdx, log) } panic("no compatible version available") } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1901/abf_vppcalls_test.go b/plugins/vpp/abfplugin/vppcalls/vpp1901/abf_vppcalls_test.go index 4f2a6a7baa..7f57095e02 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1901/abf_vppcalls_test.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1901/abf_vppcalls_test.go @@ -271,6 +271,6 @@ func abfTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.ABFVppAPI, iface log := logrus.NewLogger("test-log") aclIdx := aclidx.NewACLIndex(log, "acl-index") ifIdx := ifaceidx.NewIfaceIndex(log, "if-index") - abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx) + abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log) return ctx, abfHandler, ifIdx } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1901/vppcalls_handlers.go b/plugins/vpp/abfplugin/vppcalls/vpp1901/vppcalls_handlers.go index 3c662739e7..6f2571bc57 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1901/vppcalls_handlers.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1901/vppcalls_handlers.go @@ -16,6 +16,7 @@ package vpp1901 import ( govppapi "git.fd.io/govpp.git/api" + "github.com/ligato/cn-infra/logging" "github.com/ligato/vpp-agent/plugins/vpp/abfplugin/vppcalls" "github.com/ligato/vpp-agent/plugins/vpp/aclplugin/aclidx" @@ -29,24 +30,26 @@ func init() { vppcalls.Versions["vpp1901"] = vppcalls.HandlerVersion{ Msgs: msgs, - New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex) vppcalls.ABFVppAPI { - return NewABFVppHandler(ch, aclIndexes, ifIndexes) + New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.ABFVppAPI { + return NewABFVppHandler(ch, aclIndexes, ifIndexes, log) }, } } -// ABFVppHandler is accessor for abfrelated vppcalls methods +// ABFVppHandler is accessor for abf-related vppcalls methods type ABFVppHandler struct { callsChannel govppapi.Channel aclIndexes aclidx.ACLMetadataIndex ifIndexes ifaceidx.IfaceMetadataIndex + log logging.Logger } // NewABFVppHandler returns new ABFVppHandler. -func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex) *ABFVppHandler { +func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *ABFVppHandler { return &ABFVppHandler{ callsChannel: calls, aclIndexes: aclIdx, ifIndexes: ifIdx, + log: log, } } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1904/abf_vppcalls_test.go b/plugins/vpp/abfplugin/vppcalls/vpp1904/abf_vppcalls_test.go index 6e89096077..ab2ec1ca8f 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1904/abf_vppcalls_test.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1904/abf_vppcalls_test.go @@ -271,6 +271,6 @@ func abfTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.ABFVppAPI, iface log := logrus.NewLogger("test-log") aclIdx := aclidx.NewACLIndex(log, "acl-index") ifIdx := ifaceidx.NewIfaceIndex(log, "if-index") - abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx) + abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log) return ctx, abfHandler, ifIdx } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1904/vppcalls_handlers.go b/plugins/vpp/abfplugin/vppcalls/vpp1904/vppcalls_handlers.go index 121b4299ed..d36ed64313 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1904/vppcalls_handlers.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1904/vppcalls_handlers.go @@ -16,6 +16,7 @@ package vpp1904 import ( govppapi "git.fd.io/govpp.git/api" + "github.com/ligato/cn-infra/logging" "github.com/ligato/vpp-agent/plugins/vpp/abfplugin/vppcalls" "github.com/ligato/vpp-agent/plugins/vpp/aclplugin/aclidx" @@ -29,24 +30,26 @@ func init() { vppcalls.Versions["vpp1904"] = vppcalls.HandlerVersion{ Msgs: msgs, - New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex) vppcalls.ABFVppAPI { - return NewABFVppHandler(ch, aclIndexes, ifIndexes) + New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.ABFVppAPI { + return NewABFVppHandler(ch, aclIndexes, ifIndexes, log) }, } } -// ABFVppHandler is accessor for abfrelated vppcalls methods +// ABFVppHandler is accessor for abf-related vppcalls methods type ABFVppHandler struct { callsChannel govppapi.Channel aclIndexes aclidx.ACLMetadataIndex ifIndexes ifaceidx.IfaceMetadataIndex + log logging.Logger } // NewABFVppHandler returns new ABFVppHandler. -func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex) *ABFVppHandler { +func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *ABFVppHandler { return &ABFVppHandler{ callsChannel: calls, aclIndexes: aclIdx, ifIndexes: ifIdx, + log: log, } } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go index d177dae455..98272cebe9 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls.go @@ -125,6 +125,7 @@ func (h *ABFVppHandler) abfAddDelPolicy(policyID, aclID uint32, abfPaths []*vpp_ } func (h *ABFVppHandler) toFibPaths(abfPaths []*vpp_abf.ABF_ForwardingPath) (fibPaths []abf.FibPath) { + var err error for _, abfPath := range abfPaths { // fib path interface ifData, exists := h.ifIndexes.LookupByName(abfPath.InterfaceName) @@ -138,7 +139,9 @@ func (h *ABFVppHandler) toFibPaths(abfPaths []*vpp_abf.ABF_ForwardingPath) (fibP Preference: uint8(abfPath.Preference), Type: setFibPathType(abfPath.Dvr), } - fibPath.Nh, fibPath.Proto = setFibPathNhAndProto(abfPath.NextHopIp) + if fibPath.Nh, fibPath.Proto, err = setFibPathNhAndProto(abfPath.NextHopIp); err != nil { + h.log.Errorf("ABF path next hop error: %v", err) + } fibPaths = append(fibPaths, fibPath) } @@ -154,26 +157,28 @@ func setFibPathType(isDvr bool) abf.FibPathType { } // resolve IP address and return FIB path next hop (IP address) and IPv4/IPv6 version -func setFibPathNhAndProto(ipStr string) (nh abf.FibPathNh, proto abf.FibPathNhProto) { +func setFibPathNhAndProto(ipStr string) (nh abf.FibPathNh, proto abf.FibPathNhProto, err error) { netIP := net.ParseIP(ipStr) if netIP == nil { - return + return nh, proto, errors.Errorf("failed to parse next hop IP address %s", ipStr) } - var ipData [16]byte - if netIP.To4() == nil { + var au abf.AddressUnion + if ipv4 := netIP.To4(); ipv4 == nil { + var address abf.IP6Address proto = abf.FIB_API_PATH_NH_PROTO_IP6 - copy(ipData[:], netIP[:]) + copy(address[:], netIP[:]) + au.SetIP6(address) } else { + var address abf.IP4Address proto = abf.FIB_API_PATH_NH_PROTO_IP4 - copy(ipData[:], netIP[12:]) + copy(address[:], netIP[12:]) + au.SetIP4(address) } return abf.FibPathNh{ - Address: abf.AddressUnion{ - XXX_UnionData: ipData, - }, + Address: au, ViaLabel: NextHopViaLabelUnset, ClassifyTableIndex: ClassifyTableIndexUnset, - }, proto + }, proto, nil } func boolToUint(input bool) uint8 { diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go index ed37096cfc..464228ef15 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/abf_vppcalls_test.go @@ -75,9 +75,9 @@ func TestAddABFPolicy(t *testing.T) { Expect(req.Policy.ACLIndex).To(Equal(uint32(2))) Expect(req.Policy.NPaths).To(Equal(uint8(2))) Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5))) - Expect(req.Policy.Paths[0].Nh.Address.XXX_UnionData[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) + Expect(req.Policy.Paths[0].Nh.Address.GetIP4()).To(BeEquivalentTo(abf.IP4Address([4]uint8{10, 0, 0, 1}))) Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10))) - Expect(req.Policy.Paths[1].Nh.Address.XXX_UnionData[:]).To(BeEquivalentTo(net.ParseIP("ffff::").To16())) + Expect(req.Policy.Paths[1].Nh.Address.GetIP6()).To(BeEquivalentTo(abf.IP6Address([16]uint8{255, 255}))) } func TestAddABFPolicyError(t *testing.T) { @@ -271,6 +271,6 @@ func abfTestSetup(t *testing.T) (*vppcallmock.TestCtx, vppcalls.ABFVppAPI, iface log := logrus.NewLogger("test-log") aclIdx := aclidx.NewACLIndex(log, "acl-index") ifIdx := ifaceidx.NewIfaceIndex(log, "if-index") - abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx) + abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log) return ctx, abfHandler, ifIdx } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go index 1b998f95c1..6fd3d91157 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/dump_abf_vppcalls.go @@ -150,15 +150,14 @@ func (h *ABFVppHandler) dumpABFPolicy() ([]*vppcalls.ABFDetails, error) { // returns next hop IP address func parseNextHopToString(nh abf.FibPathNh, proto abf.FibPathNhProto) string { - var nhIP net.IP = make([]byte, 16) - copy(nhIP[:], nh.Address.XXX_UnionData[:]) if proto == abf.FIB_API_PATH_NH_PROTO_IP4 { - return nhIP[:4].To4().String() + addr := nh.Address.GetIP4() + return net.IP(addr[:]).To4().String() } if proto == abf.FIB_API_PATH_NH_PROTO_IP6 { - return nhIP.To16().String() + addr := nh.Address.GetIP6() + return net.IP(addr[:]).To16().String() } - return "" } diff --git a/plugins/vpp/abfplugin/vppcalls/vpp1908/vppcalls_handlers.go b/plugins/vpp/abfplugin/vppcalls/vpp1908/vppcalls_handlers.go index b253f8237c..3521bea928 100644 --- a/plugins/vpp/abfplugin/vppcalls/vpp1908/vppcalls_handlers.go +++ b/plugins/vpp/abfplugin/vppcalls/vpp1908/vppcalls_handlers.go @@ -16,6 +16,7 @@ package vpp1908 import ( govppapi "git.fd.io/govpp.git/api" + "github.com/ligato/cn-infra/logging" "github.com/ligato/vpp-agent/plugins/vpp/abfplugin/vppcalls" "github.com/ligato/vpp-agent/plugins/vpp/aclplugin/aclidx" @@ -29,24 +30,26 @@ func init() { vppcalls.Versions["vpp1908"] = vppcalls.HandlerVersion{ Msgs: msgs, - New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex) vppcalls.ABFVppAPI { - return NewABFVppHandler(ch, aclIndexes, ifIndexes) + New: func(ch govppapi.Channel, aclIndexes aclidx.ACLMetadataIndex, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.ABFVppAPI { + return NewABFVppHandler(ch, aclIndexes, ifIndexes, log) }, } } -// ABFVppHandler is accessor for abfrelated vppcalls methods +// ABFVppHandler is accessor for abf-related vppcalls methods type ABFVppHandler struct { callsChannel govppapi.Channel aclIndexes aclidx.ACLMetadataIndex ifIndexes ifaceidx.IfaceMetadataIndex + log logging.Logger } // NewABFVppHandler returns new ABFVppHandler. -func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex) *ABFVppHandler { +func NewABFVppHandler(calls govppapi.Channel, aclIdx aclidx.ACLMetadataIndex, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *ABFVppHandler { return &ABFVppHandler{ callsChannel: calls, aclIndexes: aclIdx, ifIndexes: ifIdx, + log: log, } } diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go index 9afe186f48..873600bb02 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump.go @@ -18,8 +18,6 @@ import ( "fmt" "net" - "github.com/ligato/cn-infra/logging" - l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" l3binapi "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/ip" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" @@ -71,7 +69,6 @@ func (h *RouteHandler) dumpRouteIPDetails(ipRoute l3binapi.IPRoute) ([]*vppcalls var nextHopIP string netIP := make([]byte, 16) copy(netIP[:], path.Nh.Address.XXX_UnionData[:]) - logging.DefaultLogger.Warnf("netip: %v, proto %v", path.Nh.Address.XXX_UnionData, path.Proto) if path.Proto == l3binapi.FIB_API_PATH_NH_PROTO_IP6 { nextHopIP = fmt.Sprintf("%s", net.IP(netIP).To16().String()) } else { diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go index b8e42c64ae..1781fb4503 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_dump_test.go @@ -40,9 +40,7 @@ func TestDumpStaticRoutes(t *testing.T) { Prefix: ip.Prefix{ Address: ip.Address{ Af: ip.ADDRESS_IP4, - Un: ip.AddressUnion{ - XXX_UnionData: [16]byte{10, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - }, + Un: ip.AddressUnionIP4([4]uint8{10, 0, 0, 1}), }, }, Paths: []ip.FibPath{ @@ -57,9 +55,7 @@ func TestDumpStaticRoutes(t *testing.T) { Prefix: ip.Prefix{ Address: ip.Address{ Af: ip.ADDRESS_IP6, - Un: ip.AddressUnion{ - XXX_UnionData: [16]byte{255, 255, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - }, + Un: ip.AddressUnionIP6([16]uint8{255, 255, 10, 1}), }, }, Paths: []ip.FibPath{ diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go index 91ec4fd83b..860e9ae7e4 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/route_vppcalls.go @@ -17,8 +17,6 @@ package vpp1908 import ( "net" - "github.com/ligato/cn-infra/utils/addrs" - vpp_l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/ip" "github.com/pkg/errors" @@ -68,7 +66,7 @@ func (h *RouteHandler) vppAddDelRoute(route *vpp_l3.Route, rtIfIdx uint32, delet fibPath.TableID = route.VrfId } // Destination address - prefix, err := setRoutePrefix(route.DstNetwork) + prefix, err := networkToPrefix(route.DstNetwork) if err != nil { return err } @@ -131,34 +129,6 @@ func setFibPathNhAndProto(ipStr string) (nh ip.FibPathNh, proto ip.FibPathNhProt }, proto } -func setRoutePrefix(dstNetwork string) (ip.Prefix, error) { - addr, isIPv6, err := addrs.ParseIPWithPrefix(dstNetwork) - if err != nil { - return ip.Prefix{}, err - } - mask, _ := addr.Mask.Size() - return ip.Prefix{ - Address: ip.Address{ - Af: func(isIPv6 bool) ip.AddressFamily { - if isIPv6 { - return ip.ADDRESS_IP6 - } - return ip.ADDRESS_IP4 - }(isIPv6), - Un: func(ipAddr []byte) ip.AddressUnion { - var addrUnion ip.AddressUnion - if isIPv6 { - copy(addrUnion.XXX_UnionData[:], ipAddr[:]) - } else { - copy(addrUnion.XXX_UnionData[:], ipAddr[12:]) - } - return addrUnion - }(addr.IP), - }, - Len: uint8(mask), - }, nil -} - func (h *RouteHandler) getRouteSwIfIndex(ifName string) (swIfIdx uint32, err error) { swIfIdx = NextHopOutgoingIfUnset if ifName != "" { diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go index 58ca775101..a51526be50 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go @@ -18,6 +18,8 @@ import ( "fmt" "net" + "github.com/ligato/cn-infra/utils/addrs" + "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/dhcp" govppapi "git.fd.io/govpp.git/api" @@ -198,6 +200,30 @@ func ipToAddress(ipstr string) (addr ip.Address, err error) { return } +func networkToPrefix(dstNetwork string) (ip.Prefix, error) { + netIP, isIPv6, err := addrs.ParseIPWithPrefix(dstNetwork) + if err != nil { + return ip.Prefix{}, err + } + var addr ip.Address + if isIPv6 { + addr.Af = ip.ADDRESS_IP6 + var ip6addr ip.IP6Address + copy(ip6addr[:], netIP.IP.To16()) + addr.Un.SetIP6(ip6addr) + } else { + addr.Af = ip.ADDRESS_IP4 + var ip4addr ip.IP4Address + copy(ip4addr[:], netIP.IP.To4()) + addr.Un.SetIP4(ip4addr) + } + mask, _ := netIP.Mask.Size() + return ip.Prefix{ + Address: addr, + Len: uint8(mask), + }, nil +} + func uintToBool(value uint8) bool { if value == 0 { return false From 6c0c50223466610b6b1635fdf74794ab08ccaca2 Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Tue, 9 Jul 2019 11:22:34 +0200 Subject: [PATCH 7/9] added support for VRF index map Signed-off-by: Vladimir Lavor --- plugins/configurator/options.go | 2 + plugins/configurator/plugin.go | 5 +- plugins/restapi/options.go | 2 + plugins/restapi/plugin_restapi.go | 5 +- .../l3plugin/descriptor/adapter/vrftable.go | 15 +- plugins/vpp/l3plugin/descriptor/vrf_table.go | 28 ++- plugins/vpp/l3plugin/l3plugin.go | 33 +++- plugins/vpp/l3plugin/l3plugin_api.go | 23 +++ plugins/vpp/l3plugin/vppcalls/l3_vppcalls.go | 6 +- .../vppcalls/vpp1901/vppcalls_handlers.go | 3 +- .../vppcalls/vpp1904/vppcalls_handlers.go | 4 +- .../vppcalls/vpp1908/vppcalls_handlers.go | 14 +- plugins/vpp/l3plugin/vrfidx/doc.go | 3 + plugins/vpp/l3plugin/vrfidx/vrfidx.go | 161 ++++++++++++++++++ plugins/vpp/l3plugin/vrfidx/vrfidx_test.go | 118 +++++++++++++ 15 files changed, 395 insertions(+), 27 deletions(-) create mode 100644 plugins/vpp/l3plugin/l3plugin_api.go create mode 100644 plugins/vpp/l3plugin/vrfidx/doc.go create mode 100644 plugins/vpp/l3plugin/vrfidx/vrfidx.go create mode 100644 plugins/vpp/l3plugin/vrfidx/vrfidx_test.go diff --git a/plugins/configurator/options.go b/plugins/configurator/options.go index 62dc71a3da..329f71257c 100644 --- a/plugins/configurator/options.go +++ b/plugins/configurator/options.go @@ -21,6 +21,7 @@ import ( "github.com/ligato/vpp-agent/plugins/vpp/aclplugin" "github.com/ligato/vpp-agent/plugins/vpp/ifplugin" "github.com/ligato/vpp-agent/plugins/vpp/l2plugin" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin" ) // DefaultPlugin is default instance of Plugin @@ -37,6 +38,7 @@ func NewPlugin(opts ...Option) *Plugin { p.VPPACLPlugin = &aclplugin.DefaultPlugin p.VPPIfPlugin = &ifplugin.DefaultPlugin p.VPPL2Plugin = &l2plugin.DefaultPlugin + p.VPPL3Plugin = &l3plugin.DefaultPlugin for _, o := range opts { o(p) diff --git a/plugins/configurator/plugin.go b/plugins/configurator/plugin.go index f1d9edaf6a..7e41704968 100644 --- a/plugins/configurator/plugin.go +++ b/plugins/configurator/plugin.go @@ -35,6 +35,7 @@ import ( ipsecvppcalls "github.com/ligato/vpp-agent/plugins/vpp/ipsecplugin/vppcalls" "github.com/ligato/vpp-agent/plugins/vpp/l2plugin" l2vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l2plugin/vppcalls" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin" l3vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" natvppcalls "github.com/ligato/vpp-agent/plugins/vpp/natplugin/vppcalls" puntvppcalls "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls" @@ -59,6 +60,7 @@ type Deps struct { VPPACLPlugin aclplugin.API VPPIfPlugin ifplugin.API VPPL2Plugin *l2plugin.L2Plugin + VPPL3Plugin l3plugin.API } // Init sets plugin child loggers @@ -107,6 +109,7 @@ func (p *Plugin) initHandlers() (err error) { dhcpIndexes := p.VPPIfPlugin.GetDHCPIndex() bdIndexes := p.VPPL2Plugin.GetBDIndex() aclIndexes := p.VPPACLPlugin.GetACLIndex() // TODO: make ACL optional + vrfIndexes := p.VPPL3Plugin.GetVRFIndex() // VPP handlers @@ -119,7 +122,7 @@ func (p *Plugin) initHandlers() (err error) { if p.configurator.l2Handler == nil { p.Log.Info("VPP L2 handler is not available, it will be skipped") } - p.configurator.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, p.Log) + p.configurator.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, vrfIndexes, p.Log) if p.configurator.l3Handler == nil { p.Log.Info("VPP L3 handler is not available, it will be skipped") } diff --git a/plugins/restapi/options.go b/plugins/restapi/options.go index 697952e188..c07df891aa 100644 --- a/plugins/restapi/options.go +++ b/plugins/restapi/options.go @@ -16,6 +16,7 @@ package restapi import ( "github.com/ligato/cn-infra/rpc/rest" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin" "github.com/ligato/vpp-agent/plugins/govppmux" "github.com/ligato/vpp-agent/plugins/vpp/aclplugin" @@ -36,6 +37,7 @@ func NewPlugin(opts ...Option) *Plugin { p.VPPACLPlugin = &aclplugin.DefaultPlugin p.VPPIfPlugin = &ifplugin.DefaultPlugin p.VPPL2Plugin = &l2plugin.DefaultPlugin + p.VPPL3Plugin = &l3plugin.DefaultPlugin for _, o := range opts { o(p) diff --git a/plugins/restapi/plugin_restapi.go b/plugins/restapi/plugin_restapi.go index fee0679e28..74f5c392c2 100644 --- a/plugins/restapi/plugin_restapi.go +++ b/plugins/restapi/plugin_restapi.go @@ -38,6 +38,7 @@ import ( ipsecvppcalls "github.com/ligato/vpp-agent/plugins/vpp/ipsecplugin/vppcalls" "github.com/ligato/vpp-agent/plugins/vpp/l2plugin" l2vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l2plugin/vppcalls" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin" l3vppcalls "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" natvppcalls "github.com/ligato/vpp-agent/plugins/vpp/natplugin/vppcalls" puntvppcalls "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls" @@ -86,6 +87,7 @@ type Deps struct { VPPACLPlugin aclplugin.API VPPIfPlugin ifplugin.API VPPL2Plugin *l2plugin.L2Plugin + VPPL3Plugin *l3plugin.L3Plugin } // index defines map of main index page entries @@ -111,6 +113,7 @@ func (p *Plugin) Init() (err error) { bdIndexes := p.VPPL2Plugin.GetBDIndex() dhcpIndexes := p.VPPIfPlugin.GetDHCPIndex() aclIndexes := p.VPPACLPlugin.GetACLIndex() // TODO: make ACL optional + vrfIndexes := p.VPPL3Plugin.GetVRFIndex() // Initialize VPP handlers p.vpeHandler = vpevppcalls.CompatibleVpeHandler(p.vppChan) @@ -131,7 +134,7 @@ func (p *Plugin) Init() (err error) { if p.l2Handler == nil { p.Log.Info("VPP L2 handler is not available, it will be skipped") } - p.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, p.Log) + p.l3Handler = l3vppcalls.CompatibleL3VppHandler(p.vppChan, ifIndexes, vrfIndexes, p.Log) if p.l3Handler == nil { p.Log.Info("VPP L3 handler is not available, it will be skipped") } diff --git a/plugins/vpp/l3plugin/descriptor/adapter/vrftable.go b/plugins/vpp/l3plugin/descriptor/adapter/vrftable.go index 69036cfaac..9361840217 100644 --- a/plugins/vpp/l3plugin/descriptor/adapter/vrftable.go +++ b/plugins/vpp/l3plugin/descriptor/adapter/vrftable.go @@ -5,6 +5,7 @@ package adapter import ( "github.com/gogo/protobuf/proto" . "github.com/ligato/vpp-agent/plugins/kvscheduler/api" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" "github.com/ligato/vpp-agent/api/models/vpp/l3" ) @@ -13,7 +14,7 @@ import ( type VrfTableKVWithMetadata struct { Key string Value *vpp_l3.VrfTable - Metadata interface{} + Metadata *vrfidx.VRFMetadata Origin ValueOrigin } @@ -29,10 +30,10 @@ type VrfTableDescriptor struct { WithMetadata bool MetadataMapFactory MetadataMapFactory Validate func(key string, value *vpp_l3.VrfTable) error - Create func(key string, value *vpp_l3.VrfTable) (metadata interface{}, err error) - Delete func(key string, value *vpp_l3.VrfTable, metadata interface{}) error - Update func(key string, oldValue, newValue *vpp_l3.VrfTable, oldMetadata interface{}) (newMetadata interface{}, err error) - UpdateWithRecreate func(key string, oldValue, newValue *vpp_l3.VrfTable, metadata interface{}) bool + Create func(key string, value *vpp_l3.VrfTable) (metadata *vrfidx.VRFMetadata, err error) + Delete func(key string, value *vpp_l3.VrfTable, metadata *vrfidx.VRFMetadata) error + Update func(key string, oldValue, newValue *vpp_l3.VrfTable, oldMetadata *vrfidx.VRFMetadata) (newMetadata *vrfidx.VRFMetadata, err error) + UpdateWithRecreate func(key string, oldValue, newValue *vpp_l3.VrfTable, metadata *vrfidx.VRFMetadata) bool Retrieve func(correlate []VrfTableKVWithMetadata) ([]VrfTableKVWithMetadata, error) IsRetriableFailure func(err error) bool DerivedValues func(key string, value *vpp_l3.VrfTable) []KeyValuePair @@ -221,11 +222,11 @@ func castVrfTableValue(key string, value proto.Message) (*vpp_l3.VrfTable, error return typedValue, nil } -func castVrfTableMetadata(key string, metadata Metadata) (interface{}, error) { +func castVrfTableMetadata(key string, metadata Metadata) (*vrfidx.VRFMetadata, error) { if metadata == nil { return nil, nil } - typedMetadata, ok := metadata.(interface{}) + typedMetadata, ok := metadata.(*vrfidx.VRFMetadata) if !ok { return nil, ErrInvalidMetadataType(key) } diff --git a/plugins/vpp/l3plugin/descriptor/vrf_table.go b/plugins/vpp/l3plugin/descriptor/vrf_table.go index ff7be47983..25f3d8b288 100644 --- a/plugins/vpp/l3plugin/descriptor/vrf_table.go +++ b/plugins/vpp/l3plugin/descriptor/vrf_table.go @@ -18,6 +18,8 @@ import ( "fmt" "strings" + "github.com/ligato/cn-infra/idxmap" + "github.com/pkg/errors" "github.com/ligato/cn-infra/logging" @@ -25,6 +27,7 @@ import ( kvs "github.com/ligato/vpp-agent/plugins/kvscheduler/api" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/descriptor/adapter" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" ) const ( @@ -62,6 +65,8 @@ func NewVrfTableDescriptor( ValueTypeName: l3.ModelVrfTable.ProtoName(), KeySelector: l3.ModelVrfTable.IsKeyValid, KeyLabel: l3.ModelVrfTable.StripKeyPrefix, + WithMetadata: true, + MetadataMapFactory: ctx.MetadataFactory, ValueComparator: ctx.EquivalentVrfTables, Validate: ctx.Validate, Create: ctx.Create, @@ -79,6 +84,11 @@ func (d *VrfTableDescriptor) EquivalentVrfTables(key string, oldVrfTable, newVrf return true } +// MetadataFactory is a factory for index-map customized for VRFss. +func (d *VrfTableDescriptor) MetadataFactory() idxmap.NamedMappingRW { + return vrfidx.NewVRFIndex(d.log, "vpp-vrf-index") +} + // Validate validates configuration of VPP VRF table. func (d *VrfTableDescriptor) Validate(key string, vrfTable *l3.VrfTable) (err error) { if len(vrfTable.Label) > labelLengthLimit { @@ -88,7 +98,7 @@ func (d *VrfTableDescriptor) Validate(key string, vrfTable *l3.VrfTable) (err er } // Create adds VPP VRF table. -func (d *VrfTableDescriptor) Create(key string, vrfTable *l3.VrfTable) (metadata interface{}, err error) { +func (d *VrfTableDescriptor) Create(key string, vrfTable *l3.VrfTable) (metadata *vrfidx.VRFMetadata, err error) { if vrfTable.Id == 0 { // nothing to do, automatically created by VPP } @@ -97,11 +107,16 @@ func (d *VrfTableDescriptor) Create(key string, vrfTable *l3.VrfTable) (metadata return nil, err } - return nil, nil + // fill the metadata + metadata = &vrfidx.VRFMetadata{ + Index: vrfTable.Id, + } + + return metadata, nil } // Delete removes VPP VRF table. -func (d *VrfTableDescriptor) Delete(key string, vrfTable *l3.VrfTable, metadata interface{}) error { +func (d *VrfTableDescriptor) Delete(key string, vrfTable *l3.VrfTable, metadata *vrfidx.VRFMetadata) error { if vrfTable.Id == 0 { // nothing to do, VRF ID=0 always exists } @@ -128,8 +143,11 @@ func (d *VrfTableDescriptor) Retrieve(correlate []adapter.VrfTableKVWithMetadata origin = kvs.FromNB } retrieved = append(retrieved, adapter.VrfTableKVWithMetadata{ - Key: l3.VrfTableKey(table.Id, table.Protocol), - Value: table, + Key: l3.VrfTableKey(table.Id, table.Protocol), + Value: table, + Metadata: &vrfidx.VRFMetadata{ + Index: table.Id, + }, Origin: origin, }) } diff --git a/plugins/vpp/l3plugin/l3plugin.go b/plugins/vpp/l3plugin/l3plugin.go index b8281dc795..b1eabaaba0 100644 --- a/plugins/vpp/l3plugin/l3plugin.go +++ b/plugins/vpp/l3plugin/l3plugin.go @@ -17,7 +17,7 @@ //go:generate descriptor-adapter --descriptor-name ProxyARP --value-type *vpp_l3.ProxyARP --import "github.com/ligato/vpp-agent/api/models/vpp/l3" --output-dir "descriptor" //go:generate descriptor-adapter --descriptor-name ProxyARPInterface --value-type *vpp_l3.ProxyARP_Interface --import "github.com/ligato/vpp-agent/api/models/vpp/l3" --output-dir "descriptor" //go:generate descriptor-adapter --descriptor-name IPScanNeighbor --value-type *vpp_l3.IPScanNeighbor --import "github.com/ligato/vpp-agent/api/models/vpp/l3" --output-dir "descriptor" -//go:generate descriptor-adapter --descriptor-name VrfTable --value-type *vpp_l3.VrfTable --import "github.com/ligato/vpp-agent/api/models/vpp/l3" --output-dir "descriptor" +//go:generate descriptor-adapter --descriptor-name VrfTable --value-type *vpp_l3.VrfTable --meta-type *vrfidx.VRFMetadata --import "vrfidx" --import "github.com/ligato/vpp-agent/api/models/vpp/l3" --output-dir "descriptor" //go:generate descriptor-adapter --descriptor-name DHCPProxy --value-type *vpp_l3.DHCPProxy --import "github.com/ligato/vpp-agent/api/models/vpp/l3" --output-dir "descriptor" package l3plugin @@ -33,6 +33,7 @@ import ( "github.com/ligato/vpp-agent/plugins/vpp/ifplugin" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/descriptor" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" _ "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls/vpp1901" _ "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls/vpp1904" @@ -49,6 +50,9 @@ type L3Plugin struct { // VPP handler l3Handler vppcalls.L3VppAPI + // index maps + vrfIndex vrfidx.VRFMetadataIndex + // descriptors proxyArpIfaceDescriptor *descriptor.ProxyArpInterfaceDescriptor ipScanNeighborDescriptor *descriptor.IPScanNeighborDescriptor @@ -74,7 +78,25 @@ func (p *L3Plugin) Init() error { } // init handlers - p.l3Handler = vppcalls.CompatibleL3VppHandler(p.vppCh, p.IfPlugin.GetInterfaceIndex(), p.Log) + p.l3Handler = vppcalls.CompatibleL3VppHandler(p.vppCh, p.IfPlugin.GetInterfaceIndex(), p.vrfIndex, p.Log) + if p.l3Handler == nil { + return errors.Errorf("could not find compatible L2VppHandler") + } + + // init and register VRF descriptor + vrfTableDescriptor := descriptor.NewVrfTableDescriptor(p.l3Handler, p.Log) + if err = p.Deps.KVScheduler.RegisterKVDescriptor(vrfTableDescriptor); err != nil { + return err + } + metadataMap := p.KVScheduler.GetMetadataMap(vrfTableDescriptor.Name) + var withIndex bool + p.vrfIndex, withIndex = metadataMap.(vrfidx.VRFMetadataIndex) + if !withIndex { + return errors.New("missing index with VRF metadata") + } + + // set l3 handler again since it was nil before + p.l3Handler = vppcalls.CompatibleL3VppHandler(p.vppCh, p.IfPlugin.GetInterfaceIndex(), p.vrfIndex, p.Log) // init & register descriptors routeDescriptor := descriptor.NewRouteDescriptor(p.l3Handler, p.Log) @@ -82,7 +104,6 @@ func (p *L3Plugin) Init() error { proxyArpDescriptor := descriptor.NewProxyArpDescriptor(p.KVScheduler, p.l3Handler, p.Log) proxyArpIfaceDescriptor := descriptor.NewProxyArpInterfaceDescriptor(p.KVScheduler, p.l3Handler, p.Log) ipScanNeighborDescriptor := descriptor.NewIPScanNeighborDescriptor(p.KVScheduler, p.l3Handler, p.Log) - vrfTableDescriptor := descriptor.NewVrfTableDescriptor(p.l3Handler, p.Log) dhcpProxyDescriptor := descriptor.NewDHCPProxyDescriptor(p.KVScheduler, p.l3Handler, p.Log) err = p.Deps.KVScheduler.RegisterKVDescriptor( @@ -91,7 +112,6 @@ func (p *L3Plugin) Init() error { proxyArpDescriptor, proxyArpIfaceDescriptor, ipScanNeighborDescriptor, - vrfTableDescriptor, dhcpProxyDescriptor, ) if err != nil { @@ -108,3 +128,8 @@ func (p *L3Plugin) AfterInit() error { } return nil } + +// GetVRFIndex gives read-only access to map with metadata of all configured VPP VRFs. +func (p *L3Plugin) GetVRFIndex() vrfidx.VRFMetadataIndex { + return p.vrfIndex +} diff --git a/plugins/vpp/l3plugin/l3plugin_api.go b/plugins/vpp/l3plugin/l3plugin_api.go new file mode 100644 index 0000000000..34c0e173c0 --- /dev/null +++ b/plugins/vpp/l3plugin/l3plugin_api.go @@ -0,0 +1,23 @@ +// Copyright (c) 2019 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package l3plugin + +import "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" + +// API defines methods exposed by VPP-L3Plugin. +type API interface { + // GetVRFIndex gives read-only access to map with metadata of all configured VPP VRFs. + GetVRFIndex() vrfidx.VRFMetadataIndex +} diff --git a/plugins/vpp/l3plugin/vppcalls/l3_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/l3_vppcalls.go index 8d574c8842..39dee54d6e 100644 --- a/plugins/vpp/l3plugin/vppcalls/l3_vppcalls.go +++ b/plugins/vpp/l3plugin/vppcalls/l3_vppcalls.go @@ -17,6 +17,7 @@ package vppcalls import ( govppapi "git.fd.io/govpp.git/api" "github.com/ligato/cn-infra/logging" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" l3 "github.com/ligato/vpp-agent/api/models/vpp/l3" "github.com/ligato/vpp-agent/plugins/vpp/ifplugin/ifaceidx" @@ -199,12 +200,13 @@ var Versions = map[string]HandlerVersion{} type HandlerVersion struct { Msgs []govppapi.Message - New func(govppapi.Channel, ifaceidx.IfaceMetadataIndex, logging.Logger) L3VppAPI + New func(govppapi.Channel, ifaceidx.IfaceMetadataIndex, vrfidx.VRFMetadataIndex, logging.Logger) L3VppAPI } func CompatibleL3VppHandler( ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, + vrfIdx vrfidx.VRFMetadataIndex, log logging.Logger, ) L3VppAPI { for ver, h := range Versions { @@ -213,7 +215,7 @@ func CompatibleL3VppHandler( continue } log.Debug("found compatible version:", ver) - return h.New(ch, ifIdx, log) + return h.New(ch, ifIdx, vrfIdx, log) } panic("no compatible version available") } diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1901/vppcalls_handlers.go b/plugins/vpp/l3plugin/vppcalls/vpp1901/vppcalls_handlers.go index 4fade19eda..d75c245cf2 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1901/vppcalls_handlers.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1901/vppcalls_handlers.go @@ -25,6 +25,7 @@ import ( "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1901/vpe" "github.com/ligato/vpp-agent/plugins/vpp/ifplugin/ifaceidx" "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vppcalls" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" ) func init() { @@ -35,7 +36,7 @@ func init() { vppcalls.Versions["vpp1901"] = vppcalls.HandlerVersion{ Msgs: msgs, - New: func(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger, + New: func(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, vrfIdx vrfidx.VRFMetadataIndex, log logging.Logger, ) vppcalls.L3VppAPI { return NewL3VppHandler(ch, ifIdx, log) }, diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1904/vppcalls_handlers.go b/plugins/vpp/l3plugin/vppcalls/vpp1904/vppcalls_handlers.go index 510352d35d..e80698a8a4 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1904/vppcalls_handlers.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1904/vppcalls_handlers.go @@ -18,6 +18,8 @@ import ( "fmt" "net" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" + "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1904/dhcp" govppapi "git.fd.io/govpp.git/api" @@ -40,7 +42,7 @@ func init() { vppcalls.Versions["vpp1904"] = vppcalls.HandlerVersion{ Msgs: msgs, - New: func(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger, + New: func(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, vrfIdx vrfidx.VRFMetadataIndex, log logging.Logger, ) vppcalls.L3VppAPI { return NewL3VppHandler(ch, ifIdx, log) }, diff --git a/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go b/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go index a51526be50..33fa9964d9 100644 --- a/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go +++ b/plugins/vpp/l3plugin/vppcalls/vpp1908/vppcalls_handlers.go @@ -18,6 +18,8 @@ import ( "fmt" "net" + "github.com/ligato/vpp-agent/plugins/vpp/l3plugin/vrfidx" + "github.com/ligato/cn-infra/utils/addrs" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/dhcp" @@ -42,9 +44,9 @@ func init() { vppcalls.Versions["vpp1908"] = vppcalls.HandlerVersion{ Msgs: msgs, - New: func(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger, + New: func(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, vrfIdx vrfidx.VRFMetadataIndex, log logging.Logger, ) vppcalls.L3VppAPI { - return NewL3VppHandler(ch, ifIdx, log) + return NewL3VppHandler(ch, ifIdx, vrfIdx, log) }, } } @@ -59,12 +61,12 @@ type L3VppHandler struct { } func NewL3VppHandler( - ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger, + ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, vrfIdx vrfidx.VRFMetadataIndex, log logging.Logger, ) *L3VppHandler { return &L3VppHandler{ ArpVppHandler: NewArpVppHandler(ch, ifIdx, log), ProxyArpVppHandler: NewProxyArpVppHandler(ch, ifIdx, log), - RouteHandler: NewRouteVppHandler(ch, ifIdx, log), + RouteHandler: NewRouteVppHandler(ch, ifIdx, vrfIdx, log), IPNeighHandler: NewIPNeighVppHandler(ch, log), VrfTableHandler: NewVrfTableVppHandler(ch, log), DHCPProxyHandler: NewDHCPProxyHandler(ch, log), @@ -95,6 +97,7 @@ type ProxyArpVppHandler struct { type RouteHandler struct { callsChannel govppapi.Channel ifIndexes ifaceidx.IfaceMetadataIndex + vrfIndexes vrfidx.VRFMetadataIndex log logging.Logger } @@ -136,13 +139,14 @@ func NewProxyArpVppHandler(callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceM } // NewRouteVppHandler creates new instance of route vppcalls handler -func NewRouteVppHandler(callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) *RouteHandler { +func NewRouteVppHandler(callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, vrfIdx vrfidx.VRFMetadataIndex, log logging.Logger) *RouteHandler { if log == nil { log = logrus.NewLogger("route-handler") } return &RouteHandler{ callsChannel: callsChan, ifIndexes: ifIndexes, + vrfIndexes: vrfIdx, log: log, } } diff --git a/plugins/vpp/l3plugin/vrfidx/doc.go b/plugins/vpp/l3plugin/vrfidx/doc.go new file mode 100644 index 0000000000..2927565a32 --- /dev/null +++ b/plugins/vpp/l3plugin/vrfidx/doc.go @@ -0,0 +1,3 @@ +// Package vrfidx implements name-to-index mapping registry and cache +// for VPP VRFs. +package vrfidx diff --git a/plugins/vpp/l3plugin/vrfidx/vrfidx.go b/plugins/vpp/l3plugin/vrfidx/vrfidx.go new file mode 100644 index 0000000000..78464539da --- /dev/null +++ b/plugins/vpp/l3plugin/vrfidx/vrfidx.go @@ -0,0 +1,161 @@ +// Copyright (c) 2019 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package vrfidx + +import ( + "time" + + "github.com/ligato/cn-infra/idxmap" + "github.com/ligato/cn-infra/logging" + + "github.com/ligato/vpp-agent/pkg/idxvpp" +) + +// VRFMetadataIndex provides read-only access to mapping with VPP VRF +// metadata. It extends from NameToIndex. +type VRFMetadataIndex interface { + // LookupByName retrieves a previously stored metadata of VRF + // identified by