mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
sd-netlink: rename rtnl_get_link_iftype() -> rtnl_get_link_info() and make it optionally return link flags
This commit is contained in:
parent
ce01c07f1c
commit
f25e642bca
@ -302,10 +302,18 @@ int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rtnl_get_link_iftype(sd_netlink **rtnl, int ifindex, unsigned short *ret) {
|
||||
int rtnl_get_link_info(sd_netlink **rtnl, int ifindex, unsigned short *ret_iftype, unsigned *ret_flags) {
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
|
||||
unsigned short iftype;
|
||||
unsigned flags;
|
||||
int r;
|
||||
|
||||
assert(rtnl);
|
||||
assert(ifindex > 0);
|
||||
|
||||
if (!ret_iftype && !ret_flags)
|
||||
return 0;
|
||||
|
||||
if (!*rtnl) {
|
||||
r = sd_netlink_open(rtnl);
|
||||
if (r < 0)
|
||||
@ -322,7 +330,23 @@ int rtnl_get_link_iftype(sd_netlink **rtnl, int ifindex, unsigned short *ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_rtnl_message_link_get_type(reply, ret);
|
||||
if (ret_iftype) {
|
||||
r = sd_rtnl_message_link_get_type(reply, &iftype);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (ret_flags) {
|
||||
r = sd_rtnl_message_link_get_flags(reply, &flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (ret_iftype)
|
||||
*ret_iftype = iftype;
|
||||
if (ret_flags)
|
||||
*ret_flags = flags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtnl_message_new_synthetic_error(sd_netlink *rtnl, int error, uint32_t serial, sd_netlink_message **ret) {
|
||||
|
@ -92,7 +92,7 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
|
||||
int rtnl_set_link_alternative_names_by_ifname(sd_netlink **rtnl, const char *ifname, char * const *alternative_names);
|
||||
int rtnl_delete_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
||||
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name);
|
||||
int rtnl_get_link_iftype(sd_netlink **rtnl, int ifindex, unsigned short *ret);
|
||||
int rtnl_get_link_info(sd_netlink **rtnl, int ifindex, unsigned short *ret_iftype, unsigned *ret_flags);
|
||||
|
||||
int rtnl_log_parse_error(int r);
|
||||
int rtnl_log_create_error(int r);
|
||||
|
@ -240,7 +240,7 @@ bool link_config_should_reload(LinkConfigContext *ctx) {
|
||||
int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret) {
|
||||
unsigned name_assign_type = NET_NAME_UNKNOWN;
|
||||
struct ether_addr permanent_mac = {};
|
||||
unsigned short iftype = 0;
|
||||
unsigned short iftype;
|
||||
LinkConfig *link;
|
||||
const char *name;
|
||||
int ifindex, r;
|
||||
@ -257,7 +257,7 @@ int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret)
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = rtnl_get_link_iftype(&ctx->rtnl, ifindex, &iftype);
|
||||
r = rtnl_get_link_info(&ctx->rtnl, ifindex, &iftype, NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user