diff --git a/flowtable.go b/flowtable.go index 01df08e..93dbcb5 100644 --- a/flowtable.go +++ b/flowtable.go @@ -219,7 +219,7 @@ func (cc *Conn) getFlowtables(t *Table) ([]netlink.Message, error) { reply, err := receiveAckAware(conn, message.Header.Flags) if err != nil { - return nil, fmt.Errorf("Receive: %v", err) + return nil, fmt.Errorf("receiveAckAware: %v", err) } return reply, nil diff --git a/monitor_test.go b/monitor_test.go index b0f2667..f47b5de 100644 --- a/monitor_test.go +++ b/monitor_test.go @@ -62,29 +62,27 @@ func TestMonitor(t *testing.T) { defer wg.Done() count := int32(0) for { - select { - case event, ok := <-events: - if !ok { - return - } - if event.Error != nil { - err = fmt.Errorf("monitor err: %s", event.Error) - return - } - switch event.Type { - case nftables.MonitorEventTypeNewTable: - gotTable = event.Data.(*nftables.Table) - atomic.AddInt32(&count, 1) - case nftables.MonitorEventTypeNewChain: - gotChain = event.Data.(*nftables.Chain) - atomic.AddInt32(&count, 1) - case nftables.MonitorEventTypeNewRule: - gotRule = event.Data.(*nftables.Rule) - atomic.AddInt32(&count, 1) - } - if atomic.LoadInt32(&count) == 3 { - return - } + event, ok := <-events + if !ok { + return + } + if event.Error != nil { + err = fmt.Errorf("monitor err: %s", event.Error) + return + } + switch event.Type { + case nftables.MonitorEventTypeNewTable: + gotTable = event.Data.(*nftables.Table) + atomic.AddInt32(&count, 1) + case nftables.MonitorEventTypeNewChain: + gotChain = event.Data.(*nftables.Chain) + atomic.AddInt32(&count, 1) + case nftables.MonitorEventTypeNewRule: + gotRule = event.Data.(*nftables.Rule) + atomic.AddInt32(&count, 1) + } + if atomic.LoadInt32(&count) == 3 { + return } } }() diff --git a/obj.go b/obj.go index 997c1c5..9331481 100644 --- a/obj.go +++ b/obj.go @@ -354,7 +354,7 @@ func (cc *Conn) getObjWithLegacyType(o Obj, t *Table, msgType uint16, returnLega reply, err := receiveAckAware(conn, message.Header.Flags) if err != nil { - return nil, fmt.Errorf("Receive: %v", err) + return nil, fmt.Errorf("receiveAckAware: %v", err) } var objs []Obj for _, msg := range reply { diff --git a/rule.go b/rule.go index 8bcfda1..0706834 100644 --- a/rule.go +++ b/rule.go @@ -92,7 +92,7 @@ func (cc *Conn) GetRules(t *Table, c *Chain) ([]*Rule, error) { reply, err := receiveAckAware(conn, message.Header.Flags) if err != nil { - return nil, fmt.Errorf("Receive: %v", err) + return nil, fmt.Errorf("receiveAckAware: %v", err) } var rules []*Rule for _, msg := range reply { diff --git a/set.go b/set.go index 36163a9..401b9b4 100644 --- a/set.go +++ b/set.go @@ -832,7 +832,7 @@ func (cc *Conn) GetSets(t *Table) ([]*Set, error) { reply, err := receiveAckAware(conn, message.Header.Flags) if err != nil { - return nil, fmt.Errorf("Receive: %v", err) + return nil, fmt.Errorf("receiveAckAware: %v", err) } var sets []*Set for _, msg := range reply { @@ -877,11 +877,11 @@ func (cc *Conn) GetSetByName(t *Table, name string) (*Set, error) { reply, err := receiveAckAware(conn, message.Header.Flags) if err != nil { - return nil, fmt.Errorf("Receive: %w", err) + return nil, fmt.Errorf("receiveAckAware: %w", err) } if len(reply) != 1 { - return nil, fmt.Errorf("Receive: expected to receive 1 message but got %d", len(reply)) + return nil, fmt.Errorf("receiveAckAware: expected to receive 1 message but got %d", len(reply)) } rs, err := setsFromMsg(reply[0]) if err != nil { @@ -922,7 +922,7 @@ func (cc *Conn) GetSetElements(s *Set) ([]SetElement, error) { reply, err := receiveAckAware(conn, message.Header.Flags) if err != nil { - return nil, fmt.Errorf("Receive: %v", err) + return nil, fmt.Errorf("receiveAckAware: %v", err) } var elems []SetElement for _, msg := range reply {