William A. Kennington III | b163a2c | 2021-05-20 17:33:01 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | source "$(dirname "${BASH_SOURCE[0]}")"/ncsid_lib.sh |
| 3 | |
| 4 | UpdateRA() { |
| 5 | local netdev="$1" |
| 6 | |
| 7 | local service='xyz.openbmc_project.Network' |
| 8 | local gateways |
| 9 | if ! gateways="$(GetGateways "$service" "$netdev")"; then |
| 10 | echo "Failed to look up gateways" >&2 |
| 11 | return 1 |
| 12 | fi |
| 13 | local vars |
| 14 | vars="$(echo "$gateways" | JSONToVars)" || return |
| 15 | eval "$vars" || return |
| 16 | |
| 17 | echo "GW($netdev): ${DefaultGateway6:-(none)}" >&2 |
| 18 | if [ -z "$DefaultGateway6" ]; then |
| 19 | return 0 |
| 20 | fi |
| 21 | |
| 22 | local disc |
| 23 | if ! disc="$(DiscoverRouter6 "$netdev" -1 360000 "$DefaultGateway6")"; then |
| 24 | echo "Failed to discover router" >&2 |
| 25 | return 1 |
| 26 | fi |
| 27 | local vars |
| 28 | vars="$(echo "$disc" | JSONToVars)" || return |
| 29 | eval "$vars" || return |
| 30 | echo "GW($netdev) MAC: $router_mac" >&2 |
| 31 | |
| 32 | SuppressTerm |
| 33 | local rc=0 |
| 34 | UpdateNeighbor "$service" "$netdev" "$router_ip" "$router_mac" || rc=$? |
| 35 | UnsuppressTerm |
| 36 | return $rc |
| 37 | } |
| 38 | |
| 39 | Main() { |
| 40 | set -o nounset |
| 41 | set -o errexit |
| 42 | set -o pipefail |
| 43 | |
| 44 | InitTerm |
| 45 | UpdateRA "$@" |
| 46 | } |
| 47 | |
| 48 | return 0 2>/dev/null |
| 49 | Main "$@" |