network/address: drop unused functions
This commit is contained in:
@@ -408,55 +408,6 @@ DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(
|
||||
address_kernel_compare_func,
|
||||
address_free);
|
||||
|
||||
int address_compare_func(const Address *a1, const Address *a2) {
|
||||
int r;
|
||||
|
||||
r = CMP(a1->family, a2->family);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
if (!IN_SET(a1->family, AF_INET, AF_INET6))
|
||||
return 0;
|
||||
|
||||
r = CMP(a1->prefixlen, a2->prefixlen);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a1->in_addr, &a2->in_addr, FAMILY_ADDRESS_SIZE(a1->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = memcmp(&a1->in_addr_peer, &a2->in_addr_peer, FAMILY_ADDRESS_SIZE(a1->family));
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
if (a1->family == AF_INET) {
|
||||
/* On update, the kernel ignores the address label and broadcast address, hence we need
|
||||
* to distinguish addresses with different labels or broadcast addresses. Otherwise,
|
||||
* the label or broadcast address change will not be applied when we reconfigure the
|
||||
* interface. */
|
||||
r = strcmp_ptr(a1->label, a2->label);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = CMP(a1->broadcast.s_addr, a2->broadcast.s_addr);
|
||||
if (r != 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int address_equal(const Address *a1, const Address *a2) {
|
||||
if (a1 == a2)
|
||||
return true;
|
||||
|
||||
if (!a1 || !a2)
|
||||
return false;
|
||||
|
||||
return address_compare_func(a1, a2) == 0;
|
||||
}
|
||||
|
||||
static bool address_can_update(const Address *la, const Address *na) {
|
||||
assert(la);
|
||||
assert(la->link);
|
||||
|
||||
@@ -119,9 +119,6 @@ int manager_rtnl_process_address(sd_netlink *nl, sd_netlink_message *message, Ma
|
||||
|
||||
int network_drop_invalid_addresses(Network *network);
|
||||
|
||||
int address_compare_func(const Address *a1, const Address *a2);
|
||||
int address_equal(const Address *a1, const Address *a2);
|
||||
|
||||
DEFINE_NETWORK_CONFIG_STATE_FUNCTIONS(Address, address);
|
||||
|
||||
void link_mark_addresses(Link *link, NetworkConfigSource source);
|
||||
|
||||
@@ -180,54 +180,6 @@ static int test_load_config(Manager *manager) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_address_equality(void) {
|
||||
_cleanup_(address_freep) Address *a1 = NULL, *a2 = NULL;
|
||||
|
||||
assert_se(address_new(&a1) >= 0);
|
||||
assert_se(address_new(&a2) >= 0);
|
||||
|
||||
assert_se(address_equal(NULL, NULL));
|
||||
assert_se(!address_equal(a1, NULL));
|
||||
assert_se(!address_equal(NULL, a2));
|
||||
assert_se(address_equal(a1, a2));
|
||||
|
||||
a1->family = AF_INET;
|
||||
assert_se(!address_equal(a1, a2));
|
||||
|
||||
a2->family = AF_INET;
|
||||
assert_se(address_equal(a1, a2));
|
||||
|
||||
assert_se(in_addr_from_string(AF_INET, "192.168.3.9", &a1->in_addr) >= 0);
|
||||
assert_se(!address_equal(a1, a2));
|
||||
assert_se(in_addr_from_string(AF_INET, "192.168.3.9", &a2->in_addr) >= 0);
|
||||
assert_se(address_equal(a1, a2));
|
||||
assert_se(in_addr_from_string(AF_INET, "192.168.3.10", &a1->in_addr_peer) >= 0);
|
||||
assert_se(!address_equal(a1, a2));
|
||||
assert_se(in_addr_from_string(AF_INET, "192.168.3.11", &a2->in_addr_peer) >= 0);
|
||||
assert_se(!address_equal(a1, a2));
|
||||
assert_se(in_addr_from_string(AF_INET, "192.168.3.10", &a2->in_addr_peer) >= 0);
|
||||
assert_se(address_equal(a1, a2));
|
||||
a1->prefixlen = 10;
|
||||
assert_se(!address_equal(a1, a2));
|
||||
a2->prefixlen = 10;
|
||||
assert_se(address_equal(a1, a2));
|
||||
|
||||
a1->family = AF_INET6;
|
||||
assert_se(!address_equal(a1, a2));
|
||||
|
||||
a2->family = AF_INET6;
|
||||
assert_se(in_addr_from_string(AF_INET6, "2001:4ca0:4f01::2", &a1->in_addr) >= 0);
|
||||
assert_se(in_addr_from_string(AF_INET6, "2001:4ca0:4f01::2", &a2->in_addr) >= 0);
|
||||
assert_se(address_equal(a1, a2));
|
||||
|
||||
a2->prefixlen = 8;
|
||||
assert_se(!address_equal(a1, a2));
|
||||
|
||||
a2->prefixlen = 10;
|
||||
assert_se(in_addr_from_string(AF_INET6, "2001:4ca0:4f01::1", &a2->in_addr) >= 0);
|
||||
assert_se(!address_equal(a1, a2));
|
||||
}
|
||||
|
||||
static void test_dhcp_hostname_shorten_overlong(void) {
|
||||
int r;
|
||||
|
||||
@@ -281,7 +233,6 @@ int main(void) {
|
||||
|
||||
test_deserialize_in_addr();
|
||||
test_deserialize_dhcp_routes();
|
||||
test_address_equality();
|
||||
test_dhcp_hostname_shorten_overlong();
|
||||
|
||||
assert_se(manager_new(&manager, /* test_mode = */ true) >= 0);
|
||||
|
||||
Reference in New Issue
Block a user