diff --git a/rule_linux.go b/rule_linux.go index 69f53e4..5f4f98d 100644 --- a/rule_linux.go +++ b/rule_linux.go @@ -223,6 +223,7 @@ func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) ( rule := NewRule() rule.Invert = msg.Flags&FibRuleInvert > 0 + rule.Family = int(msg.Family) rule.Tos = uint(msg.Tos) for j := range attrs { diff --git a/rule_test.go b/rule_test.go index f43d436..cb7657d 100644 --- a/rule_test.go +++ b/rule_test.go @@ -23,6 +23,7 @@ func TestRuleAddDel(t *testing.T) { } rule := NewRule() + rule.Family = FAMILY_V4 rule.Table = unix.RT_TABLE_MAIN rule.Src = srcNet rule.Dst = dstNet @@ -121,6 +122,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Src = srcNet r.Priority = 1 // Must add priority and table otherwise it's auto-assigned + r.Family = family r.Table = 1 RuleAdd(r) return r @@ -138,6 +140,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Dst = dstNet r.Priority = 1 // Must add priority and table otherwise it's auto-assigned + r.Family = family r.Table = 1 RuleAdd(r) return r @@ -155,6 +158,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Dst = dstNet r.Priority = 1 // Must add priority and table otherwise it's auto-assigned + r.Family = family r.Table = 1 RuleAdd(r) @@ -190,6 +194,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Dst = dstNet r.Priority = 1 // Must add priority and table otherwise it's auto-assigned + r.Family = family r.Table = 1 RuleAdd(r) @@ -225,6 +230,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Src = srcNet r.Priority = 5 + r.Family = family r.Table = 1 RuleAdd(r) @@ -266,6 +272,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Src = srcNet r.Priority = 1 // Must add priority otherwise it's auto-assigned + r.Family = family r.Table = 199 RuleAdd(r) return r @@ -283,6 +290,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Src = srcNet r.Priority = 1 // Must add priority and table otherwise it's auto-assigned + r.Family = family r.Table = 1 r.Mask = 0x5 RuleAdd(r) @@ -301,6 +309,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Src = srcNet r.Priority = 1 // Must add priority, table, mask otherwise it's auto-assigned + r.Family = family r.Table = 1 r.Mask = 0xff r.Mark = 0xbb @@ -320,6 +329,7 @@ func runRuleListFiltered(t *testing.T, family int, srcNet, dstNet *net.IPNet) { r := NewRule() r.Src = srcNet r.Priority = 1 // Must add priority, table, mask otherwise it's auto-assigned + r.Family = family r.Table = 12 r.Tos = 12 // Tos must equal table RuleAdd(r) @@ -418,6 +428,7 @@ func ruleEquals(a, b Rule) bool { (a.Dst != nil && b.Dst != nil && a.Dst.String() == b.Dst.String())) && a.OifName == b.OifName && a.Priority == b.Priority && + a.Family == b.Family && a.IifName == b.IifName && a.Invert == b.Invert && a.Tos == b.Tos &&