blob: 016ec4cc0d4b7214ffb61f87d7b19561e1b9efa9 [file] [log] [blame]
William A. Kennington III5f9f81f2024-09-04 15:06:51 -07001#!/bin/bash
2# Copyright 2024 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16RA_IF=$1
17IP_OFFSET=1
18# NCSI is known to be closer to the ToR than bridge routes. Prefer over bridge routes.
19ROUTE_METRIC=900
20
21has_bridge=1
22# shellcheck source=meta-google/recipes-google/networking/gbmc-bridge/gbmc-br-lib.sh
23source /usr/share/gbmc-br-lib.sh || has_bridge=
24
25update_rtr() {
26 busctl set-property xyz.openbmc_project.Network /xyz/openbmc_project/network/"$RA_IF" \
27 xyz.openbmc_project.Network.EthernetInterface DefaultGateway6 s "" || true
28
29 default_update_rtr "$@"
30}
31
32ncsi_is_active() {
33 systemctl is-active -q nic-hostless@"$RA_IF".target && return
34 systemctl is-active -q nic-hostful@"$RA_IF".target && return
35 return 1
36}
37
38update_fqdn() {
39 # We only do this for smartNICs (which don't use NCSI)
40 ncsi_is_active && return
41
42 default_update_fqdn "$@"
43}
44
45update_pfx() {
46 local pfx="$1"
47
48 # We only do this for smartNICs (which don't use NCSI)
49 ncsi_is_active && return
50
51 # Don't change anything for an empty prefix
52 [ -z "$pfx" ] && return
53
54 # We no longer need NCSId if we are in this configuration
55 systemctl stop --no-block ncsid@"$RA_IF" || true
56
57 # Save the IP address for the interface
58 if [ -n "$has_bridge" ]; then
59 gbmc_br_set_ip "$1" || true
60 echo "IP $pfx set on $RA_IF" >&2
61 fi
62
63 # DHCP Relay workaround until alternate source port is supported
64 # TODO: Remove this once internal relaying cleanups land
65 gbmc-ncsi-smartnic-wa.sh || true
66}
67
68# shellcheck source=meta-google/recipes-google/networking/gbmc-net-common/gbmc-ra.sh
69source /usr/share/gbmc-ra.sh || exit