diff options
author | baude <bbaude@redhat.com> | 2020-10-06 12:24:21 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2020-10-07 10:03:21 -0500 |
commit | fe3faa517e1bbc3b2e82afaae32d8712c844fdae (patch) | |
tree | 3b4a74edc98a2861d2e1b6bb1d9769e078b9ba3c /libpod/network/netconflist_test.go | |
parent | defb754945b3f99c1d786dac95d9b17b24f55e59 (diff) | |
download | podman-fe3faa517e1bbc3b2e82afaae32d8712c844fdae.tar.gz podman-fe3faa517e1bbc3b2e82afaae32d8712c844fdae.tar.bz2 podman-fe3faa517e1bbc3b2e82afaae32d8712c844fdae.zip |
prevent unpredictable results with network create|remove
due to a lack of "locking" on cni operations, we could get ourselves in trouble when doing rapid creation or removal of networks. added a simple file lock to deal with the collision and because it is not considered a performent path, use of the file lock should be ok. if proven otherwise in the future, some generic shared memory lock should be implemented for libpod and also used here.
moved pkog/network to libpod/network because libpod is now being pulled into the package and it has therefore lost its generic nature. this will make it easier to absorb into libpod as we try to make the network closer to core operations.
Fixes: #7807
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/network/netconflist_test.go')
-rw-r--r-- | libpod/network/netconflist_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libpod/network/netconflist_test.go b/libpod/network/netconflist_test.go new file mode 100644 index 000000000..5893bf985 --- /dev/null +++ b/libpod/network/netconflist_test.go @@ -0,0 +1,38 @@ +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 error expected: %v", err) + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("NewIPAMDefaultRoute() = %v, want %v", got, tt.want) + } + }) + } +} |