public inbox for network@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH 1/7] settings: remove dot from log message
@ 2017-07-04 15:46 Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 2/7] inetcalc: do not print the default prefix Jonatan Schlag
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 812 bytes --]

The dots at the end of log messages can be confusing.
Especially behind variables,it is often unclear if the dot was part of the variable or not
which make debugging much harder.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/functions/functions.settings | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/functions/functions.settings b/src/functions/functions.settings
index 0e50bf1..9efbe8e 100644
--- a/src/functions/functions.settings
+++ b/src/functions/functions.settings
@@ -159,7 +159,7 @@ settings_write() {
 		return ${EXIT_ERROR}
 	fi
 
-	log DEBUG "Writing settings file ${settings_file}."
+	log DEBUG "Writing settings file '${settings_file}'."
 
 	mkdir -p $(dirname ${settings_file}) 2>/dev/null
 	> ${settings_file}
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/7] inetcalc: do not print the default prefix
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
@ 2017-07-04 15:46 ` Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 3/7] zone: add function to avoid multiple configs which are senseless Jonatan Schlag
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/inetcalc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/inetcalc.c b/src/inetcalc.c
index d08f0f3..da3444e 100644
--- a/src/inetcalc.c
+++ b/src/inetcalc.c
@@ -245,7 +245,10 @@ static void ip_address_print(const ip_address_t* ip) {
 	if (r)
 		return;
 
-	if (ip->prefix >= 0) {
+	int address_prefix = default_prefix(ip->family);
+
+	// Only print prefix when it is not the default one
+	if (ip->prefix != address_prefix) {
 		size_t len = strlen(buffer);
 		snprintf(buffer + len, sizeof(buffer) - len, "/%d", ip->prefix);
 	}
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/7] zone: add function to avoid multiple configs which are senseless
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 2/7] inetcalc: do not print the default prefix Jonatan Schlag
@ 2017-07-04 15:46 ` Jonatan Schlag
  2017-07-04 16:07   ` Michael Tremer
  2017-07-04 15:46 ` [PATCH 4/7] ipv4-dhcp: prevent multiple configs for the same zone Jonatan Schlag
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/functions/functions.zone | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/functions/functions.zone b/src/functions/functions.zone
index 058110d..f2c5ddc 100644
--- a/src/functions/functions.zone
+++ b/src/functions/functions.zone
@@ -1008,6 +1008,28 @@ zone_config_get_hook() {
 	print "${HOOK}"
 }
 
+zone_config_hook_is_configured() {
+	# Checks if a zone has already at least one config with the given hook.
+	# Returns True when yes and False when no
+
+	assert [ $# -eq 2 ]
+	local zone=${1}
+	local hook=${2}
+
+	local config
+	for config in $(zone_configs_list "${zone}"); do
+		local config_hook="$(zone_config_get_hook "${zone}" "${config}")"
+		assert isset config_hook
+		if [[ ${hook} == ${config_hook} ]]; then
+			return ${EXIT_TRUE}
+		fi
+
+	done
+
+	# If we get here the zone has no config with the given hook
+	return ${EXIT_FALSE}
+}
+
 zone_has_ip() {
 	device_has_ip $@
 }
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/7] ipv4-dhcp: prevent multiple configs for the same zone
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 2/7] inetcalc: do not print the default prefix Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 3/7] zone: add function to avoid multiple configs which are senseless Jonatan Schlag
@ 2017-07-04 15:46 ` Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 5/7] ipv6-dhcp: " Jonatan Schlag
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

It is senseless to configure the ipv4-dhcp hook
multiple times for a zone.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/ipv4-dhcp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/hooks/configs/ipv4-dhcp b/src/hooks/configs/ipv4-dhcp
index ef23082..39e0312 100644
--- a/src/hooks/configs/ipv4-dhcp
+++ b/src/hooks/configs/ipv4-dhcp
@@ -35,6 +35,11 @@ hook_new() {
 	local zone="${1}"
 	shift
 
+	if zone_config_hook_is_configured ${zone} "ipv4-dhcp"; then
+		log ERROR "You can configure the ipv4-dhcp hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
 	while [ $# -gt 0 ]; do
 		case "${1}" in
 			--delay=*)
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/7] ipv6-dhcp: prevent multiple configs for the same zone
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
                   ` (2 preceding siblings ...)
  2017-07-04 15:46 ` [PATCH 4/7] ipv4-dhcp: prevent multiple configs for the same zone Jonatan Schlag
@ 2017-07-04 15:46 ` Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 6/7] ipv6-auto: " Jonatan Schlag
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 690 bytes --]

It is senseless to configure the ipv6-dhcp hook
multiple times for a zone.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/ipv6-dhcp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/hooks/configs/ipv6-dhcp b/src/hooks/configs/ipv6-dhcp
index 03dbbf0..74ec765 100644
--- a/src/hooks/configs/ipv6-dhcp
+++ b/src/hooks/configs/ipv6-dhcp
@@ -27,6 +27,11 @@ hook_new() {
 	local zone="${1}"
 	shift
 
+	if zone_config_hook_is_configured ${zone} "ipv6-dhcp"; then
+		log ERROR "You can configure the ipv6-dhcp hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
 	zone_config_settings_write "${zone}" "${HOOK}"
 
 	exit ${EXIT_OK}
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/7] ipv6-auto: prevent multiple configs for the same zone
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
                   ` (3 preceding siblings ...)
  2017-07-04 15:46 ` [PATCH 5/7] ipv6-dhcp: " Jonatan Schlag
@ 2017-07-04 15:46 ` Jonatan Schlag
  2017-07-04 15:46 ` [PATCH 7/7] pppoe-server: " Jonatan Schlag
  2017-07-04 16:06 ` [PATCH 1/7] settings: remove dot from log message Michael Tremer
  6 siblings, 0 replies; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 690 bytes --]

It is senseless to configure the ipv6-auto hook
multiple times for a zone.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/ipv6-auto | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/hooks/configs/ipv6-auto b/src/hooks/configs/ipv6-auto
index 44cef48..c362797 100644
--- a/src/hooks/configs/ipv6-auto
+++ b/src/hooks/configs/ipv6-auto
@@ -34,6 +34,11 @@ hook_new() {
 	local zone="${1}"
 	shift
 
+	if zone_config_hook_is_configured ${zone} "ipv6-auto"; then
+		log ERROR "You can configure the ipv6-auto hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
 	while read arg; do
 		case "${arg}" in
 			--privacy-extensions=*)
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/7] pppoe-server: prevent multiple configs for the same zone
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
                   ` (4 preceding siblings ...)
  2017-07-04 15:46 ` [PATCH 6/7] ipv6-auto: " Jonatan Schlag
@ 2017-07-04 15:46 ` Jonatan Schlag
  2017-07-04 16:06 ` [PATCH 1/7] settings: remove dot from log message Michael Tremer
  6 siblings, 0 replies; 9+ messages in thread
From: Jonatan Schlag @ 2017-07-04 15:46 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 705 bytes --]

It is senseless to configure the ppoe-server hook
multiple times for a zone.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/pppoe-server | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server
index 6f95212..22e0906 100644
--- a/src/hooks/configs/pppoe-server
+++ b/src/hooks/configs/pppoe-server
@@ -52,6 +52,11 @@ hook_new() {
 	local zone=${1}
 	shift
 
+	if zone_config_hook_is_configured ${zone} "pppoe-server"; then
+		log ERROR "You can configure the pppoe-server hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
 	while [ $# -gt 0 ]; do
 		case "${1}" in
 			--dns-server=*)
-- 
2.6.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/7] settings: remove dot from log message
  2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
                   ` (5 preceding siblings ...)
  2017-07-04 15:46 ` [PATCH 7/7] pppoe-server: " Jonatan Schlag
@ 2017-07-04 16:06 ` Michael Tremer
  6 siblings, 0 replies; 9+ messages in thread
From: Michael Tremer @ 2017-07-04 16:06 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 981 bytes --]

Hi,

this commit message says that you removed the dot, but it is still
there...

-Michael

On Tue, 2017-07-04 at 17:46 +0200, Jonatan Schlag wrote:
> The dots at the end of log messages can be confusing.
> Especially behind variables,it is often unclear if the dot was part
> of the variable or not
> which make debugging much harder.
> 
> Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
> ---
>  src/functions/functions.settings | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/functions/functions.settings
> b/src/functions/functions.settings
> index 0e50bf1..9efbe8e 100644
> --- a/src/functions/functions.settings
> +++ b/src/functions/functions.settings
> @@ -159,7 +159,7 @@ settings_write() {
>  		return ${EXIT_ERROR}
>  	fi
>  
> -	log DEBUG "Writing settings file ${settings_file}."
> +	log DEBUG "Writing settings file '${settings_file}'."
>  
>  	mkdir -p $(dirname ${settings_file}) 2>/dev/null
>  	> ${settings_file}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/7] zone: add function to avoid multiple configs which are senseless
  2017-07-04 15:46 ` [PATCH 3/7] zone: add function to avoid multiple configs which are senseless Jonatan Schlag
@ 2017-07-04 16:07   ` Michael Tremer
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Tremer @ 2017-07-04 16:07 UTC (permalink / raw)
  To: network

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

Perfect coding style here! :)

On Tue, 2017-07-04 at 17:46 +0200, Jonatan Schlag wrote:
> Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
> ---
>  src/functions/functions.zone | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/src/functions/functions.zone
> b/src/functions/functions.zone
> index 058110d..f2c5ddc 100644
> --- a/src/functions/functions.zone
> +++ b/src/functions/functions.zone
> @@ -1008,6 +1008,28 @@ zone_config_get_hook() {
>  	print "${HOOK}"
>  }
>  
> +zone_config_hook_is_configured() {
> +	# Checks if a zone has already at least one config with the
> given hook.
> +	# Returns True when yes and False when no
> +
> +	assert [ $# -eq 2 ]
> +	local zone=${1}
> +	local hook=${2}
> +
> +	local config
> +	for config in $(zone_configs_list "${zone}"); do
> +		local config_hook="$(zone_config_get_hook "${zone}"
> "${config}")"
> +		assert isset config_hook
> +		if [[ ${hook} == ${config_hook} ]]; then
> +			return ${EXIT_TRUE}
> +		fi
> +
> +	done
> +
> +	# If we get here the zone has no config with the given hook
> +	return ${EXIT_FALSE}
> +}
> +
>  zone_has_ip() {
>  	device_has_ip $@
>  }

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-07-04 16:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-04 15:46 [PATCH 1/7] settings: remove dot from log message Jonatan Schlag
2017-07-04 15:46 ` [PATCH 2/7] inetcalc: do not print the default prefix Jonatan Schlag
2017-07-04 15:46 ` [PATCH 3/7] zone: add function to avoid multiple configs which are senseless Jonatan Schlag
2017-07-04 16:07   ` Michael Tremer
2017-07-04 15:46 ` [PATCH 4/7] ipv4-dhcp: prevent multiple configs for the same zone Jonatan Schlag
2017-07-04 15:46 ` [PATCH 5/7] ipv6-dhcp: " Jonatan Schlag
2017-07-04 15:46 ` [PATCH 6/7] ipv6-auto: " Jonatan Schlag
2017-07-04 15:46 ` [PATCH 7/7] pppoe-server: " Jonatan Schlag
2017-07-04 16:06 ` [PATCH 1/7] settings: remove dot from log message Michael Tremer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox