Linux rule list results have Family populated

Fixes #708
This commit is contained in:
Derek Dagit 2023-07-10 17:37:32 -05:00 committed by Vish (Ishaya) Abrams
parent 1b5637395d
commit dbf1bd04f9
2 changed files with 12 additions and 0 deletions

View File

@ -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 {

View File

@ -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 &&