ncsid: Remove unused services
We no longer need IPv4 support or any of the neighbor finding logic, as
we have all of the neighbor information updated via the primary RA from
the router.
Tested: Ran on a lab and prod machine to verify the networking behavior
is still consistent and gateway information is updated accurately.
Change-Id: I0e247291ae3a1f98064a3bc9a94b28d9a2223843
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/subprojects/ncsid/src/dhcp4@.service.in b/subprojects/ncsid/src/dhcp4@.service.in
deleted file mode 100644
index de94729..0000000
--- a/subprojects/ncsid/src/dhcp4@.service.in
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=DHCPv4 Updater
-Wants=mapper-wait@-xyz-openbmc_project-network-%i.service
-After=mapper-wait@-xyz-openbmc_project-network-%i.service
-Requisite=nic-hostless@%i.target
-After=nic-hostless@%i.target
-BindsTo=nic-hostless@%i.target
-ConditionPathExists=!/run/dhcp4.done
-
-[Service]
-KillMode=mixed
-Restart=on-failure
-ExecStart=@/usr/bin/env udhcpc -V gBMC -f -q -i %I -s @SCRIPT@
-SyslogIdentifier=dhcp4@%I
diff --git a/subprojects/ncsid/src/dhcp6@.service.in b/subprojects/ncsid/src/dhcp6@.service.in
deleted file mode 100644
index 5e03458..0000000
--- a/subprojects/ncsid/src/dhcp6@.service.in
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=DHCPv6 Updater
-Wants=mapper-wait@-xyz-openbmc_project-network-%i.service
-After=mapper-wait@-xyz-openbmc_project-network-%i.service
-Requisite=nic-hostless@%i.target
-After=nic-hostless@%i.target
-BindsTo=nic-hostless@%i.target
-ConditionPathExists=!/run/dhcp6.done
-
-[Service]
-KillMode=mixed
-Restart=on-failure
-ExecStart=@/usr/bin/env udhcpc6 -f -q -O bootfile_url -O bootfile_param -i %I -s @SCRIPT@
-SyslogIdentifier=dhcp6@%I
diff --git a/subprojects/ncsid/src/meson.build b/subprojects/ncsid/src/meson.build
index 6a85c68..2bb1c82 100644
--- a/subprojects/ncsid/src/meson.build
+++ b/subprojects/ncsid/src/meson.build
@@ -61,11 +61,7 @@
install: true)
install_data(
- 'ncsid_udhcpc4.script',
- 'ncsid_udhcpc6.script',
'update_ra_gw.sh',
- 'update_ra_neighbor.sh',
- 'update_static_neighbors.sh',
install_mode: 'rwxr-xr-x',
install_dir: get_option('libexecdir'))
@@ -93,40 +89,8 @@
install_mode: 'rw-r--r--',
install_dir: systemunitdir)
-configure_file(
- configuration: {'BIN': libexecdir / 'update_ra_neighbor.sh'},
- input: 'update-ra-neighbor@.service.in',
- output: 'update-ra-neighbor@.service',
- install_mode: 'rw-r--r--',
- install_dir: systemunitdir)
-
-configure_file(
- configuration: {'BIN': libexecdir / 'update_static_neighbors.sh'},
- input: 'update-static-neighbors@.service.in',
- output: 'update-static-neighbors@.service',
- install_mode: 'rw-r--r--',
- install_dir: systemunitdir)
-
-configure_file(
- configuration: {
- 'SCRIPT': libexecdir / 'ncsid_udhcpc4.script'},
- input: 'dhcp4@.service.in',
- output: 'dhcp4@.service',
- install_mode: 'rw-r--r--',
- install_dir: systemunitdir)
-
-configure_file(
- configuration: {
- 'SCRIPT': libexecdir / 'ncsid_udhcpc6.script'},
- input: 'dhcp6@.service.in',
- output: 'dhcp6@.service',
- install_mode: 'rw-r--r--',
- install_dir: systemunitdir)
-
install_data(
'nic-hostful@.target',
'nic-hostless@.target',
- 'update-ra-neighbor@.timer',
- 'update-static-neighbors@.timer',
install_mode: 'rw-r--r--',
install_dir: systemunitdir)
diff --git a/subprojects/ncsid/src/ncsid_udhcpc4.script b/subprojects/ncsid/src/ncsid_udhcpc4.script
deleted file mode 100644
index fbf90f1..0000000
--- a/subprojects/ncsid/src/ncsid_udhcpc4.script
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/bash
-source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh
-
-function DetermineRouterMac() {
- # Attempt to find the neighbor once, in case our configuration is already
- # valid. Errors are silenced to make the logs more clear. The next call
- # will print any real errors.
- if DetermineNeighbor4 "$interface" "$router" 2>/dev/null; then
- return 0
- fi
-
- # arping might not have a valid source address, so we need to assign
- # the given address so arping has a source to write into the request
- # packet. We don't want a persistent configuration yet so we modify
- # the kernel directly.
- if ! ip -4 addr flush dev "$interface"; then
- echo "Failed to flush $interface" >&2
- return 1
- fi
- if ! ip addr add "$ip/$mask" dev "$interface"; then
- echo "Failed to assign $ip/$mask to $interface" >&2
- # Don't return, because we need to reset networkd
- fi
-
- local rc=0
- DetermineNeighbor4 "$interface" "$router" || rc=$?
-
- # We need to ensure that our old network configuration gets
- # restored, in case our early flushing breaks things.
- systemctl restart systemd-networkd || return $?
- return $rc
-}
-
-function HandleDHCP4() {
- local op="$1"
-
- if [ "$op" = "bound" ]; then
- echo "INTF: $interface" >&2
- echo "IP: $ip/$mask" >&2
- echo "GW: $router" >&2
-
- local router_mac
- if ! router_mac="$(DetermineRouterMac "$interface" "$router")"; then
- echo "Failed to acquire gateway mac for $router" >&2
- return 1
- fi
- echo "GW_MAC: $router_mac" >&2
-
- SuppressTerm
- local service='xyz.openbmc_project.Network'
- local rc=0
- SetStatic "$service" "$interface" && \
- UpdateIP "$service" "$interface" "$ip" "$mask" && \
- UpdateGateway "$service" "$interface" "$router" && \
- UpdateNeighbor "$service" "$interface" "$router" "$router_mac" || \
- rc=$?
- UnsuppressTerm
- touch /run/dhcp4.done
- return $rc
- fi
-}
-
-function Main() {
- set -o nounset
- set -o errexit
- set -o pipefail
-
- InitTerm
- HandleDHCP4 "$@"
-}
-
-return 0 2>/dev/null
-Main "$@"
diff --git a/subprojects/ncsid/src/ncsid_udhcpc6.script b/subprojects/ncsid/src/ncsid_udhcpc6.script
deleted file mode 100644
index e78a0ca..0000000
--- a/subprojects/ncsid/src/ncsid_udhcpc6.script
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh
-
-function HandleDHCP6() {
- local op="$1"
-
- if [ "$op" = "bound" ]; then
- echo "INTF: $interface" >&2
- echo "IP: $ipv6/128" >&2
-
- local disc
- if ! disc="$(DiscoverRouter6 "$interface" 5 1000)"; then
- echo "Failed to discover router" >&2
- return 1
- fi
- local vars
- vars="$(echo "$disc" | JSONToVars)" || return
- eval "$vars" || return
- echo "GW: $router_ip" >&2
- echo "GW_MAC: $router_mac" >&2
-
- SuppressTerm
- local service='xyz.openbmc_project.Network'
- local rc=0
- SetStatic "$service" "$interface" && \
- UpdateIP "$service" "$interface" "$ipv6" '128' && \
- UpdateGateway "$service" "$interface" "$router_ip" && \
- UpdateNeighbor "$service" "$interface" "$router_ip" "$router_mac" || \
- rc=$?
- UnsuppressTerm
- touch /run/dhcp6.done
- return $rc
- fi
-}
-
-function Main() {
- set -o nounset
- set -o errexit
- set -o pipefail
-
- InitTerm
- HandleDHCP6 "$@"
-}
-
-return 0 2>/dev/null
-Main "$@"
diff --git a/subprojects/ncsid/src/update-ra-neighbor@.service.in b/subprojects/ncsid/src/update-ra-neighbor@.service.in
deleted file mode 100644
index d946939..0000000
--- a/subprojects/ncsid/src/update-ra-neighbor@.service.in
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=RA Neighbor Updater
-Wants=mapper-wait@-xyz-openbmc_project-network-%i.service
-After=mapper-wait@-xyz-openbmc_project-network-%i.service
-BindsTo=ncsid@%i.service
-After=ncsid@%i.service
-StartLimitIntervalSec=1min
-StartLimitBurst=5
-
-[Service]
-KillMode=mixed
-Restart=on-failure
-ExecStart=@@BIN@ update-ra-neighbor %I
-SyslogIdentifier=update-ra-neighbor@%I
-SuccessExitStatus=10
diff --git a/subprojects/ncsid/src/update-ra-neighbor@.timer b/subprojects/ncsid/src/update-ra-neighbor@.timer
deleted file mode 100644
index f74461a..0000000
--- a/subprojects/ncsid/src/update-ra-neighbor@.timer
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Retry neighbor update periodically
-BindsTo=ncsid@%i.service
-After=ncsid@%i.service
-
-[Timer]
-OnUnitInactiveSec=1min
diff --git a/subprojects/ncsid/src/update-static-neighbors@.service.in b/subprojects/ncsid/src/update-static-neighbors@.service.in
deleted file mode 100644
index c729cc5..0000000
--- a/subprojects/ncsid/src/update-static-neighbors@.service.in
+++ /dev/null
@@ -1,16 +0,0 @@
-[Unit]
-Description=Static Neighbor Updater
-Wants=mapper-wait@-xyz-openbmc_project-network-%i.service
-After=mapper-wait@-xyz-openbmc_project-network-%i.service
-Requisite=nic-hostless@%i.target
-After=nic-hostless@%i.target
-BindsTo=nic-hostless@%i.target
-StartLimitIntervalSec=1min
-StartLimitBurst=5
-
-[Service]
-KillMode=mixed
-Restart=on-failure
-ExecStart=@@BIN@ update-static-neighbors %I
-SyslogIdentifier=update-static-neighbors@%I
-SuccessExitStatus=10
diff --git a/subprojects/ncsid/src/update-static-neighbors@.timer b/subprojects/ncsid/src/update-static-neighbors@.timer
deleted file mode 100644
index 883780e..0000000
--- a/subprojects/ncsid/src/update-static-neighbors@.timer
+++ /dev/null
@@ -1,8 +0,0 @@
-[Unit]
-Description=Retry neighbor update periodically
-Requisite=nic-hostless@%i.target
-After=nic-hostless@%i.target
-BindsTo=nic-hostless@%i.target
-
-[Timer]
-OnUnitInactiveSec=1min
diff --git a/subprojects/ncsid/src/update_ra_neighbor.sh b/subprojects/ncsid/src/update_ra_neighbor.sh
deleted file mode 100644
index 8d0a3c9..0000000
--- a/subprojects/ncsid/src/update_ra_neighbor.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh
-
-function UpdateRA() {
- local netdev="$1"
-
- local service='xyz.openbmc_project.Network'
- local gateways
- if ! gateways="$(GetGateways "$service" "$netdev")"; then
- echo "Failed to look up gateways" >&2
- return 1
- fi
- local vars
- vars="$(echo "$gateways" | JSONToVars)" || return
- eval "$vars" || return
-
- echo "GW($netdev): ${DefaultGateway6:-(none)}" >&2
- if [ -z "$DefaultGateway6" ]; then
- return 0
- fi
-
- local st=0
- local disc
- CaptureInterruptible disc DiscoverRouter6 "$netdev" -1 360000 "$DefaultGateway6" || st=$?
- if (( st != 0 )); then
- echo "Failed to discover router" >&2
- return 1
- fi
- local vars
- vars="$(echo "$disc" | JSONToVars)" || return
- eval "$vars" || return
- echo "GW($netdev) MAC: $router_mac" >&2
-
- SuppressTerm
- local rc=0
- UpdateNeighbor "$service" "$netdev" "$router_ip" "$router_mac" || rc=$?
- UnsuppressTerm
- return $rc
-}
-
-function Main() {
- set -o nounset
- set -o errexit
- set -o pipefail
-
- InitTerm
- UpdateRA "$@"
-}
-
-return 0 2>/dev/null
-Main "$@"
diff --git a/subprojects/ncsid/src/update_static_neighbors.sh b/subprojects/ncsid/src/update_static_neighbors.sh
deleted file mode 100644
index 2f46f82..0000000
--- a/subprojects/ncsid/src/update_static_neighbors.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash
-# Copyright 2021 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh
-
-function UpdateNeighbor() {
- local netdev="$1"
- local service="$2"
- local object="$3"
-
- eval "$(GetNeighbor "$service" "$object" | JSONToVars)" || return $?
- local new_mac
- if ! new_mac="$(DetermineNeighbor "$netdev" "$IPAddress")"; then
- echo "Faild to find $IPAddress" >&2
- return 10
- fi
- new_mac=$(normalize_mac "$new_mac") || return
- if [ "$new_mac" != "$(normalize_mac "$MACAddress")" ]; then
- echo "Updating $IPAddress: $MACAddress -> $new_mac" >&2
- SuppressTerm
- local rc=0
- DeleteObject "$service" "$object" && \
- AddNeighbor "$service" "$netdev" "$IPAddress" "$new_mac" || \
- rc=$?
- UnsuppressTerm
- return $rc
- fi
-}
-
-function UpdateNeighbors() {
- local netdev="$1"
-
- local entry
- while read entry; do
- eval "$(echo "$entry" | JSONToVars)"
- RunInterruptibleBg UpdateNeighbor "$netdev" "$service" "$object"
- done < <(GetNeighborObjects "$netdev" 2>/dev/null)
- WaitInterruptibleBg
-}
-
-function Main() {
- set -o nounset
- set -o errexit
- set -o pipefail
-
- InitTerm
- UpdateNeighbors "$@"
-}
-
-return 0 2>/dev/null
-Main "$@"