diff mbox series

[odhcpd,1/2] config: skip interface setup if interface not IFF_RUNNING

Message ID 20230317005345.29092-1-ansuelsmth@gmail.com
State Superseded
Delegated to: Ansuel Smith
Headers show
Series [odhcpd,1/2] config: skip interface setup if interface not IFF_RUNNING | expand

Commit Message

Christian Marangi March 17, 2023, 12:53 a.m. UTC
We currently setup odhcp service even if the interface is not running.
This is the case for bridge or specific interface that are flagged as UP
but have no carrier as nothing is connected to it.
This cause a similar error like:

Failed to send to ff02::1%br-lan (Address not available)

This is caused by the kernel assigning IPV6 address only when the
interface is set to IFF_RUNNING.
A LINK-LOCAL IPV6 address is required for odhcpd_send() to work or every
request will be rejected.

To fix this setup services only when interface is in IFF_RUNNING state.
When an interface change state, odhcpd is reloaded and the services are
correctly setup again.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 src/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hans Dedecker March 18, 2023, 8:24 p.m. UTC | #1
On Fri, Mar 17, 2023 at 1:54 AM Christian Marangi <ansuelsmth@gmail.com> wrote:
>
> We currently setup odhcp service even if the interface is not running.
> This is the case for bridge or specific interface that are flagged as UP
> but have no carrier as nothing is connected to it.
> This cause a similar error like:
>
> Failed to send to ff02::1%br-lan (Address not available)
>
> This is caused by the kernel assigning IPV6 address only when the
> interface is set to IFF_RUNNING.
> A LINK-LOCAL IPV6 address is required for odhcpd_send() to work or every
> request will be rejected.
>
> To fix this setup services only when interface is in IFF_RUNNING state.
> When an interface change state, odhcpd is reloaded and the services are
> correctly setup again.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Hans Dedecker <dedeckeh@gmail.com>
> ---
>  src/config.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/config.c b/src/config.c
> index 9b1f659..30da879 100644
> --- a/src/config.c
> +++ b/src/config.c
> @@ -1303,7 +1303,7 @@ void odhcpd_reload(void)
>
>
>         avl_for_each_element_safe(&interfaces, i, avl, tmp) {
> -               if (i->inuse) {
> +               if (i->inuse && i->ifflags & IFF_RUNNING) {
>                         /* Resolve hybrid mode */
>                         if (i->dhcpv6 == MODE_HYBRID)
>                                 i->dhcpv6 = (master && master->dhcpv6 == MODE_RELAY) ?
> --
> 2.39.2
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

diff --git a/src/config.c b/src/config.c
index 9b1f659..30da879 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1303,7 +1303,7 @@  void odhcpd_reload(void)
 
 
 	avl_for_each_element_safe(&interfaces, i, avl, tmp) {
-		if (i->inuse) {
+		if (i->inuse && i->ifflags & IFF_RUNNING) {
 			/* Resolve hybrid mode */
 			if (i->dhcpv6 == MODE_HYBRID)
 				i->dhcpv6 = (master && master->dhcpv6 == MODE_RELAY) ?