@@ -539,13 +539,9 @@ error:
static int
addr_cmp(const void *k1, const void *k2, void *ptr)
{
- const struct device_addr *a1 = k1;
- const struct device_addr *a2 = k2;
- const int cmp_offset = offsetof(struct device_addr, flags);
- const int cmp_size = sizeof(struct device_addr) - cmp_offset;
+ const int cmp_offset = offsetof(struct device_addr, addr);
+ const int cmp_size = sizeof(union if_addr);
- if (a1->index != a2->index)
- return a1->index - a2->index;
return memcmp(k1+cmp_offset, k2+cmp_offset, cmp_size);
}
@@ -130,7 +130,6 @@ struct device_addr {
struct vlist_node node;
bool enabled;
bool failed;
- int index;
unsigned int policy_table;
struct device_route subnet;
@@ -172,7 +172,6 @@ parse_static_address_option(struct interface *iface, struct blob_attr *attr,
interface_add_error(iface, "proto", "INVALID_ADDRESS", &str, 1);
return -1;
}
- addr->index = n_addr;
n_addr++;
vlist_add(&iface->proto_ip.addr, &addr->node, addr);
}
@@ -273,7 +272,6 @@ parse_address_list(struct interface *iface, struct blob_attr *attr, bool v6,
if (!addr)
return -1;
- addr->index = n_addr;
n_addr++;
vlist_add(&iface->proto_ip.addr, &addr->node, addr);
}
Due to the index attribute, IPs are stored and returned in the order they were reported by the protocol implementation. In case of odhcp6c, this results in initially using the order provided by the DHCP/RA server and later adding new IPs at the end of the list. This has the side effect that initially, the first IP is the public IP while later, the last IP is the public one as the private IP is stable. This in turn has an effect because the commonly used function network_get_ipaddr6 returns the first IP. Signed-off-by: Jonas Lochmann <openwrt@jonaslochmann.de> --- interface-ip.c | 8 ++------ interface-ip.h | 1 - proto.c | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-)