mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
18477: gnrc_static: add static network configuration r=miri64 a=benpicco 19101: CI: update check-labels-action r=miri64 a=kaspar030 19155: Revert "sys/pm_layered: pm_(un)block add attribute optimize(3)" r=maribu a=Teufelchen1 Revert "sys/pm_layered: pm_(un)block add attribute optimize(3) -shortens hotpath" This reverts commit5447203921
. ### Contribution description Compiling `examples/gnrc_networking_mac` using `TOOLCHAIN=llvm` yields the following error: ``` RIOT/sys/pm_layered/pm.c:77:16: error: unknown attribute 'optimize' ignored [-Werror,-Wunknown-attributes] __attribute__((optimize(3))) ``` As indicated, this is because the attribute `optimize` is GCC only and not present in LLVM. Compare the manpages of [GCC](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html) and [LLVM](https://clang.llvm.org/docs/AttributeReference.html). ### Testing procedure Since this should only affect performance and not behavior, no special testing is needed. I am not aware of any tests in RIOT which could verify that assumption. ### Issues/PRs references Introduced in #18846 There is another instance of this attribute being used in[ shell_lock.c](6fb340d654/sys/shell_lock/shell_lock.c (L80)
). Since the usage is security related, I omit it from this PR. Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com> Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de> Co-authored-by: Teufelchen1 <bennet.blischke@haw-hamburg.de>
This commit is contained in:
commit
211db05401
5
.github/workflows/check-labels.yml
vendored
5
.github/workflows/check-labels.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: check-labels
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
types: [opened, reopened, labeled, unlabeled, synchronize]
|
||||
pull_request_review:
|
||||
types: [submitted, dismissed]
|
||||
@ -8,8 +8,9 @@ jobs:
|
||||
check-labels:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: RIOT-OS/check-labels-action@v1.0.0
|
||||
- uses: RIOT-OS/check-labels-action@v1.1.0
|
||||
with:
|
||||
access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
unset_labels: 'CI: needs squashing,State: waiting for CI update,State: waiting for other PR,Process: blocked by feature freeze'
|
||||
cond_labels: '(Process: needs >1 ACK,review.approvals>1),(Area: RDM,review.approvals>2)'
|
||||
missing_approvals_label: 'Process: missing approvals'
|
||||
|
@ -3,7 +3,8 @@
|
||||
pr_status = [
|
||||
"python-tests",
|
||||
"tools-build-success",
|
||||
"check-labels",
|
||||
# temporarily disabling while testing updated check-labels-action (#19101)
|
||||
# "check-labels",
|
||||
"static-tests",
|
||||
"check-commits (commit-msg)",
|
||||
"check-commits (pr_check)",
|
||||
|
@ -50,8 +50,8 @@ else
|
||||
endif
|
||||
|
||||
# Check if the selected method for prefix configuration is valid
|
||||
ifeq (,$(filter dhcpv6 uhcp auto_subnets,$(PREFIX_CONF)))
|
||||
$(error Supported methods for prefix configuration are `dhcpv6`, `uhcp` and `auto_subnets`)
|
||||
ifeq (,$(filter dhcpv6 uhcp auto_subnets static,$(PREFIX_CONF)))
|
||||
$(error Supported methods for prefix configuration are `dhcpv6`, `uhcp` `static` and `auto_subnets`)
|
||||
endif
|
||||
|
||||
ifeq (dhcpv6,$(PREFIX_CONF))
|
||||
@ -62,6 +62,10 @@ else ifeq (uhcp,$(PREFIX_CONF))
|
||||
USEMODULE += gnrc_uhcpc
|
||||
else ifeq (auto_subnets,$(PREFIX_CONF))
|
||||
USEMODULE += gnrc_ipv6_auto_subnets_simple
|
||||
else ifeq (static,$(PREFIX_CONF))
|
||||
IPV6_ADDR ?= 2001:db8:1::1
|
||||
IPV6_DEFAULT_ROUTER ?= fe80::1
|
||||
USEMODULE += gnrc_ipv6_static_addr
|
||||
endif
|
||||
|
||||
# Comment this out to disable code in RIOT that does safety checking
|
||||
@ -126,6 +130,16 @@ ifeq (dhcpv6,$(PREFIX_CONF))
|
||||
CFLAGS += -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=3
|
||||
endif
|
||||
endif
|
||||
else ifeq (static,$(PREFIX_CONF))
|
||||
ifndef CONFIG_GNRC_IPV6_STATIC_ADDR
|
||||
CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_ADDR=\"$(IPV6_ADDR)\"
|
||||
endif
|
||||
ifndef CONFIG_GNRC_IPV6_STATIC_PREFIX
|
||||
CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_PREFIX=\"$(IPV6_PREFIX)\"
|
||||
endif
|
||||
ifndef CONFIG_GNRC_IPV6_STATIC_DEFAULT_ROUTER
|
||||
CFLAGS += -DCONFIG_GNRC_IPV6_STATIC_DEFAULT_ROUTER=\"$(IPV6_DEFAULT_ROUTER)\"
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
@ -332,6 +332,11 @@ extern void auto_init_sock_dns(void);
|
||||
AUTO_INIT(auto_init_sock_dns,
|
||||
AUTO_INIT_PRIO_MOD_DOCK_DNS);
|
||||
#endif
|
||||
#if IS_USED(MODULE_GNRC_IPV6_STATIC_ADDR)
|
||||
extern void auto_init_gnrc_ipv6_static_addr(void);
|
||||
AUTO_INIT(auto_init_gnrc_ipv6_static_addr,
|
||||
AUTO_INIT_PRIO_MOD_GNRC_IPV6_STATIC_ADDR);
|
||||
#endif
|
||||
|
||||
void auto_init(void)
|
||||
{
|
||||
|
@ -365,6 +365,12 @@ extern "C" {
|
||||
*/
|
||||
#define AUTO_INIT_PRIO_MOD_DOCK_DNS 1550
|
||||
#endif
|
||||
#ifndef AUTO_INIT_PRIO_MOD_GNRC_IPV6_STATIC_ADDR
|
||||
/**
|
||||
* @brief Static network configuration priority
|
||||
*/
|
||||
#define AUTO_INIT_PRIO_MOD_GNRC_IPV6_STATIC_ADDR 1560
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ extern "C" {
|
||||
#if CONFIG_GNRC_IPV6_NIB_ROUTER && \
|
||||
(!CONFIG_GNRC_IPV6_NIB_6LR || CONFIG_GNRC_IPV6_NIB_6LBR) && \
|
||||
!(IS_USED(MODULE_DHCPV6_CLIENT_IA_PD) || IS_USED(MODULE_GNRC_UHCPC) || \
|
||||
IS_USED(MODULE_GNRC_IPV6_AUTO_SUBNETS))
|
||||
IS_USED(MODULE_GNRC_IPV6_AUTO_SUBNETS) || IS_USED(MODULE_GNRC_IPV6_STATIC_ADDR))
|
||||
#define CONFIG_GNRC_IPV6_NIB_ADV_ROUTER 1
|
||||
#else
|
||||
#define CONFIG_GNRC_IPV6_NIB_ADV_ROUTER 0
|
||||
|
@ -737,6 +737,22 @@ char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len
|
||||
*/
|
||||
ipv6_addr_t *ipv6_addr_from_str(ipv6_addr_t *result, const char *addr);
|
||||
|
||||
/**
|
||||
* @brief Converts an IPv6 prefix string representation to a byte-represented
|
||||
* IPv6 address
|
||||
*
|
||||
* @see <a href="https://tools.ietf.org/html/rfc5952">
|
||||
* RFC 5952
|
||||
* </a>
|
||||
*
|
||||
* @param[out] result The resulting byte representation
|
||||
* @param[in] prefix An IPv6 prefix string representation
|
||||
*
|
||||
* @return prefix length in bits, on success
|
||||
* @return <0 on error
|
||||
*/
|
||||
int ipv6_prefix_from_str(ipv6_addr_t *result, const char *prefix);
|
||||
|
||||
/**
|
||||
* @brief Converts an IPv6 address from a buffer of characters to a
|
||||
* byte-represented IPv6 address
|
||||
|
@ -88,6 +88,9 @@ endif
|
||||
ifneq (,$(filter gnrc_rpl_p2p,$(USEMODULE)))
|
||||
DIRS += routing/rpl/p2p
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_static_addr,$(USEMODULE)))
|
||||
DIRS += network_layer/ipv6/static_addr
|
||||
endif
|
||||
ifneq (,$(filter gnrc_ipv6_auto_subnets,$(USEMODULE)))
|
||||
DIRS += routing/ipv6_auto_subnets
|
||||
endif
|
||||
|
@ -28,5 +28,6 @@ rsource "blacklist/Kconfig"
|
||||
rsource "ext/frag/Kconfig"
|
||||
rsource "nib/Kconfig"
|
||||
rsource "whitelist/Kconfig"
|
||||
rsource "static_addr/Kconfig"
|
||||
|
||||
endmenu # IPv6
|
||||
|
35
sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig
Normal file
35
sys/net/gnrc/network_layer/ipv6/static_addr/Kconfig
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2022 ML!PA Consulting GmbH
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
#
|
||||
menuconfig KCONFIG_USEMODULE_GNRC_IPV6_STATIC_ADDR
|
||||
bool "Configure static IPv6 addresses and routes"
|
||||
depends on USEMODULE_GNRC_IPV6_STATIC_ADDR
|
||||
help
|
||||
Configure GNRC IPv6 Whitelisting module using Kconfig.
|
||||
|
||||
if KCONFIG_USEMODULE_GNRC_IPV6_STATIC_ADDR
|
||||
|
||||
config GNRC_IPV6_STATIC_ADDR
|
||||
string "Static IPv6 address of the upstream interface"
|
||||
default "2001:db8::100"
|
||||
|
||||
config GNRC_IPV6_STATIC_ADDR_UPSTREAM
|
||||
int "ID of the upstream interface, use 0 to auto-select wired interface"
|
||||
default 0
|
||||
|
||||
config GNRC_IPV6_STATIC_PREFIX
|
||||
string "Static IPv6 prefix for the downstream network"
|
||||
default "2001:db8:8000::/48"
|
||||
|
||||
config GNRC_IPV6_STATIC_ADDR_DOWNSTREAM
|
||||
int "ID of the downstream interface, use 0 to auto-select wireless interface"
|
||||
default 0
|
||||
|
||||
config GNRC_IPV6_STATIC_DEFAULT_ROUTER
|
||||
string "Static IPv6 address of the default router"
|
||||
default "2001:db8::1"
|
||||
|
||||
endif # KCONFIG_USEMODULE_GNRC_IPV6_STATIC_ADDR
|
3
sys/net/gnrc/network_layer/ipv6/static_addr/Makefile
Normal file
3
sys/net/gnrc/network_layer/ipv6/static_addr/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = gnrc_ipv6_static_addr
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2022 ML!PA Consulting GmbH
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
*/
|
||||
|
||||
#include "net/gnrc/ipv6/nib.h"
|
||||
#include "net/gnrc/ipv6.h"
|
||||
#include "net/gnrc/netapi.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc/rpl.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/netdev.h"
|
||||
#include "net/netopt.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* @brief ID of the upstream interface, set to 0 to attempt auto-select
|
||||
*/
|
||||
#ifndef CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM
|
||||
#define CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief ID of the downstream interface, set to 0 to attempt auto-select
|
||||
*/
|
||||
#ifndef CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM
|
||||
#define CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM 0
|
||||
#endif
|
||||
|
||||
static void _config_upstream(gnrc_netif_t *upstream)
|
||||
{
|
||||
ipv6_addr_t addr;
|
||||
|
||||
const char *static_addr =
|
||||
#ifdef CONFIG_GNRC_IPV6_STATIC_ADDR
|
||||
CONFIG_GNRC_IPV6_STATIC_ADDR;
|
||||
#else
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
const char *static_route =
|
||||
#ifdef CONFIG_GNRC_IPV6_STATIC_DEFAULT_ROUTER
|
||||
CONFIG_GNRC_IPV6_STATIC_DEFAULT_ROUTER;
|
||||
#else
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
DEBUG("gnrc_ipv6_static_addr: interface %u selected as upstream\n", upstream->pid);
|
||||
|
||||
/* configure static address */
|
||||
int addr_len;
|
||||
if (static_addr != NULL &&
|
||||
(addr_len = ipv6_prefix_from_str(&addr, static_addr)) > 0) {
|
||||
gnrc_netif_ipv6_addr_add_internal(upstream, &addr, addr_len,
|
||||
GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID);
|
||||
}
|
||||
|
||||
/* configure static route */
|
||||
if (static_route != NULL &&
|
||||
ipv6_addr_from_str(&addr, static_route) != NULL) {
|
||||
gnrc_ipv6_nib_ft_add(&addr, 0, &addr, upstream->pid, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void _config_downstream(gnrc_netif_t *downstream)
|
||||
{
|
||||
const char *static_prefix =
|
||||
#ifdef CONFIG_GNRC_IPV6_STATIC_PREFIX
|
||||
CONFIG_GNRC_IPV6_STATIC_PREFIX;
|
||||
#else
|
||||
NULL;
|
||||
#endif
|
||||
|
||||
DEBUG("gnrc_ipv6_static_addr: interface %u selected as downstream\n", downstream->pid);
|
||||
|
||||
if (CONFIG_GNRC_IPV6_STATIC_PREFIX == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ipv6_addr_t prefix;
|
||||
int len = ipv6_prefix_from_str(&prefix, static_prefix);
|
||||
if (len <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* configure subnet on downstream interface */
|
||||
int idx = gnrc_netif_ipv6_add_prefix(downstream, &prefix, len,
|
||||
UINT32_MAX, UINT32_MAX);
|
||||
if (idx < 0) {
|
||||
DEBUG("gnrc_ipv6_static_addr: adding prefix to %u failed\n", downstream->pid);
|
||||
return;
|
||||
}
|
||||
|
||||
/* start advertising subnet */
|
||||
gnrc_ipv6_nib_change_rtr_adv_iface(downstream, true);
|
||||
|
||||
/* configure RPL root if applicable */
|
||||
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)) {
|
||||
gnrc_rpl_configure_root(downstream, &downstream->ipv6.addrs[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
void auto_init_gnrc_ipv6_static_addr(void)
|
||||
{
|
||||
gnrc_netif_t *netif = NULL;
|
||||
gnrc_netif_t *upstream = NULL;
|
||||
gnrc_netif_t *downstream = NULL;
|
||||
|
||||
if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM)) {
|
||||
upstream = gnrc_netif_get_by_pid(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM);
|
||||
}
|
||||
|
||||
if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM)) {
|
||||
downstream = gnrc_netif_get_by_pid(CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM);
|
||||
}
|
||||
|
||||
while ((netif = gnrc_netif_iter(netif))) {
|
||||
bool is_wired = gnrc_netapi_get(netif->pid, NETOPT_IS_WIRED, 0, NULL, 0) == 1;
|
||||
|
||||
if (!upstream && is_wired) {
|
||||
upstream = netif;
|
||||
} else if (!downstream && !is_wired) {
|
||||
downstream = netif;
|
||||
}
|
||||
}
|
||||
|
||||
if (upstream) {
|
||||
_config_upstream(upstream);
|
||||
}
|
||||
|
||||
if (downstream) {
|
||||
_config_downstream(downstream);
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
@ -26,6 +26,7 @@
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -163,6 +164,34 @@ ipv6_addr_t *ipv6_addr_from_str(ipv6_addr_t *result, const char *addr)
|
||||
return ipv6_addr_from_buf(result, addr, strlen(addr));
|
||||
}
|
||||
|
||||
int ipv6_prefix_from_str(ipv6_addr_t *result, const char *addr)
|
||||
{
|
||||
size_t str_len;
|
||||
int pfx_len;
|
||||
const char *separator;
|
||||
|
||||
if ((result == NULL) || (addr == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((separator = strrchr(addr, '/')) == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
str_len = separator - addr;
|
||||
pfx_len = strtol(separator + 1, NULL, 10);
|
||||
|
||||
if (pfx_len <= 0) {
|
||||
return pfx_len;
|
||||
}
|
||||
|
||||
if (ipv6_addr_from_buf(result, addr, str_len) == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return pfx_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -74,7 +74,6 @@ void pm_set_lowest(void)
|
||||
irq_restore(state);
|
||||
}
|
||||
|
||||
__attribute__((optimize(3)))
|
||||
void pm_block(unsigned mode)
|
||||
{
|
||||
DEBUG("[pm_layered] pm_block(%d)\n", mode);
|
||||
@ -85,7 +84,6 @@ void pm_block(unsigned mode)
|
||||
irq_restore(state);
|
||||
}
|
||||
|
||||
__attribute__((optimize(3)))
|
||||
void pm_unblock(unsigned mode)
|
||||
{
|
||||
DEBUG("[pm_layered] pm_unblock(%d)\n", mode);
|
||||
|
Loading…
Reference in New Issue
Block a user