From 8e61f10823bb4dcbe765555959872906638333e5 Mon Sep 17 00:00:00 2001 From: Tahir Rauf Date: Mon, 4 Nov 2019 22:37:29 -0800 Subject: [PATCH 1/3] Adding physical device --- plugin/meshnet.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugin/meshnet.go b/plugin/meshnet.go index 876148b..e694ffe 100644 --- a/plugin/meshnet.go +++ b/plugin/meshnet.go @@ -7,7 +7,7 @@ import ( "net" "os" "runtime" - + "strings" "log" "github.com/containernetworking/cni/pkg/invoke" @@ -251,7 +251,16 @@ func cmdAdd(args *skel.CmdArgs) error { } log.Printf("macvlan interfacee %s@%s has been added", link.LocalIntf, link.PeerIntf) continue - } + } + if strings.Contains(link.PeerPod, "phy") { + log.Printf("Peer link is Physical host") + vxlan := makeVxlan(srcIntf, link.PeerIp, link.Uid) + if err = koko.MakeVxLan(*myVeth, *vxlan); err != nil { + log.Printf("Error when creating a Vxlan interface with koko: %s", err) + return err + } + continue + } // Initialising peer pod's metadata log.Printf("Retrieving peer pod %s information from meshnet daemon", link.PeerPod) From e2d504793d693dd886bd6163c9abdcf8b18ce6b3 Mon Sep 17 00:00:00 2001 From: Tahir Rauf Date: Tue, 5 Nov 2019 11:52:06 -0800 Subject: [PATCH 2/3] Small fix in vxlan creation --- plugin/meshnet.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/meshnet.go b/plugin/meshnet.go index e694ffe..a147cf9 100644 --- a/plugin/meshnet.go +++ b/plugin/meshnet.go @@ -254,7 +254,9 @@ func cmdAdd(args *skel.CmdArgs) error { } if strings.Contains(link.PeerPod, "phy") { log.Printf("Peer link is Physical host") - vxlan := makeVxlan(srcIntf, link.PeerIp, link.Uid) + log.Printf("LocalIntf=%s LocalIp=%s srcIntf=%s PeerIp=%s", link.LocalIntf, link.LocalIp, srcIntf, link.PeerIp) + remoteIp := strings.Split(link.PeerIp, "/")[0] + vxlan := makeVxlan(srcIntf, remoteIp, link.Uid) if err = koko.MakeVxLan(*myVeth, *vxlan); err != nil { log.Printf("Error when creating a Vxlan interface with koko: %s", err) return err From f0c1f1e44cb6ff6f16272223e45a8706dec3169c Mon Sep 17 00:00:00 2001 From: Tahir Rauf Date: Tue, 5 Nov 2019 16:53:01 -0800 Subject: [PATCH 3/3] small format changes --- plugin/meshnet.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plugin/meshnet.go b/plugin/meshnet.go index a147cf9..d676bdd 100644 --- a/plugin/meshnet.go +++ b/plugin/meshnet.go @@ -251,18 +251,19 @@ func cmdAdd(args *skel.CmdArgs) error { } log.Printf("macvlan interfacee %s@%s has been added", link.LocalIntf, link.PeerIntf) continue - } - if strings.Contains(link.PeerPod, "phy") { - log.Printf("Peer link is Physical host") - log.Printf("LocalIntf=%s LocalIp=%s srcIntf=%s PeerIp=%s", link.LocalIntf, link.LocalIp, srcIntf, link.PeerIp) - remoteIp := strings.Split(link.PeerIp, "/")[0] - vxlan := makeVxlan(srcIntf, remoteIp, link.Uid) - if err = koko.MakeVxLan(*myVeth, *vxlan); err != nil { - log.Printf("Error when creating a Vxlan interface with koko: %s", err) - return err - } - continue - } + } + // If peer endpoint is a 'physical' device running outside of our k8s cluster, then all we need to do is to + // create a vxlan link on our pod. Use ip in 'phy' endpoint as 'remote' VTEP of vxlan. + if strings.Contains(link.PeerPod, "phy") { + log.Printf("Peer link is Physical host") + remoteIp := strings.Split(link.PeerIp, "/")[0] + vxlan := makeVxlan(srcIntf, remoteIp, link.Uid) + if err = koko.MakeVxLan(*myVeth, *vxlan); err != nil { + log.Printf("Error when creating a Vxlan interface with koko: %s", err) + return err + } + continue + } // Initialising peer pod's metadata log.Printf("Retrieving peer pod %s information from meshnet daemon", link.PeerPod)