Skip to content

Commit

Permalink
feat: Add tunnel mode support for VPP TAP interfaces (#1671)
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Fabry <[email protected]>
  • Loading branch information
ondrej-fabry authored Jun 25, 2020
1 parent a52954c commit dfd2d53
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 154 deletions.
3 changes: 3 additions & 0 deletions plugins/vpp/ifplugin/vppcalls/vpp1904/tap_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (h *InterfaceVppHandler) AddTapInterface(ifName string, tapIf *interfaces.T
if tapIf.EnableGso {
flags |= TapFlagGSO
}
if tapIf.EnableTunnel {
h.log.Warnf("tunnel mode not supported for VPP 19.04")
}

// Configure fast virtio-based TAP interface
req := &tapv2.TapCreateV2{
Expand Down
3 changes: 3 additions & 0 deletions plugins/vpp/ifplugin/vppcalls/vpp1908/tap_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (h *InterfaceVppHandler) AddTapInterface(ifName string, tapIf *interfaces.T
if tapIf.EnableGso {
flags |= TapFlagGSO
}
if tapIf.EnableTunnel {
h.log.Warnf("tunnel mode not supported for VPP 19.08")
}

// Configure fast virtio-based TAP interface
req := &tapv2.TapCreateV2{
Expand Down
3 changes: 3 additions & 0 deletions plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (h *InterfaceVppHandler) AddTapInterface(ifName string, tapIf *ifs.TapLink)
if tapIf.EnableGso {
flags |= vpp_tapv2.TAP_FLAG_GSO
}
if tapIf.EnableTunnel {
h.log.Warnf("tunnel mode not supported for VPP 20.01")
}

// Configure fast virtio-based TAP interface
req := &vpp_tapv2.TapCreateV2{
Expand Down
11 changes: 6 additions & 5 deletions plugins/vpp/ifplugin/vppcalls/vpp2005/dump_interface_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,12 @@ func (h *InterfaceVppHandler) dumpTapDetails(interfaces map[uint32]*vppcalls.Int
}
interfaces[tapDetails.SwIfIndex].Interface.Link = &ifs.Interface_Tap{
Tap: &ifs.TapLink{
Version: 2,
HostIfName: cleanString(tapDetails.HostIfName),
RxRingSize: uint32(tapDetails.RxRingSz),
TxRingSize: uint32(tapDetails.TxRingSz),
EnableGso: tapDetails.TapFlags&vpp_tapv2.TAP_API_FLAG_GSO == vpp_tapv2.TAP_API_FLAG_GSO,
Version: 2,
HostIfName: cleanString(tapDetails.HostIfName),
RxRingSize: uint32(tapDetails.RxRingSz),
TxRingSize: uint32(tapDetails.TxRingSz),
EnableGso: tapDetails.TapFlags&vpp_tapv2.TAP_API_FLAG_GSO == vpp_tapv2.TAP_API_FLAG_GSO,
EnableTunnel: tapDetails.TapFlags&vpp_tapv2.TAP_API_FLAG_TUN == vpp_tapv2.TAP_API_FLAG_TUN,
},
}
interfaces[tapDetails.SwIfIndex].Interface.Type = ifs.Interface_TAP
Expand Down
8 changes: 3 additions & 5 deletions plugins/vpp/ifplugin/vppcalls/vpp2005/tap_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import (
ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
)

// TapFlags definitions from https://github.com/FDio/vpp/blob/stable/2001/src/vnet/devices/tap/tap.h#L33
const (
TapFlagGSO uint32 = 1 << iota
)

func (h *InterfaceVppHandler) AddTapInterface(ifName string, tapIf *ifs.TapLink) (swIfIdx uint32, err error) {
if tapIf == nil || tapIf.HostIfName == "" {
return 0, errors.New("host interface name was not provided for the TAP interface")
Expand All @@ -40,6 +35,9 @@ func (h *InterfaceVppHandler) AddTapInterface(ifName string, tapIf *ifs.TapLink)
if tapIf.EnableGso {
flags |= vpp_tapv2.TAP_API_FLAG_GSO
}
if tapIf.EnableTunnel {
flags |= vpp_tapv2.TAP_API_FLAG_TUN
}

// Configure fast virtio-based TAP interface
req := &vpp_tapv2.TapCreateV2{
Expand Down
299 changes: 155 additions & 144 deletions proto/ligato/vpp/interfaces/interface.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions proto/ligato/vpp/interfaces/interface.proto
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ message TapLink {
uint32 rx_ring_size = 4;
// Tx ring buffer size; must be power of 2; default is 256; only for TAP v.2
uint32 tx_ring_size = 5;
// EnableGso enables GSO mode for TAP interface.
bool enable_gso = 6;
// EnableTunnel enables tunnel mode for TAP interface.
bool enable_tunnel = 7;
}

// IPSecLink defines configuration for interface type: IPSEC_TUNNEL
Expand Down

0 comments on commit dfd2d53

Please sign in to comment.