Commit 73830a0
committed
improvement(network-legacy): change
systemd-network-generator tries to support the same IP configuration
syntax as Dracut. One difference is that Dracut supports multiple
comma-separated autoconf values (e.g. `dhcp,dhcp6`) whereas systemd only
permits one. Fixing this in systemd may not be straightforward.
This matters because Afterburn can emit `dhcp,dhcp6` for KubeVirt, and
it is now being adapted to support systemd-network-generator as well as
Dracut's network-legacy module.
Even if systemd-network-generator did support multiple values, the
behaviour would not be the same. Both systemd-networkd and
NetworkManager always try both IPv4 and IPv6, normally requiring just
one of them to work, whereas network-legacy will not even try IPv6 if
IPv4 works, or vice-versa depending on the order given. It is not
currently possible to make network-legacy always try both.
To workaround the lack of multi-value support in systemd and to mirror
how systemd and NetworkManager behave, I am changing `ip=any` to always
try both protocols, requiring just one to work. They are tried in
parallel to avoid the cost of a double timeout. Despite the name, this
is currently treated by network-legacy as IPv4-only. The history of
ifup.sh reveals that `any` was supported before IPv6 was, and that IPv6
was initially added with "preliminary" support. Perhaps the author
didn't want to change the behaviour of `any` until that support was
better established and then forgot, or perhaps it was merely an
oversight.
systemd-network-generator also treats `ip=on` as dual stack, but that
would be a more controversial change. Users may not expect IPv6 alone to
be considered successful. NetworkManager even treats `ip=dhcp` as dual
stack, but I feel that is wrong. With `ip=any`, the intent is clearer,
and this at least gives us one option where the behaviour is consistent.
Much of this change is adjusting the dhclient PID and lease paths to be
protocol-specific so that IPv4 and IPv6 instances can be run
simultaneously.
There were no tests for explicit IP configuration at all, but I felt it
was important to have this covered, so some have been added. To avoid
unnecessary overhead, this spins up just one VM with several differently
configured interfaces.
The module changes were mostly written by me with a little help from AI.
The tests were entirely written by AI.
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>ip=any to mean dual stack DHCP1 parent a83d800 commit 73830a0
14 files changed
Lines changed: 480 additions & 74 deletions
File tree
- .github/workflows
- man
- modules.d
- 35network-legacy
- 45net-lib
- test
- TEST-51-NETWORK-LEGACY
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
610 | | - | |
611 | | - | |
612 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
613 | 616 | | |
614 | 617 | | |
615 | 618 | | |
| |||
625 | 628 | | |
626 | 629 | | |
627 | 630 | | |
628 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
629 | 635 | | |
630 | 636 | | |
631 | 637 | | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | 638 | | |
636 | 639 | | |
637 | 640 | | |
638 | 641 | | |
639 | 642 | | |
640 | | - | |
| 643 | + | |
641 | 644 | | |
642 | 645 | | |
643 | 646 | | |
644 | 647 | | |
645 | 648 | | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | 649 | | |
653 | | - | |
| 650 | + | |
654 | 651 | | |
655 | 652 | | |
656 | 653 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
240 | 252 | | |
241 | 253 | | |
242 | 254 | | |
243 | | - | |
| 255 | + | |
244 | 256 | | |
245 | 257 | | |
246 | 258 | | |
247 | 259 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | 260 | | |
255 | 261 | | |
256 | 262 | | |
| |||
282 | 288 | | |
283 | 289 | | |
284 | 290 | | |
285 | | - | |
| 291 | + | |
286 | 292 | | |
287 | 293 | | |
288 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
33 | | - | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | | - | |
| 63 | + | |
62 | 64 | | |
63 | | - | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
115 | | - | |
| 115 | + | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
0 commit comments