+ &$check_mtu($ifaces, $iface, $p);
+ }
+ }
+ }
+
+ # check bond
+ foreach my $iface (keys %$ifaces) {
+ my $d = $ifaces->{$iface};
+ if ($d->{type} eq 'bond' && $d->{slaves}) {
+ foreach my $p (split (/\s+/, $d->{slaves})) {
+ my $n = $ifaces->{$p};
+
+ die "bond '$iface' - unable to find slave '$p'\n"
+ if !$n;
+ die "bond '$iface' - wrong interface type on slave '$p' " .
+ "('$n->{type}' != 'eth')\n" if $n->{type} ne 'eth';
+ &$check_mtu($ifaces, $iface, $p);
+ }
+ }
+ }
+
+ # check vxlan
+ my $vxlans = {};
+ foreach my $iface (keys %$ifaces) {
+ my $d = $ifaces->{$iface};
+
+ if ($d->{type} eq 'vxlan' && $d->{'vxlan-id'}) {
+ my $vxlanid = $d->{'vxlan-id'};
+ die "iface $iface - duplicate vxlan-id $vxlanid already used in $vxlans->{$vxlanid}\n" if $vxlans->{$vxlanid};
+ $vxlans->{$vxlanid} = $iface;
+ }
+
+ my $ips = 0;
+ ++$ips if defined $d->{'vxlan-svcnodeip'};
+ ++$ips if defined $d->{'vxlan-remoteip'};
+ ++$ips if defined $d->{'vxlan-local-tunnelip'};
+ if ($ips > 1) {
+ die "iface $iface - vxlan-svcnodeip, vxlan-remoteip and vxlan-localtunnelip are mutually exclusive\n";
+ }
+
+ if (defined($d->{'vxlan-svcnodeip'}) != defined($d->{'vxlan-physdev'})) {
+ die "iface $iface - vxlan-svcnodeip and vxlan-physdev must be define together\n";
+ }
+ #fixme : check if vxlan mtu is lower than 50bytes than physical interface where tunnel is going out
+ }
+
+ # check vlan
+ foreach my $iface (keys %$ifaces) {
+ my $d = $ifaces->{$iface};
+ if ($d->{type} eq 'vlan' && $iface =~ m/^(\S+)\.\d+$/) {
+ my $p = $1;
+ my $n = $ifaces->{$p};
+
+ die "vlan '$iface' - unable to find parent '$p'\n"
+ if !$n;
+
+ if ($n->{type} eq 'bridge' && !$n->{bridge_vlan_aware}) {
+ die "vlan '$iface' - bridge vlan aware is not enabled on parent '$p'\n";
+ } elsif ($n->{type} ne 'eth' && $n->{type} ne 'bridge' && $n->{type} ne 'bond' && $n->{type} ne 'vlan') {
+ die "vlan '$iface' - wrong interface type on parent '$p' " .
+ "('$n->{type}' != 'eth|bond|bridge|vlan' )\n";
+ }
+
+ &$check_mtu($ifaces, $p, $iface);
+
+ }
+ }
+
+ # check bridgeport option
+ my $bridgeports = {};
+ my $bridges = {};
+ foreach my $iface (keys %$ifaces) {
+ my $d = $ifaces->{$iface};
+ if ($d->{type} eq 'bridge') {
+ foreach my $p (split (/\s+/, $d->{bridge_ports})) {
+ $p =~ s/\.\d+$//;
+ my $n = $ifaces->{$p};
+ die "bridge '$iface' - unable to find bridge port '$p'\n"
+ if !$n;
+ &$check_mtu($ifaces, $iface, $p);
+ $bridgeports->{$p} = $iface;