blob: 80a42bd1723ed2371fa69024d52ab375bec52f78 [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
8FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
9SRC_URI += " \
10 file://-bmc-gbmcbr.netdev.in \
11 file://-bmc-gbmcbr.network \
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 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 III832f02b2021-04-23 12:53:36 -070021 "
22
23FILES_${PN}_append = " \
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070024 ${datadir}/gbmc-ip-monitor \
William A. Kennington III832f02b2021-04-23 12:53:36 -070025 ${systemd_unitdir}/network \
26 ${sysconfdir}/nftables \
27 ${sysconfdir}/avahi/services \
28 "
29
30RDEPENDS_${PN}_append = " \
William A. Kennington III24615562021-04-26 14:10:52 -070031 bash \
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070032 gbmc-ip-monitor \
William A. Kennington III832f02b2021-04-23 12:53:36 -070033 mstpd-mstpd \
William A. Kennington IIIb08a9e62021-04-26 12:43:43 -070034 network-sh \
William A. Kennington III24615562021-04-26 14:10:52 -070035 ndisc6-rdisc6 \
William A. Kennington III832f02b2021-04-23 12:53:36 -070036 "
37
William A. Kennington III24615562021-04-26 14:10:52 -070038SYSTEMD_SERVICE_${PN} += "gbmc-br-ensure-ra.service"
39
William A. Kennington III832f02b2021-04-23 12:53:36 -070040GBMC_BR_MAC_ADDR ?= ""
41
42# Generated via https://cd34.com/rfc4193/ based on a MAC from a machine I own
43# and we allocated it downstream. Intended to only be used within a complete
44# system of multiple network endpoints.
45GBMC_ULA_PREFIX = "fdb5:0481:10ce:0"
46
47def mac_to_eui64(mac):
48 if not mac:
49 return ''
50 b = [int(c, 16) for c in mac.split(':')]
51 b[0] ^= 2
52 b.insert(3, 0xfe)
53 b.insert(3, 0xff)
54 idx = range(0, len(b)-1, 2)
55 return ':'.join([format((b[i] << 8) + b[i+1], '04x') for i in idx])
56
57do_install() {
58 netdir=${D}${systemd_unitdir}/network
59 install -d -m0755 $netdir
60
61 if [ ! -z "${GBMC_BR_MAC_ADDR}" ]; then
William A. Kennington III7b6d7c92021-04-26 12:57:42 -070062 sed -i 's,@MAC@,Address=fe80::${@mac_to_eui64(GBMC_BR_MAC_ADDR)}/64,' \
63 ${WORKDIR}/-bmc-gbmcbr.netdev.in
William A. Kennington III832f02b2021-04-23 12:53:36 -070064 addr=${GBMC_ULA_PREFIX}:${@mac_to_eui64(GBMC_BR_MAC_ADDR)}/64
65 sed -i "s,@ADDR@,Address=$addr," ${WORKDIR}/-bmc-gbmcbr.netdev.in
66 else
67 sed -i '/@MAC@/d' ${WORKDIR}/-bmc-gbmcbr.netdev.in
68 sed -i '/@ADDR@/d' ${WORKDIR}/-bmc-gbmcbr.netdev.in
69 fi
70
71 install -m0644 ${WORKDIR}/-bmc-gbmcbr.netdev.in $netdir/-bmc-gbmcbr.netdev
72 install -m0644 ${WORKDIR}/-bmc-gbmcbr.network $netdir/
73 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"/
92
93 install -d -m0755 ${D}${libexecdir}
94 install -m0755 ${WORKDIR}/gbmc-br-ensure-ra.sh ${D}${libexecdir}/
95 install -d -m0755 ${D}${systemd_system_unitdir}
96 install -m0755 ${WORKDIR}/gbmc-br-ensure-ra.service ${D}${systemd_system_unitdir}/
William A. Kennington III832f02b2021-04-23 12:53:36 -070097}