Skip to content

Commit

Permalink
wireguard plugin support
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art committed Oct 1, 2020
1 parent 8482476 commit ebc14d1
Show file tree
Hide file tree
Showing 39 changed files with 3,457 additions and 460 deletions.
3 changes: 3 additions & 0 deletions cmd/vpp-agent/app/vpp_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin"
"go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin"
"go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin"
"go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin"
)

// VPPAgent defines plugins which will be loaded and their order.
Expand Down Expand Up @@ -181,6 +182,7 @@ type VPP struct {
PuntPlugin *puntplugin.PuntPlugin
STNPlugin *stnplugin.STNPlugin
SRPlugin *srplugin.SRPlugin
WgPlugin *wireguardplugin.WgPlugin
}

func DefaultVPP() VPP {
Expand All @@ -196,6 +198,7 @@ func DefaultVPP() VPP {
PuntPlugin: &puntplugin.DefaultPlugin,
STNPlugin: &stnplugin.DefaultPlugin,
SRPlugin: &srplugin.DefaultPlugin,
WgPlugin: &wireguardplugin.DefaultPlugin,
}
}

Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/Songmu/prompter v0.0.0-20150725163906-b5721e8d5566/go.mod h1:fNhSFBGC+sg+dZ7AqDHgq+xYiom23TeTESzUbO7PIrE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 h1:45bxf7AZMwWcqkLzDAQugVEwedisr5nRJ1r+7LYnv0U=
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
Expand Down
24 changes: 24 additions & 0 deletions plugins/configurator/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
l3vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls"
natvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls"
"go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls"
wireguardvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin/vppcalls"
rpc "go.ligato.io/vpp-agent/v3/proto/ligato/configurator"
linux_interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/linux/interfaces"
linux_l3 "go.ligato.io/vpp-agent/v3/proto/ligato/linux/l3"
Expand All @@ -41,6 +42,7 @@ import (
vpp_l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3"
vpp_nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat"
vpp_punt "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt"
vpp_wg "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/wireguard"
)

type dumpService struct {
Expand All @@ -56,6 +58,7 @@ type dumpService struct {
abfHandler abfvppcalls.ABFVppRead
natHandler natvppcalls.NatVppRead
puntHandler vppcalls.PuntVPPRead
wireguardHandler wireguardvppcalls.WgVppRead

// Linux handlers
linuxIfHandler iflinuxcalls.NetlinkAPIRead
Expand Down Expand Up @@ -160,6 +163,11 @@ func (svc *dumpService) Dump(ctx context.Context, req *rpc.DumpRequest) (*rpc.Du
svc.log.Errorf("DumpPuntExceptions failed: %v", err)
return nil, err
}
dump.VppConfig.WgPeers, err = svc.DumpWgPeers()
if err != nil {
svc.log.Errorf("DumpWgPeers failed: %v", err)
return nil, err
}

// -----
// Linux
Expand Down Expand Up @@ -464,6 +472,22 @@ func (svc *dumpService) DumpPuntExceptions() (punts []*vpp_punt.Exception, err e
return punts, nil
}

func (svc *dumpService) DumpWgPeers() (peers []*vpp_wg.Peer, err error) {
if svc.wireguardHandler == nil {
// handler is not available
return nil, nil
}

_peers, err := svc.wireguardHandler.DumpWgPeers()
if err != nil {
return nil, err
}
for _, peer := range _peers {
peers = append(peers, peer)
}
return
}

// DumpLinuxInterfaces reads linux interfaces and returns them as an *LinuxInterfaceResponse. If reading ends up with error,
// only error is send back in response
func (svc *dumpService) DumpLinuxInterfaces() (linuxIfs []*linux_interfaces.Interface, err error) {
Expand Down
5 changes: 5 additions & 0 deletions plugins/configurator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
l3vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls"
natvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls"
puntvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls"
wireguardvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin/vppcalls"
rpc "go.ligato.io/vpp-agent/v3/proto/ligato/configurator"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp"
)
Expand Down Expand Up @@ -150,6 +151,10 @@ func (p *Plugin) initHandlers() (err error) {
if p.configurator.puntHandler == nil {
p.Log.Info("VPP Punt handler is not available, it will be skipped")
}
p.configurator.wireguardHandler = wireguardvppcalls.CompatibleWgVppHandler(p.VPP, ifIndexes, p.Log)
if p.configurator.wireguardHandler == nil {
p.Log.Info("VPP Wg handler is not available, it will be skipped")
}

// Linux handlers
p.configurator.linuxIfHandler = iflinuxcalls.NewNetLinkHandler(p.NsPlugin, linuxIfIndexes,
Expand Down
6 changes: 6 additions & 0 deletions plugins/restapi/plugin_restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
l3vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls"
natvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls"
puntvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls"
wireguardvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin/vppcalls"
)

// REST api methods
Expand Down Expand Up @@ -75,6 +76,7 @@ type Plugin struct {
l3Handler l3vppcalls.L3VppAPI
ipSecHandler ipsecvppcalls.IPSecVPPRead
puntHandler puntvppcalls.PuntVPPRead
wireguardHandler wireguardvppcalls.WgVppRead
// Linux handlers
linuxIfHandler iflinuxcalls.NetlinkAPIRead
linuxL3Handler l3linuxcalls.NetlinkAPIRead
Expand Down Expand Up @@ -167,6 +169,10 @@ func (p *Plugin) Init() (err error) {
if p.puntHandler == nil {
p.Log.Infof("Punt handler is not available, it will be skipped")
}
p.wireguardHandler = wireguardvppcalls.CompatibleWgVppHandler(p.VPP, ifIndexes, p.Log)
if p.wireguardHandler == nil {
p.Log.Info("Wireguard handler is not available, it will be skipped")
}

// Linux handlers
p.linuxIfHandler = iflinuxcalls.NewNetLinkHandler(p.NsPlugin, linuxIfIndexes, p.ServiceLabel.GetAgentPrefix(),
Expand Down
5 changes: 5 additions & 0 deletions plugins/restapi/resturl/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ const (
PuntSocket = "/dump/vpp/v2/punt/sockets"
)

// VPP Wireguard plugin
const (
Peers = "/dump/vpp/v2/wireguard/peers"
)

// Telemetry
const (
// Telemetry reads various types of metrics data from the VPP
Expand Down
3 changes: 3 additions & 0 deletions plugins/vpp/binapi/vpp2009/vpp2009.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vpe"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vxlan"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vxlan_gpe"
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/wireguard"
)

// Version is used to identify VPP binapi version
Expand Down Expand Up @@ -91,6 +92,7 @@ func init() {
nat.AllMessages,
stn.AllMessages,
vmxnet3.AllMessages,
wireguard.AllMessages,
),
}
}
Expand Down Expand Up @@ -128,3 +130,4 @@ func init() {
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/nat.api.json
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/stn.api.json
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/vmxnet3.api.json
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/wireguard.api.json
Loading

0 comments on commit ebc14d1

Please sign in to comment.