Skip to content

Commit 6e25d44

Browse files
committed
fix lint issues
1 parent cb7da61 commit 6e25d44

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

internal/lldp/afpacket.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const (
1818

1919
func afPacketComputeSize(targetSizeMb int, snaplen int, pageSize int) (
2020
frameSize int, blockSize int, numBlocks int, err error) {
21-
2221
if snaplen < pageSize {
2322
frameSize = pageSize / (pageSize / snaplen)
2423
} else {

internal/lldp/lldp.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ func (l *LLDP) Start() error {
7474
l.l.Error().Err(err).Msg("unable to set up AF_PACKET")
7575
return err
7676
}
77-
l.startCapture()
77+
if err := l.startCapture(); err != nil {
78+
l.l.Error().Err(err).Msg("unable to start capture")
79+
return err
80+
}
7881
}
7982

8083
go l.neighbors.Start()
@@ -93,7 +96,7 @@ func (l *LLDP) Stop() error {
9396
}
9497

9598
if l.enableRx {
96-
l.shutdownCapture()
99+
_ = l.shutdownCapture()
97100
}
98101

99102
l.neighbors.Stop()

internal/lldp/rx.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var (
2020

2121
// from lldpd
2222
// https://github.com/lldpd/lldpd/blob/9034c9332cca0c8b1a20e1287f0e5fed81f7eb2a/src/daemon/lldpd.h#L246
23+
//
24+
//nolint:govet
2325
var bpfFilter = []bpf.RawInstruction{
2426
{0x30, 0, 0, 0x00000000}, {0x54, 0, 0, 0x00000001}, {0x15, 0, 16, 0x00000001},
2527
{0x28, 0, 0, 0x0000000c}, {0x15, 0, 6, 0x000088cc},
@@ -110,7 +112,6 @@ func (l *LLDP) startCapture() error {
110112
}
111113
}
112114
}
113-
114115
}()
115116

116117
return nil
@@ -239,7 +240,7 @@ func (l *LLDP) handlePacketCDP(mac string, raw *layers.CiscoDiscovery, info *lay
239240
}
240241

241242
if len(info.MgmtAddresses) > 0 {
242-
n.ManagementAddress = fmt.Sprintf("%s", info.MgmtAddresses[0])
243+
n.ManagementAddress = string(info.MgmtAddresses[0])
243244
}
244245

245246
l.addNeighbor(mac, *n, ttl)

internal/network/lldp.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ func (s *NetworkInterfaceState) shouldStartLLDP() bool {
1414

1515
s.l.Trace().Msgf("LLDP mode: %s", s.config.LLDPMode.String)
1616

17-
if s.config.LLDPMode.String == "disabled" {
18-
return false
19-
}
20-
21-
return true
17+
return s.config.LLDPMode.String != "disabled"
2218
}
2319

2420
func (s *NetworkInterfaceState) startLLDP() {
@@ -27,15 +23,19 @@ func (s *NetworkInterfaceState) startLLDP() {
2723
}
2824

2925
s.l.Trace().Msg("starting LLDP")
30-
s.lldp.Start()
26+
if err := s.lldp.Start(); err != nil {
27+
s.l.Error().Err(err).Msg("unable to start LLDP")
28+
}
3129
}
3230

3331
func (s *NetworkInterfaceState) stopLLDP() {
3432
if s.lldp == nil {
3533
return
3634
}
3735
s.l.Trace().Msg("stopping LLDP")
38-
s.lldp.Stop()
36+
if err := s.lldp.Stop(); err != nil {
37+
s.l.Error().Err(err).Msg("unable to stop LLDP")
38+
}
3939
}
4040

4141
func (s *NetworkInterfaceState) GetLLDPNeighbors() ([]lldp.Neighbor, error) {

0 commit comments

Comments
 (0)