mirror of
https://github.com/containers/podman.git
synced 2025-09-10 15:46:07 +08:00

podman containers using IPv6 were missing the default route, breaking deployments trying to use them. The problem is that the default route was hardcoded to IPv4, this takes into consideration the podman subnet IP family to generate the corresponding default route. Signed-off-by: Antonio Ojea <aojea@redhat.com>
39 lines
686 B
Go
39 lines
686 B
Go
package network
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewIPAMDefaultRoute(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
name string
|
|
isIPv6 bool
|
|
want IPAMRoute
|
|
}{
|
|
{
|
|
name: "IPv4 default route",
|
|
isIPv6: false,
|
|
want: IPAMRoute{defaultIPv4Route},
|
|
},
|
|
{
|
|
name: "IPv6 default route",
|
|
isIPv6: true,
|
|
want: IPAMRoute{defaultIPv6Route},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
tt := tt
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := NewIPAMDefaultRoute(tt.isIPv6)
|
|
if err != nil {
|
|
t.Errorf("no errorr expected: %v", err)
|
|
}
|
|
if !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("NewIPAMDefaultRoute() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|