Skip to content

Commit

Permalink
chore: Remove ipv6_subnet parameter remnants
Browse files Browse the repository at this point in the history
  • Loading branch information
garym-dfinity committed Jan 24, 2024
1 parent 4344a92 commit 84e4f37
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 54 deletions.
1 change: 0 additions & 1 deletion ic-os/docs/ConfigStore-SetupOSHostOS.adoc
Expand Up @@ -23,7 +23,6 @@ The `config.ini` file contains all network-related settings, which must be provi
The configuration file expects the following key-value pairs in lower-case format. For example:

ipv6_prefix=2a00:fb01:400:100
ipv6_subnet=/64
ipv6_gateway=2a00:fb01:400:100::1

[NOTE]
Expand Down
1 change: 0 additions & 1 deletion ic-os/hostos/rootfs/opt/ic/bin/generate-guestos-config.sh
Expand Up @@ -89,7 +89,6 @@ function read_variables() {
while IFS="=" read -r key value; do
case "$key" in
"ipv6_prefix") ipv6_prefix="${value}" ;;
"ipv6_subnet") ipv6_subnet="${value}" ;;
"ipv6_gateway") ipv6_gateway="${value}" ;;
"ipv4_address") ipv4_address="${value}" ;;
"ipv4_prefix_length") ipv4_prefix_length="${value}" ;;
Expand Down
1 change: 0 additions & 1 deletion ic-os/hostos/rootfs/opt/ic/bin/setup-hostname.sh
Expand Up @@ -76,7 +76,6 @@ function read_variables() {
while IFS="=" read -r key value; do
case "$key" in
"ipv6_prefix") ipv6_prefix="${value}" ;;
"ipv6_subnet") ipv6_subnet="${value}" ;;
"ipv6_gateway") ipv6_gateway="${value}" ;;
"ipv6_address") ipv6_address="${value}" ;;
"hostname") hostname="${value}" ;;
Expand Down
12 changes: 3 additions & 9 deletions ic-os/scripts/calculate-deterministic-ipv6.sh
Expand Up @@ -25,10 +25,9 @@ Arguments:
-i=, --index= required: specify the single digit node index (Examples: host: 0, guest: 1, boundary: 2)
-m=, --mac= required: specify the management MAC address (Examples: b0:7b:25:c8:f6:90)
--prefix= required: specify the IPv6 prefix (Examples: 2a02:41b:300e:0)
-s=, --subnet= required: specify the IPv6 subnet (Examples: /64)
Example:
./calculate-deterministic-ipv6.sh --deployment=mainnet --index=1 --mac=b0:7b:25:c8:f6:90 --prefix=2a02:41b:300e:0 --subnet=/64
./calculate-deterministic-ipv6.sh --deployment=mainnet --index=1 --mac=b0:7b:25:c8:f6:90 --prefix=2a02:41b:300e:0
'
exit 1
;;
Expand All @@ -44,10 +43,6 @@ Example:
PREFIX="${argument#*=}"
shift
;;
-s=* | --subnet=*)
SUBNET="${argument#*=}"
shift
;;
*)
echo "Error: Argument is not supported."
exit 1
Expand All @@ -56,7 +51,7 @@ Example:
done

