tree-wide: IFA_FLAGS is supported since kernel v3.14
Now our baseline on the kernel is v5.4.
Let's unconditionally use the IFA_FLAGS attribute, and drop the getter
and setter for the deprecated header element.
Continuation of 29c2d4e158.
This commit is contained in:
@@ -136,8 +136,6 @@ DEFINE_RTNL_MESSAGE_ADDR_GETTER(ifa_index, ifindex, int);
|
||||
DEFINE_RTNL_MESSAGE_ADDR_GETTER(ifa_family, family, int);
|
||||
DEFINE_RTNL_MESSAGE_PREFIXLEN_SETTER(addr, struct ifaddrmsg, ifa_family, ifa_prefixlen, prefixlen, uint8_t);
|
||||
DEFINE_RTNL_MESSAGE_ADDR_GETTER(ifa_prefixlen, prefixlen, uint8_t);
|
||||
DEFINE_RTNL_MESSAGE_ADDR_SETTER(ifa_flags, flags, uint8_t);
|
||||
DEFINE_RTNL_MESSAGE_ADDR_GETTER(ifa_flags, flags, uint8_t);
|
||||
DEFINE_RTNL_MESSAGE_ADDR_SETTER(ifa_scope, scope, uint8_t);
|
||||
DEFINE_RTNL_MESSAGE_ADDR_GETTER(ifa_scope, scope, uint8_t);
|
||||
|
||||
|
||||
@@ -421,8 +421,9 @@ TEST(dump_addresses) {
|
||||
|
||||
for (sd_netlink_message *m = reply; m; m = sd_netlink_message_next(m)) {
|
||||
uint16_t type;
|
||||
unsigned char scope, flags;
|
||||
unsigned char scope;
|
||||
int family, ifindex;
|
||||
uint32_t flags;
|
||||
|
||||
ASSERT_OK(sd_netlink_message_get_type(m, &type));
|
||||
ASSERT_EQ(type, RTM_NEWADDR);
|
||||
@@ -430,7 +431,7 @@ TEST(dump_addresses) {
|
||||
ASSERT_OK(sd_rtnl_message_addr_get_ifindex(m, &ifindex));
|
||||
ASSERT_OK(sd_rtnl_message_addr_get_family(m, &family));
|
||||
ASSERT_OK(sd_rtnl_message_addr_get_scope(m, &scope));
|
||||
ASSERT_OK(sd_rtnl_message_addr_get_flags(m, &flags));
|
||||
ASSERT_OK(sd_netlink_message_read_u32(m, IFA_FLAGS, &flags));
|
||||
|
||||
ASSERT_GT(ifindex, 0);
|
||||
ASSERT_TRUE(IN_SET(family, AF_INET, AF_INET6));
|
||||
|
||||
@@ -1161,7 +1161,7 @@ int link_address_update_rtnl(LinkAddress *a, sd_netlink_message *m) {
|
||||
assert(a);
|
||||
assert(m);
|
||||
|
||||
r = sd_rtnl_message_addr_get_flags(m, &a->flags);
|
||||
r = sd_netlink_message_read_u32(m, IFA_FLAGS, &a->flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ struct LinkAddress {
|
||||
union in_addr_union in_addr_broadcast;
|
||||
unsigned char prefixlen;
|
||||
|
||||
unsigned char flags, scope;
|
||||
unsigned char scope;
|
||||
uint32_t flags;
|
||||
|
||||
DnsResourceRecord *llmnr_address_rr;
|
||||
DnsResourceRecord *llmnr_ptr_rr;
|
||||
|
||||
@@ -154,7 +154,7 @@ int local_addresses(
|
||||
|
||||
for (sd_netlink_message *m = reply; m; m = sd_netlink_message_next(m)) {
|
||||
union in_addr_union a;
|
||||
unsigned char flags, scope;
|
||||
unsigned char scope;
|
||||
uint16_t type;
|
||||
int ifi, family;
|
||||
|
||||
@@ -182,7 +182,8 @@ int local_addresses(
|
||||
if (af != AF_UNSPEC && af != family)
|
||||
continue;
|
||||
|
||||
r = sd_rtnl_message_addr_get_flags(m, &flags);
|
||||
uint32_t flags;
|
||||
r = sd_netlink_message_read_u32(m, IFA_FLAGS, &flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if ((flags & (IFA_F_DEPRECATED|IFA_F_TENTATIVE)) != 0)
|
||||
|
||||
@@ -79,11 +79,11 @@ static int add_ipv4_address(sd_netlink *rtnl, struct state *s) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT);
|
||||
r = sd_rtnl_message_addr_set_scope(req, RT_SCOPE_HOST);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_rtnl_message_addr_set_scope(req, RT_SCOPE_HOST);
|
||||
r = sd_netlink_message_append_u32(req, IFA_FLAGS, IFA_F_PERMANENT);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -115,14 +115,9 @@ static int add_ipv6_address(sd_netlink *rtnl, struct state *s) {
|
||||
return r;
|
||||
|
||||
uint32_t flags = IFA_F_PERMANENT|IFA_F_NOPREFIXROUTE;
|
||||
r = sd_rtnl_message_addr_set_flags(req, flags & 0xffu); /* rtnetlink wants low 8 bit of flags via regular flags field… */
|
||||
r = sd_netlink_message_append_u32(req, IFA_FLAGS, flags);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if ((flags & ~0xffu) != 0) {
|
||||
r = sd_netlink_message_append_u32(req, IFA_FLAGS, flags); /* …and the rest of the flags via IFA_FLAGS */
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_rtnl_message_addr_set_scope(req, RT_SCOPE_HOST);
|
||||
if (r < 0)
|
||||
|
||||
@@ -146,8 +146,6 @@ int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ret); /* ifa_in
|
||||
int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *ret); /* ifa_family */
|
||||
int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, uint8_t prefixlen); /* ifa_prefixlen */
|
||||
int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, uint8_t flags); /* ifa_flags */
|
||||
int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, uint8_t *ret);
|
||||
int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, uint8_t scope); /* ifa_scope */
|
||||
int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, uint8_t *ret);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user