mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-07-31 02:39:36 +02:00
modules: Support interface creation at runtime
Interfaces might be created at runtime, e.g. USB network adapters or VPN connections. To support these we (a) don't close the module if the interface can't be found at startup and (b) check the interface index for every link event, as it might have changed after recreation.
This commit is contained in:
parent
e4a0b375e5
commit
a6126c774f
1 changed files with 5 additions and 11 deletions
|
@ -230,13 +230,9 @@ handle_link(struct module *mod, uint16_t type,
|
||||||
|
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
|
|
||||||
if (m->ifindex == -1) {
|
if (!find_my_ifindex(mod, msg, len)) {
|
||||||
/* We don't know our own ifindex yet. Let's see if we can find
|
/* Message wasn't for us (IFLA_IFNAME mismatch) */
|
||||||
* it in the message */
|
return;
|
||||||
if (!find_my_ifindex(mod, msg, len)) {
|
|
||||||
/* Nope, message wasn't for us (IFLA_IFNAME mismatch) */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(m->ifindex >= 0);
|
assert(m->ifindex >= 0);
|
||||||
|
@ -314,8 +310,6 @@ handle_address(struct module *mod, uint16_t type,
|
||||||
|
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
|
|
||||||
assert(m->ifindex >= 0);
|
|
||||||
|
|
||||||
if (msg->ifa_index != m->ifindex) {
|
if (msg->ifa_index != m->ifindex) {
|
||||||
/* Not for us */
|
/* Not for us */
|
||||||
return;
|
return;
|
||||||
|
@ -420,8 +414,8 @@ parse_reply(struct module *mod, const struct nlmsghdr *hdr, size_t len)
|
||||||
switch (hdr->nlmsg_type) {
|
switch (hdr->nlmsg_type) {
|
||||||
case NLMSG_DONE:
|
case NLMSG_DONE:
|
||||||
if (m->ifindex == -1) {
|
if (m->ifindex == -1) {
|
||||||
LOG_ERR("%s: failed to find interface", m->iface);
|
LOG_WARN("%s: failed to find interface", m->iface);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request initial list of IPv4/6 addresses */
|
/* Request initial list of IPv4/6 addresses */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue