[pve-devel] [PATCH common] support for udev-systemd-style physical interface names (like enp3s0)

Wolfgang Bumiller w.bumiller at proxmox.com
Wed May 11 10:57:37 CEST 2016


On Mon, May 09, 2016 at 06:23:22PM +0300, Igor Vlasenko wrote:
> I am trying to port PVE to run under ALT Linux (rpm based platform)
> that runs udev+systemd. It has another name convention for
> network interface names: instead of eth0, eth1...
> they are called enp3s0, enp3s6, ...

That's not the only names you can have. Really the best thing would be
to not go by name at all. systemd's persistent names can be more than
just 'enpXsY'.
<https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-net_id.c#L29>
(The comment in this code isn't complete apparently, as I've seen usb
ethernet devices have their name prefixed with 'usb' instead of 'en'.)

> The patch enables PVE to run properly on any system with
> systemd-style network interface names.
> 
> 
> Signed-off-by: Igor Vlasenko <viy at altlinux.org>
> ---
>  src/PVE/INotify.pm | 8 ++++----
>  src/PVE/Network.pm | 6 +++---
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
> index 74a0fe1..06c5aa5 100644
> --- a/src/PVE/INotify.pm
> +++ b/src/PVE/INotify.pm
> @@ -800,7 +800,7 @@ sub __read_etc_network_interfaces {
> 
>      if ($proc_net_dev) {
>      while (defined ($line = <$proc_net_dev>)) {
> -        if ($line =~ m/^\s*(eth\d+):.*/) {
> +        if ($line =~ m/^\s*(eth\d+|enp\d+s\d+):.*/) {
>          $ifaces->{$1}->{exists} = 1;
>          }
>      }
> @@ -973,7 +973,7 @@ sub __read_etc_network_interfaces {
>          $ifaces->{$1}->{exists} = 0;
>          $d->{exists} = 0;
>          }
> -    } elsif ($iface =~ m/^eth\d+$/) {
> +    } elsif ($iface =~ m/^(?:eth\d+|enp\d+s\d+)$/) {
>          if (!$d->{ovs_type}) {
>          $d->{type} = 'eth';
>          } elsif ($d->{ovs_type} eq 'OVSPort') {
> @@ -1200,7 +1200,7 @@ sub __write_etc_network_interfaces {
>          $d->{type} eq 'OVSBond') {
>          my $brname = $used_ports->{$iface};
>          if (!$brname || !$ifaces->{$brname}) {
> -        if ($iface =~ /^eth/) {
> +        if ($iface =~ /^(?:eth|enp)/) {
>              $ifaces->{$iface} = { type => 'eth',
>                        exists => 1,
>                        method => 'manual',
> @@ -1289,7 +1289,7 @@ NETWORKDOC
>      my $pri;
>      if ($iface eq 'lo') {
>          $pri = $if_type_hash->{loopback};
> -    } elsif ($iface =~ m/^eth\d+$/) {
> +    } elsif ($iface =~ m/^(?:eth\d+|enp\d+s\d+)$/) {
>          $pri = $if_type_hash->{eth} + $child;
>      } elsif ($iface =~ m/^bond\d+$/) {
>          $pri = $if_type_hash->{bond} + $child;
> diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
> index bda2067..81c2e77 100644
> --- a/src/PVE/Network.pm
> +++ b/src/PVE/Network.pm
> @@ -131,10 +131,10 @@ my $parse_tap_device_name = sub {
> 
>      my ($vmid, $devid);
> 
> -    if ($iface =~ m/^tap(\d+)i(\d+)$/) {
> +    if ($iface =~ m/^tap(\d+)i(\d+(?:s\d+)?)$/) {
>      $vmid = $1;
>      $devid = $2;
> -    } elsif ($iface =~ m/^veth(\d+)i(\d+)$/) {
> +    } elsif ($iface =~ m/^veth(\d+)i(\d+(?:s\d+)?)$/) {
>      $vmid = $1;
>      $devid = $2;
>      } else {
> @@ -439,7 +439,7 @@ sub activate_bridge_vlan {
> 
>      my @ifaces = ();
>      my $dir = "/sys/class/net/$bridge/brif";
> -    PVE::Tools::dir_glob_foreach($dir, '((eth|bond)\d+(\.\d+)?)', sub {
> +    PVE::Tools::dir_glob_foreach($dir,
> '((eth\d+|enp\d+s\d+|bond\d+)(\.\d+)?)', sub {
>          push @ifaces, $_[0];
>      });
> 
> -- 
> 2.6.5
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 




More information about the pve-devel mailing list