Skip to content

Commit 88effb0

Browse files
committed
Fix IncludeInterface/ExcludeInterface priority
1 parent dc32f53 commit 88effb0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tun_linux.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ func (t *NativeTun) rules() []*netlink.Rule {
668668
}
669669
}
670670
if len(t.options.IncludeInterface) > 0 {
671-
matchPriority := priority + 2*len(t.options.IncludeInterface) + 1
671+
matchPriority := priority + 2
672672
for _, includeInterface := range t.options.IncludeInterface {
673673
if p4 {
674674
it = netlink.NewRule()
@@ -677,7 +677,6 @@ func (t *NativeTun) rules() []*netlink.Rule {
677677
it.Goto = matchPriority
678678
it.Family = unix.AF_INET
679679
rules = append(rules, it)
680-
priority++
681680
}
682681
if p6 {
683682
it = netlink.NewRule()
@@ -686,9 +685,14 @@ func (t *NativeTun) rules() []*netlink.Rule {
686685
it.Goto = matchPriority
687686
it.Family = unix.AF_INET6
688687
rules = append(rules, it)
689-
priority6++
690688
}
691689
}
690+
if p4 {
691+
priority++
692+
}
693+
if p6 {
694+
priority6++
695+
}
692696
if p4 {
693697
it = netlink.NewRule()
694698
it.Priority = priority
@@ -726,7 +730,6 @@ func (t *NativeTun) rules() []*netlink.Rule {
726730
it.Goto = nopPriority
727731
it.Family = unix.AF_INET
728732
rules = append(rules, it)
729-
priority++
730733
}
731734
if p6 {
732735
it = netlink.NewRule()
@@ -735,9 +738,15 @@ func (t *NativeTun) rules() []*netlink.Rule {
735738
it.Goto = nopPriority
736739
it.Family = unix.AF_INET6
737740
rules = append(rules, it)
738-
priority6++
739741
}
740742
}
743+
744+
if p4 {
745+
priority++
746+
}
747+
if p6 {
748+
priority6++
749+
}
741750
}
742751

743752
if runtime.GOOS == "android" && t.options.InterfaceMonitor.AndroidVPNEnabled() {

0 commit comments

Comments
 (0)