diff options
author | Christian Marangi <ansuelsmth@gmail.com> | 2023-03-29 00:16:46 +0200 |
---|---|---|
committer | Christian Marangi <ansuelsmth@gmail.com> | 2023-04-03 21:19:18 +0200 |
commit | 4b38e6b5bb967f0ee2e378a9016a5adaaa90eba5 (patch) | |
tree | be8c4fc6ca39a2d4ef512090cceaeb5c069e0f95 /src/netlink.c | |
parent | 29c934d7ab98ca0b5da0e3757b885a1d3c19a2f4 (diff) |
config: fix feature for enabling service only when interface RUNNING
With ba30afcfec0a26ce4bcd96ea4d687c498b0ba4df it was found that odhcpd
service are setup even if an interface had no connection and was not
running. The commit introduced the change but required more fixup for
the feature to work correctly.
The close_interface() remove the interface from the avl list and this
cause the interface to be missing later in the code flow.
The intention of the commit was to just disable the service and enable
them later when the interface is correctly set to running with the flag
IFF_RUNNING.
Change the logic and introduce a new function reload_servies() that will
check IFF_RUNNING and enable or disable odhcp services.
This function is called on odhcpd_reload() for each interface. In
odhcpd_reload() also restore the original pattern with calling
close_interface() only when the interface is not inuse for odhcp.
Also call reload_services() on the single interface when a RTM_NEWLINK
event is fired reacting to a link change of an odhcp interface and
enabling the services if IFF_RUNNING is set.
Fixes ba30afcfec0a ("config: skip interface setup if interface not IFF_RUNNING")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'src/netlink.c')
-rw-r--r-- | src/netlink.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/netlink.c b/src/netlink.c index 0a2da03..9b9fdb8 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -313,8 +313,15 @@ static int handle_rtm_link(struct nlmsghdr *hdr) iface->ifflags = ifi->ifi_flags; - if (iface->ifindex == ifi->ifi_index) + /* + * Assume for link event of the same index, that link changed + * and reload services to enable or disable them based on the + * RUNNING state of the interface. + */ + if (iface->ifindex == ifi->ifi_index) { + reload_services(iface); continue; + } iface->ifindex = ifi->ifi_index; event_info.iface = iface; |