blob: 91cbdb5b5bea86e6ef73b8a5273263be68a258e9 [file] [log] [blame]
William A. Kennington III71fc1892021-12-13 14:32:20 -08001#!/bin/bash
2# 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 IIIac01f532024-09-05 02:08:09 -070016HAS_DHCRELAY='@GBMC_DHCP_RELAY@'
William A. Kennington III95e2e992023-11-08 17:13:19 -080017
18if [ "$HAS_DHCRELAY" = 1 ]; then
William A. Kennington III95e2e992023-11-08 17:13:19 -080019 # Remove the source relay port from the relay, bringing it back to run on
20 # the default port 547. Our relays don't support the source port option needed
21 # to run on 3967 for our legacy NICs.
William A. Kennington III420c0bb2024-09-16 13:13:14 -070022 echo 'RP_FLAG=' >/run/gbmc-ncsi-dhcrelay.env
William A. Kennington III95e2e992023-11-08 17:13:19 -080023 systemctl reset-failed gbmc-ncsi-dhcrelay
24 systemctl restart --no-block gbmc-ncsi-dhcrelay
25fi
William A. Kennington III420c0bb2024-09-16 13:13:14 -070026
William A. Kennington III6dc6cd72024-10-31 00:25:21 -070027echo '@NCSI_IF@' >>/run/gbmc-br-dhcp-intfs
William A. Kennington III463eeb12024-11-01 12:03:03 -070028if systemctl is-active --quiet gbmc-br-dhcp@gbmcbr; then
29 systemctl reset-failed gbmc-br-dhcp@@NCSI_IF@
30 systemctl restart --no-block gbmc-br-dhcp@@NCSI_IF@
31fi
William A. Kennington III71fc1892021-12-13 14:32:20 -080032
33read -r -d '' contents <<EOF
34table inet filter {
35 chain ncsi_legacy_input {
William A. Kennington IIIa8d40472022-01-25 16:13:00 -080036 udp dport {546,547} accept
William A. Kennington III71fc1892021-12-13 14:32:20 -080037 }
38}
39EOF
40rfile=/run/nftables/60-gbmc-ncsi-ra.rules
41mkdir -p "$(dirname "$rfile")"
42printf '%s' "$contents" >"$rfile"
43systemctl reset-failed nftables
44systemctl --no-block reload-or-restart nftables