From 0642ad4a3fee39182b0e91b838e0be75e834aeb8 Mon Sep 17 00:00:00 2001
From: Trekkie Coder <trekkie@netlox.io>
Date: Fri, 22 Dec 2023 20:19:18 +0900
Subject: [PATCH] Fix for ipsec vti cicd not working

---
 api/loxinlp/nlp.go  | 13 +++++++++++++
 loxinet/neighbor.go |  2 +-
 loxinet/port.go     |  8 ++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/api/loxinlp/nlp.go b/api/loxinlp/nlp.go
index 9aeb64386..59880d2e4 100644
--- a/api/loxinlp/nlp.go
+++ b/api/loxinlp/nlp.go
@@ -825,6 +825,19 @@ func ModLink(link nlp.Link, add bool) int {
 		tunDst = iptun.Remote
 		tunSrc = iptun.Local
 		tk.LogIt(tk.LogInfo, "[NLP] IPTun %v (%s:%s), %s\n", name, tunSrc.String(), tunDst.String(), mod)
+	} else if vtiTun, ok := link.(*nlp.Vti); ok {
+		pType = cmn.PortVti
+		if vtiTun.Remote == nil || vtiTun.Local == nil {
+			return -1
+		}
+
+		if vtiTun.Remote.IsUnspecified() || vtiTun.Local.IsUnspecified() {
+			return -1
+		}
+		tunId = int(vtiTun.OKey)
+		tunDst = vtiTun.Remote
+		tunSrc = vtiTun.Local
+		tk.LogIt(tk.LogInfo, "[NLP] VTITun %v (%s:%s), %s\n", name, tunSrc.String(), tunDst.String(), mod)
 	} else if master != "" {
 		pType = cmn.PortBondSif
 	}
diff --git a/loxinet/neighbor.go b/loxinet/neighbor.go
index e1e919d8b..042bee351 100644
--- a/loxinet/neighbor.go
+++ b/loxinet/neighbor.go
@@ -244,7 +244,7 @@ func (n *NeighH) NeighRecursiveResolve(ne *Neigh) bool {
 
 	if ne.Resolved == true {
 
-		if port.IsL3TunPort() {
+		if port.IsIPinIPTunPort() {
 			err, pDstNet, tDat := n.Zone.Rt.Trie4.FindTrie(port.HInfo.TunDst.String())
 			if err == 0 && pDstNet != nil {
 				switch rtn := tDat.(type) {
diff --git a/loxinet/port.go b/loxinet/port.go
index cbb41e3fb..c8683fafb 100644
--- a/loxinet/port.go
+++ b/loxinet/port.go
@@ -1068,3 +1068,11 @@ func (p *Port) IsL3TunPort() bool {
 	}
 	return false
 }
+
+// IsIPinIPTunPort - check if the port is of IPinIPTun type
+func (p *Port) IsIPinIPTunPort() bool {
+	if p.SInfo.PortType&(cmn.PortIPTun) != 0 {
+		return true
+	}
+	return false
+}