summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-07-11 04:22:35 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-07-31 11:15:26 +0200
commit35f0cd02d8857fa1f5d0b11a0aab58d871eaf6ea (patch)
tree8c42c5abd7e686aa23f9628996e632124ca781aa /src/network
parenttest-network: add more tests for address properties (diff)
downloadsystemd-35f0cd02d8857fa1f5d0b11a0aab58d871eaf6ea.tar.xz
systemd-35f0cd02d8857fa1f5d0b11a0aab58d871eaf6ea.zip
network/address: drop unused functions
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-address.c49
-rw-r--r--src/network/networkd-address.h3
-rw-r--r--src/network/test-network.c49
3 files changed, 0 insertions, 101 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index d9dbe56590..0bc8e0f020 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -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);
diff --git a/src/network/networkd-address.h b/src/network/networkd-address.h
index bdb5b5b5e5..7a611529f7 100644
--- a/src/network/networkd-address.h
+++ b/src/network/networkd-address.h
@@ -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);
diff --git a/src/network/test-network.c b/src/network/test-network.c
index 35592e0733..5f3b4c0b31 100644
--- a/src/network/test-network.c
+++ b/src/network/test-network.c
@@ -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);