public inbox for network@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH] Fix hook for static address configuration.
@ 2018-07-10 18:04 Stefan Schantl
  2018-07-11 13:14 ` Michael Tremer
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Schantl @ 2018-07-10 18:04 UTC (permalink / raw)
  To: network

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

Add the required hook_new function and "id" information which have been
introduced in earlier commits to make this hook work again.

Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
 src/hooks/configs/static | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/hooks/configs/static b/src/hooks/configs/static
index 91bba8a..37f3d32 100644
--- a/src/hooks/configs/static
+++ b/src/hooks/configs/static
@@ -52,6 +52,8 @@ hook_check_config_settings() {
 
 hook_parse_cmdline() {
 	local protocol
+	local id="${1}"
+	shift
 
 	while [ $# -gt 0 ]; do
 		case "${1}" in
@@ -153,12 +155,34 @@ hook_parse_cmdline() {
 	fi
 
 	# Check any conflicts
-	if zone_config_check_same_setting "${zone}" "static" "ADDRESS" "${ADDRESS}"; then
+	if zone_config_check_same_setting "${zone}" "static" "${id}" "ADDRESS" "${ADDRESS}"; then
 		error "A static configuration with the same address is already configured"
 		return ${EXIT_CONF_ERROR}
 	fi
 }
 
+hook_new() {
+	local zone="${1}"
+	shift
+
+	if zone_config_hook_is_configured ${zone} "static"; then
+		log ERROR "You can configure the static hook only once for a zone"
+		return ${EXIT_ERROR}
+	fi
+
+	local id=$(zone_config_get_new_id ${zone})
+	log DEBUG "ID for the config is: ${id}"
+
+	if ! hook_parse_cmdline "${id}" "$@"; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
+
+	zone_config_settings_write "${zone}" "${HOOK}" "${id}"
+
+	exit ${EXIT_OK}
+}
+
 hook_up() {
 	local zone="${1}"
 	local config="${2}"
-- 
2.17.1


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

* Re: [PATCH] Fix hook for static address configuration.
  2018-07-10 18:04 [PATCH] Fix hook for static address configuration Stefan Schantl
@ 2018-07-11 13:14 ` Michael Tremer
  2018-08-11 19:21   ` [PATCHv2] " Stefan Schantl
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Tremer @ 2018-07-11 13:14 UTC (permalink / raw)
  To: network

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

On Tue, 2018-07-10 at 20:04 +0200, Stefan Schantl wrote:
> Add the required hook_new function and "id" information which have been
> introduced in earlier commits to make this hook work again.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
> ---
>  src/hooks/configs/static | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/src/hooks/configs/static b/src/hooks/configs/static
> index 91bba8a..37f3d32 100644
> --- a/src/hooks/configs/static
> +++ b/src/hooks/configs/static
> @@ -52,6 +52,8 @@ hook_check_config_settings() {
>  
>  hook_parse_cmdline() {
>  	local protocol
> +	local id="${1}"
> +	shift
>  
>  	while [ $# -gt 0 ]; do
>  		case "${1}" in
> @@ -153,12 +155,34 @@ hook_parse_cmdline() {
>  	fi
>  
>  	# Check any conflicts
> -	if zone_config_check_same_setting "${zone}" "static" "ADDRESS"
> "${ADDRESS}"; then
> +	if zone_config_check_same_setting "${zone}" "static" "${id}"
> "ADDRESS" "${ADDRESS}"; then
>  		error "A static configuration with the same address is
> already configured"
>  		return ${EXIT_CONF_ERROR}
>  	fi
>  }
>  
> +hook_new() {
> +	local zone="${1}"
> +	shift
> +
> +	if zone_config_hook_is_configured ${zone} "static"; then
> +		log ERROR "You can configure the static hook only once for a
> zone"
> +		return ${EXIT_ERROR}
> +	fi

This is incorrect. Why should it only be possible once?

> +
> +	local id=$(zone_config_get_new_id ${zone})
> +	log DEBUG "ID for the config is: ${id}"
> +
> +	if ! hook_parse_cmdline "${id}" "$@"; then
> +		# Return an error if the parsing of the cmd line fails
> +		return ${EXIT_ERROR}
> +	fi
> +
> +	zone_config_settings_write "${zone}" "${HOOK}" "${id}"
> +
> +	exit ${EXIT_OK}
> +}
> +
>  hook_up() {
>  	local zone="${1}"
>  	local config="${2}"

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

* [PATCHv2] Fix hook for static address configuration.
  2018-07-11 13:14 ` Michael Tremer
