Skip to content

Commit 57fc59d

Browse files
committed
wireguard plugin support
Signed-off-by: Artem Glazychev <[email protected]>
1 parent 8482476 commit 57fc59d

39 files changed

+3496
-460
lines changed

cmd/vpp-agent/app/vpp_agent.go

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin"
5050
"go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin"
5151
"go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin"
52+
"go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin"
5253
)
5354

5455
// VPPAgent defines plugins which will be loaded and their order.
@@ -181,6 +182,7 @@ type VPP struct {
181182
PuntPlugin *puntplugin.PuntPlugin
182183
STNPlugin *stnplugin.STNPlugin
183184
SRPlugin *srplugin.SRPlugin
185+
WgPlugin *wireguardplugin.WgPlugin
184186
}
185187

186188
func DefaultVPP() VPP {
@@ -196,6 +198,7 @@ func DefaultVPP() VPP {
196198
PuntPlugin: &puntplugin.DefaultPlugin,
197199
STNPlugin: &stnplugin.DefaultPlugin,
198200
SRPlugin: &srplugin.DefaultPlugin,
201+
WgPlugin: &wireguardplugin.DefaultPlugin,
199202
}
200203
}
201204

go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
2121
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
2222
github.com/Songmu/prompter v0.0.0-20150725163906-b5721e8d5566/go.mod h1:fNhSFBGC+sg+dZ7AqDHgq+xYiom23TeTESzUbO7PIrE=
2323
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
24+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
2425
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
2526
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 h1:45bxf7AZMwWcqkLzDAQugVEwedisr5nRJ1r+7LYnv0U=
2627
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=

plugins/configurator/dump.go

+24
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
l3vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls"
3131
natvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls"
3232
"go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls"
33+
wireguardvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin/vppcalls"
3334
rpc "go.ligato.io/vpp-agent/v3/proto/ligato/configurator"
3435
linux_interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/linux/interfaces"
3536
linux_l3 "go.ligato.io/vpp-agent/v3/proto/ligato/linux/l3"
@@ -41,6 +42,7 @@ import (
4142
vpp_l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3"
4243
vpp_nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat"
4344
vpp_punt "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt"
45+
vpp_wg "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/wireguard"
4446
)
4547

