William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 1 | SUMMARY = "Configures ncsi for a gBMC system" |
| 2 | PR = "r1" |
| 3 | LICENSE = "Apache-2.0" |
| 4 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" |
| 5 | |
| 6 | inherit systemd |
| 7 | |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 8 | GBMC_NCSI_DHCP_RELAY ??= "${@'' if int(d.getVar('FLASH_SIZE')) < 65536 else '1'}" |
William A. Kennington III | d812230 | 2023-10-16 18:25:18 -0700 | [diff] [blame] | 9 | GBMC_NCSI_IF_OLD ??= "" |
William A. Kennington III | f0b88e2 | 2023-10-16 18:26:32 -0700 | [diff] [blame] | 10 | GBMC_NCSI_PURGE_ETC ??= "" |
William A. Kennington III | f31b5c6 | 2023-12-07 15:32:26 -0800 | [diff] [blame^] | 11 | GBMC_NCSI_DHCP_IMPERSONATE_HOST ??= "1" |
William A. Kennington III | d812230 | 2023-10-16 18:25:18 -0700 | [diff] [blame] | 12 | |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 13 | SRC_URI += " \ |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 14 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'file://-bmc-gbmcbrncsidhcp.netdev'} \ |
| 15 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'file://-bmc-gbmcbrncsidhcp.network'} \ |
| 16 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'file://-bmc-gbmcncsidhcp.netdev'} \ |
| 17 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'file://-bmc-gbmcncsidhcp.network'} \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 18 | file://50-gbmc-ncsi.rules.in \ |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 19 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'file://gbmc-ncsi-dhcrelay.service.in'} \ |
William A. Kennington III | c7454fb | 2021-09-14 16:01:37 -0700 | [diff] [blame] | 20 | file://gbmc-ncsi-ip-from-ra.service.in \ |
| 21 | file://gbmc-ncsi-ip-from-ra.sh.in \ |
William A. Kennington III | 71fc189 | 2021-12-13 14:32:20 -0800 | [diff] [blame] | 22 | file://gbmc-ncsi-smartnic-wa.sh.in \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 23 | file://gbmc-ncsi-sslh.socket.in \ |
| 24 | file://gbmc-ncsi-sslh.service \ |
William A. Kennington III | 1ef795b | 2021-03-10 18:59:12 -0800 | [diff] [blame] | 25 | file://gbmc-ncsi-nft.sh.in \ |
William A. Kennington III | e99168a | 2021-03-10 23:40:47 -0800 | [diff] [blame] | 26 | file://gbmc-ncsi-br-pub-addr.sh.in \ |
William A. Kennington III | 21e7e45 | 2021-11-05 01:31:59 -0700 | [diff] [blame] | 27 | file://gbmc-ncsi-br-deprecated-ips.sh.in \ |
Vivekanand Veeracholan | e3f3370 | 2021-06-16 15:29:15 -0700 | [diff] [blame] | 28 | file://gbmc-ncsi-set-nicenabled.service.in \ |
William A. Kennington III | 9f57cee | 2022-11-03 14:17:35 -0700 | [diff] [blame] | 29 | file://gbmc-ncsi-alias.service.in \ |
William A. Kennington III | 37e6f39 | 2022-05-16 16:19:11 -0700 | [diff] [blame] | 30 | file://50-gbmc-ncsi-clear-ip.sh.in \ |
William A. Kennington III | d812230 | 2023-10-16 18:25:18 -0700 | [diff] [blame] | 31 | file://gbmc-ncsi-old.service.in \ |
William A. Kennington III | f0b88e2 | 2023-10-16 18:26:32 -0700 | [diff] [blame] | 32 | file://gbmc-ncsi-purge.service.in \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 33 | " |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 34 | |
| 35 | S = "${WORKDIR}" |
| 36 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 37 | RDEPENDS:${PN} += " \ |
William A. Kennington III | b03ef8c | 2021-10-01 01:16:24 -0700 | [diff] [blame] | 38 | bash \ |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 39 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'dhcp-relay'} \ |
William A. Kennington III | 1ef795b | 2021-03-10 18:59:12 -0800 | [diff] [blame] | 40 | gbmc-ip-monitor \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 41 | ncsid \ |
William A. Kennington III | 5aa84b5 | 2021-11-15 15:20:13 -0800 | [diff] [blame] | 42 | network-sh \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 43 | nftables-systemd \ |
| 44 | sslh \ |
William A. Kennington III | 5aa84b5 | 2021-11-15 15:20:13 -0800 | [diff] [blame] | 45 | ndisc6-rdisc6 \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 46 | " |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 47 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 48 | FILES:${PN} += " \ |
William A. Kennington III | 37e6f39 | 2022-05-16 16:19:11 -0700 | [diff] [blame] | 49 | ${datadir}/gbmc-br-lib \ |
William A. Kennington III | 1ef795b | 2021-03-10 18:59:12 -0800 | [diff] [blame] | 50 | ${datadir}/gbmc-ip-monitor \ |
| 51 | ${systemd_unitdir} \ |
| 52 | " |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 53 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 54 | SYSTEMD_SERVICE:${PN} += " \ |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 55 | ${@'' if d.getVar('GBMC_NCSI_DHCP_RELAY') != '1' else 'gbmc-ncsi-dhcrelay.service'} \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 56 | gbmc-ncsi-sslh.service \ |
| 57 | gbmc-ncsi-sslh.socket \ |
Vivekanand Veeracholan | e3f3370 | 2021-06-16 15:29:15 -0700 | [diff] [blame] | 58 | gbmc-ncsi-set-nicenabled.service \ |
William A. Kennington III | c7454fb | 2021-09-14 16:01:37 -0700 | [diff] [blame] | 59 | gbmc-ncsi-ip-from-ra.service \ |
William A. Kennington III | d812230 | 2023-10-16 18:25:18 -0700 | [diff] [blame] | 60 | ${@'' if d.getVar('GBMC_NCSI_IF_OLD') == '' else 'gbmc-ncsi-old.service'} \ |
William A. Kennington III | f0b88e2 | 2023-10-16 18:26:32 -0700 | [diff] [blame] | 61 | ${@'' if d.getVar('GBMC_NCSI_PURGE_ETC') == '' else 'gbmc-ncsi-purge.service'} \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 62 | " |
| 63 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 64 | do_install:append() { |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 65 | if_name='${GBMC_NCSI_IF_NAME}' |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 66 | if [ -z "$if_name" ]; then |
| 67 | echo "Missing if_name" >&2 |
| 68 | exit 1 |
| 69 | fi |
| 70 | |
| 71 | install -d -m0755 ${D}${sysconfdir}/sysctl.d |
| 72 | echo "net.ipv6.conf.$if_name.accept_dad=0" \ |
| 73 | >>${D}${sysconfdir}/sysctl.d/25-gbmc-ncsi.conf |
| 74 | echo "net.ipv6.conf.$if_name.dad_transmits=0" \ |
| 75 | >>${D}${sysconfdir}/sysctl.d/25-gbmc-ncsi.conf |
| 76 | |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 77 | if [ "${GBMC_NCSI_DHCP_RELAY}" = 1 ]; then |
| 78 | install -d -m0755 ${D}${systemd_unitdir}/network |
| 79 | install -m0644 ${WORKDIR}/-bmc-gbmcbrncsidhcp.netdev \ |
| 80 | ${D}${systemd_unitdir}/network/ |
| 81 | install -m0644 ${WORKDIR}/-bmc-gbmcbrncsidhcp.network \ |
| 82 | ${D}${systemd_unitdir}/network/ |
| 83 | install -m0644 ${WORKDIR}/-bmc-gbmcncsidhcp.netdev \ |
| 84 | ${D}${systemd_unitdir}/network/ |
| 85 | install -m0644 ${WORKDIR}/-bmc-gbmcncsidhcp.network \ |
| 86 | ${D}${systemd_unitdir}/network/ |
| 87 | fi |
William A. Kennington III | 9674509 | 2021-08-06 00:06:42 -0700 | [diff] [blame] | 88 | |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 89 | netdir=${D}${systemd_unitdir}/network/00-bmc-$if_name.network.d |
| 90 | install -d -m0755 "$netdir" |
| 91 | echo '[Network]' >>"$netdir"/gbmc-ncsi.conf |
| 92 | echo 'DHCP=false' >>"$netdir"/gbmc-ncsi.conf |
| 93 | echo 'IPv6AcceptRA=false' >>"$netdir"/gbmc-ncsi.conf |
| 94 | echo 'LLMNR=false' >>"$netdir"/gbmc-ncsi.conf |
| 95 | echo 'MulticastDNS=false' >>"$netdir"/gbmc-ncsi.conf |
| 96 | echo 'LinkLocalAddressing=ipv6' >>"$netdir"/gbmc-ncsi.conf |
| 97 | |
| 98 | nftdir=${D}${sysconfdir}/nftables |
| 99 | install -d -m0755 "$nftdir" |
William A. Kennington III | 1ef795b | 2021-03-10 18:59:12 -0800 | [diff] [blame] | 100 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/50-gbmc-ncsi.rules.in \ |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 101 | >"$nftdir"/50-gbmc-ncsi.rules |
| 102 | |
| 103 | wantdir=${D}${systemd_system_unitdir}/multi-user.target.wants |
| 104 | install -d -m0755 "$wantdir" |
| 105 | ln -sv ../ncsid@.service "$wantdir"/ncsid@$if_name.service |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 106 | |
William A. Kennington III | 9f57cee | 2022-11-03 14:17:35 -0700 | [diff] [blame] | 107 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-alias.service.in \ |
| 108 | >${D}${systemd_system_unitdir}/gbmc-ncsi-alias.service |
| 109 | install -d -m0755 "${D}${systemd_system_unitdir}/nic-hostless@$if_name.target.wants" |
| 110 | ln -sv ../gbmc-ncsi-alias.service "${D}${systemd_system_unitdir}/nic-hostless@$if_name.target.wants"/ |
| 111 | install -d -m0755 "${D}${systemd_system_unitdir}/nic-hostful@$if_name.target.wants" |
| 112 | ln -sv ../gbmc-ncsi-alias.service "${D}${systemd_system_unitdir}/nic-hostful@$if_name.target.wants"/ |
| 113 | |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 114 | install -m 0644 ${WORKDIR}/gbmc-ncsi-sslh.service ${D}${systemd_system_unitdir} |
William A. Kennington III | 1ef795b | 2021-03-10 18:59:12 -0800 | [diff] [blame] | 115 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-sslh.socket.in \ |
William A. Kennington III | 7f11d1f | 2021-02-16 14:57:41 -0800 | [diff] [blame] | 116 | >${D}${systemd_system_unitdir}/gbmc-ncsi-sslh.socket |
William A. Kennington III | 1ef795b | 2021-03-10 18:59:12 -0800 | [diff] [blame] | 117 | |
| 118 | mondir=${D}${datadir}/gbmc-ip-monitor/ |
| 119 | install -d -m0755 $mondir |
| 120 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-nft.sh.in \ |
| 121 | >${WORKDIR}/gbmc-ncsi-nft.sh |
| 122 | install -m644 ${WORKDIR}/gbmc-ncsi-nft.sh $mondir |
William A. Kennington III | e99168a | 2021-03-10 23:40:47 -0800 | [diff] [blame] | 123 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-br-pub-addr.sh.in \ |
| 124 | >${WORKDIR}/gbmc-ncsi-br-pub-addr.sh |
| 125 | install -m644 ${WORKDIR}/gbmc-ncsi-br-pub-addr.sh $mondir |
William A. Kennington III | 21e7e45 | 2021-11-05 01:31:59 -0700 | [diff] [blame] | 126 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-br-deprecated-ips.sh.in \ |
| 127 | >${WORKDIR}/gbmc-ncsi-br-deprecated-ips.sh |
| 128 | install -m644 ${WORKDIR}/gbmc-ncsi-br-deprecated-ips.sh $mondir |
Vivekanand Veeracholan | e3f3370 | 2021-06-16 15:29:15 -0700 | [diff] [blame] | 129 | |
William A. Kennington III | 37e6f39 | 2022-05-16 16:19:11 -0700 | [diff] [blame] | 130 | brlibdir=${D}${datadir}/gbmc-br-lib/ |
| 131 | install -d -m0755 $brlibdir |
| 132 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/50-gbmc-ncsi-clear-ip.sh.in \ |
| 133 | >${WORKDIR}/50-gbmc-ncsi-clear-ip.sh |
| 134 | install -m644 ${WORKDIR}/50-gbmc-ncsi-clear-ip.sh $brlibdir |
William A. Kennington III | b174c18 | 2021-11-03 14:54:51 -0700 | [diff] [blame] | 135 | |
Vivekanand Veeracholan | e3f3370 | 2021-06-16 15:29:15 -0700 | [diff] [blame] | 136 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-set-nicenabled.service.in \ |
| 137 | >${D}${systemd_system_unitdir}/gbmc-ncsi-set-nicenabled.service |
William A. Kennington III | 9674509 | 2021-08-06 00:06:42 -0700 | [diff] [blame] | 138 | |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 139 | if [ "${GBMC_NCSI_DHCP_RELAY}" = "1" ]; then |
| 140 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-dhcrelay.service.in \ |
| 141 | >${D}${systemd_system_unitdir}/gbmc-ncsi-dhcrelay.service |
| 142 | fi |
William A. Kennington III | c7454fb | 2021-09-14 16:01:37 -0700 | [diff] [blame] | 143 | |
William A. Kennington III | d812230 | 2023-10-16 18:25:18 -0700 | [diff] [blame] | 144 | if [ -n "${GBMC_NCSI_IF_OLD}" ]; then |
| 145 | sed -e "s,@NCSI_IF@,$if_name,g" -e "s,@OLD_IF@,${GBMC_NCSI_IF_OLD},g" ${WORKDIR}/gbmc-ncsi-old.service.in \ |
| 146 | >${D}${systemd_system_unitdir}/gbmc-ncsi-old.service |
| 147 | fi |
| 148 | |
William A. Kennington III | f0b88e2 | 2023-10-16 18:26:32 -0700 | [diff] [blame] | 149 | if [ -n "${GBMC_NCSI_PURGE_ETC}" ]; then |
| 150 | sed -e "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-purge.service.in \ |
| 151 | >${D}${systemd_system_unitdir}/gbmc-ncsi-purge.service |
| 152 | fi |
| 153 | |
William A. Kennington III | c7454fb | 2021-09-14 16:01:37 -0700 | [diff] [blame] | 154 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-ip-from-ra.service.in \ |
| 155 | >${WORKDIR}/gbmc-ncsi-ip-from-ra.service |
| 156 | install -m0644 ${WORKDIR}/gbmc-ncsi-ip-from-ra.service ${D}${systemd_system_unitdir} |
| 157 | sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-ip-from-ra.sh.in \ |
| 158 | >${WORKDIR}/gbmc-ncsi-ip-from-ra.sh |
| 159 | install -d -m0755 ${D}${libexecdir} |
| 160 | install -m0755 ${WORKDIR}/gbmc-ncsi-ip-from-ra.sh ${D}${libexecdir}/ |
William A. Kennington III | 71fc189 | 2021-12-13 14:32:20 -0800 | [diff] [blame] | 161 | |
William A. Kennington III | 95e2e99 | 2023-11-08 17:13:19 -0800 | [diff] [blame] | 162 | sed -e "s,@NCSI_IF@,$if_name,g" -e "s,@GBMC_NCSI_DHCP_RELAY@,${GBMC_NCSI_DHCP_RELAY},g" \ |
| 163 | ${WORKDIR}/gbmc-ncsi-smartnic-wa.sh.in >${WORKDIR}/gbmc-ncsi-smartnic-wa.sh |
William A. Kennington III | 71fc189 | 2021-12-13 14:32:20 -0800 | [diff] [blame] | 164 | install -d -m0755 ${D}${bindir} |
| 165 | install -m0755 ${WORKDIR}/gbmc-ncsi-smartnic-wa.sh ${D}${bindir}/ |
William A. Kennington III | f31b5c6 | 2023-12-07 15:32:26 -0800 | [diff] [blame^] | 166 | |
| 167 | if [ '${GBMC_NCSI_DHCP_IMPERSONATE_HOST}' != 1 ]; then |
| 168 | ln -sv /dev/null ${D}${systemd_system_unitdir}/dhcp6@.service |
| 169 | ln -sv /dev/null ${D}${systemd_system_unitdir}/dhcp4@.service |
| 170 | fi |
William A. Kennington III | 9674509 | 2021-08-06 00:06:42 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | do_rm_work:prepend() { |
| 174 | # HACK: Work around broken do_rm_work not properly calling rm with `--` |
| 175 | # It doesn't like filenames that start with `-` |
| 176 | rm -rf -- ${WORKDIR}/-* |
William A. Kennington III | f19a838 | 2021-02-16 14:16:47 -0800 | [diff] [blame] | 177 | } |