diff mbox

[OpenWrt-Devel,3/3] netifd: Set interface device config when device has old settings

Message ID 1423759277-14275-3-git-send-email-dedeckeh@gmail.com
State Accepted
Headers show

Commit Message

Hans Dedecker Feb. 12, 2015, 4:41 p.m. UTC
If interface device settings are removed in UCI they were not removed in the
device settings; calling device_set_config when device settings are present
solves this.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
---
 config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Felix Fietkau Feb. 13, 2015, 1:57 a.m. UTC | #1
On 2015-02-13 03:41, Hans Dedecker wrote:
> If interface device settings are removed in UCI they were not removed in the
> device settings; calling device_set_config when device settings are present
> solves this.
> 
> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
> ---
>  config.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/config.c b/config.c
> index 34d2f2b..9108ab4 100644
> --- a/config.c
> +++ b/config.c
> @@ -136,7 +136,7 @@ config_parse_interface(struct uci_section *s, bool alias)
>  	if (blob_len(b.head) == 0)
>  		return;
>  
> -	if (iface->device_config)
> +	if (iface->device_config || dev->settings.flags)
>  		device_set_config(dev, dev->type, b.head);
Wouldn't that overwrite device config added via 'config device' sections?

- Felix
Hans Dedecker Feb. 13, 2015, 7:58 a.m. UTC | #2
On Fri, Feb 13, 2015 at 2:57 AM, Felix Fietkau <nbd@openwrt.org> wrote:
> On 2015-02-13 03:41, Hans Dedecker wrote:
>> If interface device settings are removed in UCI they were not removed in the
>> device settings; calling device_set_config when device settings are present
>> solves this.
>>
>> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
>> ---
>>  config.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/config.c b/config.c
>> index 34d2f2b..9108ab4 100644
>> --- a/config.c
>> +++ b/config.c
>> @@ -136,7 +136,7 @@ config_parse_interface(struct uci_section *s, bool alias)
>>       if (blob_len(b.head) == 0)
>>               return;
>>
>> -     if (iface->device_config)
>> +     if (iface->device_config || dev->settings.flags)
>>               device_set_config(dev, dev->type, b.head);
> Wouldn't that overwrite device config added via 'config device' sections?
>
> - Felix
Hi Felix,

Function config_parse_interface checks default_config for a given
device; if set to false the interface device config logic is skipped.
As default_config is set to false in function config_init_devices when
parsing the config device sections;
an overwrite of the device config section data is avoided in this case.

Hans
Felix Fietkau Feb. 13, 2015, 10:08 a.m. UTC | #3
On 2015-02-13 18:58, Hans Dedecker wrote:
> On Fri, Feb 13, 2015 at 2:57 AM, Felix Fietkau <nbd@openwrt.org> wrote:
>> On 2015-02-13 03:41, Hans Dedecker wrote:
>>> If interface device settings are removed in UCI they were not removed in the
>>> device settings; calling device_set_config when device settings are present
>>> solves this.
>>>
>>> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
>>> ---
>>>  config.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/config.c b/config.c
>>> index 34d2f2b..9108ab4 100644
>>> --- a/config.c
>>> +++ b/config.c
>>> @@ -136,7 +136,7 @@ config_parse_interface(struct uci_section *s, bool alias)
>>>       if (blob_len(b.head) == 0)
>>>               return;
>>>
>>> -     if (iface->device_config)
>>> +     if (iface->device_config || dev->settings.flags)
>>>               device_set_config(dev, dev->type, b.head);
>> Wouldn't that overwrite device config added via 'config device' sections?
>>
>> - Felix
> Hi Felix,
> 
> Function config_parse_interface checks default_config for a given
> device; if set to false the interface device config logic is skipped.
> As default_config is set to false in function config_init_devices when
> parsing the config device sections;
> an overwrite of the device config section data is avoided in this case.
You're right, I misread that part. Patches look good to me.

- Felix
Steven Barth Feb. 17, 2015, 2:15 p.m. UTC | #4
All applied, thanks.
diff mbox

Patch

diff --git a/config.c b/config.c
index 34d2f2b..9108ab4 100644
--- a/config.c
+++ b/config.c
@@ -136,7 +136,7 @@  config_parse_interface(struct uci_section *s, bool alias)
 	if (blob_len(b.head) == 0)
 		return;
 
-	if (iface->device_config)
+	if (iface->device_config || dev->settings.flags)
 		device_set_config(dev, dev->type, b.head);
 	return;
 error_free_config: