mirror of
https://github.com/vishvananda/netlink
synced 2025-01-13 18:45:05 +00:00
rule: fix parsing zero priority rule
This commit is contained in:
parent
f4e6e3d5d5
commit
578e95cc31
@ -221,6 +221,7 @@ func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) (
|
||||
}
|
||||
|
||||
rule := NewRule()
|
||||
rule.Priority = 0 // The default priority from kernel
|
||||
|
||||
rule.Invert = msg.Flags&FibRuleInvert > 0
|
||||
rule.Family = int(msg.Family)
|
||||
|
41
rule_test.go
41
rule_test.go
@ -222,6 +222,47 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) {
|
||||
return rs, false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "returns one rule filtered by Priority(0) and Table",
|
||||
ruleFilter: &Rule{Priority: 0, Table: 1},
|
||||
filterMask: RT_FILTER_PRIORITY | RT_FILTER_TABLE,
|
||||
preRun: func() *Rule {
|
||||
r := NewRule()
|
||||
r.Src = srcNet
|
||||
r.Priority = 0
|
||||
r.Family = family
|
||||
r.Table = 1
|
||||
RuleAdd(r)
|
||||
return r
|
||||
},
|
||||
postRun: func(r *Rule) {
|
||||
RuleDel(r)
|
||||
},
|
||||
setupWant: func(r *Rule) ([]Rule, bool) {
|
||||
return []Rule{*r}, false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "returns one rule filtered by Priority preceding main-table rule",
|
||||
ruleFilter: &Rule{Priority: 32765},
|
||||
filterMask: RT_FILTER_PRIORITY,
|
||||
preRun: func() *Rule {
|
||||
r := NewRule()
|
||||
r.Src = srcNet
|
||||
r.Family = family
|
||||
r.Table = 1
|
||||
RuleAdd(r)
|
||||
|
||||
r.Priority = 32765 // Set priority for assertion
|
||||
return r
|
||||
},
|
||||
postRun: func(r *Rule) {
|
||||
RuleDel(r)
|
||||
},
|
||||
setupWant: func(r *Rule) ([]Rule, bool) {
|
||||
return []Rule{*r}, false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "returns rules with specific priority",
|
||||
ruleFilter: &Rule{Priority: 5},
|
||||
|
Loading…
Reference in New Issue
Block a user