Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

olsrd: don't start service when ignored #780

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dddaniel
Copy link

@dddaniel dddaniel commented Feb 2, 2022

When olsrd was disabled by uci (olsrd.olsrd.ignore=true),
the service got started anyway.
This results in olsrd spamming the syslog when getting started by
procd without a valid configuration:

daemon.err olsrd[8223]: olsrd exit: main: Bad configuration

This commit only starts the olsrd service when not set to ignore.

Signed-off-by: Daniel Danzberger [email protected]

Maintainer: me / @<github-user> (find it by checking history of the package Makefile)
Compile tested: (put here arch, model, OpenWrt version)
Run tested: (put here arch, model, OpenWrt version, tests done)

Description:

When olsrd was disabled by uci (olsrd.olsrd.ignore=true),
the service got started anyway.
This results in olsrd spamming the syslog when getting started by
procd without a valid configuration:
--
daemon.err olsrd[8223]: olsrd exit: main: Bad configuration
--

This commit only starts the olsrd service when not set to ignore.

Signed-off-by: Daniel Danzberger <[email protected]>
@PolynomialDivision
Copy link
Member

Why do you need a disable flag, when you can disable the complete service?

@dddaniel
Copy link
Author

dddaniel commented Feb 2, 2022

Why do you need a disable flag, when you can disable the complete service?

So I can disable it via config without having to call /etc/inti.d/olsrd disable, like most services in openwrt

@PolynomialDivision
Copy link
Member

If you do that and set it on ignore, what is /etc/init.d/olsrd status returning?

@dddaniel
Copy link
Author

dddaniel commented Feb 4, 2022

If you do that and set it on ignore, what is /etc/init.d/olsrd status returning?

root@openwrt:~# /etc/init.d/olsrd status

active with no instances

@zioproto
Copy link
Contributor

zioproto commented Feb 4, 2022

This seems to me a duplication of functionality. You can already disable the service.
Can you bring an example of another service in OpenWrt that does the same ? Can you confirm, showing data, that this is a best practice ?

When olsrd was disabled by uci (olsrd.olsrd.ignore=true),
the service got started anyway.

Reading the above it seems that you are proposing a workaround for a bug of another component. You should fix the root cause of the UCI config not correctly disabling the service.

@dddaniel
Copy link
Author

dddaniel commented Feb 4, 2022

Can you bring an example of another service in OpenWrt that does the same ? Can you confirm, showing data, that this is a best practice ?

dnsmasq, for example:
`dnsmasq_start()
{
local cfg="$1"
local disabled user_dhcpscript
local resolvfile resolvdir localuse=0

config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -gt 0 ] && return 0`

@mwarning
Copy link
Contributor

mwarning commented Mar 30, 2022

I have to say to I also have ignore or disable options in my projects. The use case is when I have multiple sections in one configuration file to start multiple instances, but only want to start some of them. /etc/init.d/<sevice> disable would disable all instances.

In face of this use case, this MR seem to have a valid use case. @zioproto what do you think?

@@ -1,6 +1,7 @@
config olsrd
config olsrd olsrd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the second olsrd word a typo ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait, I understand how, it is because UCI expects olsrd.olsrd.ignore=true

@zioproto
Copy link
Contributor

@mwarning your use case with multiple instances makes sense.

But this PR to olsrd does not involve multiple instances to be turned off individually. It seems to me this is a workaround to fix a UCI problem expecting olsrd.olsrd.ignore=true. Not only the ignore option is added, but also the config stanza is changed from config olsrd to config olsrd olsrd to make another system that expects that syntax happy.

@dddaniel can you clarify if the olsrd.olsrd.ignore=true comes from disabling the service using a UCI cli command or using the LUCI web interface ?

Olsrd config is using the "unnamed section" that is a valid UCI syntax:
https://openwrt.org/docs/guide-user/base-system/uci#uci_dataobject_model
So I dont understand why the move to config olsrd olsrd that could potentially cause problem to other things.

Please provide more context so we can identify the correct place where to fix this issue. I suspect this is just a web interface implementation bug.

thank you

@dddaniel
Copy link
Author

dddaniel commented Aug 1, 2022

Hi @zioproto,

But this PR to olsrd does not involve multiple instances to be turned off individually. It seems to me this is a workaround to fix a UCI problem expecting olsrd.olsrd.ignore=true. Not only the ignore option is added, but also the config stanza is changed from config olsrd to config olsrd olsrd to make another system that expects that syntax happy.

There is no multi instance for the current olsrd. The init script always just starts one instance in the start_service() hook.
The section must be named for reading it's values with config_get. Otherwise I have iterate over the whole config with config_foreach, which makes no sense when there is no multi instance support.

So I dont understand why the move to config olsrd olsrd that could potentially cause problem to other things.

Naming the section doesn't break anything, If there would be code that iterates over all sections with config_foreach, it would still work when the section has a name. It get's an anonymous name derived form it's hash anyway if no name is set.

I could rename it to 'global' which would make it more readable/obvious.

@Hurricos
Copy link

Hurricos commented Oct 4, 2023

The main use I can see is for disabling olsrd6 and maintaining that disablement over a sysupgrade - by default, service disablement isn't preserved over a sysupgrade. I'm testing now whether a symlink of /etc/rc.d/S65olsrd6 -> /dev/null + a correctly configured /etc/sysupgrade.conf would work.

Update: Yes, it does work. Unfortunately it assumes the priority of olsrd remains 65, but it's probably OK that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants