mirror of https://github.com/jetkvm/kvm.git
fix lint issues
This commit is contained in:
parent
cb7da61ab4
commit
6e25d44597
|
@ -18,7 +18,6 @@ const (
|
|||
|
||||
func afPacketComputeSize(targetSizeMb int, snaplen int, pageSize int) (
|
||||
frameSize int, blockSize int, numBlocks int, err error) {
|
||||
|
||||
if snaplen < pageSize {
|
||||
frameSize = pageSize / (pageSize / snaplen)
|
||||
} else {
|
||||
|
|
|
@ -74,7 +74,10 @@ func (l *LLDP) Start() error {
|
|||
l.l.Error().Err(err).Msg("unable to set up AF_PACKET")
|
||||
return err
|
||||
}
|
||||
l.startCapture()
|
||||
if err := l.startCapture(); err != nil {
|
||||
l.l.Error().Err(err).Msg("unable to start capture")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
go l.neighbors.Start()
|
||||
|
@ -93,7 +96,7 @@ func (l *LLDP) Stop() error {
|
|||
}
|
||||
|
||||
if l.enableRx {
|
||||
l.shutdownCapture()
|
||||
_ = l.shutdownCapture()
|
||||
}
|
||||
|
||||
l.neighbors.Stop()
|
||||
|
|
|
@ -20,6 +20,8 @@ var (
|
|||
|
||||
// from lldpd
|
||||
// https://github.com/lldpd/lldpd/blob/9034c9332cca0c8b1a20e1287f0e5fed81f7eb2a/src/daemon/lldpd.h#L246
|
||||
//
|
||||
//nolint:govet
|
||||
var bpfFilter = []bpf.RawInstruction{
|
||||
{0x30, 0, 0, 0x00000000}, {0x54, 0, 0, 0x00000001}, {0x15, 0, 16, 0x00000001},
|
||||
{0x28, 0, 0, 0x0000000c}, {0x15, 0, 6, 0x000088cc},
|
||||
|
@ -110,7 +112,6 @@ func (l *LLDP) startCapture() error {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
return nil
|
||||
|
@ -239,7 +240,7 @@ func (l *LLDP) handlePacketCDP(mac string, raw *layers.CiscoDiscovery, info *lay
|
|||
}
|
||||
|
||||
if len(info.MgmtAddresses) > 0 {
|
||||
n.ManagementAddress = fmt.Sprintf("%s", info.MgmtAddresses[0])
|
||||
n.ManagementAddress = string(info.MgmtAddresses[0])
|
||||
}
|
||||
|
||||
l.addNeighbor(mac, *n, ttl)
|
||||
|
|
|
@ -14,11 +14,7 @@ func (s *NetworkInterfaceState) shouldStartLLDP() bool {
|
|||
|
||||
s.l.Trace().Msgf("LLDP mode: %s", s.config.LLDPMode.String)
|
||||
|
||||
if s.config.LLDPMode.String == "disabled" {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return s.config.LLDPMode.String != "disabled"
|
||||
}
|
||||
|
||||
func (s *NetworkInterfaceState) startLLDP() {
|
||||
|
@ -27,7 +23,9 @@ func (s *NetworkInterfaceState) startLLDP() {
|
|||
}
|
||||
|
||||
s.l.Trace().Msg("starting LLDP")
|
||||
s.lldp.Start()
|
||||
if err := s.lldp.Start(); err != nil {
|
||||
s.l.Error().Err(err).Msg("unable to start LLDP")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *NetworkInterfaceState) stopLLDP() {
|
||||
|
@ -35,7 +33,9 @@ func (s *NetworkInterfaceState) stopLLDP() {
|
|||
return
|
||||
}
|
||||
s.l.Trace().Msg("stopping LLDP")
|
||||
s.lldp.Stop()
|
||||
if err := s.lldp.Stop(); err != nil {
|
||||
s.l.Error().Err(err).Msg("unable to stop LLDP")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *NetworkInterfaceState) GetLLDPNeighbors() ([]lldp.Neighbor, error) {
|
||||
|
|
Loading…
Reference in New Issue