|
5 | 5 | package network_test
|
6 | 6 |
|
7 | 7 | import (
|
| 8 | + "fmt" |
8 | 9 | "net"
|
9 | 10 | "net/netip"
|
10 | 11 | "sort"
|
@@ -432,6 +433,58 @@ func (suite *CmdlineSuite) TestParse() {
|
432 | 433 | },
|
433 | 434 | },
|
434 | 435 | },
|
| 436 | + { |
| 437 | + name: "vlan configuration with alternative link name vlan0008", |
| 438 | + cmdline: "vlan=vlan0008:eth1", |
| 439 | + expectedSettings: network.CmdlineNetworking{ |
| 440 | + NetworkLinkSpecs: []netconfig.LinkSpecSpec{ |
| 441 | + { |
| 442 | + Name: "eth1.8", |
| 443 | + Logical: true, |
| 444 | + Up: true, |
| 445 | + Kind: netconfig.LinkKindVLAN, |
| 446 | + Type: nethelpers.LinkEther, |
| 447 | + ParentName: "eth1", |
| 448 | + ConfigLayer: netconfig.ConfigCmdline, |
| 449 | + VLAN: netconfig.VLANSpec{ |
| 450 | + VID: 8, |
| 451 | + Protocol: nethelpers.VLANProtocol8021Q, |
| 452 | + }, |
| 453 | + }, |
| 454 | + }, |
| 455 | + }, |
| 456 | + }, |
| 457 | + { |
| 458 | + name: "vlan configuration with alternative link name vlan1", |
| 459 | + cmdline: "vlan=vlan4095:eth1", |
| 460 | + expectedSettings: network.CmdlineNetworking{ |
| 461 | + NetworkLinkSpecs: []netconfig.LinkSpecSpec{ |
| 462 | + { |
| 463 | + Name: "eth1.4095", |
| 464 | + Logical: true, |
| 465 | + Up: true, |
| 466 | + Kind: netconfig.LinkKindVLAN, |
| 467 | + Type: nethelpers.LinkEther, |
| 468 | + ParentName: "eth1", |
| 469 | + ConfigLayer: netconfig.ConfigCmdline, |
| 470 | + VLAN: netconfig.VLANSpec{ |
| 471 | + VID: 4095, |
| 472 | + Protocol: nethelpers.VLANProtocol8021Q, |
| 473 | + }, |
| 474 | + }, |
| 475 | + }, |
| 476 | + }, |
| 477 | + }, |
| 478 | + { |
| 479 | + name: "vlan configuration with invalid vlan ID 4096", |
| 480 | + cmdline: "vlan=eth1.4096:eth1", |
| 481 | + expectedError: fmt.Sprintf("invalid vlanID=%d, must be in the range 1..4095: %s", 4096, "eth1.4096:eth1"), |
| 482 | + }, |
| 483 | + { |
| 484 | + name: "vlan configuration with invalid vlan ID 0", |
| 485 | + cmdline: "vlan=eth1.0:eth1", |
| 486 | + expectedError: fmt.Sprintf("invalid vlanID=%d, must be in the range 1..4095: %s", 0, "eth1.0:eth1"), |
| 487 | + }, |
435 | 488 | {
|
436 | 489 | name: "multiple ip configurations",
|
437 | 490 | cmdline: "ip=172.20.0.2::172.20.0.1:255.255.255.0::eth1::::: ip=eth3:dhcp ip=:::::eth4:dhcp::::",
|
|
0 commit comments