blob: 533888cbb4f9f67f809a02ba65528d6780592465 [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
16override=/run/systemd/system/gbmc-ncsi-dhcrelay.service.d/10-nosp.conf
17mkdir -p "$(dirname "$override")"
18echo '[Service]' >"$override"
19echo 'ExecStart=' >>"$override"
20# Remove the source relay port from the relay, bringing it back to run on
21# the default port 547. Our relays don't support the source port option needed
22# to run on 3967 for our legacy NICs.
William A. Kennington IIId5a68df2022-06-29 16:55:07 -070023grep '^ExecStart=' /lib/systemd/system/gbmc-ncsi-dhcrelay.service | \
24 sed 's, -rp 3967,,' >>"$override"
William A. Kennington IIIa8d40472022-01-25 16:13:00 -080025
26override=/run/systemd/system/gbmc-br-dhcp.service.d/10-direct.conf
27mkdir -p "$(dirname "$override")"
28echo '[Service]' >"$override"
29echo 'ExecStart=' >>"$override"
30# Switch the gbmcbr interface for the NCSI one to avoid passing the SOLICIT
31# message through the BMC relay.
William A. Kennington IIId5a68df2022-06-29 16:55:07 -070032grep '^ExecStart=' /lib/systemd/system/gbmc-br-dhcp.service | \
33 sed 's, -i gbmcbr, -i @NCSI_IF@,' >>"$override"
William A. Kennington IIIa8d40472022-01-25 16:13:00 -080034
William A. Kennington III71fc1892021-12-13 14:32:20 -080035systemctl daemon-reload
36systemctl reset-failed gbmc-ncsi-dhcrelay
37systemctl restart --no-block gbmc-ncsi-dhcrelay
William A. Kennington IIIa8d40472022-01-25 16:13:00 -080038systemctl reset-failed gbmc-br-dhcp
39systemctl restart --no-block gbmc-br-dhcp
William A. Kennington III71fc1892021-12-13 14:32:20 -080040
41read -r -d '' contents <<EOF
42table inet filter {
43 chain ncsi_legacy_input {
William A. Kennington IIIa8d40472022-01-25 16:13:00 -080044 udp dport {546,547} accept
William A. Kennington III71fc1892021-12-13 14:32:20 -080045 }
46}
47EOF
48rfile=/run/nftables/60-gbmc-ncsi-ra.rules
49mkdir -p "$(dirname "$rfile")"
50printf '%s' "$contents" >"$rfile"
51systemctl reset-failed nftables
52systemctl --no-block reload-or-restart nftables