blob: 52c73d0124b283ef0e43d17bfd4d5286e8b399e0 [file] [log] [blame]
Patrick Williams5d074372022-12-04 15:33:08 -06001#!/bin/bash
Brandon Kimdab96f12021-02-18 11:21:37 -08002# Copyright 2021 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
William A. Kennington III7d6fa422021-02-08 17:04:02 -080016# Internal handler used for signalling child processes that they should
17# terminate.
Patrick Williams59486672022-12-08 06:23:47 -060018function HandleTerm() {
19 GOT_TERM=1
20 if ShouldTerm && (( ${#CHILD_PIDS[@]} > 0 )); then
21 kill -s TERM "${!CHILD_PIDS[@]}"
22 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -080023}
24
25# Sets up the signal handler and global variables needed to run interruptible
26# services that can be killed gracefully.
Patrick Williams59486672022-12-08 06:23:47 -060027function InitTerm() {
28 declare -g -A CHILD_PIDS=()
29 declare -g GOT_TERM=0
30 declare -g SUPPRESS_TERM=0
31 trap HandleTerm TERM
William A. Kennington III7d6fa422021-02-08 17:04:02 -080032}
33
34# Used to suppress the handling of SIGTERM for critical components that should
35# not respect SIGTERM. To finish suppressing, use UnsuppressTerm()
Patrick Williams59486672022-12-08 06:23:47 -060036function SuppressTerm() {
37 SUPPRESS_TERM=$((SUPPRESS_TERM + 1))
William A. Kennington III7d6fa422021-02-08 17:04:02 -080038}
39
40# Stops suppressing SIGTERM for a single invocation of SuppresssTerm()
Patrick Williams59486672022-12-08 06:23:47 -060041function UnsuppressTerm() {
42 SUPPRESS_TERM=$((SUPPRESS_TERM - 1))
William A. Kennington III7d6fa422021-02-08 17:04:02 -080043}
44
45# Determines if we got a SIGTERM and should respect it
Patrick Williams59486672022-12-08 06:23:47 -060046function ShouldTerm() {
47 (( GOT_TERM == 1 && SUPPRESS_TERM == 0 ))
William A. Kennington III7d6fa422021-02-08 17:04:02 -080048}
49
50# Internal, ensures that functions called in a subprocess properly initialize
51# their SIGTERM handling logic
Patrick Williams59486672022-12-08 06:23:47 -060052function RunInterruptibleFunction() {
53 CHILD_PIDS=()
54 trap HandleTerm TERM
55 "$@"
William A. Kennington III7d6fa422021-02-08 17:04:02 -080056}
57
58# Runs the provided commandline in the background, and passes any received
59# SIGTERMS to the child. Can be waited on using WaitInterruptibleBg
Patrick Williams59486672022-12-08 06:23:47 -060060function RunInterruptibleBg() {
61 if ShouldTerm; then
62 return 143
63 fi
64 if [ "$(type -t "$1")" = "function" ]; then
65 RunInterruptibleFunction "$@" &
66 else
67 "$@" &
68 fi
69 CHILD_PIDS["$!"]=1
William A. Kennington III7d6fa422021-02-08 17:04:02 -080070}
71
72# Runs the provided commandline to completion, and passes any received
73# SIGTERMS to the child.
Patrick Williams59486672022-12-08 06:23:47 -060074function RunInterruptible() {
75 RunInterruptibleBg "$@" || return
76 local child_pid="$!"
77 wait "$child_pid" || true
78 unset CHILD_PIDS["$child_pid"]
79 wait "$child_pid"
William A. Kennington III7d6fa422021-02-08 17:04:02 -080080}
81
82# Waits until all of the RunInterruptibleBg() jobs have terminated
Patrick Williams59486672022-12-08 06:23:47 -060083function WaitInterruptibleBg() {
84 local wait_on=("${!CHILD_PIDS[@]}")
85 if (( ${#wait_on[@]} > 0 )); then
86 wait "${wait_on[@]}" || true
87 CHILD_PIDS=()
88 local rc=0
89 local id
90 for id in "${wait_on[@]}"; do
91 wait "$id" || rc=$?
92 done
93 return $rc
94 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -080095}
96
William A. Kennington IIId7989582022-05-27 16:41:44 -070097# Runs the provided commandline to completion, capturing stdout
98# into a variable
Patrick Williams59486672022-12-08 06:23:47 -060099function CaptureInterruptible() {
100 local var="$1"
101 shift
102 if ShouldTerm; then
103 return 143
104 fi
105 coproc "$@" || return
106 local child_pid="$COPROC_PID"
107 CHILD_PIDS["$child_pid"]=1
108 exec {COPROC[1]}>&-
109 read -d $'\0' -ru "${COPROC[0]}" "$var" || true
110 wait "$child_pid" || true
111 unset CHILD_PIDS[$child_pid]
112 wait "$child_pid"
William A. Kennington IIId7989582022-05-27 16:41:44 -0700113}
114
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800115# Determines if an address could be a valid IPv4 address
116# NOTE: this doesn't sanitize invalid IPv4 addresses
Patrick Williams59486672022-12-08 06:23:47 -0600117function IsIPv4() {
118 local ip="$1"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800119
Patrick Williams59486672022-12-08 06:23:47 -0600120 [[ "$ip" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800121}
122
123# Takes lines of text from an application on stdin and parses out a single
124# MAC address per line of input.
Patrick Williams59486672022-12-08 06:23:47 -0600125function ParseMACFromLine() {
126 sed -n 's,.*\(\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}\).*,\1,p'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800127}
128
129# Looks up the MAC address of the IPv4 neighbor using ARP
Patrick Williams59486672022-12-08 06:23:47 -0600130function DetermineNeighbor4() {
131 local netdev="$1"
132 local ip="$2"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800133
Patrick Williams59486672022-12-08 06:23:47 -0600134 # Grep intentionally prevented from returning an error to preserve the error
135 # value of arping
136 RunInterruptible arping -f -c 5 -w 5 -I "$netdev" "$ip" | \
137 { grep 'reply from' || true; } | ParseMACFromLine
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800138}
139
140# Looks up the MAC address of the IPv6 neighbor using ICMPv6 ND
Patrick Williams59486672022-12-08 06:23:47 -0600141function DetermineNeighbor6() {
142 local netdev="$1"
143 local ip="$2"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800144
Patrick Williams59486672022-12-08 06:23:47 -0600145 RunInterruptible ndisc6 -1 -r 5 -w 1000 -q "$ip" "$netdev"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800146}
147
148# Looks up the MAC address of the neighbor regardless of type
Patrick Williams59486672022-12-08 06:23:47 -0600149function DetermineNeighbor() {
150 local netdev="$1"
151 local ip="$2"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800152
Patrick Williams59486672022-12-08 06:23:47 -0600153 if IsIPv4 "$ip"; then
154 DetermineNeighbor4 "$netdev" "$ip"
155 else
156 DetermineNeighbor6 "$netdev" "$ip"
157 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800158}
159
160# Performs a mapper call to get the subroot for the object root
161# with a maxdepth and list of required interfaces. Returns a streamed list
162# of JSON objects that contain an { object, service }.
Patrick Williams59486672022-12-08 06:23:47 -0600163function GetSubTree() {
164 local root="$1"
165 shift
166 local max_depth="$1"
167 shift
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800168
Patrick Williams59486672022-12-08 06:23:47 -0600169 busctl --json=short call \
170 'xyz.openbmc_project.ObjectMapper' \
171 '/xyz/openbmc_project/object_mapper' \
172 'xyz.openbmc_project.ObjectMapper' \
173 'GetSubTree' sias "$root" "$max_depth" "$#" "$@" | \
174 jq -c '.data[0] | to_entries[] | { object: .key, service: (.value | keys[0]) }'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800175}
176
177# Returns all of the properties for a DBus interface on an object as a JSON
178# object where the keys are the property names
Patrick Williams59486672022-12-08 06:23:47 -0600179function GetProperties() {
180 local service="$1"
181 local object="$2"
182 local interface="$3"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800183
Patrick Williams59486672022-12-08 06:23:47 -0600184 busctl --json=short call \
185 "$service" \
186 "$object" \
187 'org.freedesktop.DBus.Properties' \
188 'GetAll' s "$interface" | \
189 jq -c '.data[0] | with_entries({ key, value: .value.data })'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800190}
191
192# Returns the property for a DBus interface on an object
Patrick Williams59486672022-12-08 06:23:47 -0600193function GetProperty() {
194 local service="$1"
195 local object="$2"
196 local interface="$3"
197 local property="$4"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800198
Patrick Williams59486672022-12-08 06:23:47 -0600199 busctl --json=short call \
200 "$service" \
201 "$object" \
202 'org.freedesktop.DBus.Properties' \
203 'Get' ss "$interface" "$property" | \
204 jq -r '.data[0].data'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800205}
206
207# Deletes any OpenBMC DBus object from a service
Patrick Williams59486672022-12-08 06:23:47 -0600208function DeleteObject() {
209 local service="$1"
210 local object="$2"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800211
Patrick Williams59486672022-12-08 06:23:47 -0600212 busctl call \
213 "$service" \
214 "$object" \
215 'xyz.openbmc_project.Object.Delete' \
216 'Delete'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800217}
218
219# Transforms the given JSON dictionary into bash local variable
220# statements that can be directly evaluated by the interpreter
Patrick Williams59486672022-12-08 06:23:47 -0600221function JSONToVars() {
222 jq -r 'to_entries[] | @sh "local \(.key)=\(.value)"'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800223}
224
225# Returns the DBus object root for the ethernet interface
Patrick Williams59486672022-12-08 06:23:47 -0600226function EthObjRoot() {
227 local netdev="$1"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800228
Patrick Williams59486672022-12-08 06:23:47 -0600229 echo "/xyz/openbmc_project/network/$netdev"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800230}
231
232# Returns the DBus object root for the static neighbors of an intrerface
Patrick Williams59486672022-12-08 06:23:47 -0600233function StaticNeighborObjRoot() {
234 local netdev="$1"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800235
Patrick Williams59486672022-12-08 06:23:47 -0600236 echo "$(EthObjRoot "$netdev")/static_neighbor"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800237}
238
239# Returns all of the neighbor { service, object } data for an interface as if
240# a call to GetSubTree() was made
Patrick Williams59486672022-12-08 06:23:47 -0600241function GetNeighborObjects() {
242 local netdev="$1"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800243
Patrick Williams59486672022-12-08 06:23:47 -0600244 GetSubTree "$(StaticNeighborObjRoot "$netdev")" 0 \
245 'xyz.openbmc_project.Network.Neighbor'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800246}
247
248# Returns the neighbor properties as a JSON object
Patrick Williams59486672022-12-08 06:23:47 -0600249function GetNeighbor() {
250 local service="$1"
251 local object="$2"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800252
Patrick Williams59486672022-12-08 06:23:47 -0600253 GetProperties "$service" "$object" 'xyz.openbmc_project.Network.Neighbor'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800254}
255
256# Adds a static neighbor to the system network daemon
Patrick Williams59486672022-12-08 06:23:47 -0600257function AddNeighbor() {
258 local service="$1"
259 local netdev="$2"
260 local ip="$3"
261 local mac="$4"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800262
Patrick Williams59486672022-12-08 06:23:47 -0600263 busctl call \
264 "$service" \
265 "$(EthObjRoot "$netdev")" \
266 'xyz.openbmc_project.Network.Neighbor.CreateStatic' \
267 'Neighbor' ss "$ip" "$mac" >/dev/null
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800268}
269
270# Returns all of the IP { service, object } data for an interface as if
271# a call to GetSubTree() was made
Patrick Williams59486672022-12-08 06:23:47 -0600272function GetIPObjects() {
273 local netdev="$1"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800274
Patrick Williams59486672022-12-08 06:23:47 -0600275 GetSubTree "$(EthObjRoot "$netdev")" 0 \
276 'xyz.openbmc_project.Network.IP'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800277}
278
279# Returns the IP properties as a JSON object
Patrick Williams59486672022-12-08 06:23:47 -0600280function GetIP() {
281 local service="$1"
282 local object="$2"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800283
Patrick Williams59486672022-12-08 06:23:47 -0600284 GetProperties "$service" "$object" 'xyz.openbmc_project.Network.IP'
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800285}
286
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700287# Returns the Gateway address for the interface and type
Patrick Williams59486672022-12-08 06:23:47 -0600288function GetGateways() {
289 local service="$1"
290 local netdev="$2"
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700291
Patrick Williams59486672022-12-08 06:23:47 -0600292 # We fetch both the system properties and the netdev specific properties
293 # as OpenBMC is in the process of transitioning these to the netdev object
294 # but the migration is not yet complete.
295 {
296 GetProperties "$service" '/xyz/openbmc_project/network/config' \
297 'xyz.openbmc_project.Network.SystemConfiguration'
298 GetProperties "$service" "$(EthObjRoot "$netdev")" \
299 'xyz.openbmc_project.Network.EthernetInterface'
300 } | jq -s '
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700301 . | map(
302 if .DefaultGateway != "" then
303 {DefaultGateway: .DefaultGateway}
304 else
305 {}
306 end +
307 if .DefaultGateway6 != "" then
308 {DefaultGateway6: .DefaultGateway6}
309 else
310 {}
311 end
Patrick Williams59486672022-12-08 06:23:47 -0600312 ) | {DefaultGateway: "", DefaultGateway6: ""} + add'
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700313}
314
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800315# Adds a static IP to the system network daemon
Patrick Williams59486672022-12-08 06:23:47 -0600316function AddIP() {
317 local service="$1"
318 local netdev="$2"
319 local ip="$3"
320 local prefix="$4"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800321
Patrick Williams59486672022-12-08 06:23:47 -0600322 local protocol='xyz.openbmc_project.Network.IP.Protocol.IPv4'
323 if ! IsIPv4 "$ip"; then
324 protocol='xyz.openbmc_project.Network.IP.Protocol.IPv6'
325 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800326
Patrick Williams59486672022-12-08 06:23:47 -0600327 busctl call \
328 "$service" \
329 "$(EthObjRoot "$netdev")" \
330 'xyz.openbmc_project.Network.IP.Create' \
331 'IP' ssys "$protocol" "$ip" "$prefix" '' >/dev/null
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800332}
333
334# Determines if two IP addresses have the same address family
335# IE: Both are IPv4 or both are IPv6
Patrick Williams59486672022-12-08 06:23:47 -0600336function MatchingAF() {
337 local rc1=0 rc2=0
338 IsIPv4 "$1" || rc1=$?
339 IsIPv4 "$2" || rc2=$?
340 (( rc1 == rc2 ))
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800341}
342
343# Checks to see if the machine has the provided IP address information
344# already configured. If not, it deletes all of the information for that
345# address family and adds the provided IP address.
Patrick Williams59486672022-12-08 06:23:47 -0600346function UpdateIP() {
347 local service="$1"
348 local netdev="$2"
349 local ip="$3"
350 local prefix="$4"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800351
Patrick Williams59486672022-12-08 06:23:47 -0600352 local should_add=1
353 local delete_services=()
354 local delete_objects=()
355 local entry
356 while read entry; do
357 eval "$(echo "$entry" | JSONToVars)" || return $?
358 eval "$(GetIP "$service" "$object" | JSONToVars)" || return $?
359 if [ "$(normalize_ip "$Address")" = "$(normalize_ip "$ip")" ] && \
360 [ "$PrefixLength" = "$prefix" ]; then
361 should_add=0
362 elif MatchingAF "$ip" "$Address"; then
363 echo "Deleting spurious IP: $Address/$PrefixLength" >&2
364 delete_services+=("$service")
365 delete_objects+=("$object")
366 fi
367 done < <(GetIPObjects "$netdev")
368
369 local i
370 for (( i=0; i<${#delete_objects[@]}; ++i )); do
371 DeleteObject "${delete_services[$i]}" "${delete_objects[$i]}" || true
372 done
373
374 if (( should_add == 0 )); then
375 echo "Not adding IP: $ip/$prefix" >&2
376 else
377 echo "Adding IP: $ip/$prefix" >&2
378 AddIP "$service" "$netdev" "$ip" "$prefix" || return $?
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800379 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800380}
381
382# Sets the system gateway property to the provided IP address if not already
383# set to the current value.
Patrick Williams59486672022-12-08 06:23:47 -0600384function UpdateGateway() {
385 local service="$1"
386 local netdev="$2"
387 local ip="$3"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800388
Patrick Williams59486672022-12-08 06:23:47 -0600389 local object="$(EthObjRoot "$netdev")"
390 local interface='xyz.openbmc_project.Network.EthernetInterface'
391 local property='DefaultGateway'
392 if ! IsIPv4 "$ip"; then
393 property='DefaultGateway6'
394 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800395
Patrick Williams59486672022-12-08 06:23:47 -0600396 local current_ip
397 current_ip="$(GetProperty "$service" "$object" "$interface" "$property")" || \
398 return $?
399 if [ -n "$current_ip" ] && \
400 [ "$(normalize_ip "$ip")" = "$(normalize_ip "$current_ip")" ]; then
401 echo "Not reconfiguring gateway: $ip" >&2
402 return 0
403 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800404
Patrick Williams59486672022-12-08 06:23:47 -0600405 echo "Setting gateway: $ip" >&2
406 busctl set-property "$service" "$object" "$interface" "$property" s "$ip"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800407}
408
409# Checks to see if the machine has the provided neighbor information
410# already configured. If not, it deletes all of the information for that
411# address family and adds the provided neighbor entry.
Patrick Williams59486672022-12-08 06:23:47 -0600412function UpdateNeighbor() {
413 local service="$1"
414 local netdev="$2"
415 local ip="$3"
416 local mac="$4"
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800417
Patrick Williams59486672022-12-08 06:23:47 -0600418 local should_add=1
419 local delete_services=()
420 local delete_objects=()
421 local entry
422 while read entry; do
423 eval "$(echo "$entry" | JSONToVars)" || return $?
424 eval "$(GetNeighbor "$service" "$object" | JSONToVars)" || return $?
425 if [ "$(normalize_ip "$IPAddress")" = "$(normalize_ip "$ip")" ] && \
426 [ "$(normalize_mac "$MACAddress")" = "$(normalize_mac "$mac")" ]; then
427 should_add=0
428 elif MatchingAF "$ip" "$IPAddress"; then
429 echo "Deleting spurious neighbor: $IPAddress $MACAddress" >&2
430 delete_services+=("$service")
431 delete_objects+=("$object")
432 fi
433 done < <(GetNeighborObjects "$netdev" 2>/dev/null)
434
435 local i
436 for (( i=0; i<${#delete_objects[@]}; ++i )); do
437 DeleteObject "${delete_services[$i]}" "${delete_objects[$i]}" || true
438 done
439
440 if (( should_add == 0 )); then
441 echo "Not adding neighbor: $ip $mac" >&2
442 else
443 echo "Adding neighbor: $ip $mac" >&2
444 AddNeighbor "$service" "$netdev" "$ip" "$mac" || return $?
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800445 fi
William A. Kennington III7d6fa422021-02-08 17:04:02 -0800446}
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700447
448# Determines the ip and mac of the IPv6 router
Patrick Williams59486672022-12-08 06:23:47 -0600449function DiscoverRouter6() {
450 local netdev="$1"
451 local retries="$2"
452 local timeout="$3"
453 local router="${4-}"
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700454
Patrick Williams59486672022-12-08 06:23:47 -0600455 local output
456 local st=0
457 local args=(-1 -w "$timeout" -n $router "$netdev")
458 if (( retries < 0 )); then
459 args+=(-d)
460 else
461 args+=(-r "$retries")
462 fi
463 CaptureInterruptible output rdisc6 "${args[@]}" || st=$?
464 if (( st != 0 )); then
465 echo "rdisc6 failed with: " >&2
466 echo "$output" >&2
467 return $st
468 fi
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700469
Patrick Williams59486672022-12-08 06:23:47 -0600470 local ip="$(echo "$output" | grep 'from' | awk '{print $2}')"
471 local mac="$(echo "$output" | grep 'Source link-layer' | ParseMACFromLine)"
472 local staddr="$(echo "$output" | grep 'Stateful address conf.*Yes')"
473 printf '{"router_ip":"%s","router_mac":"%s","stateful_address":"%s"}\n' \
474 "$ip" "$mac" "$staddr"
William A. Kennington IIIb163a2c2021-05-20 17:33:01 -0700475}
William A. Kennington IIIa7af2e02022-02-13 22:47:39 -0800476
477# Sets the network configuration of an interface to be static
Patrick Williams59486672022-12-08 06:23:47 -0600478function SetStatic() {
479 local service="$1"
480 local netdev="$2"
William A. Kennington IIIa7af2e02022-02-13 22:47:39 -0800481
Patrick Williams59486672022-12-08 06:23:47 -0600482 echo "Disabling DHCP" >&2
483 busctl set-property "$service" "$(EthObjRoot "$netdev")" \
484 xyz.openbmc_project.Network.EthernetInterface DHCPEnabled \
485 s xyz.openbmc_project.Network.EthernetInterface.DHCPConf.none
William A. Kennington IIIa7af2e02022-02-13 22:47:39 -0800486}