Change logic of searching for rule's ID (#34)
Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
This commit is contained in:
parent
7c0b8e78d4
commit
b62e86457d
12
rule.go
12
rule.go
|
@ -114,16 +114,18 @@ func (cc *Conn) GetRuleHandle(t *Table, c *Chain, ruleID uint32) (uint64, error)
|
|||
if err != nil {
|
||||
return 0, fmt.Errorf("Receive: %v", err)
|
||||
}
|
||||
if len(reply) != 1 {
|
||||
return 0, fmt.Errorf("Receive: Expected 1 message but got %d", len(reply))
|
||||
}
|
||||
rr, err := ruleFromMsg(reply[0])
|
||||
for _, msg := range reply {
|
||||
rr, err := ruleFromMsg(msg)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if rr.RuleID == ruleID {
|
||||
return rr.Handle, nil
|
||||
}
|
||||
}
|
||||
|
||||
return 0, fmt.Errorf("rule with id %d is not found", ruleID)
|
||||
}
|
||||
|
||||
// AddRule adds the specified Rule
|
||||
func (cc *Conn) AddRule(r *Rule) *Rule {
|
||||
|
|
Loading…
Reference in New Issue