@ 2018-08-11 19:21   ` Stefan Schantl
  2018-09-15 12:20     ` Jonatan Schlag
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Schantl @ 2018-08-11 19:21 UTC (permalink / raw)
  To: network

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

Add the required hook_new function and "id" information which have been
introduced in earlier commits to make this hook work again.

Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
 src/hooks/configs/static | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/hooks/configs/static b/src/hooks/configs/static
index 91bba8a..23ae2d8 100644
--- a/src/hooks/configs/static
+++ b/src/hooks/configs/static
@@ -52,6 +52,8 @@ hook_check_config_settings() {
 
 hook_parse_cmdline() {
 	local protocol
+	local id="${1}"
+	shift
 
 	while [ $# -gt 0 ]; do
 		case "${1}" in
@@ -153,12 +155,29 @@ hook_parse_cmdline() {
 	fi
 
 	# Check any conflicts
-	if zone_config_check_same_setting "${zone}" "static" "ADDRESS" "${ADDRESS}"; then
+	if zone_config_check_same_setting "${zone}" "static" "${id}" "ADDRESS" "${ADDRESS}"; then
 		error "A static configuration with the same address is already configured"
 		return ${EXIT_CONF_ERROR}
 	fi
 }
 
+hook_new() {
+	local zone="${1}"
+	shift
+
+	local id=$(zone_config_get_new_id ${zone})
+	log DEBUG "ID for the config is: ${id}"
+
+	if ! hook_parse_cmdline "${id}" "$@"; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
+
+	zone_config_settings_write "${zone}" "${HOOK}" "${id}"
+
+	exit ${EXIT_OK}
+}
+
 hook_up() {
 	local zone="${1}"
 	local config="${2}"
-- 
2.17.1


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

* Re: [PATCHv2] Fix hook for static address configuration.
  2018-08-11 19:21   ` [PATCHv2] " Stefan Schantl
@ 2018-09-15 12:20     ` Jonatan Schlag
  0 siblings, 0 replies; 4+ messages in thread
From: Jonatan Schlag @ 2018-09-15 12:20 UTC (permalink / raw)
  To: network

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

Am Samstag, den 11.08.2018, 21:21 +0200 schrieb Stefan Schantl:
> Add the required hook_new function and "id" information which have
> been
> introduced in earlier commits to make this hook work again.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
> ---
>  src/hooks/configs/static | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/src/hooks/configs/static b/src/hooks/configs/static
> index 91bba8a..23ae2d8 100644
> --- a/src/hooks/configs/static
> +++ b/src/hooks/configs/static
> @@ -52,6 +52,8 @@ hook_check_config_settings() {
>  
>  hook_parse_cmdline() {
>  	local protocol
> +	local id="${1}"
> +	shift
>  
>  	while [ $# -gt 0 ]; do
>  		case "${1}" in
> @@ -153,12 +155,29 @@ hook_parse_cmdline() {
>  	fi
>  
>  	# Check any conflicts
> -	if zone_config_check_same_setting "${zone}" "static"
> "ADDRESS" "${ADDRESS}"; then
> +	if zone_config_check_same_setting "${zone}" "static" "${id}"
> "ADDRESS" "${ADDRESS}"; then
>  		error "A static configuration with the same address
> is already configured"
>  		return ${EXIT_CONF_ERROR}
>  	fi
>  }
>  
> +hook_new() {
> +	local zone="${1}"
> +	shift
> +
> +	local id=$(zone_config_get_new_id ${zone})
> +	log DEBUG "ID for the config is: ${id}"
> +
> +	if ! hook_parse_cmdline "${id}" "$@"; then
> +		# Return an error if the parsing of the cmd line
> fails
> +		return ${EXIT_ERROR}
> +	fi
> +
> +	zone_config_settings_write "${zone}" "${HOOK}" "${id}"
> +
> +	exit ${EXIT_OK}
> +}
> +
>  hook_up() {
>  	local zone="${1}"
>  	local config="${2}"
Tested-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>

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

end of thread, other threads:[~2018-09-15 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10 18:04 [PATCH] Fix hook for static address configuration Stefan Schantl
2018-07-11 13:14 ` Michael Tremer
2018-08-11 19:21   ` [PATCHv2] " Stefan Schantl
2018-09-15 12:20     ` Jonatan Schlag

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