Skip to content

Commit 5581720

Browse files
skitttpantelis
authored andcommitted
Libreswan: always specify encapsulation
Instead of only specifying the encapsulation option when encapsulation is forced, configure it explicitly in all circumstances. This ensures that the option is tested even in default scenarios. Signed-off-by: Stephen Kitt <skitt@redhat.com> (cherry picked from commit 3756172)
1 parent 35b58d9 commit 5581720

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/cable/libreswan/libreswan.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252
whackTimeout = 5 * time.Second
5353
dpdDelay = 30 // seconds
5454
encryptArg = "--encrypt"
55-
forceencapsArg = "--encaps=yes"
55+
forceencapsArg = "--encaps="
5656
nameArg = "--name"
5757
hostArg = "--host"
5858
clientArg = "--client"
@@ -491,7 +491,9 @@ func (i *libreswan) bidirectionalConnectToEndpoint(connectionName string, endpoi
491491

492492
args := []string{"--psk", encryptArg}
493493
if endpointInfo.UseNAT || i.forceUDPEncapsulation {
494-
args = append(args, forceencapsArg)
494+
args = append(args, forceencapsArg+"yes")
495+
} else {
496+
args = append(args, forceencapsArg+"auto")
495497
}
496498

497499
args = append(args, nameArg, connectionName, ipFamilyArgs[endpointInfo.UseFamily],
@@ -539,7 +541,9 @@ func (i *libreswan) serverConnectToEndpoint(connectionName string, endpointInfo
539541

540542
args := []string{"--psk", encryptArg}
541543
if endpointInfo.UseNAT || i.forceUDPEncapsulation {
542-
args = append(args, forceencapsArg)
544+
args = append(args, forceencapsArg+"yes")
545+
} else {
546+
args = append(args, forceencapsArg+"auto")
543547
}
544548

545549
args = append(args, nameArg, connectionName, ipFamilyArgs[endpointInfo.UseFamily],
@@ -580,7 +584,9 @@ func (i *libreswan) clientConnectToEndpoint(connectionName string, endpointInfo
580584

581585
args := []string{"--psk", encryptArg}
582586
if endpointInfo.UseNAT || i.forceUDPEncapsulation {
583-
args = append(args, forceencapsArg)
587+
args = append(args, forceencapsArg+"yes")
588+
} else {
589+
args = append(args, forceencapsArg+"auto")
584590
}
585591

586592
args = append(args, nameArg, connectionName, ipFamilyArgs[endpointInfo.UseFamily],

0 commit comments

Comments
 (0)