* [pve-devel] [PATCH v2 common] fix #3153: INotify: adding comment of interface to inet6 section when this is the only section
@ 2021-06-25 12:29 Lorenz Stechauner
2021-06-28 13:03 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Lorenz Stechauner @ 2021-06-25 12:29 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
---
changes to v1:
* using delete instead of undef
* added length check for families
src/PVE/INotify.pm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 562a243..8cf4b44 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -1156,6 +1156,10 @@ sub __read_etc_network_interfaces {
$d->{method} = 'manual' if !$d->{method};
$d->{method6} = 'manual' if !$d->{method6};
+ if (my $comments6 = delete $d->{comments6}) {
+ $d->{comments} = ($d->{comments} // '') . $comments6;
+ }
+
$d->{families} ||= ['inet'];
}
@@ -1242,7 +1246,7 @@ sub __interface_to_string {
my $done = { type => 1, priority => 1, method => 1, active => 1, exists => 1,
comments => 1, autostart => 1, options => 1,
address => 1, netmask => 1, gateway => 1, broadcast => 1,
- method6 => 1, families => 1, options6 => 1,
+ method6 => 1, families => 1, options6 => 1, comments6 => 1,
address6 => 1, netmask6 => 1, gateway6 => 1, broadcast6 => 1, 'uplink-id' => 1 };
if (!$first_block) {
@@ -1733,6 +1737,11 @@ NETWORKDOC
}
}
+ # if 'inet6' is the only family
+ if (scalar($d->{families}->@*) == 1 && $d->{families}[0] eq 'inet6') {
+ $d->{comments6} = delete $d->{comments};
+ }
+
my $i = 0; # some options should be printed only once
$raw .= __interface_to_string($iface, $d, $_, !$i++, $ifupdown2) foreach @{$d->{families}};
}
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH v2 common] fix #3153: INotify: adding comment of interface to inet6 section when this is the only section
2021-06-25 12:29 [pve-devel] [PATCH v2 common] fix #3153: INotify: adding comment of interface to inet6 section when this is the only section Lorenz Stechauner
@ 2021-06-28 13:03 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-06-28 13:03 UTC (permalink / raw)
To: Proxmox VE development discussion, Lorenz Stechauner
On 25.06.21 14:29, Lorenz Stechauner wrote:
> Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
> ---
> changes to v1:
> * using delete instead of undef
> * added length check for families
>
You were right regarding the "inet6" only logic, but it should not hurt to make it
more specific either and having more limited assumptions (i.e., that the serializer
has the invariant of merging those comment properties) is often more robust, so I'd
have slightly preferred this variant, but just for the record as you went for the
"right" one anyway.
> src/PVE/INotify.pm | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-28 13:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25 12:29 [pve-devel] [PATCH v2 common] fix #3153: INotify: adding comment of interface to inet6 section when this is the only section Lorenz Stechauner
2021-06-28 13:03 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox