* [PATCH v2] Fix radvd startup
@ 2018-02-10 12:14 Jonatan Schlag
2018-02-11 20:00 ` Michael Tremer
0 siblings, 1 reply; 2+ messages in thread
From: Jonatan Schlag @ 2018-02-10 12:14 UTC (permalink / raw)
To: network
[-- Attachment #1: Type: text/plain, Size: 2685 bytes --]
We now only start radvd when we write a config for a zone into the config
file.
Fixes: #11450
Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
src/functions/functions.radvd | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/functions/functions.radvd b/src/functions/functions.radvd
index 4e41160..1c8b8d0 100644
--- a/src/functions/functions.radvd
+++ b/src/functions/functions.radvd
@@ -23,16 +23,16 @@ RADVD_CONFIGFILE="/etc/radvd.conf"
radvd_update() {
# (Re-)write the configuration file
- radvd_write_config
-
- # Reload the radvd service if it is already running
- if service_is_active radvd; then
- service_reload radvd
- return ${EXIT_OK}
+ if radvd_write_config; then
+ # Reload the radvd service if it is already running
+ if service_is_active radvd; then
+ service_reload radvd
+ return ${EXIT_OK}
+ fi
+
+ # Start the radvd service
+ service_start radvd
fi
-
- # Start the radvd service
- service_start radvd
}
radvd_clear_config() {
@@ -48,14 +48,21 @@ radvd_write_config() {
# Write the configuration for all zones.
local zone
- for zone in $(zones_get_local); do
- __radvd_config_interface ${zone}
+ # The return value determine if radvd is started or not
+ local return_value=${EXIT_FALSE}
+
+ for zone in $(zones_get_local); do
+ if __radvd_config_interface ${zone}; then
+ # We return TRUE when __radvd_config_interface returns True
+ return_value=${EXIT_TRUE}
+ fi
done >> ${RADVD_CONFIGFILE}
- return ${EXIT_OK}
+ return ${return_value}
}
+# This function return ${EXIT_FALSE} if no radvd config was written and ${EXIT_TRUE} in all other cases
__radvd_config_interface() {
local zone=${1}
assert isset zone
@@ -65,17 +72,17 @@ __radvd_config_interface() {
# If the interface does not provide any routing information,
# we can skip this whole stuff.
if ! db_exists "${zone}/ipv6"; then
- return ${EXIT_OK}
+ return ${EXIT_FALSE}
fi
# Skip if zone is not active.
local active="$(db_get "${zone}/ipv6/active")"
- [ "${active}" = "0" ] && return ${EXIT_OK}
+ [ "${active}" = "0" ] && return ${EXIT_FALSE}
# Skip if there is no prefix or prefix is link-local.
local addr="$(db_get "${zone}/ipv6/local-ip-address")"
if [ -z "${addr}" ] || [ "${addr:0:5}" = "fe80:" ]; then
- return ${EXIT_OK}
+ return ${EXIT_FALSE}
fi
# Check if the subnet is configured by the DHCP server.
@@ -116,6 +123,8 @@ __radvd_config_interface() {
print "};"
print
+
+ return ${EXIT_TRUE}
}
__radvd_config_dns() {
--
2.6.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Fix radvd startup
2018-02-10 12:14 [PATCH v2] Fix radvd startup Jonatan Schlag
@ 2018-02-11 20:00 ` Michael Tremer
0 siblings, 0 replies; 2+ messages in thread
From: Michael Tremer @ 2018-02-11 20:00 UTC (permalink / raw)
To: network
[-- Attachment #1: Type: text/plain, Size: 2941 bytes --]
Thank you. Merged.
On Sat, 2018-02-10 at 12:14 +0000, Jonatan Schlag wrote:
> We now only start radvd when we write a config for a zone into the config
> file.
>
> Fixes: #11450
>
> Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
> ---
> src/functions/functions.radvd | 39 ++++++++++++++++++++++++---------------
> 1 file changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/src/functions/functions.radvd b/src/functions/functions.radvd
> index 4e41160..1c8b8d0 100644
> --- a/src/functions/functions.radvd
> +++ b/src/functions/functions.radvd
> @@ -23,16 +23,16 @@ RADVD_CONFIGFILE="/etc/radvd.conf"
>
> radvd_update() {
> # (Re-)write the configuration file
> - radvd_write_config
> -
> - # Reload the radvd service if it is already running
> - if service_is_active radvd; then
> - service_reload radvd
> - return ${EXIT_OK}
> + if radvd_write_config; then
> + # Reload the radvd service if it is already running
> + if service_is_active radvd; then
> + service_reload radvd
> + return ${EXIT_OK}
> + fi
> +
> + # Start the radvd service
> + service_start radvd
> fi
> -
> - # Start the radvd service
> - service_start radvd
> }
>
> radvd_clear_config() {
> @@ -48,14 +48,21 @@ radvd_write_config() {
>
> # Write the configuration for all zones.
> local zone
> - for zone in $(zones_get_local); do
> - __radvd_config_interface ${zone}
>
> + # The return value determine if radvd is started or not
> + local return_value=${EXIT_FALSE}
> +
> + for zone in $(zones_get_local); do
> + if __radvd_config_interface ${zone}; then
> + # We return TRUE when __radvd_config_interface returns True
> + return_value=${EXIT_TRUE}
> + fi
> done >> ${RADVD_CONFIGFILE}
>
> - return ${EXIT_OK}
> + return ${return_value}
> }
>
> +# This function return ${EXIT_FALSE} if no radvd config was written and ${EXIT_TRUE} in all other cases
> __radvd_config_interface() {
> local zone=${1}
> assert isset zone
> @@ -65,17 +72,17 @@ __radvd_config_interface() {
> # If the interface does not provide any routing information,
> # we can skip this whole stuff.
> if ! db_exists "${zone}/ipv6"; then
> - return ${EXIT_OK}
> + return ${EXIT_FALSE}
> fi
>
> # Skip if zone is not active.
> local active="$(db_get "${zone}/ipv6/active")"
> - [ "${active}" = "0" ] && return ${EXIT_OK}
> + [ "${active}" = "0" ] && return ${EXIT_FALSE}
>
> # Skip if there is no prefix or prefix is link-local.
> local addr="$(db_get "${zone}/ipv6/local-ip-address")"
> if [ -z "${addr}" ] || [ "${addr:0:5}" = "fe80:" ]; then
> - return ${EXIT_OK}
> + return ${EXIT_FALSE}
> fi
>
> # Check if the subnet is configured by the DHCP server.
> @@ -116,6 +123,8 @@ __radvd_config_interface() {
>
> print "};"
> print
> +
> + return ${EXIT_TRUE}
> }
>
> __radvd_config_dns() {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-11 20:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-10 12:14 [PATCH v2] Fix radvd startup Jonatan Schlag
2018-02-11 20:00 ` Michael Tremer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox