@@ -69,6 +69,12 @@ type Interface interface {
69
69
AddReloadFunc (reloadFunc func ())
70
70
// Destroy cleans up resources used by the Interface
71
71
Destroy ()
72
+ // HasRandomFully reveals whether `-j MASQUERADE` takes the
73
+ // `--random-fully` option. This is helpful to work around a
74
+ // Linux kernel bug that sometimes causes multiple flows to get
75
+ // mapped to the same IP:PORT and consequently some suffer packet
76
+ // drops.
77
+ HasRandomFully () bool
72
78
}
73
79
74
80
type Protocol byte
@@ -121,6 +127,8 @@ const NoFlushTables FlushFlag = false
121
127
// (test whether a rule exists).
122
128
var MinCheckVersion = utilversion .MustParseGeneric ("1.4.11" )
123
129
130
+ var RandomFullyMinVersion = utilversion .MustParseGeneric ("1.6.2" )
131
+
124
132
// Minimum iptables versions supporting the -w and -w<seconds> flags
125
133
var WaitMinVersion = utilversion .MustParseGeneric ("1.4.20" )
126
134
var WaitSecondsMinVersion = utilversion .MustParseGeneric ("1.4.22" )
@@ -139,6 +147,7 @@ type runner struct {
139
147
protocol Protocol
140
148
hasCheck bool
141
149
hasListener bool
150
+ hasRandomFully bool
142
151
waitFlag []string
143
152
restoreWaitFlag []string
144
153
lockfilePath string
@@ -166,6 +175,7 @@ func newInternal(exec utilexec.Interface, dbus utildbus.Interface, protocol Prot
166
175
protocol : protocol ,
167
176
hasCheck : version .AtLeast (MinCheckVersion ),
168
177
hasListener : false ,
178
+ hasRandomFully : version .AtLeast (RandomFullyMinVersion ),
169
179
waitFlag : getIPTablesWaitFlag (version ),
170
180
restoreWaitFlag : getIPTablesRestoreWaitFlag (version ),
171
181
lockfilePath : lockfilePath ,
@@ -632,6 +642,10 @@ func (runner *runner) reload() {
632
642
}
633
643
}
634
644
645
+ func (runner * runner ) HasRandomFully () bool {
646
+ return runner .hasRandomFully
647
+ }
648
+
635
649
var iptablesNotFoundStrings = []string {
636
650
// iptables-legacy [-A|-I] BAD-CHAIN [...]
637
651
// iptables-legacy [-C|-D] GOOD-CHAIN [...non-matching rule...]
0 commit comments