William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 1 | SUMMARY = "Configures the gbmc bridge and filter rules" |
| 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 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 8 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 9 | SRC_URI += " \ |
William A. Kennington III | eda6f00 | 2021-05-11 03:09:54 -0700 | [diff] [blame] | 10 | file://-bmc-gbmcbr.netdev \ |
| 11 | file://-bmc-gbmcbr.network.in \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 12 | file://-bmc-gbmcbrdummy.netdev \ |
| 13 | file://-bmc-gbmcbrdummy.network \ |
| 14 | file://+-bmc-gbmcbrusb.network \ |
| 15 | file://ipmi.service.in \ |
| 16 | file://50-gbmc-br.rules \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame] | 17 | file://gbmc-br-ula.sh \ |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 18 | file://gbmc-br-from-ra.sh \ |
| 19 | file://gbmc-br-ensure-ra.sh \ |
| 20 | file://gbmc-br-ensure-ra.service \ |
William A. Kennington III | cd40c7e | 2021-05-05 14:44:41 -0700 | [diff] [blame] | 21 | file://gbmc-br-gw-src.sh \ |
William A. Kennington III | 53527f3 | 2021-04-27 13:05:45 -0700 | [diff] [blame] | 22 | file://gbmc-br-nft.sh \ |
William A. Kennington III | b174c18 | 2021-11-03 14:54:51 -0700 | [diff] [blame] | 23 | file://gbmc-br-dhcp.sh \ |
| 24 | file://gbmc-br-dhcp.service \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 25 | " |
| 26 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 27 | FILES:${PN}:append = " \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame] | 28 | ${datadir}/gbmc-ip-monitor \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 29 | ${systemd_unitdir}/network \ |
| 30 | ${sysconfdir}/nftables \ |
| 31 | ${sysconfdir}/avahi/services \ |
| 32 | " |
| 33 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 34 | RDEPENDS:${PN}:append = " \ |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 35 | bash \ |
William A. Kennington III | 7e2d05d | 2022-02-12 15:36:05 -0800 | [diff] [blame] | 36 | dhcp-done \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame] | 37 | gbmc-ip-monitor \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 38 | mstpd-mstpd \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame] | 39 | network-sh \ |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 40 | ndisc6-rdisc6 \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 41 | " |
| 42 | |
William A. Kennington III | b174c18 | 2021-11-03 14:54:51 -0700 | [diff] [blame] | 43 | SYSTEMD_SERVICE:${PN} += " \ |
| 44 | gbmc-br-ensure-ra.service \ |
| 45 | gbmc-br-dhcp.service \ |
| 46 | " |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 47 | |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 48 | GBMC_BR_MAC_ADDR ?= "" |
| 49 | |
| 50 | # Generated via https://cd34.com/rfc4193/ based on a MAC from a machine I own |
| 51 | # and we allocated it downstream. Intended to only be used within a complete |
| 52 | # system of multiple network endpoints. |
| 53 | GBMC_ULA_PREFIX = "fdb5:0481:10ce:0" |
| 54 | |
| 55 | def mac_to_eui64(mac): |
| 56 | if not mac: |
| 57 | return '' |
| 58 | b = [int(c, 16) for c in mac.split(':')] |
| 59 | b[0] ^= 2 |
| 60 | b.insert(3, 0xfe) |
| 61 | b.insert(3, 0xff) |
| 62 | idx = range(0, len(b)-1, 2) |
| 63 | return ':'.join([format((b[i] << 8) + b[i+1], '04x') for i in idx]) |
| 64 | |
| 65 | do_install() { |
| 66 | netdir=${D}${systemd_unitdir}/network |
| 67 | install -d -m0755 $netdir |
| 68 | |
| 69 | if [ ! -z "${GBMC_BR_MAC_ADDR}" ]; then |
William A. Kennington III | 8a5853a | 2021-05-12 18:01:22 -0700 | [diff] [blame] | 70 | sfx='${@mac_to_eui64(GBMC_BR_MAC_ADDR)}' |
| 71 | addr="Address=${GBMC_ULA_PREFIX}:$sfx/64\nAddress=fe80::$sfx/64" |
William A. Kennington III | eda6f00 | 2021-05-11 03:09:54 -0700 | [diff] [blame] | 72 | sed -i "s,@ADDR@,$addr," ${WORKDIR}/-bmc-gbmcbr.network.in |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 73 | else |
William A. Kennington III | eda6f00 | 2021-05-11 03:09:54 -0700 | [diff] [blame] | 74 | sed -i '/@ADDR@/d' ${WORKDIR}/-bmc-gbmcbr.network.in |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 75 | fi |
| 76 | |
William A. Kennington III | eda6f00 | 2021-05-11 03:09:54 -0700 | [diff] [blame] | 77 | install -m0644 ${WORKDIR}/-bmc-gbmcbr.netdev $netdir/ |
| 78 | install -m0644 ${WORKDIR}/-bmc-gbmcbr.network.in $netdir/-bmc-gbmcbr.network |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 79 | install -m0644 ${WORKDIR}/-bmc-gbmcbrdummy.netdev $netdir/ |
| 80 | install -m0644 ${WORKDIR}/-bmc-gbmcbrdummy.network $netdir/ |
| 81 | install -m0644 ${WORKDIR}/+-bmc-gbmcbrusb.network $netdir/ |
| 82 | |
| 83 | nftables_dir=${D}${sysconfdir}/nftables |
| 84 | install -d -m0755 "$nftables_dir" |
| 85 | install -m0644 ${WORKDIR}/50-gbmc-br.rules $nftables_dir/ |
| 86 | |
| 87 | avahi_dir=${D}${sysconfdir}/avahi/services |
| 88 | install -d -m 0755 "$avahi_dir" |
| 89 | sed -i 's,@MACHINE@,${MACHINE},g' ${WORKDIR}/ipmi.service.in |
| 90 | sed -i 's,@EXTRA_ATTRS@,,g' ${WORKDIR}/ipmi.service.in |
| 91 | sed 's,@NAME@,bmc,g' ${WORKDIR}/ipmi.service.in >${avahi_dir}/bmc.ipmi.service |
| 92 | sed 's,@NAME@,${MACHINE}-bmc,g' ${WORKDIR}/ipmi.service.in >${avahi_dir}/${MACHINE}-bmc.ipmi.service |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame] | 93 | |
| 94 | mondir=${D}${datadir}/gbmc-ip-monitor |
| 95 | install -d -m0755 "$mondir" |
| 96 | install -m0644 ${WORKDIR}/gbmc-br-ula.sh "$mondir"/ |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 97 | install -m0644 ${WORKDIR}/gbmc-br-from-ra.sh "$mondir"/ |
William A. Kennington III | cd40c7e | 2021-05-05 14:44:41 -0700 | [diff] [blame] | 98 | install -m0644 ${WORKDIR}/gbmc-br-gw-src.sh "$mondir"/ |
William A. Kennington III | 53527f3 | 2021-04-27 13:05:45 -0700 | [diff] [blame] | 99 | install -m0644 ${WORKDIR}/gbmc-br-nft.sh "$mondir"/ |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 100 | |
| 101 | install -d -m0755 ${D}${libexecdir} |
| 102 | install -m0755 ${WORKDIR}/gbmc-br-ensure-ra.sh ${D}${libexecdir}/ |
William A. Kennington III | b174c18 | 2021-11-03 14:54:51 -0700 | [diff] [blame] | 103 | install -m0755 ${WORKDIR}/gbmc-br-dhcp.sh ${D}${libexecdir}/ |
William A. Kennington III | 2461556 | 2021-04-26 14:10:52 -0700 | [diff] [blame] | 104 | install -d -m0755 ${D}${systemd_system_unitdir} |
William A. Kennington III | bdccd86 | 2021-12-15 13:51:55 -0800 | [diff] [blame] | 105 | install -m0644 ${WORKDIR}/gbmc-br-ensure-ra.service ${D}${systemd_system_unitdir}/ |
| 106 | install -m0644 ${WORKDIR}/gbmc-br-dhcp.service ${D}${systemd_system_unitdir}/ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 107 | } |
William A. Kennington III | 16fcffb | 2021-05-12 18:52:20 -0700 | [diff] [blame] | 108 | |
Willy Tu | 4dd03ca | 2021-08-06 09:37:35 -0700 | [diff] [blame] | 109 | do_rm_work:prepend() { |
William A. Kennington III | 16fcffb | 2021-05-12 18:52:20 -0700 | [diff] [blame] | 110 | # HACK: Work around broken do_rm_work not properly calling rm with `--` |
| 111 | # It doesn't like filenames that start with `-` |
William A. Kennington III | 67f5063 | 2021-05-13 11:19:25 -0700 | [diff] [blame] | 112 | rm -rf -- ${WORKDIR}/-* |
William A. Kennington III | 16fcffb | 2021-05-12 18:52:20 -0700 | [diff] [blame] | 113 | } |