[pve-devel] applied: [PATCH v3 container 2/4] lxc: Avoid open-coding normal vs SDN-specific tap_plug()

Christoph Heiss c.heiss at proxmox.com
Wed Feb 22 10:34:24 CET 2023


Thanks!

On Tue, Feb 21, 2023 at 06:07:20PM +0100, Thomas Lamprecht wrote:
> Am 21/02/2023 um 09:05 schrieb Christoph Heiss:
> > [..]
> >
>
> 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.
I agree, it indeed is not all that sane. Plus it really clutters up all
the callsites.

>
> 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?
Sounds like a very reasonable idea, especially being able to
de-duplicate the whole link_down logic later on. I didn't even notice
that I was basically introducing the same pattern again that I cleaned
up ..

I'll rework this a send a re-spin of patch 3/4 soon.





More information about the pve-devel mailing list