Skip to content

Commit 19ea691

Browse files
committed
Populate rule type and new l3mdev-flag when listing rules.
1 parent bb01d76 commit 19ea691

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

rule.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Rule struct {
2929
UIDRange *RuleUIDRange
3030
Protocol uint8
3131
Type uint8
32+
L3mdev uint8
3233
}
3334

3435
func (r Rule) Equal(x Rule) bool {
@@ -59,7 +60,8 @@ func (r Rule) Equal(x Rule) bool {
5960
r.SuppressPrefixlen == x.SuppressPrefixlen &&
6061
(r.Dport == x.Dport || (r.Dport != nil && x.Dport != nil && r.Dport.Equal(*x.Dport))) &&
6162
(r.Sport == x.Sport || (r.Sport != nil && x.Sport != nil && r.Sport.Equal(*x.Sport))) &&
62-
(r.UIDRange == x.UIDRange || (r.UIDRange != nil && x.UIDRange != nil && r.UIDRange.Equal(*x.UIDRange)))
63+
(r.UIDRange == x.UIDRange || (r.UIDRange != nil && x.UIDRange != nil && r.UIDRange.Equal(*x.UIDRange))) &&
64+
r.L3mdev == x.L3mdev
6365
}
6466

6567
func (r Rule) String() string {

rule_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) (
239239
rule.Invert = msg.Flags&FibRuleInvert > 0
240240
rule.Family = int(msg.Family)
241241
rule.Tos = uint(msg.Tos)
242+
rule.Type = msg.Type
242243

243244
for j := range attrs {
244245
switch attrs[j].Attr.Type {
@@ -291,6 +292,8 @@ func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) (
291292
rule.UIDRange = NewRuleUIDRange(native.Uint32(attrs[j].Value[0:4]), native.Uint32(attrs[j].Value[4:8]))
292293
case nl.FRA_PROTOCOL:
293294
rule.Protocol = uint8(attrs[j].Value[0])
295+
case nl.FRA_L3MDEV:
296+
rule.L3mdev = uint8(attrs[j].Value[0])
294297
}
295298
}
296299

rule_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ func TestRuleEqual(t *testing.T) {
699699
{UIDRange: &RuleUIDRange{Start: 3, End: 5}},
700700
{Protocol: FAMILY_V6},
701701
{Type: unix.RTN_UNREACHABLE},
702+
{L3mdev: 1},
702703
}
703704
for i1 := range cases {
704705
for i2 := range cases {

0 commit comments

Comments
 (0)