function validate_arguments() {
if [ "${DEPLOYMENT}" == "" -o "${INDEX}" == "" -o "${MAC}" == "" -o "${PREFIX}" == "" -o "${SUBNET}" == "" ]; then
if [ "${DEPLOYMENT}" == "" -o "${INDEX}" == "" -o "${MAC}" == "" -o "${PREFIX}" == "" ]; then
$0 --help
fi
}
Expand All @@ -82,14 +77,13 @@ function print_deterministic_mac() {

function calculate_deterministic_ipv6() {
local ipv6_prefix=${PREFIX}
local ipv6_subnet=${SUBNET}
local output=$(echo "${DETERMINISTIC_MAC}" | sed 's/[.:-]//g' | tr '[:upper:]' '[:lower:]')
local output="${output:0:6}fffe${output:6}"
local output=$(printf "%02x%s" "$((0x${output:0:2} ^ 2))" "${output:2}")
local output=$(echo "${output}" | sed 's/.\{4\}/&:/g;s/:$//')
IPV6_RAW=$(echo "${ipv6_prefix}:${output}")
IPV6_COMPRESSED=$(echo ${IPV6_RAW} | python3 -c 'import ipaddress, sys; print(ipaddress.ip_address(sys.stdin.read().strip()))')
DETERMINISTIC_IPV6=$(echo ${IPV6_COMPRESSED}${ipv6_subnet})
DETERMINISTIC_IPV6=$(echo ${IPV6_COMPRESSED}/64)
}

function print_deterministic_ipv6() {
Expand Down
1 change: 1 addition & 0 deletions ic-os/setupos/config/config.ini
@@ -1,5 +1,6 @@
# Please update the template/example below.
#
ipv6_prefix=2a00:fb01:400:200
# `ipv6_subnet` deprecated - will be removed in a future version. Has no effect now.
ipv6_subnet=/64
ipv6_gateway=2a00:fb01:400:200::1
6 changes: 0 additions & 6 deletions ic-os/setupos/rootfs/opt/ic/bin/config.sh
Expand Up @@ -15,7 +15,6 @@ SSH_AUTHORIZED_KEYS_CLONE="${CONFIG_TMP}/ssh_authorized_keys"

# Define empty variables so they are not unset
ipv6_prefix=""
ipv6_subnet=""
ipv6_gateway=""

function print_config_file() {
Expand Down Expand Up @@ -90,7 +89,6 @@ function read_variables() {
while IFS="=" read -r key value; do
case "$key" in
"ipv6_prefix") ipv6_prefix="${value}" ;;
"ipv6_subnet") ipv6_subnet="${value}" ;;
"ipv6_gateway") ipv6_gateway="${value}" ;;
esac
done <"${CONFIG_INI_CLONE}"
Expand All @@ -101,10 +99,6 @@ function verify_variables() {
log_and_reboot_on_error "1" "Variable 'ipv6_prefix' is not defined in 'config.ini'."
fi

if [ -z "${ipv6_subnet}" ]; then
log_and_reboot_on_error "1" "Variable 'ipv6_subnet' is not defined in 'config.ini'."
fi

if [ -z "${ipv6_gateway}" ]; then
log_and_reboot_on_error "1" "Variable 'ipv6_gateway' is not defined in 'config.ini'."
fi
Expand Down
2 changes: 0 additions & 2 deletions ic-os/setupos/rootfs/opt/ic/bin/network.sh
Expand Up @@ -15,7 +15,6 @@ function read_variables() {
while IFS="=" read -r key value; do
case "$key" in
"ipv6_prefix") ipv6_prefix="${value}" ;;
"ipv6_subnet") ipv6_subnet="${value}" ;;
"ipv6_gateway") ipv6_gateway="${value}" ;;
"ipv4_address") ipv4_address="${value}" ;;
"ipv4_prefix_length") ipv4_prefix_length="${value}" ;;
Expand Down Expand Up @@ -123,7 +122,6 @@ function get_network_settings() {
function print_network_settings() {
echo "* Printing user defined network settings..."
echo " IPv6 Prefix : ${ipv6_prefix}"
echo " IPv6 Subnet : ${ipv6_subnet}"
echo " IPv6 Gateway: ${ipv6_gateway}"
if [[ -n ${ipv4_address} && -n ${ipv4_prefix_length} && -n ${ipv4_gateway} && -n ${domain} ]]; then
echo " IPv4 Address: ${ipv4_address}"
Expand Down
21 changes: 6 additions & 15 deletions rs/ic_os/network/src/info.rs
Expand Up @@ -95,7 +95,6 @@ pub mod tests {
// Example config.ini
let config_map = HashMap::from([
("ipv6_prefix".to_string(), "2a00:fb01:400:100".to_string()),
("ipv6_subnet".to_string(), "\\64".to_string()),
(
"ipv6_gateway".to_string(),
"2a00:fb01:400:100::1".to_string(),
Expand All @@ -106,7 +105,6 @@ pub mod tests {
// With ipv6_address and ipv6_prefix
let config_map = HashMap::from([
("ipv6_prefix".to_string(), "2a00:fb01:400:100".to_string()),
("ipv6_subnet".to_string(), "\\64".to_string()),
(
"ipv6_gateway".to_string(),
"2a00:fb01:400:100::1".to_string(),
Expand Down Expand Up @@ -134,7 +132,6 @@ pub mod tests {
"ipv6_address".to_string(),
"2a00:fb01:400:100::1".to_string(),
),
("ipv6_subnet".to_string(), "\\64".to_string()),
(
"ipv6_gateway".to_string(),
"2a00:fb01:400:100::1".to_string(),
Expand All @@ -143,23 +140,17 @@ pub mod tests {
assert!(NetworkInfo::from_config_map(&config_map).is_ok());

// Need prefix or address, gateway
let config_map = HashMap::from([
("ipv6_subnet".to_string(), "\\64".to_string()),
(
"ipv6_gateway".to_string(),
"2a00:fb01:400:100::1".to_string(),
),
]);
let config_map = HashMap::from([(
"ipv6_gateway".to_string(),
"2a00:fb01:400:100::1".to_string(),
)]);
assert!(NetworkInfo::from_config_map(&config_map).is_err());
let config_map = HashMap::from([
("ipv6_prefix".to_string(), "2a00:fb01:400:100".to_string()),
("ipv6_subnet".to_string(), "\\64".to_string()),
]);
let config_map =
HashMap::from([("ipv6_prefix".to_string(), "2a00:fb01:400:100".to_string())]);
assert!(NetworkInfo::from_config_map(&config_map).is_err());

// With ipv6_address with subnet len
let config_map = HashMap::from([
("ipv6_subnet".to_string(), "\\64".to_string()),
(
"ipv6_gateway".to_string(),
"2a00:fb01:400:100::1".to_string(),
Expand Down
1 change: 0 additions & 1 deletion rs/ic_os/setupos-inject-configuration/src/main.rs
Expand Up @@ -179,7 +179,6 @@ async fn write_config(path: &Path, cfg: &NetworkConfig) -> Result<(), Error> {
segments[0], segments[1], segments[2], segments[3],
)?;

writeln!(&mut f, "ipv6_subnet=/{}", ipv6_prefix.prefix_len())?;
writeln!(&mut f, "ipv6_gateway={}", ipv6_gateway.addr())?;
}

Expand Down
7 changes: 1 addition & 6 deletions testnet/ansible/inventory/inventory.py
Expand Up @@ -214,7 +214,7 @@ def _host_patch_vars(self, host):
# That didn't work, try to build IPv6 from the MAC address
if ic_host:
ipv6_prefix = self._get_ipv6_prefix_for_ic_host(ic_host)
ipv6_subnet = self._get_ipv6_subnet_for_ic_host(ic_host)
ipv6_subnet = '/64'
# For the mainnet deployments, the MAC address is calculated based on the number of guests on
# the physical host, so we need to enumerate and count the guests on each physical host.
# Assign a unique ID to each physical host. This will be a serial number if
Expand Down Expand Up @@ -478,10 +478,6 @@ def _get_ipv6_prefix_for_ic_host(self, ic_host):
dc = self._get_dc_config_for_ic_host(ic_host)
return dc.get("vars", {}).get("ipv6_prefix")

def _get_ipv6_subnet_for_ic_host(self, ic_host):
dc = self._get_dc_config_for_ic_host(ic_host)
return dc.get("vars", {}).get("ipv6_subnet")

def _get_dc_config_for_ic_host(self, ic_host):
hostname_short = ic_host.split(".")[0]
dc = hostname_short.split("-")[0]
Expand Down Expand Up @@ -580,7 +576,6 @@ def media_config(self):
dc_config = {
"name": dc_name,
"ipv6_prefix": dc_vars["ipv6_prefix"],
"ipv6_subnet": dc_vars["ipv6_subnet"],
"nodes": [],
"api_nodes": [],
"aux_nodes": [],
Expand Down
8 changes: 0 additions & 8 deletions testnet/env/shared-config.yml
Expand Up @@ -10,35 +10,27 @@ data_centers:
ch1:
vars:
ipv6_prefix: "2607:f6f0:3004:1"
ipv6_subnet: "/64"
dm1:
vars:
ipv6_prefix: "2604:6800:258:1"
ipv6_subnet: "/64"
fr1:
vars:
ipv6_prefix: "2001:4d78:40d"
ipv6_subnet: "/64"
ln1:
vars:
ipv6_prefix: "2a0b:21c0:4003:2"
ipv6_subnet: "/64"
se1:
vars:
ipv6_prefix: "2600:c00:2:100"
ipv6_subnet: "/64"
sf1-old:
vars:
ipv6_prefix: "2607:fb58:9005:42"
ipv6_subnet: "/64"
sf1:
vars:
ipv6_prefix: "2602:fb2b:100:10"
ipv6_subnet: "/64"
zh1:
vars:
ipv6_prefix: "2a00:fb01:400:42"
ipv6_subnet: "/64"

physical_hosts:
vars:
Expand Down
6 changes: 2 additions & 4 deletions testnet/tools/build-guestos-configs.sh
Expand Up @@ -143,9 +143,8 @@ NODES=0
VALUES=$(echo ${CONFIG} \
| jq -r -c '.datacenters[]
| .aux_nodes[] += { "type": "aux" } | .boundary_nodes[] += {"type": "boundary"} | .nodes[] += { "type": "replica" }
| [.aux_nodes[], .boundary_nodes[], .nodes[]][] + { "ipv6_prefix": .ipv6_prefix, "ipv6_subnet": .ipv6_subnet } | [
| [.aux_nodes[], .boundary_nodes[], .nodes[]][] + { "ipv6_prefix": .ipv6_prefix } | [
.ipv6_prefix,
.ipv6_subnet,
.ipv6_address,
.hostname,
.subnet_type,
Expand All @@ -154,10 +153,9 @@ VALUES=$(echo ${CONFIG} \
.use_hsm,
.type
] | join("\u0001")')
while IFS=$'\1' read -r ipv6_prefix ipv6_subnet ipv6_address hostname subnet_type subnet_idx node_idx use_hsm type; do
while IFS=$'\1' read -r ipv6_prefix ipv6_address hostname subnet_type subnet_idx node_idx use_hsm type; do
eval "declare -A __RAW_NODE_${NODES}=(
['ipv6_prefix']=${ipv6_prefix}
['ipv6_subnet']=${ipv6_subnet}
['ipv6_address']=${ipv6_address}
['hostname']=${hostname}
['subnet_type']=${subnet_type}
Expand Down

0 comments on commit 84e4f37

Please sign in to comment.