ipvlan_test.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. package ipvlan
  2. import (
  3. "strings"
  4. "testing"
  5. "time"
  6. "github.com/docker/docker/api/types"
  7. "github.com/docker/docker/api/types/network"
  8. dclient "github.com/docker/docker/client"
  9. "github.com/docker/docker/integration/internal/container"
  10. n "github.com/docker/docker/integration/network"
  11. "github.com/docker/docker/internal/test/daemon"
  12. "github.com/gotestyourself/gotestyourself/assert"
  13. "github.com/gotestyourself/gotestyourself/skip"
  14. "golang.org/x/net/context"
  15. )
  16. func TestDockerNetworkIpvlanPersistance(t *testing.T) {
  17. // verify the driver automatically provisions the 802.1q link (di-dummy0.70)
  18. skip.If(t, testEnv.DaemonInfo.OSType != "linux")
  19. skip.If(t, testEnv.IsRemoteDaemon())
  20. skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan")
  21. d := daemon.New(t, daemon.WithExperimental)
  22. d.StartWithBusybox(t)
  23. defer d.Stop(t)
  24. // master dummy interface 'di' notation represent 'docker ipvlan'
  25. master := "di-dummy0"
  26. n.CreateMasterDummy(t, master)
  27. defer n.DeleteInterface(t, master)
  28. client, err := d.NewClient()
  29. assert.NilError(t, err)
  30. // create a network specifying the desired sub-interface name
  31. _, err = client.NetworkCreate(context.Background(), "di-persist", types.NetworkCreate{
  32. Driver: "ipvlan",
  33. Options: map[string]string{
  34. "parent": "di-dummy0.70",
  35. },
  36. })
  37. assert.NilError(t, err)
  38. assert.Check(t, n.IsNetworkAvailable(client, "di-persist"))
  39. // Restart docker daemon to test the config has persisted to disk
  40. d.Restart(t)
  41. assert.Check(t, n.IsNetworkAvailable(client, "di-persist"))
  42. }
  43. func TestDockerNetworkIpvlan(t *testing.T) {
  44. skip.If(t, testEnv.DaemonInfo.OSType != "linux")
  45. skip.If(t, testEnv.IsRemoteDaemon())
  46. skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan")
  47. for _, tc := range []struct {
  48. name string
  49. test func(dclient.APIClient) func(*testing.T)
  50. }{
  51. {
  52. name: "Subinterface",
  53. test: testIpvlanSubinterface,
  54. }, {
  55. name: "OverlapParent",
  56. test: testIpvlanOverlapParent,
  57. }, {
  58. name: "L2NilParent",
  59. test: testIpvlanL2NilParent,
  60. }, {
  61. name: "L2InternalMode",
  62. test: testIpvlanL2InternalMode,
  63. }, {
  64. name: "L3NilParent",
  65. test: testIpvlanL3NilParent,
  66. }, {
  67. name: "L3InternalMode",
  68. test: testIpvlanL3InternalMode,
  69. }, {
  70. name: "L2MultiSubnet",
  71. test: testIpvlanL2MultiSubnet,
  72. }, {
  73. name: "L3MultiSubnet",
  74. test: testIpvlanL3MultiSubnet,
  75. }, {
  76. name: "Addressing",
  77. test: testIpvlanAddressing,
  78. },
  79. } {
  80. d := daemon.New(t, daemon.WithExperimental)
  81. d.StartWithBusybox(t)
  82. client, err := d.NewClient()
  83. assert.NilError(t, err)
  84. t.Run(tc.name, tc.test(client))
  85. d.Stop(t)
  86. // FIXME(vdemeester) clean network
  87. }
  88. }
  89. func testIpvlanSubinterface(client dclient.APIClient) func(*testing.T) {
  90. return func(t *testing.T) {
  91. master := "di-dummy0"
  92. n.CreateMasterDummy(t, master)
  93. defer n.DeleteInterface(t, master)
  94. _, err := client.NetworkCreate(context.Background(), "di-subinterface", types.NetworkCreate{
  95. Driver: "ipvlan",
  96. Options: map[string]string{
  97. "parent": "di-dummy0.60",
  98. },
  99. })
  100. assert.NilError(t, err)
  101. assert.Check(t, n.IsNetworkAvailable(client, "di-subinterface"))
  102. // delete the network while preserving the parent link
  103. err = client.NetworkRemove(context.Background(), "di-subinterface")
  104. assert.NilError(t, err)
  105. assert.Check(t, n.IsNetworkNotAvailable(client, "di-subinterface"))
  106. // verify the network delete did not delete the predefined link
  107. n.LinkExists(t, "di-dummy0")
  108. }
  109. }
  110. func testIpvlanOverlapParent(client dclient.APIClient) func(*testing.T) {
  111. return func(t *testing.T) {
  112. // verify the same parent interface cannot be used if already in use by an existing network
  113. master := "di-dummy0"
  114. n.CreateMasterDummy(t, master)
  115. defer n.DeleteInterface(t, master)
  116. n.CreateVlanInterface(t, master, "di-dummy0.30", "30")
  117. _, err := client.NetworkCreate(context.Background(), "di-subinterface", types.NetworkCreate{
  118. Driver: "ipvlan",
  119. Options: map[string]string{
  120. "parent": "di-dummy0.30",
  121. },
  122. })
  123. assert.NilError(t, err)
  124. assert.Check(t, n.IsNetworkAvailable(client, "di-subinterface"))
  125. _, err = client.NetworkCreate(context.Background(), "di-subinterface", types.NetworkCreate{
  126. Driver: "ipvlan",
  127. Options: map[string]string{
  128. "parent": "di-dummy0.30",
  129. },
  130. })
  131. // verify that the overlap returns an error
  132. assert.Check(t, err != nil)
  133. }
  134. }
  135. func testIpvlanL2NilParent(client dclient.APIClient) func(*testing.T) {
  136. return func(t *testing.T) {
  137. // ipvlan l2 mode - dummy parent interface is provisioned dynamically
  138. _, err := client.NetworkCreate(context.Background(), "di-nil-parent", types.NetworkCreate{
  139. Driver: "ipvlan",
  140. })
  141. assert.NilError(t, err)
  142. assert.Check(t, n.IsNetworkAvailable(client, "di-nil-parent"))
  143. ctx := context.Background()
  144. id1 := container.Run(t, ctx, client, container.WithNetworkMode("di-nil-parent"))
  145. id2 := container.Run(t, ctx, client, container.WithNetworkMode("di-nil-parent"))
  146. _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", id1})
  147. assert.NilError(t, err)
  148. }
  149. }
  150. func testIpvlanL2InternalMode(client dclient.APIClient) func(*testing.T) {
  151. return func(t *testing.T) {
  152. _, err := client.NetworkCreate(context.Background(), "di-internal", types.NetworkCreate{
  153. Driver: "ipvlan",
  154. Internal: true,
  155. })
  156. assert.NilError(t, err)
  157. assert.Check(t, n.IsNetworkAvailable(client, "di-internal"))
  158. ctx := context.Background()
  159. id1 := container.Run(t, ctx, client, container.WithNetworkMode("di-internal"))
  160. id2 := container.Run(t, ctx, client, container.WithNetworkMode("di-internal"))
  161. timeoutCtx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
  162. defer cancel()
  163. _, err = container.Exec(timeoutCtx, client, id1, []string{"ping", "-c", "1", "-w", "1", "8.8.8.8"})
  164. // FIXME(vdemeester) check the time of error ?
  165. assert.Check(t, err != nil)
  166. assert.Check(t, timeoutCtx.Err() == context.DeadlineExceeded)
  167. _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", id1})
  168. assert.NilError(t, err)
  169. }
  170. }
  171. func testIpvlanL3NilParent(client dclient.APIClient) func(*testing.T) {
  172. return func(t *testing.T) {
  173. _, err := client.NetworkCreate(context.Background(), "di-nil-parent-l3", types.NetworkCreate{
  174. Driver: "ipvlan",
  175. Options: map[string]string{
  176. "ipvlan_mode": "l3",
  177. },
  178. IPAM: &network.IPAM{
  179. Config: []network.IPAMConfig{
  180. {
  181. Subnet: "172.28.230.0/24",
  182. AuxAddress: map[string]string{},
  183. },
  184. {
  185. Subnet: "172.28.220.0/24",
  186. AuxAddress: map[string]string{},
  187. },
  188. },
  189. },
  190. })
  191. assert.NilError(t, err)
  192. assert.Check(t, n.IsNetworkAvailable(client, "di-nil-parent-l3"))
  193. ctx := context.Background()
  194. id1 := container.Run(t, ctx, client,
  195. container.WithNetworkMode("di-nil-parent-l3"),
  196. container.WithIPv4("di-nil-parent-l3", "172.28.220.10"),
  197. )
  198. id2 := container.Run(t, ctx, client,
  199. container.WithNetworkMode("di-nil-parent-l3"),
  200. container.WithIPv4("di-nil-parent-l3", "172.28.230.10"),
  201. )
  202. _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", id1})
  203. assert.NilError(t, err)
  204. }
  205. }
  206. func testIpvlanL3InternalMode(client dclient.APIClient) func(*testing.T) {
  207. return func(t *testing.T) {
  208. _, err := client.NetworkCreate(context.Background(), "di-internal-l3", types.NetworkCreate{
  209. Driver: "ipvlan",
  210. Internal: true,
  211. Options: map[string]string{
  212. "ipvlan_mode": "l3",
  213. },
  214. IPAM: &network.IPAM{
  215. Config: []network.IPAMConfig{
  216. {
  217. Subnet: "172.28.230.0/24",
  218. AuxAddress: map[string]string{},
  219. },
  220. {
  221. Subnet: "172.28.220.0/24",
  222. AuxAddress: map[string]string{},
  223. },
  224. },
  225. },
  226. })
  227. assert.NilError(t, err)
  228. assert.Check(t, n.IsNetworkAvailable(client, "di-internal-l3"))
  229. ctx := context.Background()
  230. id1 := container.Run(t, ctx, client,
  231. container.WithNetworkMode("di-internal-l3"),
  232. container.WithIPv4("di-internal-l3", "172.28.220.10"),
  233. )
  234. id2 := container.Run(t, ctx, client,
  235. container.WithNetworkMode("di-internal-l3"),
  236. container.WithIPv4("di-internal-l3", "172.28.230.10"),
  237. )
  238. timeoutCtx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
  239. defer cancel()
  240. _, err = container.Exec(timeoutCtx, client, id1, []string{"ping", "-c", "1", "-w", "1", "8.8.8.8"})
  241. // FIXME(vdemeester) check the time of error ?
  242. assert.Check(t, err != nil)
  243. assert.Check(t, timeoutCtx.Err() == context.DeadlineExceeded)
  244. _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", id1})
  245. assert.NilError(t, err)
  246. }
  247. }
  248. func testIpvlanL2MultiSubnet(client dclient.APIClient) func(*testing.T) {
  249. return func(t *testing.T) {
  250. _, err := client.NetworkCreate(context.Background(), "dualstackl2", types.NetworkCreate{
  251. Driver: "ipvlan",
  252. EnableIPv6: true,
  253. IPAM: &network.IPAM{
  254. Config: []network.IPAMConfig{
  255. {
  256. Subnet: "172.28.200.0/24",
  257. AuxAddress: map[string]string{},
  258. },
  259. {
  260. Subnet: "172.28.202.0/24",
  261. Gateway: "172.28.202.254",
  262. AuxAddress: map[string]string{},
  263. },
  264. {
  265. Subnet: "2001:db8:abc8::/64",
  266. AuxAddress: map[string]string{},
  267. },
  268. {
  269. Subnet: "2001:db8:abc6::/64",
  270. Gateway: "2001:db8:abc6::254",
  271. AuxAddress: map[string]string{},
  272. },
  273. },
  274. },
  275. })
  276. assert.NilError(t, err)
  277. assert.Check(t, n.IsNetworkAvailable(client, "dualstackl2"))
  278. // start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.100.0/24 and 2001:db8:abc2::/64
  279. ctx := context.Background()
  280. id1 := container.Run(t, ctx, client,
  281. container.WithNetworkMode("dualstackl2"),
  282. container.WithIPv4("dualstackl2", "172.28.200.20"),
  283. container.WithIPv6("dualstackl2", "2001:db8:abc8::20"),
  284. )
  285. id2 := container.Run(t, ctx, client,
  286. container.WithNetworkMode("dualstackl2"),
  287. container.WithIPv4("dualstackl2", "172.28.200.21"),
  288. container.WithIPv6("dualstackl2", "2001:db8:abc8::21"),
  289. )
  290. c1, err := client.ContainerInspect(ctx, id1)
  291. assert.NilError(t, err)
  292. // verify ipv4 connectivity to the explicit --ipv address second to first
  293. _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks["dualstackl2"].IPAddress})
  294. assert.NilError(t, err)
  295. // verify ipv6 connectivity to the explicit --ipv6 address second to first
  296. _, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks["dualstackl2"].GlobalIPv6Address})
  297. assert.NilError(t, err)
  298. // start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.102.0/24 and 2001:db8:abc4::/64
  299. id3 := container.Run(t, ctx, client,
  300. container.WithNetworkMode("dualstackl2"),
  301. container.WithIPv4("dualstackl2", "172.28.202.20"),
  302. container.WithIPv6("dualstackl2", "2001:db8:abc6::20"),
  303. )
  304. id4 := container.Run(t, ctx, client,
  305. container.WithNetworkMode("dualstackl2"),
  306. container.WithIPv4("dualstackl2", "172.28.202.21"),
  307. container.WithIPv6("dualstackl2", "2001:db8:abc6::21"),
  308. )
  309. c3, err := client.ContainerInspect(ctx, id3)
  310. assert.NilError(t, err)
  311. // verify ipv4 connectivity to the explicit --ipv address from third to fourth
  312. _, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks["dualstackl2"].IPAddress})
  313. assert.NilError(t, err)
  314. // verify ipv6 connectivity to the explicit --ipv6 address from third to fourth
  315. _, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks["dualstackl2"].GlobalIPv6Address})
  316. assert.NilError(t, err)
  317. // Inspect the v4 gateway to ensure the proper default GW was assigned
  318. assert.Equal(t, c1.NetworkSettings.Networks["dualstackl2"].Gateway, "172.28.200.1")
  319. // Inspect the v6 gateway to ensure the proper default GW was assigned
  320. assert.Equal(t, c1.NetworkSettings.Networks["dualstackl2"].IPv6Gateway, "2001:db8:abc8::1")
  321. // Inspect the v4 gateway to ensure the proper explicitly assigned default GW was assigned
  322. assert.Equal(t, c3.NetworkSettings.Networks["dualstackl2"].Gateway, "172.28.202.254")
  323. // Inspect the v6 gateway to ensure the proper explicitly assigned default GW was assigned
  324. assert.Equal(t, c3.NetworkSettings.Networks["dualstackl2"].IPv6Gateway, "2001:db8:abc6::254")
  325. }
  326. }
  327. func testIpvlanL3MultiSubnet(client dclient.APIClient) func(*testing.T) {
  328. return func(t *testing.T) {
  329. _, err := client.NetworkCreate(context.Background(), "dualstackl3", types.NetworkCreate{
  330. Driver: "ipvlan",
  331. EnableIPv6: true,
  332. Options: map[string]string{
  333. "ipvlan_mode": "l3",
  334. },
  335. IPAM: &network.IPAM{
  336. Config: []network.IPAMConfig{
  337. {
  338. Subnet: "172.28.10.0/24",
  339. AuxAddress: map[string]string{},
  340. },
  341. {
  342. Subnet: "172.28.12.0/24",
  343. Gateway: "172.28.12.254",
  344. AuxAddress: map[string]string{},
  345. },
  346. {
  347. Subnet: "2001:db8:abc9::/64",
  348. AuxAddress: map[string]string{},
  349. },
  350. {
  351. Subnet: "2001:db8:abc7::/64",
  352. Gateway: "2001:db8:abc7::254",
  353. AuxAddress: map[string]string{},
  354. },
  355. },
  356. },
  357. })
  358. assert.NilError(t, err)
  359. assert.Check(t, n.IsNetworkAvailable(client, "dualstackl3"))
  360. // start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.100.0/24 and 2001:db8:abc2::/64
  361. ctx := context.Background()
  362. id1 := container.Run(t, ctx, client,
  363. container.WithNetworkMode("dualstackl3"),
  364. container.WithIPv4("dualstackl3", "172.28.10.20"),
  365. container.WithIPv6("dualstackl3", "2001:db8:abc9::20"),
  366. )
  367. id2 := container.Run(t, ctx, client,
  368. container.WithNetworkMode("dualstackl3"),
  369. container.WithIPv4("dualstackl3", "172.28.10.21"),
  370. container.WithIPv6("dualstackl3", "2001:db8:abc9::21"),
  371. )
  372. c1, err := client.ContainerInspect(ctx, id1)
  373. assert.NilError(t, err)
  374. // verify ipv4 connectivity to the explicit --ipv address second to first
  375. _, err = container.Exec(ctx, client, id2, []string{"ping", "-c", "1", c1.NetworkSettings.Networks["dualstackl3"].IPAddress})
  376. assert.NilError(t, err)
  377. // verify ipv6 connectivity to the explicit --ipv6 address second to first
  378. _, err = container.Exec(ctx, client, id2, []string{"ping6", "-c", "1", c1.NetworkSettings.Networks["dualstackl3"].GlobalIPv6Address})
  379. assert.NilError(t, err)
  380. // start dual stack containers and verify the user specified --ip and --ip6 addresses on subnets 172.28.102.0/24 and 2001:db8:abc4::/64
  381. id3 := container.Run(t, ctx, client,
  382. container.WithNetworkMode("dualstackl3"),
  383. container.WithIPv4("dualstackl3", "172.28.12.20"),
  384. container.WithIPv6("dualstackl3", "2001:db8:abc7::20"),
  385. )
  386. id4 := container.Run(t, ctx, client,
  387. container.WithNetworkMode("dualstackl3"),
  388. container.WithIPv4("dualstackl3", "172.28.12.21"),
  389. container.WithIPv6("dualstackl3", "2001:db8:abc7::21"),
  390. )
  391. c3, err := client.ContainerInspect(ctx, id3)
  392. assert.NilError(t, err)
  393. // verify ipv4 connectivity to the explicit --ipv address from third to fourth
  394. _, err = container.Exec(ctx, client, id4, []string{"ping", "-c", "1", c3.NetworkSettings.Networks["dualstackl3"].IPAddress})
  395. assert.NilError(t, err)
  396. // verify ipv6 connectivity to the explicit --ipv6 address from third to fourth
  397. _, err = container.Exec(ctx, client, id4, []string{"ping6", "-c", "1", c3.NetworkSettings.Networks["dualstackl3"].GlobalIPv6Address})
  398. assert.NilError(t, err)
  399. // Inspect the v4 gateway to ensure no next hop is assigned in L3 mode
  400. assert.Equal(t, c1.NetworkSettings.Networks["dualstackl3"].Gateway, "")
  401. // Inspect the v6 gateway to ensure the explicitly specified default GW is ignored per L3 mode enabled
  402. assert.Equal(t, c1.NetworkSettings.Networks["dualstackl3"].IPv6Gateway, "")
  403. // Inspect the v4 gateway to ensure no next hop is assigned in L3 mode
  404. assert.Equal(t, c3.NetworkSettings.Networks["dualstackl3"].Gateway, "")
  405. // Inspect the v6 gateway to ensure the explicitly specified default GW is ignored per L3 mode enabled
  406. assert.Equal(t, c3.NetworkSettings.Networks["dualstackl3"].IPv6Gateway, "")
  407. }
  408. }
  409. func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) {
  410. return func(t *testing.T) {
  411. // Verify ipvlan l2 mode sets the proper default gateway routes via netlink
  412. // for either an explicitly set route by the user or inferred via default IPAM
  413. _, err := client.NetworkCreate(context.Background(), "dualstackl2", types.NetworkCreate{
  414. Driver: "ipvlan",
  415. EnableIPv6: true,
  416. Options: map[string]string{
  417. "ipvlan_mode": "l2",
  418. },
  419. IPAM: &network.IPAM{
  420. Config: []network.IPAMConfig{
  421. {
  422. Subnet: "172.28.140.0/24",
  423. Gateway: "172.28.140.254",
  424. AuxAddress: map[string]string{},
  425. },
  426. {
  427. Subnet: "2001:db8:abcb::/64",
  428. AuxAddress: map[string]string{},
  429. },
  430. },
  431. },
  432. })
  433. assert.NilError(t, err)
  434. assert.Check(t, n.IsNetworkAvailable(client, "dualstackl2"))
  435. ctx := context.Background()
  436. id1 := container.Run(t, ctx, client,
  437. container.WithNetworkMode("dualstackl2"),
  438. )
  439. // Validate ipvlan l2 mode defaults gateway sets the default IPAM next-hop inferred from the subnet
  440. result, err := container.Exec(ctx, client, id1, []string{"ip", "route"})
  441. assert.NilError(t, err)
  442. assert.Check(t, strings.Contains(result.Combined(), "default via 172.28.140.254 dev eth0"))
  443. // Validate ipvlan l2 mode sets the v6 gateway to the user specified default gateway/next-hop
  444. result, err = container.Exec(ctx, client, id1, []string{"ip", "-6", "route"})
  445. assert.NilError(t, err)
  446. assert.Check(t, strings.Contains(result.Combined(), "default via 2001:db8:abcb::1 dev eth0"))
  447. // Validate ipvlan l3 mode sets the v4 gateway to dev eth0 and disregards any explicit or inferred next-hops
  448. _, err = client.NetworkCreate(context.Background(), "dualstackl3", types.NetworkCreate{
  449. Driver: "ipvlan",
  450. EnableIPv6: true,
  451. Options: map[string]string{
  452. "ipvlan_mode": "l3",
  453. },
  454. IPAM: &network.IPAM{
  455. Config: []network.IPAMConfig{
  456. {
  457. Subnet: "172.28.160.0/24",
  458. Gateway: "172.28.160.254",
  459. AuxAddress: map[string]string{},
  460. },
  461. {
  462. Subnet: "2001:db8:abcd::/64",
  463. Gateway: "2001:db8:abcd::254",
  464. AuxAddress: map[string]string{},
  465. },
  466. },
  467. },
  468. })
  469. assert.NilError(t, err)
  470. assert.Check(t, n.IsNetworkAvailable(client, "dualstackl3"))
  471. id2 := container.Run(t, ctx, client,
  472. container.WithNetworkMode("dualstackl3"),
  473. )
  474. // Validate ipvlan l3 mode sets the v4 gateway to dev eth0 and disregards any explicit or inferred next-hops
  475. result, err = container.Exec(ctx, client, id2, []string{"ip", "route"})
  476. assert.NilError(t, err)
  477. assert.Check(t, strings.Contains(result.Combined(), "default dev eth0"))
  478. // Validate ipvlan l3 mode sets the v6 gateway to dev eth0 and disregards any explicit or inferred next-hops
  479. result, err = container.Exec(ctx, client, id2, []string{"ip", "-6", "route"})
  480. assert.NilError(t, err)
  481. assert.Check(t, strings.Contains(result.Combined(), "default dev eth0"))
  482. }
  483. }
  484. // ensure Kernel version is >= v4.2 for ipvlan support
  485. func ipvlanKernelSupport() bool {
  486. return n.CheckKernelMajorVersionGreaterOrEqualThen(4, 2)
  487. }