diff --git a/plugins/configurator/dump.go b/plugins/configurator/dump.go index 15ce77faf6..12024a6265 100644 --- a/plugins/configurator/dump.go +++ b/plugins/configurator/dump.go @@ -302,13 +302,10 @@ func (svc *dumpService) DumpPunt() (punts []*vpp_punt.ToHost, err error) { if svc.puntHandler == nil { return nil, errors.New("puntHandler is not available") } - dump, err := svc.puntHandler.DumpRegisteredPuntSockets() + punts, err = svc.puntHandler.DumpRegisteredPuntSockets() if err != nil { return nil, err } - for _, puntDetails := range dump { - punts = append(punts, puntDetails.PuntData) - } return punts, nil } diff --git a/plugins/vpp/puntplugin/descriptor/punt_to_host.go b/plugins/vpp/puntplugin/descriptor/punt_to_host.go index d0af9995ad..799f5d3487 100644 --- a/plugins/vpp/puntplugin/descriptor/punt_to_host.go +++ b/plugins/vpp/puntplugin/descriptor/punt_to_host.go @@ -164,15 +164,15 @@ func (d *PuntToHostDescriptor) Retrieve(correlate []adapter.PuntToHostKVWithMeta // TODO dump for punt and punt socket register missing in api d.log.Info("Dump punt/socket register is not supported by the VPP") - socks, err := d.puntHandler.DumpRegisteredPuntSockets() + pSockets, err := d.puntHandler.DumpRegisteredPuntSockets() if err != nil { return nil, err } - for _, punt := range socks { + for _, pSocket := range pSockets { retrieved = append(retrieved, adapter.PuntToHostKVWithMetadata{ - Key: models.Key(punt.PuntData), - Value: punt.PuntData, + Key: models.Key(pSocket), + Value: pSocket, Origin: kvs.FromNB, }) } diff --git a/plugins/vpp/puntplugin/vppcalls/punt_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/punt_vppcalls.go index 8eb8bfbc3b..6e164a6af7 100644 --- a/plugins/vpp/puntplugin/vppcalls/punt_vppcalls.go +++ b/plugins/vpp/puntplugin/vppcalls/punt_vppcalls.go @@ -22,12 +22,6 @@ import ( "github.com/ligato/vpp-agent/plugins/vpp/ifplugin/ifaceidx" ) -// PuntDetails includes proto-modelled punt object and its socket path -type PuntDetails struct { - PuntData *punt.ToHost - SocketPath string -} - // PuntVppAPI provides methods for managing VPP punt configuration. type PuntVppAPI interface { PuntVPPRead @@ -49,7 +43,7 @@ type PuntVppAPI interface { // PuntVPPRead provides read methods for punt type PuntVPPRead interface { // DumpPuntRegisteredSockets returns all punt socket registrations known to the VPP agent - DumpRegisteredPuntSockets() ([]*PuntDetails, error) + DumpRegisteredPuntSockets() ([]*punt.ToHost, error) } var Versions = map[string]HandlerVersion{} diff --git a/plugins/vpp/puntplugin/vppcalls/vpp1901/dump_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/vpp1901/dump_vppcalls.go index fbd766453c..d96a81792e 100644 --- a/plugins/vpp/puntplugin/vppcalls/vpp1901/dump_vppcalls.go +++ b/plugins/vpp/puntplugin/vppcalls/vpp1901/dump_vppcalls.go @@ -18,7 +18,6 @@ import ( "github.com/ligato/vpp-agent/api/models/vpp" "github.com/ligato/vpp-agent/api/models/vpp/punt" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1901/punt" - "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls" ) // FIXME: temporary solutions for providing data in dump @@ -26,7 +25,7 @@ var socketPathMap = make(map[uint32]*vpp.PuntToHost) // DumpRegisteredPuntSockets returns punt to host via registered socket entries // TODO since the binary API is not available, all data are read from local cache for now -func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vpp_punt.ToHost, err error) { // TODO: use dumps from binapi if _, err := h.dumpPunts(false); err != nil { h.log.Errorf("punt dump failed: %v", err) @@ -41,11 +40,8 @@ func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDeta h.log.Errorf("punt socket dump failed: %v", err) } - for _, punt := range socketPathMap { - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: punt, - SocketPath: punt.SocketPath, - }) + for _, puntData := range socketPathMap { + punts = append(punts, puntData) } if len(punts) > 0 { @@ -55,7 +51,7 @@ func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDeta return punts, nil } -func (h *PuntVppHandler) dumpPuntSockets(ipv6 bool) (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) dumpPuntSockets(ipv6 bool) (punts []*vpp_punt.ToHost, err error) { var info = "IPv4" if ipv6 { info = "IPv6" @@ -76,20 +72,18 @@ func (h *PuntVppHandler) dumpPuntSockets(ipv6 bool) (punts []*vppcalls.PuntDetai } h.log.Debugf(" - dumped punt socket (%s): %+v", d.Pathname, d.Punt) - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: &vpp_punt.ToHost{ - Port: uint32(d.Punt.L4Port), - // FIXME: L3Protocol seems to return 0 when registering ALL - L3Protocol: parseL3Proto(d.Punt.IPv), - L4Protocol: parseL4Proto(d.Punt.L4Protocol), - }, + punts = append(punts, &vpp_punt.ToHost{ + Port: uint32(d.Punt.L4Port), + // FIXME: L3Protocol seems to return 0 when registering ALL + L3Protocol: parseL3Proto(d.Punt.IPv), + L4Protocol: parseL4Proto(d.Punt.L4Protocol), }) } return punts, nil } -func (h *PuntVppHandler) dumpPunts(ipv6 bool) (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) dumpPunts(ipv6 bool) (punts []*vpp_punt.ToHost, err error) { var info = "IPv4" if ipv6 { info = "IPv6" @@ -110,12 +104,10 @@ func (h *PuntVppHandler) dumpPunts(ipv6 bool) (punts []*vppcalls.PuntDetails, er } h.log.Debugf(" - dumped punt: %+v", d.Punt) - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: &vpp_punt.ToHost{ - Port: uint32(d.Punt.L4Port), - L3Protocol: parseL3Proto(d.Punt.IPv), - L4Protocol: parseL4Proto(d.Punt.L4Protocol), - }, + punts = append(punts, &vpp_punt.ToHost{ + Port: uint32(d.Punt.L4Port), + L3Protocol: parseL3Proto(d.Punt.IPv), + L4Protocol: parseL4Proto(d.Punt.L4Protocol), }) } diff --git a/plugins/vpp/puntplugin/vppcalls/vpp1904/dump_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/vpp1904/dump_vppcalls.go index 47260df61c..b8de4eccb1 100644 --- a/plugins/vpp/puntplugin/vppcalls/vpp1904/dump_vppcalls.go +++ b/plugins/vpp/puntplugin/vppcalls/vpp1904/dump_vppcalls.go @@ -18,7 +18,6 @@ import ( "github.com/ligato/vpp-agent/api/models/vpp" vpp_punt "github.com/ligato/vpp-agent/api/models/vpp/punt" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1904/punt" - "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls" ) // FIXME: temporary solutions for providing data in dump @@ -26,7 +25,7 @@ var socketPathMap = make(map[uint32]*vpp.PuntToHost) // DumpRegisteredPuntSockets returns punt to host via registered socket entries // TODO since the binary API is not available, all data are read from local cache for now -func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vpp_punt.ToHost, err error) { // TODO: use dumps from binapi if _, err := h.dumpPunts(false); err != nil { h.log.Errorf("punt dump failed: %v", err) @@ -41,11 +40,8 @@ func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDeta h.log.Errorf("punt socket dump failed: %v", err) } - for _, punt := range socketPathMap { - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: punt, - SocketPath: punt.SocketPath, - }) + for _, puntData := range socketPathMap { + punts = append(punts, puntData) } if len(punts) > 0 { @@ -55,7 +51,7 @@ func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDeta return punts, nil } -func (h *PuntVppHandler) dumpPuntSockets(ipv6 bool) (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) dumpPuntSockets(ipv6 bool) (punts []*vpp_punt.ToHost, err error) { var info = "IPv4" if ipv6 { info = "IPv6" @@ -76,20 +72,18 @@ func (h *PuntVppHandler) dumpPuntSockets(ipv6 bool) (punts []*vppcalls.PuntDetai } h.log.Debugf(" - dumped punt socket (%s): %+v", d.Pathname, d.Punt) - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: &vpp_punt.ToHost{ - Port: uint32(d.Punt.L4Port), - // FIXME: L3Protocol seems to return 0 when registering ALL - L3Protocol: parseL3Proto(d.Punt.IPv), - L4Protocol: parseL4Proto(d.Punt.L4Protocol), - }, + punts = append(punts, &vpp_punt.ToHost{ + Port: uint32(d.Punt.L4Port), + // FIXME: L3Protocol seems to return 0 when registering ALL + L3Protocol: parseL3Proto(d.Punt.IPv), + L4Protocol: parseL4Proto(d.Punt.L4Protocol), }) } return punts, nil } -func (h *PuntVppHandler) dumpPunts(ipv6 bool) (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) dumpPunts(ipv6 bool) (punts []*vpp_punt.ToHost, err error) { var info = "IPv4" if ipv6 { info = "IPv6" @@ -110,12 +104,10 @@ func (h *PuntVppHandler) dumpPunts(ipv6 bool) (punts []*vppcalls.PuntDetails, er } h.log.Debugf(" - dumped punt: %+v", d.Punt) - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: &vpp_punt.ToHost{ - Port: uint32(d.Punt.L4Port), - L3Protocol: parseL3Proto(d.Punt.IPv), - L4Protocol: parseL4Proto(d.Punt.L4Protocol), - }, + punts = append(punts, &vpp_punt.ToHost{ + Port: uint32(d.Punt.L4Port), + L3Protocol: parseL3Proto(d.Punt.IPv), + L4Protocol: parseL4Proto(d.Punt.L4Protocol), }) } diff --git a/plugins/vpp/puntplugin/vppcalls/vpp1908/dump_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/vpp1908/dump_vppcalls.go index 0fb1303163..2bbf83e2cc 100644 --- a/plugins/vpp/puntplugin/vppcalls/vpp1908/dump_vppcalls.go +++ b/plugins/vpp/puntplugin/vppcalls/vpp1908/dump_vppcalls.go @@ -19,11 +19,10 @@ import ( vpp_punt "github.com/ligato/vpp-agent/api/models/vpp/punt" "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpp1908/punt" - "github.com/ligato/vpp-agent/plugins/vpp/puntplugin/vppcalls" ) // DumpRegisteredPuntSockets returns punt to host via registered socket entries -func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vpp_punt.ToHost, err error) { // TODO: use set_punt dumps from binapi if _, err := h.dumpPunts(); err != nil { h.log.Errorf("punt dump failed: %v", err) @@ -35,7 +34,7 @@ func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDeta return punts, nil } -func (h *PuntVppHandler) dumpPuntSockets() (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) dumpPuntSockets() (punts []*vpp_punt.ToHost, err error) { h.log.Debug("=> dumping punt sockets") req := h.callsChannel.SendMultiRequest(&punt.PuntSocketDump{ @@ -53,13 +52,11 @@ func (h *PuntVppHandler) dumpPuntSockets() (punts []*vppcalls.PuntDetails, err e h.log.Debugf(" - dumped punt socket (%s): %+v", d.Pathname, d.Punt) puntL4Data := d.Punt.Punt.GetL4() - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: &vpp_punt.ToHost{ - Port: uint32(puntL4Data.Port), - // FIXME: L3Protocol seems to return 0 when registering ALL - L3Protocol: parseL3Proto(puntL4Data.Af), - L4Protocol: parseL4Proto(puntL4Data.Protocol), - }, + punts = append(punts, &vpp_punt.ToHost{ + Port: uint32(puntL4Data.Port), + // FIXME: L3Protocol seems to return 0 when registering ALL + L3Protocol: parseL3Proto(puntL4Data.Af), + L4Protocol: parseL4Proto(puntL4Data.Protocol), SocketPath: string(bytes.Trim(d.Pathname, "\x00")), }) } @@ -87,7 +84,7 @@ func parseL4Proto(p punt.IPProto) vpp_punt.L4Protocol { return vpp_punt.L4Protocol_UNDEFINED_L4 } -func (h *PuntVppHandler) dumpPunts() (punts []*vppcalls.PuntDetails, err error) { +func (h *PuntVppHandler) dumpPunts() (punts []*vpp_punt.ToHost, err error) { h.log.Debugf("=> dumping punts") req := h.callsChannel.SendMultiRequest(&punt.PuntReasonDump{}) diff --git a/plugins/vpp/puntplugin/vppcalls/vpp1908/punt_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/vpp1908/punt_vppcalls.go index c5d3ce6b53..228e41824a 100644 --- a/plugins/vpp/puntplugin/vppcalls/vpp1908/punt_vppcalls.go +++ b/plugins/vpp/puntplugin/vppcalls/vpp1908/punt_vppcalls.go @@ -28,14 +28,14 @@ const PuntSocketHeaderVersion = 1 // AddPunt configures new punt entry func (h *PuntVppHandler) AddPunt(p *punt.ToHost) error { - return errors.Errorf("passive punt add is currently now available") + return errors.Errorf("passive punt add is currently not available") // return h.addDelPunt(p, true) } // DeletePunt removes punt entry func (h *PuntVppHandler) DeletePunt(p *punt.ToHost) error { - return errors.Errorf("passive punt del is currently now available") + return errors.Errorf("passive punt del is currently not available") // return h.addDelPunt(p, false) }