4648
type dumpService struct {
@@ -56,6 +58,7 @@ type dumpService struct {
5658
abfHandler abfvppcalls.ABFVppRead
5759
natHandler natvppcalls.NatVppRead
5860
puntHandler vppcalls.PuntVPPRead
61+
wireguardHandler wireguardvppcalls.WgVppRead
5962

6063
// Linux handlers
6164
linuxIfHandler iflinuxcalls.NetlinkAPIRead
@@ -160,6 +163,11 @@ func (svc *dumpService) Dump(ctx context.Context, req *rpc.DumpRequest) (*rpc.Du
160163
svc.log.Errorf("DumpPuntExceptions failed: %v", err)
161164
return nil, err
162165
}
166+
dump.VppConfig.WgPeers, err = svc.DumpWgPeers()
167+
if err != nil {
168+
svc.log.Errorf("DumpWgPeers failed: %v", err)
169+
return nil, err
170+
}
163171

164172
// -----
165173
// Linux
@@ -464,6 +472,22 @@ func (svc *dumpService) DumpPuntExceptions() (punts []*vpp_punt.Exception, err e
464472
return punts, nil
465473
}
466474

475+
func (svc *dumpService) DumpWgPeers() (peers []*vpp_wg.Peer, err error) {
476+
if svc.wireguardHandler == nil {
477+
// handler is not available
478+
return nil, nil
479+
}
480+
481+
_peers, err := svc.wireguardHandler.DumpWgPeers()
482+
if err != nil {
483+
return nil, err
484+
}
485+
for _, peer := range _peers {
486+
peers = append(peers, peer)
487+
}
488+
return
489+
}
490+
467491
// DumpLinuxInterfaces reads linux interfaces and returns them as an *LinuxInterfaceResponse. If reading ends up with error,
468492
// only error is send back in response
469493
func (svc *dumpService) DumpLinuxInterfaces() (linuxIfs []*linux_interfaces.Interface, err error) {

plugins/configurator/plugin.go

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
l3vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls"
3939
natvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls"
4040
puntvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls"
41+
wireguardvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin/vppcalls"
4142
rpc "go.ligato.io/vpp-agent/v3/proto/ligato/configurator"
4243
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp"
4344
)
@@ -150,6 +151,10 @@ func (p *Plugin) initHandlers() (err error) {
150151
if p.configurator.puntHandler == nil {
151152
p.Log.Info("VPP Punt handler is not available, it will be skipped")
152153
}
154+
p.configurator.wireguardHandler = wireguardvppcalls.CompatibleWgVppHandler(p.VPP, ifIndexes, p.Log)
155+
if p.configurator.wireguardHandler == nil {
156+
p.Log.Info("VPP Wg handler is not available, it will be skipped")
157+
}
153158

154159
// Linux handlers
155160
p.configurator.linuxIfHandler = iflinuxcalls.NewNetLinkHandler(p.NsPlugin, linuxIfIndexes,

plugins/restapi/plugin_restapi.go

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
l3vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls"
4646
natvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls"
4747
puntvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls"
48+
wireguardvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/wireguardplugin/vppcalls"
4849
)
4950

5051
// REST api methods
@@ -75,6 +76,7 @@ type Plugin struct {
7576
l3Handler l3vppcalls.L3VppAPI
7677
ipSecHandler ipsecvppcalls.IPSecVPPRead
7778
puntHandler puntvppcalls.PuntVPPRead
79+
wireguardHandler wireguardvppcalls.WgVppRead
7880
// Linux handlers
7981
linuxIfHandler iflinuxcalls.NetlinkAPIRead
8082
linuxL3Handler l3linuxcalls.NetlinkAPIRead
@@ -167,6 +169,10 @@ func (p *Plugin) Init() (err error) {
167169
if p.puntHandler == nil {
168170
p.Log.Infof("Punt handler is not available, it will be skipped")
169171
}
172+
p.wireguardHandler = wireguardvppcalls.CompatibleWgVppHandler(p.VPP, ifIndexes, p.Log)
173+
if p.wireguardHandler == nil {
174+
p.Log.Info("Wireguard handler is not available, it will be skipped")
175+
}
170176

171177
// Linux handlers
172178
p.linuxIfHandler = iflinuxcalls.NewNetLinkHandler(p.NsPlugin, linuxIfIndexes, p.ServiceLabel.GetAgentPrefix(),

plugins/restapi/resturl/urls.go

+5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ const (
119119
PuntSocket = "/dump/vpp/v2/punt/sockets"
120120
)
121121

122+
// VPP Wireguard plugin
123+
const (
124+
Peers = "/dump/vpp/v2/wireguard/peers"
125+
)
126+
122127
// Telemetry
123128
const (
124129
// Telemetry reads various types of metrics data from the VPP

plugins/vpp/binapi/vpp2009/vpp2009.go

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vpe"
5050
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vxlan"
5151
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vxlan_gpe"
52+
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/wireguard"
5253
)
5354

5455
// Version is used to identify VPP binapi version
@@ -91,6 +92,7 @@ func init() {
9192
nat.AllMessages,
9293
stn.AllMessages,
9394
vmxnet3.AllMessages,
95+
wireguard.AllMessages,
9496
),
9597
}
9698
}
@@ -128,3 +130,4 @@ func init() {
128130
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/nat.api.json
129131
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/stn.api.json
130132
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/vmxnet3.api.json
133+
//go:generate binapigen --input-file=$VPP_API_DIR/plugins/wireguard.api.json

0 commit comments

Comments
 (0)