Skip to content

Commit

Permalink
F #59: Add QinQ network handler
Browse files Browse the repository at this point in the history
  • Loading branch information
brodriguez-opennebula committed Mar 18, 2024
1 parent afd24d9 commit 1f31ee7
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,6 @@ iface vlan${vlan} inet static
vlan-raw-device ${dev}
EOT

address 192.168.1.1
netmask 255.255.255.0

if [[ -n $ip4 ]]; then
$address=${ip4%%/*}
$netmask=${ip4##*/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,30 @@ nm_symlink_run_connections()
done
}

gen_qinq_ip4_conf()
{
# Address must have the netmask in CIDR format. Example:
# QINQ_IP4_IFACES="eth1,120,10.120.1.5/24,10.120.1.1;eth1,130,10.130.1.5/24,10.130.1.1"
for qinq_ip4_info in $(echo $QINQ_IP4_IFACES | tr ";" "\n"); do
IFS=, read -r dev vlan ip4 gw4 <<< $qinq_ip4_info;
cat <<EOT
vlan.${vlan}:
id: ${vlan}
link: ${dev}
EOT
if [[ -n $ip4 ]]; then
cat <<EOT
addresses: [ ${ip4} ]
EOT
if [[ -n $gw4 ]]; then
cat << EOT
gateway: ${gw4}
EOT
fi
fi
done
}

init_netplan_renderer()
{
if [ -z "${NETCFG_NETPLAN_RENDERER}" ] ; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,35 @@ EOT
echo ""
}

gen_qinq_ip4_conf()
{
# Address must have the netmask in CIDR format. Example:
# QINQ_IP4_IFACES="eth1,120,10.120.1.5/24,10.120.1.1;eth1,130,10.130.1.5/24,10.130.1.1"
for qinq_ip4_info in $(echo $QINQ_IP4_IFACES | tr ";" "\n"); do
IFS=, read -r dev vlan ip4 gw4 <<< $qinq_ip4_info;
cat <<EOT
[Match]
Name=VLAN${vlan}
Type=vlan
[Network]
Description=Interface for VLAN ${VLAN}
EOT
if [[ -n $ip4 ]]; then
cat <<EOT
[Address]
Address=${ip4}
EOT
if [[ -n $gw4 ]]; then
cat << EOT
Gateway={$gw4}
EOT
fi
fi
done
}


# arg: <interface>
is_networkd_iface_managed()
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,37 @@ gen_alias6_conf()
fi
}

gen_qinq_ip4_conf()
{
# Address must have the netmask in CIDR format. Example:
# QINQ_IP4_IFACES="eth1,120,10.120.1.5/24,10.120.1.1;eth1,130,10.130.1.5/24,10.130.1.1"
for qinq_ip4_info in $(echo $QINQ_IP4_IFACES | tr ";" "\n"); do
IFS=, read -r dev vlan ip4 gw4 <<< $qinq_ip4_info;

cat <<EOT > "/etc/sysconfig/network/ifcfg-${dev}.${vlan}"
VLAN=yes
DEVICE=${dev}.${vlan}
EOT


if [[ -n $ip4 ]]; then
$address=${ip4%%/*}
$netmask=${ip4##*/}
cat <<EOT
IPADDR=${address}
NETMASK=${netmask}
EOT
if [[ -n $gw4 ]]; then
cat << EOT
GATEWAY=${gw4};
EOT
fi
fi
done
}



gen_network_configuration()
{
if is_net_rhel; then
Expand Down

0 comments on commit 1f31ee7

Please sign in to comment.