Files
openthread/script/check-size
T
Abtin Keshavarzian 966baf5e6b [net] SRP client implementation (#6038)
This commit adds support for SRP (Service Registration Protocol)
client in OpenThread. The implementation allows a user to provide host
info (host name and a list of host IPv6 addresses) along with a list
of services to be registered with an SRP server. Services and/or host
addresses can be added or removed during operation of client.

Users can get the list of services and host info and their current
state (indicating, for example, if service is registered with server,
being registered or being removed, etc). Users can also provide a
callback to get notified whenever there is change or an error.

When there is a new request (e.g., a new service is added/removed)
that requires an update, the SRP client will wait for a short delay
before preparing and sending an SRP update message to server. This
allows user to provide more changes that are then all sent in the same
update message. The implementation handles retries in case of
different errors and failures. An exponentially increasing retry wait
interval (with configurable min, max, and growth factor) is
implemented.

The implementation also manages the lease renew time for each service
and refreshes (re-registers) services with server before lease is
expired. It supports "opportunistic early refresh" mechanism such that
when sending an SRP update, the services that are not yet expired but
are close, are allowed to refresh early and are included in the SRP
update. This helps place more services on the same lease refresh
schedule reducing number of messages sent to the SRP server. This
behavior (whether to allow early refresh or not, and its related
parameters) can be controlled through a set of OT config definitions.
2021-01-22 13:19:21 -08:00

237 lines
8.6 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2019, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set -euo pipefail
readonly OT_TMP_DIR=/tmp/ot-size-report
readonly OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
readonly OT_SHA_OLD="$(git cat-file -p "${OT_SHA_NEW}" | grep 'parent ' | head -n1 | cut -d' ' -f2)"
readonly OT_REPORT_FILE=/tmp/size_report
setup_arm_gcc_7()
{
if arm-none-eabi-gcc --version | grep -q 'Arm Embedded Processors 7'; then
return 0
fi
(cd /tmp/ \
&& wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2 \
&& tar xjf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2)
export PATH=/tmp/gcc-arm-none-eabi-7-2018-q2-update/bin:$PATH
arm-none-eabi-gcc --version
}
setup()
{
setup_arm_gcc_7
}
markdown_init()
{
echo '| name | branch | text | data | bss | total |'
echo '| :----: | :------: | -----: | ----: | ---: | ----: |'
}
markdown_size()
{
local name
name=$(basename "$1")
read -r -a size_old <<<"$(size "$1" | awk '{text+=$1} {bss+=$2} {data+=$3} {total+=$4} END {printf "%d %d %d %d", text, bss, data, total}')"
read -r -a size_new <<<"$(size "$2" | awk '{text+=$1} {bss+=$2} {data+=$3} {total+=$4} END {printf "%d %d %d %d", text, bss, data, total}')"
local -a size_diff
for i in 0 1 2 3; do
size_diff[$i]="$((size_new["$i"] - size_old["$i"]))"
if [[ ${size_diff["$i"]} != 0 ]]; then
size_diff["$i"]=$(printf '%+d' "${size_diff["$i"]}")
fi
done
echo "| ${name} | -${OT_SHA_OLD:0:7} | ${size_old[0]} | ${size_old[1]} | ${size_old[2]} | ${size_old[3]} |"
echo "| | +${OT_SHA_NEW:0:7} | ${size_new[0]} | ${size_new[1]} | ${size_new[2]} | ${size_new[3]} |"
echo "| | +/- | ${size_diff[0]} | ${size_diff[1]} | ${size_diff[2]} | ${size_diff[3]} |"
}
markdown()
{
case "$1" in
init)
shift
markdown_init "$@" >"${OT_REPORT_FILE}"
;;
size)
shift
markdown_size "$@" >>"${OT_REPORT_FILE}"
;;
post)
mdv "${OT_REPORT_FILE}"
;;
esac
}
size_nrf52840_version()
{
local flags=(
"BORDER_AGENT=1"
"BORDER_ROUTER=1"
"CHANNEL_MANAGER=1"
"CHANNEL_MONITOR=1"
"CHILD_SUPERVISION=1"
"COAP=1"
"COAPS=1"
"COMMISSIONER=1"
"DATASET_UPDATER=1"
"DHCP6_CLIENT=1"
"DHCP6_SERVER=1"
"DIAGNOSTIC=1"
"DISABLE_DOC=1"
"DNS_CLIENT=1"
"ECDSA=1"
"FULL_LOGS=1"
"JAM_DETECTION=1"
"JOINER=1"
"LINK_RAW=1"
"MAC_FILTER=1"
"MESSAGE_USE_HEAP=1"
"MTD_NETDIAG=1"
"SERVICE=1"
"SLAAC=1"
"SNTP_CLIENT=1"
"SRP_CLIENT=1"
"TIME_SYNC=1"
"UDP_FORWARD=1"
)
local thread_version=$1
if [[ ${thread_version} == "1.2" ]]; then
flags+=(
"THREAD_VERSION=1.2"
"BACKBONE_ROUTER=1"
"DUA=1"
"MLR=1"
"CSL_RECEIVER=1"
"LINK_METRICS=1"
)
fi
rm -rf "${OT_TMP_DIR}"
# new commit
mkdir -p "${OT_TMP_DIR}/b"
git archive "${OT_SHA_NEW}" | tar x -C "${OT_TMP_DIR}/b"
(cd "${OT_TMP_DIR}/b" \
&& ./bootstrap \
&& make -f examples/Makefile-nrf52840 "${flags[@]}")
# old commit
if [[ "${GITHUB_ACTIONS+x}" ]]; then
git fetch --depth 1 --no-recurse-submodules origin "${OT_SHA_OLD}"
fi
mkdir -p "${OT_TMP_DIR}/a"
git archive "${OT_SHA_OLD}" | tar x -C "${OT_TMP_DIR}/a"
(cd "${OT_TMP_DIR}/a" \
&& ./bootstrap \
&& make -f examples/Makefile-nrf52840 "${flags[@]}")
# rename the generated files to be ready for size-report
# shellcheck disable=SC2011
(
cd "${OT_TMP_DIR}"/a/output/nrf52840/bin
ls | xargs -I{} mv {} {}_"${thread_version}"
cd "${OT_TMP_DIR}"/b/output/nrf52840/bin
ls | xargs -I{} mv {} {}_"${thread_version}"
cd "${OT_TMP_DIR}"/a/output/nrf52840/lib/
ls ./*.a | xargs -I{} mv {} {}_"${thread_version}"
cd "${OT_TMP_DIR}"/b/output/nrf52840/lib/
ls ./*.a | xargs -I{} mv {} {}_"${thread_version}"
)
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-cli-ftd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-cli-ftd_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-cli-mtd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-cli-mtd_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-ncp-ftd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-ncp-ftd_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-ncp-mtd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-ncp-mtd_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-rcp_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-rcp_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-cli-ftd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-cli-ftd.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-cli-mtd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-cli-mtd.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ftd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ftd.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-mtd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-mtd.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ncp-ftd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ncp-ftd.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ncp-mtd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ncp-mtd.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-rcp.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-rcp.a_"${thread_version}"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-radio.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-radio.a_"${thread_version}"
}
size_nrf52840()
{
local reporter
# not on GitHub Actions or not a pull request event
if [[ ! ${GITHUB_ACTIONS+x} || ! ${GITHUB_REF-} =~ ^refs/pull/[0-9]+/merge ]]; then
reporter=markdown
else
reporter=./size-report
curl -s --retry 5 "${SIZE_REPORT_URL}/bash" >size-report
chmod a+x size-report
export OT_SHA_NEW OT_SHA_OLD
fi
"${reporter}" init OpenThread
size_nrf52840_version 1.1
size_nrf52840_version 1.2
"${reporter}" post
}
main()
{
if [[ $# == 0 ]]; then
setup
size_nrf52840
elif [[ $1 == setup ]]; then
setup
elif [[ $1 == nrf52840 ]]; then
size_nrf52840
else
echo "USAGE: $0 [setup|nrf52840]"
exit 128
fi
}
main "$@"