public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Christoph Heiss <c.heiss@proxmox.com>
Subject: [pve-devel] applied: [PATCH v3 container 2/4] lxc: Avoid open-coding normal vs SDN-specific tap_plug()
Date: Tue, 21 Feb 2023 18:07:20 +0100	[thread overview]
Message-ID: <57862005-fc5b-e180-c228-165289067254@proxmox.com> (raw)
In-Reply-To: <20230221080550.43336-3-c.heiss@proxmox.com>

Am 21/02/2023 um 09:05 schrieb Christoph Heiss:
> This pattern is used in multiple places, thus just extract it into a sub
> on its own.
> 
> No functional changes.
> 
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
> Might not be the best place for net_tap_plug(), putting this logic
> inside PVE::Network would probably make more sense. But that would
> entail a (bigger) refactoring, since it then also must be done for all
> other tap_*() and veth_*() subroutines (and maybe some other things?)
> for consistency..
> In any case, that definitely would be too much for this series. I can do
> that, but I'd do it as a follow-up series.
> 
> Changes v1 -> v2:
>  * New patch
> 
> Changes v2 -> v3:
>  * Add prototype to net_tap_plug()
> 
>  src/PVE/LXC.pm  | 28 ++++++++++++++++------------
>  src/lxcnetaddbr | 15 ++-------------
>  2 files changed, 18 insertions(+), 25 deletions(-)
> 

applied, thanks! But I got some feedback/question inline affecting patch 3/4

> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index cbbb82d..d419124 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -918,6 +918,18 @@ sub vm_stop_cleanup {
>      warn $@ if $@; # avoid errors - just warn
>  }
> 
> +sub net_tap_plug : prototype($$$$$$;$) {
> +    my ($iface, $bridge, $tag, $firewall, $trunks, $rate, $opts) = @_;

IMO having more than ~5 parameter is most of the time a code smell, and sure while we
ain't in rust where we can ensure some sane API and existence of struct/trait members
or methods it's not really that better to expand everything, as scalar on it's own is
way to broad anyway to guarantee anything relevant on calling.

So, maybe we could change this to take

sub net_tap_plug : prototype($$;$) {
    my ($iface, $net, $old_net) = @_;

as then we might even pull in the whole link_down logic separation in here and avoid
duplicating that then again (after just cleaning something similar like that up here).

What do you think?




  reply	other threads:[~2023-02-21 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21  8:05 [pve-devel] [PATCH v3 container/manager 0/4] fix #3413: Add `Disconnect` option for LXC networks Christoph Heiss
2023-02-21  8:05 ` [pve-devel] [PATCH v3 container 1/4] lxc: Fix some trailing whitespace Christoph Heiss
2023-02-21 16:59   ` [pve-devel] applied: " Thomas Lamprecht
2023-02-21  8:05 ` [pve-devel] [PATCH v3 container 2/4] lxc: Avoid open-coding normal vs SDN-specific tap_plug() Christoph Heiss
2023-02-21 17:07   ` Thomas Lamprecht [this message]
2023-02-22  9:34     ` [pve-devel] applied: " Christoph Heiss
2023-02-21  8:05 ` [pve-devel] [PATCH v3 container 3/4] lxc: Add `link_down` config to allow setting interfaces as disconnected Christoph Heiss
2023-02-21 17:25   ` Thomas Lamprecht
2023-02-22  9:51     ` Christoph Heiss
2023-02-21  8:05 ` [pve-devel] [PATCH v3 manager 4/4] lxc: Add `Disconnect` option for network interfaces Christoph Heiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57862005-fc5b-e180-c228-165289067254@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal