aboutsummaryrefslogtreecommitdiffstats
path: root/internal/pkg
diff options
context:
space:
mode:
authorRitu Sood <Ritu.Sood@intel.com>2020-05-06 13:47:11 -0700
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-09-17 17:09:13 -0700
commit178b11bcf11accdf57f0d79509d80000fafbe05c (patch)
tree045246cfedc4d1639447d338e63459c63c1246c7 /internal/pkg
parentce14abc0128d4c55a7805c52ea199e2ce6159428 (diff)
Route based chaining
1) Adding controller for route based chaining 2) nfn agent code to insert route in container namespace 3) Calculate routes based on the Chaining Routes Based on the Ritu(ovn4nfv-k8s-plugin committer) patches Co-authored-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> Signed-off-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> Change-Id: I6757f269a5df7d98d650f273468c6ccbcc055d3e
Diffstat (limited to 'internal/pkg')
-rw-r--r--internal/pkg/nfnNotify/proto/nfn.pb.go270
-rw-r--r--internal/pkg/nfnNotify/proto/nfn.proto18
-rw-r--r--internal/pkg/nfnNotify/server.go66
-rw-r--r--internal/pkg/ovn/common.go74
-rw-r--r--internal/pkg/utils/chain.go204
5 files changed, 588 insertions, 44 deletions
diff --git a/internal/pkg/nfnNotify/proto/nfn.pb.go b/internal/pkg/nfnNotify/proto/nfn.pb.go
index 750d55b..70628c6 100644
--- a/internal/pkg/nfnNotify/proto/nfn.pb.go
+++ b/internal/pkg/nfnNotify/proto/nfn.pb.go
@@ -1,5 +1,5 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: nfn.proto
+// source: proto/nfn.proto
package nfn
@@ -35,7 +35,7 @@ func (m *SubscribeContext) Reset() { *m = SubscribeContext{} }
func (m *SubscribeContext) String() string { return proto.CompactTextString(m) }
func (*SubscribeContext) ProtoMessage() {}
func (*SubscribeContext) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{0}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{0}
}
func (m *SubscribeContext) XXX_Unmarshal(b []byte) error {
@@ -69,6 +69,8 @@ type Notification struct {
// *Notification_InSync
// *Notification_ProviderNwCreate
// *Notification_ProviderNwRemove
+ // *Notification_ContainterRtInsert
+ // *Notification_ContainterRtRemove
Payload isNotification_Payload `protobuf_oneof:"payload"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@@ -79,7 +81,7 @@ func (m *Notification) Reset() { *m = Notification{} }
func (m *Notification) String() string { return proto.CompactTextString(m) }
func (*Notification) ProtoMessage() {}
func (*Notification) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{1}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{1}
}
func (m *Notification) XXX_Unmarshal(b []byte) error {
@@ -123,12 +125,24 @@ type Notification_ProviderNwRemove struct {
ProviderNwRemove *ProviderNetworkRemove `protobuf:"bytes,4,opt,name=provider_nw_remove,json=providerNwRemove,proto3,oneof"`
}
+type Notification_ContainterRtInsert struct {
+ ContainterRtInsert *ContainerRouteInsert `protobuf:"bytes,5,opt,name=containter_rt_insert,json=containterRtInsert,proto3,oneof"`
+}
+
+type Notification_ContainterRtRemove struct {
+ ContainterRtRemove *ContainerRouteRemove `protobuf:"bytes,6,opt,name=containter_rt_remove,json=containterRtRemove,proto3,oneof"`
+}
+
func (*Notification_InSync) isNotification_Payload() {}
func (*Notification_ProviderNwCreate) isNotification_Payload() {}
func (*Notification_ProviderNwRemove) isNotification_Payload() {}
+func (*Notification_ContainterRtInsert) isNotification_Payload() {}
+
+func (*Notification_ContainterRtRemove) isNotification_Payload() {}
+
func (m *Notification) GetPayload() isNotification_Payload {
if m != nil {
return m.Payload
@@ -157,12 +171,28 @@ func (m *Notification) GetProviderNwRemove() *ProviderNetworkRemove {
return nil
}
+func (m *Notification) GetContainterRtInsert() *ContainerRouteInsert {
+ if x, ok := m.GetPayload().(*Notification_ContainterRtInsert); ok {
+ return x.ContainterRtInsert
+ }
+ return nil
+}
+
+func (m *Notification) GetContainterRtRemove() *ContainerRouteRemove {
+ if x, ok := m.GetPayload().(*Notification_ContainterRtRemove); ok {
+ return x.ContainterRtRemove
+ }
+ return nil
+}
+
// XXX_OneofWrappers is for the internal use of the proto package.
func (*Notification) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*Notification_InSync)(nil),
(*Notification_ProviderNwCreate)(nil),
(*Notification_ProviderNwRemove)(nil),
+ (*Notification_ContainterRtInsert)(nil),
+ (*Notification_ContainterRtRemove)(nil),
}
}
@@ -179,7 +209,7 @@ func (m *ProviderNetworkCreate) Reset() { *m = ProviderNetworkCreate{} }
func (m *ProviderNetworkCreate) String() string { return proto.CompactTextString(m) }
func (*ProviderNetworkCreate) ProtoMessage() {}
func (*ProviderNetworkCreate) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{2}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{2}
}
func (m *ProviderNetworkCreate) XXX_Unmarshal(b []byte) error {
@@ -234,7 +264,7 @@ func (m *ProviderNetworkRemove) Reset() { *m = ProviderNetworkRemove{} }
func (m *ProviderNetworkRemove) String() string { return proto.CompactTextString(m) }
func (*ProviderNetworkRemove) ProtoMessage() {}
func (*ProviderNetworkRemove) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{3}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{3}
}
func (m *ProviderNetworkRemove) XXX_Unmarshal(b []byte) error {
@@ -289,7 +319,7 @@ func (m *VlanInfo) Reset() { *m = VlanInfo{} }
func (m *VlanInfo) String() string { return proto.CompactTextString(m) }
func (*VlanInfo) ProtoMessage() {}
func (*VlanInfo) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{4}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{4}
}
func (m *VlanInfo) XXX_Unmarshal(b []byte) error {
@@ -342,7 +372,7 @@ func (m *DirectInfo) Reset() { *m = DirectInfo{} }
func (m *DirectInfo) String() string { return proto.CompactTextString(m) }
func (*DirectInfo) ProtoMessage() {}
func (*DirectInfo) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{5}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{5}
}
func (m *DirectInfo) XXX_Unmarshal(b []byte) error {
@@ -370,6 +400,147 @@ func (m *DirectInfo) GetProviderIntf() string {
return ""
}
+type RouteData struct {
+ Dst string `protobuf:"bytes,2,opt,name=dst,proto3" json:"dst,omitempty"`
+ Gw string `protobuf:"bytes,3,opt,name=gw,proto3" json:"gw,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *RouteData) Reset() { *m = RouteData{} }
+func (m *RouteData) String() string { return proto.CompactTextString(m) }
+func (*RouteData) ProtoMessage() {}
+func (*RouteData) Descriptor() ([]byte, []int) {
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{6}
+}
+
+func (m *RouteData) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_RouteData.Unmarshal(m, b)
+}
+func (m *RouteData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_RouteData.Marshal(b, m, deterministic)
+}
+func (m *RouteData) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_RouteData.Merge(m, src)
+}
+func (m *RouteData) XXX_Size() int {
+ return xxx_messageInfo_RouteData.Size(m)
+}
+func (m *RouteData) XXX_DiscardUnknown() {
+ xxx_messageInfo_RouteData.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_RouteData proto.InternalMessageInfo
+
+func (m *RouteData) GetDst() string {
+ if m != nil {
+ return m.Dst
+ }
+ return ""
+}
+
+func (m *RouteData) GetGw() string {
+ if m != nil {
+ return m.Gw
+ }
+ return ""
+}
+
+type ContainerRouteInsert struct {
+ ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
+ Route []*RouteData `protobuf:"bytes,2,rep,name=route,proto3" json:"route,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ContainerRouteInsert) Reset() { *m = ContainerRouteInsert{} }
+func (m *ContainerRouteInsert) String() string { return proto.CompactTextString(m) }
+func (*ContainerRouteInsert) ProtoMessage() {}
+func (*ContainerRouteInsert) Descriptor() ([]byte, []int) {
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{7}
+}
+
+func (m *ContainerRouteInsert) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ContainerRouteInsert.Unmarshal(m, b)
+}
+func (m *ContainerRouteInsert) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ContainerRouteInsert.Marshal(b, m, deterministic)
+}
+func (m *ContainerRouteInsert) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ContainerRouteInsert.Merge(m, src)
+}
+func (m *ContainerRouteInsert) XXX_Size() int {
+ return xxx_messageInfo_ContainerRouteInsert.Size(m)
+}
+func (m *ContainerRouteInsert) XXX_DiscardUnknown() {
+ xxx_messageInfo_ContainerRouteInsert.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ContainerRouteInsert proto.InternalMessageInfo
+
+func (m *ContainerRouteInsert) GetContainerId() string {
+ if m != nil {
+ return m.ContainerId
+ }
+ return ""
+}
+
+func (m *ContainerRouteInsert) GetRoute() []*RouteData {
+ if m != nil {
+ return m.Route
+ }
+ return nil
+}
+
+type ContainerRouteRemove struct {
+ ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
+ Route []*RouteData `protobuf:"bytes,2,rep,name=route,proto3" json:"route,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ContainerRouteRemove) Reset() { *m = ContainerRouteRemove{} }
+func (m *ContainerRouteRemove) String() string { return proto.CompactTextString(m) }
+func (*ContainerRouteRemove) ProtoMessage() {}
+func (*ContainerRouteRemove) Descriptor() ([]byte, []int) {
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{8}
+}
+
+func (m *ContainerRouteRemove) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ContainerRouteRemove.Unmarshal(m, b)
+}
+func (m *ContainerRouteRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ContainerRouteRemove.Marshal(b, m, deterministic)
+}
+func (m *ContainerRouteRemove) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ContainerRouteRemove.Merge(m, src)
+}
+func (m *ContainerRouteRemove) XXX_Size() int {
+ return xxx_messageInfo_ContainerRouteRemove.Size(m)
+}
+func (m *ContainerRouteRemove) XXX_DiscardUnknown() {
+ xxx_messageInfo_ContainerRouteRemove.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ContainerRouteRemove proto.InternalMessageInfo
+
+func (m *ContainerRouteRemove) GetContainerId() string {
+ if m != nil {
+ return m.ContainerId
+ }
+ return ""
+}
+
+func (m *ContainerRouteRemove) GetRoute() []*RouteData {
+ if m != nil {
+ return m.Route
+ }
+ return nil
+}
+
type InSync struct {
NodeIntfIpAddress string `protobuf:"bytes,1,opt,name=node_intf_ip_address,json=nodeIntfIpAddress,proto3" json:"node_intf_ip_address,omitempty"`
NodeIntfMacAddress string `protobuf:"bytes,2,opt,name=node_intf_mac_address,json=nodeIntfMacAddress,proto3" json:"node_intf_mac_address,omitempty"`
@@ -382,7 +553,7 @@ func (m *InSync) Reset() { *m = InSync{} }
func (m *InSync) String() string { return proto.CompactTextString(m) }
func (*InSync) ProtoMessage() {}
func (*InSync) Descriptor() ([]byte, []int) {
- return fileDescriptor_5b809db4a7814953, []int{6}
+ return fileDescriptor_5ee04cc9cbb38bc3, []int{9}
}
func (m *InSync) XXX_Unmarshal(b []byte) error {
@@ -424,45 +595,56 @@ func init() {
proto.RegisterType((*ProviderNetworkRemove)(nil), "ProviderNetworkRemove")
proto.RegisterType((*VlanInfo)(nil), "VlanInfo")
proto.RegisterType((*DirectInfo)(nil), "DirectInfo")
+ proto.RegisterType((*RouteData)(nil), "RouteData")
+ proto.RegisterType((*ContainerRouteInsert)(nil), "ContainerRouteInsert")
+ proto.RegisterType((*ContainerRouteRemove)(nil), "ContainerRouteRemove")
proto.RegisterType((*InSync)(nil), "InSync")
}
func init() {
- proto.RegisterFile("nfn.proto", fileDescriptor_5b809db4a7814953)
-}
-
-var fileDescriptor_5b809db4a7814953 = []byte{
- // 472 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xdd, 0x6e, 0xd3, 0x30,
- 0x14, 0x5e, 0xd8, 0xd4, 0x34, 0xa7, 0x1d, 0xb4, 0x47, 0x1b, 0x14, 0x10, 0xd2, 0xc8, 0x6e, 0x2a,
- 0x2e, 0xd2, 0x6d, 0xdc, 0x72, 0x03, 0x43, 0x68, 0x91, 0xa0, 0x42, 0x19, 0xe2, 0xd6, 0x72, 0x1d,
- 0x07, 0x59, 0x4b, 0x8f, 0xa3, 0xd4, 0xb4, 0xe4, 0x01, 0x78, 0x0e, 0x5e, 0x8f, 0xc7, 0x40, 0xb1,
- 0x93, 0xfe, 0xac, 0xbb, 0xe1, 0x2e, 0x39, 0xdf, 0xf9, 0x7e, 0x6c, 0xf9, 0x83, 0x80, 0x32, 0x8a,
- 0x8a, 0x52, 0x1b, 0x1d, 0x4e, 0x60, 0x70, 0xfb, 0x73, 0xb6, 0x10, 0xa5, 0x9a, 0xc9, 0x6b, 0x4d,
- 0x46, 0xfe, 0x32, 0xf8, 0x12, 0x02, 0xd2, 0xa9, 0x64, 0xc4, 0xe7, 0x72, 0xe4, 0x9d, 0x79, 0xe3,
- 0x20, 0xe9, 0xd6, 0x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/nfn.proto", fileDescriptor_5ee04cc9cbb38bc3)
+}
+
+var fileDescriptor_5ee04cc9cbb38bc3 = []byte{
+ // 601 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
+ 0x10, 0x6d, 0x92, 0x36, 0xa9, 0x27, 0xfd, 0x93, 0xae, 0xd2, 0xdf, 0x2f, 0x80, 0x90, 0x82, 0x7b,
+ 0x89, 0x90, 0x70, 0xda, 0x72, 0xe5, 0x02, 0xad, 0x50, 0x2d, 0x41, 0x84, 0x5c, 0xc4, 0x85, 0xc3,
+ 0x6a, 0xbb, 0xde, 0x54, 0xab, 0x3a, 0xbb, 0xd6, 0x66, 0x9b, 0xe0, 0x0f, 0xc0, 0xe7, 0xe0, 0x9b,
+ 0x22, 0xb4, 0x7f, 0x6c, 0x27, 0x4d, 0x0e, 0x1c, 0xb8, 0xed, 0xbe, 0x37, 0xf3, 0xe6, 0xed, 0x8c,
+ 0x3d, 0x70, 0x9c, 0x2b, 0xa9, 0xe5, 0x58, 0x4c, 0x45, 0x64, 0x4f, 0xe1, 0x18, 0x7a, 0xb7, 0x8f,
+ 0x77, 0x73, 0xaa, 0xf8, 0x1d, 0xbb, 0x92, 0x42, 0xb3, 0x1f, 0x1a, 0xbd, 0x80, 0x40, 0xc8, 0x94,
+ 0x61, 0x41, 0x66, 0x6c, 0xd0, 0x18, 0x36, 0x46, 0x41, 0xb2, 0x6f, 0x80, 0x09, 0x99, 0xb1, 0xf0,
+ 0x77, 0x13, 0x0e, 0x26, 0x52, 0xf3, 0x29, 0xa7, 0x44, 0x73, 0x29, 0xd0, 0x33, 0xd8, 0xa7, 0x82,
+ 0x63, 0x5d, 0xe4, 0x65, 0x70, 0x87, 0x0a, 0xfe, 0xb5, 0xc8, 0x19, 0x0a, 0xa1, 0xc3, 0x05, 0x9e,
+ 0x17, 0x82, 0x0e,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0x60, 0x9e, 0x63, 0x92, 0xa6, 0x8a, 0xcd,
+ 0xe7, 0x5e, 0xf6, 0xc4, 0x70, 0xa6, 0x35, 0x71, 0xfe, 0xde, 0x11, 0xe8, 0x02, 0x4e, 0xeb, 0x84,
+ 0x19, 0xa1, 0x55, 0x86, 0x6b, 0x14, 0x2a, 0x33, 0x3e, 0x13, 0xea, 0x53, 0x2e, 0xdf, 0x41, 0x20,
+ 0xa6, 0xc2, 0xee, 0xa8, 0x02, 0x8d, 0x21, 0xa8, 0xf6, 0x1b, 0x3a, 0x89, 0x9e, 0xee, 0xba, 0xe7,
+ 0x87, 0xd1, 0xea, 0x32, 0x3b, 0x6f, 0xdc, 0xb5, 0xed, 0x5e, 0x7c, 0xfb, 0x27, 0x00, 0x00, 0xff,
+ 0xff, 0x47, 0xfb, 0x68, 0x42, 0x2a, 0x05, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -569,5 +751,5 @@ var _NfnNotify_serviceDesc = grpc.ServiceDesc{
ServerStreams: true,
},
},
- Metadata: "nfn.proto",
+ Metadata: "proto/nfn.proto",
}
diff --git a/internal/pkg/nfnNotify/proto/nfn.proto b/internal/pkg/nfnNotify/proto/nfn.proto
index 567df29..6bd6704 100644
--- a/internal/pkg/nfnNotify/proto/nfn.proto
+++ b/internal/pkg/nfnNotify/proto/nfn.proto
@@ -19,6 +19,9 @@ message Notification {
InSync in_sync = 2;
ProviderNetworkCreate provider_nw_create = 3;
ProviderNetworkRemove provider_nw_remove = 4;
+ ContainerRouteInsert containter_rt_insert = 5;
+ ContainerRouteRemove containter_rt_remove = 6;
+
}
}
@@ -46,6 +49,21 @@ message DirectInfo {
string provider_intf = 1;
}
+message RouteData {
+ string dst = 2;
+ string gw = 3;
+}
+
+message ContainerRouteInsert {
+ string container_id = 1;
+ repeated RouteData route = 2;
+}
+
+message ContainerRouteRemove {
+ string container_id = 1;
+ repeated RouteData route = 2;
+}
+
message InSync {
string node_intf_ip_address = 1;
string node_intf_mac_address = 2;
diff --git a/internal/pkg/nfnNotify/server.go b/internal/pkg/nfnNotify/server.go
index a201618..4257cf9 100644
--- a/internal/pkg/nfnNotify/server.go
+++ b/internal/pkg/nfnNotify/server.go
@@ -1,9 +1,26 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package nfn
import (
"fmt"
"net"
pb "ovn4nfv-k8s-plugin/internal/pkg/nfnNotify/proto"
+ chaining "ovn4nfv-k8s-plugin/internal/pkg/utils"
"ovn4nfv-k8s-plugin/internal/pkg/node"
v1alpha1 "ovn4nfv-k8s-plugin/pkg/apis/k8s/v1alpha1"
clientset "ovn4nfv-k8s-plugin/pkg/generated/clientset/versioned"
@@ -269,6 +286,55 @@ func sendMsg(msg pb.Notification, labels string, option string, nodeReq string)
return nil
}
+//SendProviderNotif to client
+func SendRouteNotif(chainRoutingInfo []chaining.RoutingInfo, msgType string) error {
+ var msg pb.Notification
+ var err error
+ var ins pb.ContainerRouteInsert
+
+ for _, r := range chainRoutingInfo {
+ ins.ContainerId = r.Id
+ ins.Route = nil
+
+ rt := &pb.RouteData{
+ Dst: r.LeftNetworkRoute.Dst,
+ Gw: r.LeftNetworkRoute.GW,
+ }
+ ins.Route = append(ins.Route, rt)
+
+ rt = &pb.RouteData{
+ Dst: r.RightNetworkRoute.Dst,
+ Gw: r.RightNetworkRoute.GW,
+ }
+ ins.Route = append(ins.Route, rt)
+
+ for _, d := range r.DynamicNetworkRoutes {
+ rt = &pb.RouteData{
+ Dst: d.Dst,
+ Gw: d.GW,
+ }
+ ins.Route = append(ins.Route, rt)
+ }
+ if msgType == "create" {
+ msg = pb.Notification{
+ CniType: "ovn4nfv",
+ Payload: &pb.Notification_ContainterRtInsert{
+ ContainterRtInsert: &ins,
+ },
+ }
+ }
+ client := notifServer.GetClient(r.Node)
+ if client.stream != nil {
+ if err := client.stream.Send(&msg); err != nil {
+ log.Error(err, "Failed to send msg", "Node", r.Node)
+ return err
+ }
+ }
+ // TODO: Handle Delete
+ }
+ return err
+}
+
func nodeListIterator(labels string) <-chan string {
ch := make(chan string)
diff --git a/internal/pkg/ovn/common.go b/internal/pkg/ovn/common.go
index e38c440..0053e56 100644
--- a/internal/pkg/ovn/common.go
+++ b/internal/pkg/ovn/common.go
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package ovn
import (
@@ -323,3 +339,61 @@ func ipToInt(ip net.IP) *big.Int {
func intToIP(i *big.Int) net.IP {
return net.IP(i.Bytes())
}
+
+// Get Subnet for a logical bridge
+func GetNetworkSubnet(nw string) (string, error) {
+ stdout, stderr, err := RunOVNNbctl("--if-exists",
+ "get", "logical_switch", nw,
+ "other_config:subnet")
+ if err != nil {
+ log.Error(err, "Failed to subnet for network", "stderr", stderr, "stdout", stdout)
+ return "", err
+ }
+ return stdout, nil
+}
+
+func GetIPAdressForPod(nw string, name string) (string, error) {
+ _, stderr, err := RunOVNNbctl("--data=bare", "--no-heading",
+ "--columns=name", "find", "logical_switch", "name="+nw)
+ if err != nil {
+ log.Error(err, "Error in obtaining list of logical switch", "stderr", stderr)
+ return "", err
+ }
+ stdout, stderr, err := RunOVNNbctl("lsp-list", nw)
+ if err != nil {
+ log.Error(err, "Failed to list ports", "stderr", stderr, "stdout", stdout)
+ return "", err
+ }
+ // stdout format
+ // <port-uuid> (<port-name>)
+ // <port-uuid> (<port-name>)
+ // ...
+ ll := strings.Split(stdout, "\n")
+ if len(ll) == 0 {
+ return "", fmt.Errorf("IPAdress Not Found")
+ }
+ for _, l := range ll {
+ pn := strings.Fields(l)
+ if len(pn) < 2 {
+ return "", fmt.Errorf("IPAdress Not Found")
+ }
+ if strings.Contains(pn[1], name) {
+ // Found Port
+ s := strings.Replace(pn[1], "(", "", -1)
+ s = strings.Replace(s, ")", "", -1)
+ dna, stderr, err := RunOVNNbctl("get", "logical_switch_port", s, "dynamic_addresses")
+ if err != nil {
+ log.Error(err, "Failed to get dynamic_addresses", "stderr", stderr, "stdout", dna)
+ return "", err
+ }
+ // format - mac:ip
+ ipAddr := strings.Fields(dna)
+ if len(ipAddr) < 2 {
+ return "", fmt.Errorf("IPAdress Not Found")
+ }
+ return ipAddr[1], nil
+ }
+ }
+ return "", fmt.Errorf("IPAdress Not Found %s", name)
+}
+
diff --git a/internal/pkg/utils/chain.go b/internal/pkg/utils/chain.go
new file mode 100644
index 0000000..aa98aa1
--- /dev/null
+++ b/internal/pkg/utils/chain.go
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package nfn
+
+import (
+ "context"
+ "fmt"
+ "ovn4nfv-k8s-plugin/internal/pkg/ovn"
+ k8sv1alpha1 "ovn4nfv-k8s-plugin/pkg/apis/k8s/v1alpha1"
+ "strings"
+
+ pb "ovn4nfv-k8s-plugin/internal/pkg/nfnNotify/proto"
+
+ "github.com/containernetworking/plugins/pkg/ns"
+ "github.com/docker/docker/client"
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/client-go/kubernetes"
+ "sigs.k8s.io/controller-runtime/pkg/client/config"
+ logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
+)
+
+var log = logf.Log.WithName("chaining")
+
+type RoutingInfo struct {
+ Name string // Name of the pod
+ Namespace string // Namespace of the Pod
+ Id string // Container ID for pod
+ Node string // Hostname where Pod is scheduled
+ LeftNetworkRoute k8sv1alpha1.Route // TODO: Update to support multiple networks
+ RightNetworkRoute k8sv1alpha1.Route // TODO: Update to support multiple networks
+ DynamicNetworkRoutes []k8sv1alpha1.Route
+}
+
+var chainRoutingInfo []RoutingInfo
+
+// Calcuate route to get to left and right edge networks and other networks (not adjacent) in the chain
+func calculateDeploymentRoutes(namespace, label string, pos int, num int, ln []k8sv1alpha1.RoutingNetwork, rn []k8sv1alpha1.RoutingNetwork, networkList, deploymentList []string) (r RoutingInfo, err error) {
+
+ var nextLeftIP string
+ var nextRightIP string
+
+ r.Namespace = namespace
+ // Get a config to talk to the apiserver
+ cfg, err := config.GetConfig()
+ if err != nil {
+ return RoutingInfo{}, err
+ }
+ var k *kubernetes.Clientset
+ k, err = kubernetes.NewForConfig(cfg)
+ if err != nil {
+ log.Error(err, "Error building Kuberenetes clientset")
+ return RoutingInfo{}, err
+ }
+ lo := v1.ListOptions{LabelSelector: label}
+ // List the Pods matching the Labels
+ pods, err := k.CoreV1().Pods(namespace).List(lo)
+ if err != nil {
+ log.Error(err, "Deloyment with label not found", "label", label)
+ return RoutingInfo{}, err
+ }
+ // LOADBALANCER NOT YET SUPPORTED - Assuming deployment has only one Pod
+ if len(pods.Items) <= 0 {
+ log.Error(err, "Deloyment with label not found", "label", label)
+ return RoutingInfo{}, fmt.Errorf("Pod not found")
+ }
+ // Get the containerID of the first container
+ r.Id = strings.TrimPrefix(pods.Items[0].Status.ContainerStatuses[0].ContainerID, "docker://")
+ r.Name = pods.Items[0].GetName()
+ r.Node = pods.Items[0].Spec.NodeName
+ // Calcluate IP addresses for next neighbours on both sides
+ if pos == 0 {
+ nextLeftIP = ln[0].GatewayIP
+ } else {
+ name := strings.Split(deploymentList[pos-1], "=")
+ nextLeftIP, err = ovn.GetIPAdressForPod(networkList[pos-1], name[1])
+ if err != nil {
+ return RoutingInfo{}, err
+ }
+ }
+ if pos == num-1 {
+ nextRightIP = rn[0].GatewayIP
+ } else {
+ name := strings.Split(deploymentList[pos+1], "=")
+ nextRightIP, err = ovn.GetIPAdressForPod(networkList[pos], name[1])
+ if err != nil {
+ return RoutingInfo{}, err
+ }
+ }
+ // Calcuate left right Route to be inserted in Pod
+ r.LeftNetworkRoute.Dst = ln[0].Subnet
+ r.LeftNetworkRoute.GW = nextLeftIP
+ r.RightNetworkRoute.Dst = rn[0].Subnet
+ r.RightNetworkRoute.GW = nextRightIP
+ // For each network that is not adjacent add route
+ for i := 0; i < len(networkList); i++ {
+ if i == pos || i == pos-1 {
+ continue
+ } else {
+ var rt k8sv1alpha1.Route
+ rt.Dst, err = ovn.GetNetworkSubnet(networkList[i])
+ if err != nil {
+ return RoutingInfo{}, err
+ }
+ if i > pos {
+ rt.GW = nextRightIP
+ } else {
+ rt.GW = nextLeftIP
+ }
+ r.DynamicNetworkRoutes = append(r.DynamicNetworkRoutes, rt)
+ }
+ }
+ return
+}
+
+func CalculateRoutes(cr *k8sv1alpha1.NetworkChaining) ([]RoutingInfo, error) {
+ //
+ var deploymentList []string
+ var networkList []string
+
+ // TODO: Add Validation of Input to this function
+ ln := cr.Spec.RoutingSpec.LeftNetwork
+ rn := cr.Spec.RoutingSpec.RightNetwork
+ chains := strings.Split(cr.Spec.RoutingSpec.NetworkChain, ",")
+ i := 0
+ for _, chain := range chains {
+ if i%2 == 0 {
+ deploymentList = append(deploymentList, chain)
+ } else {
+ networkList = append(networkList, chain)
+ }
+ i++
+ }
+ num := len(deploymentList)
+ for i, deployment := range deploymentList {
+ r, err := calculateDeploymentRoutes(cr.Namespace, deployment, i, num, ln, rn, networkList, deploymentList)
+ if err != nil {
+ return nil, err
+ }
+ chainRoutingInfo = append(chainRoutingInfo, r)
+ }
+ return chainRoutingInfo, nil
+}
+
+func ContainerAddRoute(containerPid int, route []*pb.RouteData) error {
+
+ str := fmt.Sprintf("/host/proc/%d/ns/net", containerPid)
+
+ nms, err := ns.GetNS(str)
+ if err != nil {
+ log.Error(err, "Failed namesapce", "containerID", containerPid)
+ return err
+ }
+ defer nms.Close()
+ err = nms.Do(func(_ ns.NetNS) error {
+ for _, r := range route {
+ dst := r.GetDst()
+ gw := r.GetGw()
+ stdout, stderr, err := ovn.RunIP("route", "add", dst, "via", gw)
+ if err != nil && !strings.Contains(stderr, "RTNETLINK answers: File exists") {
+ log.Error(err, "Failed to ip route add", "stdout", stdout, "stderr", stderr)
+ return err
+ }
+ }
+ return nil
+ })
+ if err != nil {
+ log.Error(err, "Failed Netns Do", "containerID", containerPid)
+ return err
+ }
+ return nil
+}
+
+func GetPidForContainer(id string) (int, error) {
+ cli, err := client.NewEnvClient()
+ if err != nil {
+ fmt.Println("Unable to create docker client")
+ return 0, err
+ }
+ cli.NegotiateAPIVersion(context.Background())
+ cj, err := cli.ContainerInspect(context.Background(), id)
+ if err != nil {
+ fmt.Println("Unable to Inspect docker container")
+ return 0, err
+ }
+ if cj.State.Pid == 0 {
+ return 0, fmt.Errorf("Container not found %s", id)
+ }
+ return cj.State.Pid, nil
+
+}