blob: dea14f00bc62edc23f8e8fcc5d3c3f05334b23bb [file] [log] [blame]
William A. Kennington III832f02b2021-04-23 12:53:36 -07001SUMMARY = "Configures the gbmc bridge and filter rules"
2PR = "r1"
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
5
6inherit systemd
7
Willy Tu4dd03ca2021-08-06 09:37:35 -07008FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
William A. Kennington III832f02b2021-04-23 12:53:36 -07009SRC_URI += " \
William A. Kennington IIIeda6f002021-05-11 03:09:54 -070010 file://-bmc-gbmcbr.netdev \
11 file://-bmc-gbmcbr.network.in \
William A. Kennington III832f02b2021-04-23 12:53:36 -070012 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 IIIb08a9e62021-04-26 12:43:43 -070017 file://gbmc-br-ula.sh \
William A. Kennington III24615562021-04-26 14:10:52 -070018 file://gbmc-br-from-ra.sh \
19 file://gbmc-br-ensure-ra.sh \
20 file://gbmc-br-ensure-ra.service \
William A. Kennington IIIcd40c7e2021-05-05 14:44:41 -070021 file://gbmc-br-gw-src.sh \
William A. Kennington III53527f32021-04-27 13:05:45 -070022 file://gbmc-br-nft.sh \
William A. Kennington III832f02b2021-04-23 12:53:36 -070023 "
24
Willy Tu4dd03ca2021-08-06 09:37:35 -070025FILES:${PN}:append = " \
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070026 ${datadir}/gbmc-ip-monitor \
William A. Kennington III832f02b2021-04-23 12:53:36 -070027 ${systemd_unitdir}/network \
28 ${sysconfdir}/nftables \
29 ${sysconfdir}/avahi/services \
30 "
31
Willy Tu4dd03ca2021-08-06 09:37:35 -070032RDEPENDS:${PN}:append = " \
William A. Kennington III24615562021-04-26 14:10:52 -070033 bash \
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070034 gbmc-ip-monitor \
William A. Kennington III832f02b2021-04-23 12:53:36 -070035 mstpd-mstpd \
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070036 network-sh \
William A. Kennington III24615562021-04-26 14:10:52 -070037 ndisc6-rdisc6 \
William A. Kennington III832f02b2021-04-23 12:53:36 -070038 "
39
Willy Tu4dd03ca2021-08-06 09:37:35 -070040SYSTEMD_SERVICE:${PN} += "gbmc-br-ensure-ra.service"
William A. Kennington III24615562021-04-26 14:10:52 -070041
William A. Kennington III832f02b2021-04-23 12:53:36 -070042GBMC_BR_MAC_ADDR ?= ""
43
44# Generated via https://cd34.com/rfc4193/ based on a MAC from a machine I own
45# and we allocated it downstream. Intended to only be used within a complete
46# system of multiple network endpoints.
47GBMC_ULA_PREFIX = "fdb5:0481:10ce:0"
48
49def mac_to_eui64(mac):
50 if not mac:
51 return ''
52 b = [int(c, 16) for c in mac.split(':')]
53 b[0] ^= 2
54 b.insert(3, 0xfe)
55 b.insert(3, 0xff)
56 idx = range(0, len(b)-1, 2)
57 return ':'.join([format((b[i] << 8) + b[i+1], '04x') for i in idx])
58
59do_install() {
60 netdir=${D}${systemd_unitdir}/network
61 install -d -m0755 $netdir
62
63 if [ ! -z "${GBMC_BR_MAC_ADDR}" ]; then
William A. Kennington III8a5853a2021-05-12 18:01:22 -070064 sfx='${@mac_to_eui64(GBMC_BR_MAC_ADDR)}'
65 addr="Address=${GBMC_ULA_PREFIX}:$sfx/64\nAddress=fe80::$sfx/64"
William A. Kennington IIIeda6f002021-05-11 03:09:54 -070066 sed -i "s,@ADDR@,$addr," ${WORKDIR}/-bmc-gbmcbr.network.in
William A. Kennington III832f02b2021-04-23 12:53:36 -070067 else
William A. Kennington IIIeda6f002021-05-11 03:09:54 -070068 sed -i '/@ADDR@/d' ${WORKDIR}/-bmc-gbmcbr.network.in
William A. Kennington III832f02b2021-04-23 12:53:36 -070069 fi
70
William A. Kennington IIIeda6f002021-05-11 03:09:54 -070071 install -m0644 ${WORKDIR}/-bmc-gbmcbr.netdev $netdir/
72 install -m0644 ${WORKDIR}/-bmc-gbmcbr.network.in $netdir/-bmc-gbmcbr.network
William A. Kennington III832f02b2021-04-23 12:53:36 -070073 install -m0644 ${WORKDIR}/-bmc-gbmcbrdummy.netdev $netdir/
74 install -m0644 ${WORKDIR}/-bmc-gbmcbrdummy.network $netdir/
75 install -m0644 ${WORKDIR}/+-bmc-gbmcbrusb.network $netdir/
76
77 nftables_dir=${D}${sysconfdir}/nftables
78 install -d -m0755 "$nftables_dir"
79 install -m0644 ${WORKDIR}/50-gbmc-br.rules $nftables_dir/
80
81 avahi_dir=${D}${sysconfdir}/avahi/services
82 install -d -m 0755 "$avahi_dir"
83 sed -i 's,@MACHINE@,${MACHINE},g' ${WORKDIR}/ipmi.service.in
84 sed -i 's,@EXTRA_ATTRS@,,g' ${WORKDIR}/ipmi.service.in
85 sed 's,@NAME@,bmc,g' ${WORKDIR}/ipmi.service.in >${avahi_dir}/bmc.ipmi.service
86 sed 's,@NAME@,${MACHINE}-bmc,g' ${WORKDIR}/ipmi.service.in >${avahi_dir}/${MACHINE}-bmc.ipmi.service
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070087
88 mondir=${D}${datadir}/gbmc-ip-monitor
89 install -d -m0755 "$mondir"
90 install -m0644 ${WORKDIR}/gbmc-br-ula.sh "$mondir"/
William A. Kennington III24615562021-04-26 14:10:52 -070091 install -m0644 ${WORKDIR}/gbmc-br-from-ra.sh "$mondir"/
William A. Kennington IIIcd40c7e2021-05-05 14:44:41 -070092 install -m0644 ${WORKDIR}/gbmc-br-gw-src.sh "$mondir"/
William A. Kennington III53527f32021-04-27 13:05:45 -070093 install -m0644 ${WORKDIR}/gbmc-br-nft.sh "$mondir"/
William A. Kennington III24615562021-04-26 14:10:52 -070094
95 install -d -m0755 ${D}${libexecdir}
96 install -m0755 ${WORKDIR}/gbmc-br-ensure-ra.sh ${D}${libexecdir}/
97 install -d -m0755 ${D}${systemd_system_unitdir}
98 install -m0755 ${WORKDIR}/gbmc-br-ensure-ra.service ${D}${systemd_system_unitdir}/
William A. Kennington III832f02b2021-04-23 12:53:36 -070099}
William A. Kennington III16fcffb2021-05-12 18:52:20 -0700100
Willy Tu4dd03ca2021-08-06 09:37:35 -0700101do_rm_work:prepend() {
William A. Kennington III16fcffb2021-05-12 18:52:20 -0700102 # HACK: Work around broken do_rm_work not properly calling rm with `--`
103 # It doesn't like filenames that start with `-`
William A. Kennington III67f50632021-05-13 11:19:25 -0700104 rm -rf -- ${WORKDIR}/-*
William A. Kennington III16fcffb2021-05-12 18:52:20 -0700105}