DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ receive_association_hash_ops_by_section,
+ ConfigSection, config_section_hash_func, config_section_compare_func,
+ ReceiveAssociation, macsec_receive_association_free);
+
static int macsec_receive_association_new_static(MACsec *s, const char *filename, unsigned section_line, ReceiveAssociation **ret) {
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(macsec_receive_association_freep) ReceiveAssociation *c = NULL;
.sa = SECURITY_ASSOCIATION_NULL,
};
- r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &config_section_hash_ops, c->section, c);
+ r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &receive_association_hash_ops_by_section, c->section, c);
if (r < 0)
return r;
*ret = TAKE_PTR(c);
-
return 0;
}
DEFINE_SECTION_CLEANUP_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ receive_channel_hash_ops,
+ uint64_t, uint64_hash_func, uint64_compare_func,
+ ReceiveChannel, macsec_receive_channel_free);
+
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ receive_channel_hash_ops_by_section,
+ ConfigSection, config_section_hash_func, config_section_compare_func,
+ ReceiveChannel, macsec_receive_channel_free);
+
static int macsec_receive_channel_new(MACsec *s, uint64_t sci, ReceiveChannel **ret) {
ReceiveChannel *c;
c->section = TAKE_PTR(n);
- r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &config_section_hash_ops, c->section, c);
+ r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &receive_channel_hash_ops_by_section, c->section, c);
if (r < 0)
return r;
*ret = TAKE_PTR(c);
-
return 0;
}
DEFINE_SECTION_CLEANUP_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
+DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
+ transmit_association_hash_ops_by_section,
+ ConfigSection, config_section_hash_func, config_section_compare_func,
+ TransmitAssociation, macsec_transmit_association_free);
+
static int macsec_transmit_association_new_static(MACsec *s, const char *filename, unsigned section_line, TransmitAssociation **ret) {
_cleanup_(config_section_freep) ConfigSection *n = NULL;
_cleanup_(macsec_transmit_association_freep) TransmitAssociation *a = NULL;
.sa = SECURITY_ASSOCIATION_NULL,
};
- r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &config_section_hash_ops, a->section, a);
+ r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &transmit_association_hash_ops_by_section, a->section, a);
if (r < 0)
return r;
*ret = TAKE_PTR(a);
-
return 0;
}
"Ignoring [MACsecReceiveChannel] section from line %u",
c->section->filename, c->section->line);
- r = ordered_hashmap_ensure_put(&c->macsec->receive_channels, &uint64_hash_ops, &c->sci.as_uint64, c);
+ r = ordered_hashmap_ensure_put(&c->macsec->receive_channels, &receive_channel_hash_ops, &c->sci.as_uint64, c);
if (r == -ENOMEM)
return log_oom();
if (r == -EEXIST)
if (r < 0)
return log_oom();
- r = ordered_hashmap_ensure_put(&a->macsec->receive_channels, &uint64_hash_ops, &new_channel->sci.as_uint64, new_channel);
+ r = ordered_hashmap_ensure_put(&a->macsec->receive_channels, &receive_channel_hash_ops, &new_channel->sci.as_uint64, new_channel);
if (r == -ENOMEM)
return log_oom();
if (r < 0)
static void macsec_done(NetDev *netdev) {
MACsec *v = MACSEC(netdev);
- ordered_hashmap_free_with_destructor(v->receive_channels, macsec_receive_channel_free);
- ordered_hashmap_free_with_destructor(v->receive_channels_by_section, macsec_receive_channel_free);
- ordered_hashmap_free_with_destructor(v->transmit_associations_by_section, macsec_transmit_association_free);
- ordered_hashmap_free_with_destructor(v->receive_associations_by_section, macsec_receive_association_free);
+ ordered_hashmap_free(v->receive_channels);
+ ordered_hashmap_free(v->receive_channels_by_section);
+ ordered_hashmap_free(v->transmit_associations_by_section);
+ ordered_hashmap_free(v->receive_associations_by_section);
}
const NetDevVTable macsec_vtable = {