William A. Kennington III | 71fc189 | 2021-12-13 14:32:20 -0800 | [diff] [blame] | 1 | #!/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 III | ac01f53 | 2024-09-05 02:08:09 -0700 | [diff] [blame] | 16 | HAS_DHCRELAY='@GBMC_DHCP_RELAY@' |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 17 | |
| 18 | if [ "$HAS_DHCRELAY" = 1 ]; then |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 19 | # 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 III | 420c0bb | 2024-09-16 13:13:14 -0700 | [diff] [blame] | 22 | echo 'RP_FLAG=' >/run/gbmc-ncsi-dhcrelay.env |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 23 | systemctl reset-failed gbmc-ncsi-dhcrelay |
| 24 | systemctl restart --no-block gbmc-ncsi-dhcrelay |
| 25 | fi |
William A. Kennington III | 420c0bb | 2024-09-16 13:13:14 -0700 | [diff] [blame] | 26 | |
William A. Kennington III | 6dc6cd7 | 2024-10-31 00:25:21 -0700 | [diff] [blame] | 27 | echo '@NCSI_IF@' >>/run/gbmc-br-dhcp-intfs |
William A. Kennington III | 463eeb1 | 2024-11-01 12:03:03 -0700 | [diff] [blame] | 28 | if 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@ |
| 31 | fi |
William A. Kennington III | 71fc189 | 2021-12-13 14:32:20 -0800 | [diff] [blame] | 32 | |
| 33 | read -r -d '' contents <<EOF |
| 34 | table inet filter { |
| 35 | chain ncsi_legacy_input { |
William A. Kennington III | a8d4047 | 2022-01-25 16:13:00 -0800 | [diff] [blame] | 36 | udp dport {546,547} accept |
William A. Kennington III | 71fc189 | 2021-12-13 14:32:20 -0800 | [diff] [blame] | 37 | } |
| 38 | } |
| 39 | EOF |
| 40 | rfile=/run/nftables/60-gbmc-ncsi-ra.rules |
| 41 | mkdir -p "$(dirname "$rfile")" |
| 42 | printf '%s' "$contents" >"$rfile" |
| 43 | systemctl reset-failed nftables |
| 44 | systemctl --no-block reload-or-restart nftables |