@@ -178,28 +178,21 @@ func TestEnsureSrcValidMarkWithStrictRPFilter(t *testing.T) {
178178 confPath := createIPv4Conf (t , "1" , "0" , "0" )
179179 testLogger := & warningRecorder {Logger : logger .NOP ()}
180180
181- state , err := enableSrcValidMark (confPath , testLogger )
181+ err := enableSrcValidMark (confPath , testLogger )
182182 require .NoError (t , err )
183- require .NotNil (t , state )
184183 value , err := os .ReadFile (confPath + "/all/src_valid_mark" )
185184 require .NoError (t , err )
186185 require .Equal (t , "1" , string (value ))
187186 require .Len (t , testLogger .warnings , 1 )
188- require .True (t , strings .Contains (testLogger .warnings [0 ], "will restore it on close" ))
189-
190- require .NoError (t , state .Close ())
191- value , err = os .ReadFile (confPath + "/all/src_valid_mark" )
192- require .NoError (t , err )
193- require .Equal (t , "0" , string (value ))
187+ require .True (t , strings .Contains (testLogger .warnings [0 ], "will remain enabled after close" ))
194188}
195189
196190func TestEnsureSrcValidMarkSkipsNonStrictRPFilter (t * testing.T ) {
197191 confPath := createIPv4Conf (t , "0" , "0" , "2" )
198192 require .NoError (t , os .Remove (confPath + "/all/src_valid_mark" ))
199193
200- state , err := enableSrcValidMark (confPath , logger .NOP ())
194+ err := enableSrcValidMark (confPath , logger .NOP ())
201195 require .NoError (t , err )
202- require .Nil (t , state )
203196 _ , err = os .Stat (confPath + "/all/src_valid_mark" )
204197 require .ErrorIs (t , err , os .ErrNotExist )
205198}
@@ -208,29 +201,25 @@ func TestEnsureSrcValidMarkPreservesEnabledValue(t *testing.T) {
208201 confPath := createIPv4Conf (t , "1" , "0" , "0" )
209202 require .NoError (t , os .WriteFile (confPath + "/all/src_valid_mark" , []byte ("1" ), 0o600 ))
210203
211- state , err := enableSrcValidMark (confPath , logger .NOP ())
204+ err := enableSrcValidMark (confPath , logger .NOP ())
212205 require .NoError (t , err )
213- require .Nil (t , state )
214206 value , err := os .ReadFile (confPath + "/all/src_valid_mark" )
215207 require .NoError (t , err )
216208 require .Equal (t , "1" , string (value ))
217209}
218210
219- func TestEnsureSrcValidMarkAllowsConcurrentBypass (t * testing.T ) {
211+ func TestEnsureSrcValidMarkIsIdempotent (t * testing.T ) {
220212 confPath := createIPv4Conf (t , "1" , "0" , "0" )
221213
222- firstState , err := enableSrcValidMark (confPath , logger .NOP ())
214+ err := enableSrcValidMark (confPath , logger .NOP ())
223215 require .NoError (t , err )
224- require .NotNil (t , firstState )
225216
226- secondState , err : = enableSrcValidMark (confPath , logger .NOP ())
217+ err = enableSrcValidMark (confPath , logger .NOP ())
227218 require .NoError (t , err )
228- require .Nil (t , secondState )
229219
230- require .NoError (t , firstState .Close ())
231220 value , err := os .ReadFile (confPath + "/all/src_valid_mark" )
232221 require .NoError (t , err )
233- require .Equal (t , "0 " , string (value ))
222+ require .Equal (t , "1 " , string (value ))
234223}
235224
236225func createIPv4Conf (t * testing.T , allRPFilter string , defaultRPFilter string , interfaceRPFilter string ) string {
0 commit comments