Skip to content

Add support for IPsec with tunnels. #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ovs/vswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ type InterfaceOptions struct {
// tunneled traffic leaving this interface. Optionally it could be set to
// "flow" which expects the flow to set tunnel ID.
Key string

// Pre-shared key to encrypt OVS tunnel with IPsec. Supports GRE, GENEVE,
// VXLAN, and STT tunnel.
PSK string

// Path to certificate of the remote server to encrypt with an self-signed cert
// using IPsec. Supports GRE, GENEVE, VXLAN, and STT tunnel.
RemoteCert string

// Common name of the remote certificate signed by an certificate authority to
// encrypt using IPsec. Supports GRE, GENEVE, VXLAN, and STT tunnel.
RemoteName string
}

// slice creates a string slice containing any non-zero option values from the
Expand Down Expand Up @@ -315,5 +327,17 @@ func (i InterfaceOptions) slice() []string {
s = append(s, fmt.Sprintf("options:key=%s", i.Key))
}

if i.PSK != "" {
s = append(s, fmt.Sprintf("options:psk=%s", i.PSK))
}

if i.RemoteCert != "" {
s = append(s, fmt.Sprintf("options:remote_cert=%s", i.RemoteCert))
}

if i.RemoteName != "" {
s = append(s, fmt.Sprintf("options:remote_name=%s", i.RemoteName))
}

return s
}
45 changes: 45 additions & 0 deletions ovs/vswitch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,51 @@ func TestInterfaceOptions_slice(t *testing.T) {
"options:key=flow",
},
},
{
desc: "ipsec PSK encrypted VXLAN tunnel",
i: InterfaceOptions{
Type: InterfaceTypeVXLAN,
RemoteIP: "10.43.22.1",
Key: "flow",
PSK: "swordfish",
},
out: []string{
"type=stt",
"options:remote_ip=10.43.22.1",
"options:key=flow",
"options:psk=swordfish",
},
},
{
desc: "ipsec self-signed encrypted VXLAN tunnel",
i: InterfaceOptions{
Type: InterfaceTypeVXLAN,
RemoteIP: "10.43.22.1",
Key: "flow",
RemoteCert: "/path/to/remote.pem",
},
out: []string{
"type=stt",
"options:remote_ip=10.43.22.1",
"options:key=flow",
"options:remote_cert=/path/to/remote.pem",
},
},
{
desc: "ipsec CA encrypted VXLAN tunnel",
i: InterfaceOptions{
Type: InterfaceTypeVXLAN,
RemoteIP: "10.43.22.1",
Key: "flow",
RemoteName: "remote_cn",
},
out: []string{
"type=stt",
"options:remote_ip=10.43.22.1",
"options:key=flow",
"options:remote_name=remote_cn",
},
},
{
desc: "all options",
i: InterfaceOptions{
Expand Down