mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Merge pull request #19913 from yuwata/network-fix-counter
network: add missing increment of Link::set_flags_messages
This commit is contained in:
commit
9868493e17
@ -667,7 +667,7 @@ int bus_link_method_reconfigure(sd_bus_message *message, void *userdata, sd_bus_
|
||||
if (r == 0)
|
||||
return 1; /* Polkit will call us back */
|
||||
|
||||
r = link_reconfigure(l, true);
|
||||
r = link_reconfigure(l, /* force = */ true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
|
@ -1199,7 +1199,7 @@ static int link_get_network(Link *link, Network **ret) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int link_reconfigure_internal(Link *link, bool force) {
|
||||
static int link_reconfigure_impl(Link *link, bool force) {
|
||||
Network *network;
|
||||
int r;
|
||||
|
||||
@ -1267,7 +1267,7 @@ static int link_reconfigure_handler_internal(sd_netlink *rtnl, sd_netlink_messag
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
r = link_reconfigure_internal(link, force);
|
||||
r = link_reconfigure_impl(link, force);
|
||||
if (r < 0)
|
||||
link_enter_failed(link);
|
||||
|
||||
@ -1497,15 +1497,6 @@ static int link_carrier_gained(Link *link) {
|
||||
/* let's shortcut things for CAN which doesn't need most of what's done below. */
|
||||
return 0;
|
||||
|
||||
r = wifi_get_info(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
r = link_reconfigure_internal(link, false);
|
||||
if (r != 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED)) {
|
||||
r = link_acquire_dynamic_conf(link);
|
||||
if (r < 0)
|
||||
@ -1830,7 +1821,7 @@ void link_update_operstate(Link *link, bool also_update_master) {
|
||||
: "")
|
||||
|
||||
static int link_update_flags(Link *link, sd_netlink_message *message) {
|
||||
bool link_was_admin_up, had_carrier;
|
||||
bool link_was_lower_up, link_was_admin_up, had_carrier;
|
||||
uint8_t operstate;
|
||||
unsigned flags;
|
||||
int r;
|
||||
@ -1892,6 +1883,7 @@ static int link_update_flags(Link *link, sd_netlink_message *message) {
|
||||
log_link_debug(link, "Unknown link flags lost, ignoring: %#.5x", unknown_flags_removed);
|
||||
}
|
||||
|
||||
link_was_lower_up = link->flags & IFF_LOWER_UP;
|
||||
link_was_admin_up = link->flags & IFF_UP;
|
||||
had_carrier = link_has_carrier(link);
|
||||
|
||||
@ -1900,6 +1892,19 @@ static int link_update_flags(Link *link, sd_netlink_message *message) {
|
||||
|
||||
link_update_operstate(link, true);
|
||||
|
||||
if (!link_was_lower_up && (link->flags & IFF_LOWER_UP)) {
|
||||
r = wifi_get_info(link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) {
|
||||
/* All link information is up-to-date. So, it is not necessary to call
|
||||
* RTM_GETLINK netlink method again. */
|
||||
r = link_reconfigure_impl(link, /* force = */ false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (!link_was_admin_up && (link->flags & IFF_UP)) {
|
||||
log_link_info(link, "Link UP");
|
||||
|
||||
|
@ -216,7 +216,7 @@ static int bus_method_reload(sd_bus_message *message, void *userdata, sd_bus_err
|
||||
return r;
|
||||
|
||||
HASHMAP_FOREACH(link, manager->links) {
|
||||
r = link_reconfigure(link, false);
|
||||
r = link_reconfigure(link, /* force = */ false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -920,7 +920,16 @@ static int link_up_or_down(Link *link, bool up, link_netlink_message_handler_t c
|
||||
}
|
||||
|
||||
int link_down(Link *link) {
|
||||
return link_up_or_down(link, false, link_down_handler);
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
||||
r = link_up_or_down(link, false, link_down_handler);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to bring down interface: %m");
|
||||
|
||||
link->set_flags_messages++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool link_is_ready_to_activate(Link *link) {
|
||||
|
@ -18,8 +18,9 @@
|
||||
int wifi_get_info(Link *link) {
|
||||
_cleanup_free_ char *ssid = NULL;
|
||||
enum nl80211_iftype iftype;
|
||||
bool updated = false;
|
||||
const char *type;
|
||||
int r, s = 0;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
||||
@ -38,23 +39,26 @@ int wifi_get_info(Link *link) {
|
||||
r = wifi_get_interface(link->manager->genl, link->ifindex, &iftype, &ssid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0 && link->wlan_iftype == iftype && streq_ptr(link->ssid, ssid))
|
||||
r = 0;
|
||||
if (r == 0)
|
||||
iftype = link->wlan_iftype; /* Assume iftype is not changed. */
|
||||
|
||||
link->wlan_iftype = iftype;
|
||||
free_and_replace(link->ssid, ssid);
|
||||
if (iftype == NL80211_IFTYPE_STATION) {
|
||||
struct ether_addr bssid;
|
||||
|
||||
if (link->wlan_iftype == NL80211_IFTYPE_STATION) {
|
||||
struct ether_addr old_bssid = link->bssid;
|
||||
r = wifi_get_station(link->manager->genl, link->ifindex, &bssid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
s = wifi_get_station(link->manager->genl, link->ifindex, &link->bssid);
|
||||
if (s < 0)
|
||||
return s;
|
||||
if (s > 0 && memcmp(&old_bssid, &link->bssid, sizeof old_bssid) == 0)
|
||||
s = 0;
|
||||
updated = !ether_addr_equal(&link->bssid, &bssid);
|
||||
link->bssid = bssid;
|
||||
}
|
||||
|
||||
if (r > 0 || s > 0) {
|
||||
updated = updated || link->wlan_iftype != iftype;
|
||||
link->wlan_iftype = iftype;
|
||||
updated = updated || !streq_ptr(link->ssid, ssid);
|
||||
free_and_replace(link->ssid, ssid);
|
||||
|
||||
if (updated) {
|
||||
if (link->wlan_iftype == NL80211_IFTYPE_STATION && link->ssid)
|
||||
log_link_info(link, "Connected WiFi access point: %s (%s)",
|
||||
link->ssid, ETHER_ADDR_TO_STR(&link->bssid));
|
||||
|
Loading…
x
Reference in New Issue
Block a user