Merge pull request #22199 from yuwata/resolve-reduce-attempts-reading-networkd-link-file
resolve: reduce attempts of reading networkd's link file
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_arp.h>
|
||||
|
||||
#include "arphrd-util.h"
|
||||
@@ -11,6 +12,20 @@
|
||||
#include "sparse-endian.h"
|
||||
#include "strv.h"
|
||||
|
||||
bool netif_has_carrier(uint8_t operstate, unsigned flags) {
|
||||
/* see Documentation/networking/operstates.txt in the kernel sources */
|
||||
|
||||
if (operstate == IF_OPER_UP)
|
||||
return true;
|
||||
|
||||
if (operstate != IF_OPER_UNKNOWN)
|
||||
return false;
|
||||
|
||||
/* operstate may not be implemented, so fall back to flags */
|
||||
return FLAGS_SET(flags, IFF_LOWER_UP | IFF_RUNNING) &&
|
||||
!FLAGS_SET(flags, IFF_DORMANT);
|
||||
}
|
||||
|
||||
int net_get_type_string(sd_device *device, uint16_t iftype, char **ret) {
|
||||
const char *t;
|
||||
char *p;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "ether-addr-util.h"
|
||||
|
||||
bool netif_has_carrier(uint8_t operstate, unsigned flags);
|
||||
int net_get_type_string(sd_device *device, uint16_t iftype, char **ret);
|
||||
const char *net_get_persistent_name(sd_device *device);
|
||||
int net_get_unique_predictable_data(sd_device *device, bool use_sysname, uint64_t *ret);
|
||||
|
||||
Reference in New Issue
Block a user