Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gtpu): Add support for arbitrary DecapNextNode #1721

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions plugins/vpp/ifplugin/vppcalls/vpp1904/gtpu_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ func (h *InterfaceVppHandler) dumpGtpuDetails(ifs map[uint32]*vppcalls.Interface
}

gtpuLink := &interfaces.GtpuLink{
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
DecapNextNode: gtpuDetails.DecapNextIndex,
}

if gtpuDetails.IsIPv6 == 1 {
Expand Down
28 changes: 18 additions & 10 deletions plugins/vpp/ifplugin/vppcalls/vpp1908/gtpu_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ import (
interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
)

const defaultDecapNextIndex = 0xFFFFFFFF

func (h *InterfaceVppHandler) gtpuAddDelTunnel(isAdd uint8, gtpuLink *interfaces.GtpuLink, multicastIf uint32) (uint32, error) {
var decapNextNode uint32 = defaultDecapNextIndex
if gtpuLink.DecapNextNode != 0 {
decapNextNode = gtpuLink.DecapNextNode
} else {
// backwards compatible fallback
if gtpuLink.DecapNext != interfaces.GtpuLink_DEFAULT {
decapNextNode = uint32(gtpuLink.DecapNext)
}
}

req := &gtpu.GtpuAddDelTunnel{
IsAdd: isAdd,
McastSwIfIndex: multicastIf,
EncapVrfID: gtpuLink.EncapVrfId,
Teid: gtpuLink.Teid,
}

if gtpuLink.DecapNext == interfaces.GtpuLink_DEFAULT {
req.DecapNextIndex = 0xFFFFFFFF
} else {
req.DecapNextIndex = uint32(gtpuLink.DecapNext)
DecapNextIndex: decapNextNode,
}

srcAddr := net.ParseIP(gtpuLink.SrcAddr)
Expand Down Expand Up @@ -149,10 +156,11 @@ func (h *InterfaceVppHandler) dumpGtpuDetails(ifs map[uint32]*vppcalls.Interface
}

gtpuLink := &interfaces.GtpuLink{
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
DecapNextNode: gtpuDetails.DecapNextIndex,
}

if gtpuDetails.IsIPv6 == 1 {
Expand Down
28 changes: 18 additions & 10 deletions plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@ import (
interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
)

const defaultDecapNextIndex = 0xFFFFFFFF

func (h *InterfaceVppHandler) gtpuAddDelTunnel(isAdd bool, gtpuLink *interfaces.GtpuLink, multicastIf uint32) (uint32, error) {
var decapNextNode uint32 = defaultDecapNextIndex
if gtpuLink.DecapNextNode != 0 {
decapNextNode = gtpuLink.DecapNextNode
} else {
// backwards compatible fallback
if gtpuLink.DecapNext != interfaces.GtpuLink_DEFAULT {
decapNextNode = uint32(gtpuLink.DecapNext)
}
}

req := &gtpu.GtpuAddDelTunnel{
IsAdd: isAdd,
McastSwIfIndex: interface_types.InterfaceIndex(multicastIf),
EncapVrfID: gtpuLink.EncapVrfId,
Teid: gtpuLink.Teid,
}

if gtpuLink.DecapNext == interfaces.GtpuLink_DEFAULT {
req.DecapNextIndex = 0xFFFFFFFF
} else {
req.DecapNextIndex = uint32(gtpuLink.DecapNext)
DecapNextIndex: decapNextNode,
}

srcAddr := net.ParseIP(gtpuLink.SrcAddr)
Expand Down Expand Up @@ -167,10 +174,11 @@ func (h *InterfaceVppHandler) dumpGtpuDetails(ifc map[uint32]*vppcalls.Interface
}

gtpuLink := &interfaces.GtpuLink{
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
DecapNextNode: gtpuDetails.DecapNextIndex,
}

if gtpuDetails.SrcAddress.Af == ip_types.ADDRESS_IP6 {
Expand Down
28 changes: 18 additions & 10 deletions plugins/vpp/ifplugin/vppcalls/vpp2005/gtpu_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@ import (
interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
)

const defaultDecapNextIndex = 0xFFFFFFFF

func (h *InterfaceVppHandler) gtpuAddDelTunnel(isAdd bool, gtpuLink *interfaces.GtpuLink, multicastIf uint32) (uint32, error) {
var decapNextNode uint32 = defaultDecapNextIndex
if gtpuLink.DecapNextNode != 0 {
decapNextNode = gtpuLink.DecapNextNode
} else {
// backwards compatible fallback
if gtpuLink.DecapNext != interfaces.GtpuLink_DEFAULT {
decapNextNode = uint32(gtpuLink.DecapNext)
}
}

req := &gtpu.GtpuAddDelTunnel{
IsAdd: isAdd,
McastSwIfIndex: interface_types.InterfaceIndex(multicastIf),
EncapVrfID: gtpuLink.EncapVrfId,
Teid: gtpuLink.Teid,
}

if gtpuLink.DecapNext == interfaces.GtpuLink_DEFAULT {
req.DecapNextIndex = 0xFFFFFFFF
} else {
req.DecapNextIndex = uint32(gtpuLink.DecapNext)
DecapNextIndex: decapNextNode,
}

srcAddr := net.ParseIP(gtpuLink.SrcAddr)
Expand Down Expand Up @@ -167,10 +174,11 @@ func (h *InterfaceVppHandler) dumpGtpuDetails(ifc map[uint32]*vppcalls.Interface
}

gtpuLink := &interfaces.GtpuLink{
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
DecapNextNode: gtpuDetails.DecapNextIndex,
}

if gtpuDetails.SrcAddress.Af == ip_types.ADDRESS_IP6 {
Expand Down
29 changes: 18 additions & 11 deletions plugins/vpp/ifplugin/vppcalls/vpp2009/gtpu_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,26 @@ import (
interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
)

const defaultDecapNextIndex = 0xFFFFFFFF

func (h *InterfaceVppHandler) gtpuAddDelTunnel(isAdd bool, gtpuLink *interfaces.GtpuLink, multicastIf uint32) (uint32, error) {
var decapNextNode uint32 = defaultDecapNextIndex
if gtpuLink.DecapNextNode != 0 {
decapNextNode = gtpuLink.DecapNextNode
} else {
// backwards compatible fallback
if gtpuLink.DecapNext != interfaces.GtpuLink_DEFAULT {
decapNextNode = uint32(gtpuLink.DecapNext)
}
}

req := &gtpu.GtpuAddDelTunnel{
IsAdd: isAdd,
McastSwIfIndex: interface_types.InterfaceIndex(multicastIf),
EncapVrfID: gtpuLink.EncapVrfId,
Teid: gtpuLink.Teid,
Tteid: gtpuLink.RemoteTeid,
}

if gtpuLink.DecapNext == interfaces.GtpuLink_DEFAULT {
req.DecapNextIndex = 0xFFFFFFFF
} else {
req.DecapNextIndex = uint32(gtpuLink.DecapNext)
DecapNextIndex: decapNextNode,
}

srcAddr := net.ParseIP(gtpuLink.SrcAddr)
Expand Down Expand Up @@ -168,11 +175,11 @@ func (h *InterfaceVppHandler) dumpGtpuDetails(ifc map[uint32]*vppcalls.Interface
}

gtpuLink := &interfaces.GtpuLink{
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
RemoteTeid: gtpuDetails.Tteid,
DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex),
Multicast: multicastIfName,
EncapVrfId: gtpuDetails.EncapVrfID,
Teid: gtpuDetails.Teid,
RemoteTeid: gtpuDetails.Tteid,
DecapNextNode: gtpuDetails.DecapNextIndex,
}

if gtpuDetails.SrcAddress.Af == ip_types.ADDRESS_IP6 {
Expand Down
63 changes: 39 additions & 24 deletions proto/ligato/vpp/interfaces/interface.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion proto/ligato/vpp/interfaces/interface.proto
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ message GtpuLink {
uint32 remote_teid = 7;
// VRF id for the encapsulated packets
uint32 encap_vrf_id = 5;
// DEPRECATED - use decap_next_node
NextNode decap_next = 6 [deprecated=true];
// Next VPP node after decapsulation
NextNode decap_next = 6;
uint32 decap_next_node = 8;
}

message IPIPLink {
Expand Down
20 changes: 11 additions & 9 deletions tests/integration/vpp/100_gtpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func TestGtpu(t *testing.T) {
DstAddr: "50.40.30.20",
Teid: 201,
EncapVrfId: 0,
DecapNext: interfaces.GtpuLink_L2,
//DecapNext: interfaces.GtpuLink_L2,
DecapNextNode: 1,
},
mcastSwIfIndex: 0xFFFFFFFF,
isFail: false,
Expand All @@ -95,7 +96,8 @@ func TestGtpu(t *testing.T) {
DstAddr: "50.40.30.20",
Teid: 202,
EncapVrfId: 0,
DecapNext: interfaces.GtpuLink_IP4,
//DecapNext: interfaces.GtpuLink_IP4,
DecapNextNode: 2,
},
mcastSwIfIndex: 0xFFFFFFFF,
isFail: false,
Expand All @@ -107,7 +109,8 @@ func TestGtpu(t *testing.T) {
DstAddr: "2002:db8:0:1:1:1:1:1",
Teid: 203,
EncapVrfId: 0,
DecapNext: interfaces.GtpuLink_IP6,
//DecapNext: interfaces.GtpuLink_IP6,
DecapNextNode: 3,
},
mcastSwIfIndex: 0xFFFFFFFF,
isFail: false,
Expand Down Expand Up @@ -139,7 +142,6 @@ func TestGtpu(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
ifName := fmt.Sprintf("test%d", i)
ifIdx, err := h.AddGtpuTunnel(ifName, test.gtpu, test.mcastSwIfIndex)

if err != nil {
if test.isFail {
return
Expand Down Expand Up @@ -181,12 +183,12 @@ func TestGtpu(t *testing.T) {
if test.gtpu.EncapVrfId != gtpu.EncapVrfId {
t.Fatalf("expected GTP-U EncapVrfId <%d>, got: <%d>", test.gtpu.EncapVrfId, gtpu.EncapVrfId)
}
testDecapNext := test.gtpu.DecapNext
if testDecapNext == interfaces.GtpuLink_DEFAULT {
testDecapNext = interfaces.GtpuLink_L2
testDecapNext := test.gtpu.DecapNextNode
if testDecapNext == uint32(interfaces.GtpuLink_DEFAULT) {
testDecapNext = uint32(interfaces.GtpuLink_L2)
}
if testDecapNext != gtpu.DecapNext {
t.Fatalf("expected GTP-U DecapNext <%d>, got: <%d>", testDecapNext, gtpu.DecapNext)
if testDecapNext != gtpu.DecapNextNode {
t.Fatalf("expected GTP-U DecapNextNode <%v>, got: <%v>", testDecapNext, gtpu.DecapNextNode)
}
} else {
t.Logf("GTP-U: DumpInterfaces skipped because of a broken API in VPP %s", ctx.versionInfo.Version)
Expand Down