summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/netdev/l2tp-tunnel.c8
-rw-r--r--src/network/netdev/macsec.c18
-rw-r--r--src/network/netdev/wireguard.c6
-rw-r--r--src/network/networkctl.c2
-rw-r--r--src/network/networkd-manager.c6
-rw-r--r--src/network/networkd-manager.h2
-rw-r--r--src/network/networkd-util.h7
-rw-r--r--src/network/tc/qdisc.c6
-rw-r--r--src/network/tc/qdisc.h2
-rw-r--r--src/network/tc/tclass.c6
-rw-r--r--src/network/tc/tclass.h2
-rw-r--r--src/network/wait-online/manager.c9
-rw-r--r--src/network/wait-online/manager.h2
13 files changed, 36 insertions, 40 deletions
diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c
index e302a2cf3b..a909b15764 100644
--- a/src/network/netdev/l2tp-tunnel.c
+++ b/src/network/netdev/l2tp-tunnel.c
@@ -39,18 +39,16 @@ static const char* const l2tp_local_address_type_table[_NETDEV_L2TP_LOCAL_ADDRES
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(l2tp_local_address_type, L2tpLocalAddressType);
-static void l2tp_session_free(L2tpSession *s) {
+static L2tpSession* l2tp_session_free(L2tpSession *s) {
if (!s)
- return;
+ return NULL;
if (s->tunnel && s->section)
ordered_hashmap_remove(s->tunnel->sessions_by_section, s->section);
network_config_section_free(s->section);
-
free(s->name);
-
- free(s);
+ return mfree(s);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(L2tpSession, l2tp_session_free);
diff --git a/src/network/netdev/macsec.c b/src/network/netdev/macsec.c
index bef5ba1c51..77c5f8c4e7 100644
--- a/src/network/netdev/macsec.c
+++ b/src/network/netdev/macsec.c
@@ -35,9 +35,9 @@ static void security_association_init(SecurityAssociation *sa) {
sa->use_for_encoding = -1;
}
-static void macsec_receive_association_free(ReceiveAssociation *c) {
+static ReceiveAssociation* macsec_receive_association_free(ReceiveAssociation *c) {
if (!c)
- return;
+ return NULL;
if (c->macsec && c->section)
ordered_hashmap_remove(c->macsec->receive_associations_by_section, c->section);
@@ -45,7 +45,7 @@ static void macsec_receive_association_free(ReceiveAssociation *c) {
network_config_section_free(c->section);
security_association_clear(&c->sa);
- free(c);
+ return mfree(c);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveAssociation, macsec_receive_association_free);
@@ -90,9 +90,9 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
return 0;
}
-static void macsec_receive_channel_free(ReceiveChannel *c) {
+static ReceiveChannel* macsec_receive_channel_free(ReceiveChannel *c) {
if (!c)
- return;
+ return NULL;
if (c->macsec) {
if (c->sci.as_uint64 > 0)
@@ -104,7 +104,7 @@ static void macsec_receive_channel_free(ReceiveChannel *c) {
network_config_section_free(c->section);
- free(c);
+ return mfree(c);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(ReceiveChannel, macsec_receive_channel_free);
@@ -162,9 +162,9 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
return 0;
}
-static void macsec_transmit_association_free(TransmitAssociation *a) {
+static TransmitAssociation* macsec_transmit_association_free(TransmitAssociation *a) {
if (!a)
- return;
+ return NULL;
if (a->macsec && a->section)
ordered_hashmap_remove(a->macsec->transmit_associations_by_section, a->section);
@@ -172,7 +172,7 @@ static void macsec_transmit_association_free(TransmitAssociation *a) {
network_config_section_free(a->section);
security_association_clear(&a->sa);
- free(a);
+ return mfree(a);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(TransmitAssociation, macsec_transmit_association_free);
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index e442ecc266..75d6d376a5 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -26,11 +26,11 @@
static void resolve_endpoints(NetDev *netdev);
-static void wireguard_peer_free(WireguardPeer *peer) {
+static WireguardPeer* wireguard_peer_free(WireguardPeer *peer) {
WireguardIPmask *mask;
if (!peer)
- return;
+ return NULL;
if (peer->wireguard) {
LIST_REMOVE(peers, peer->wireguard->peers, peer);
@@ -54,7 +54,7 @@ static void wireguard_peer_free(WireguardPeer *peer) {
free(peer->preshared_key_file);
explicit_bzero_safe(peer->preshared_key, WG_KEY_LEN);
- free(peer);
+ return mfree(peer);
}
DEFINE_NETWORK_SECTION_FUNCTIONS(WireguardPeer, wireguard_peer_free);
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 4381f63a2d..1dd3438abd 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -230,7 +230,7 @@ static int link_info_compare(const LinkInfo *a, const LinkInfo *b) {
return CMP(a->ifindex, b->ifindex);
}
-static const LinkInfo* link_info_array_free(LinkInfo *array) {
+static LinkInfo* link_info_array_free(LinkInfo *array) {
for (unsigned i = 0; array && array[i].needs_freeing; i++) {
sd_device_unref(array[i].sd_device);
free(array[i].ssid);
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index d7e0662453..debd9f1ecc 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -850,11 +850,11 @@ int manager_new(Manager **ret) {
return 0;
}
-void manager_free(Manager *m) {
+Manager* manager_free(Manager *m) {
Link *link;
if (!m)
- return;
+ return NULL;
free(m->state_file);
@@ -909,7 +909,7 @@ void manager_free(Manager *m) {
m->fw_ctx = fw_ctx_free(m->fw_ctx);
- free(m);
+ return mfree(m);
}
int manager_start(Manager *m) {
diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h
index f553abcc54..8b5f8a9dc0 100644
--- a/src/network/networkd-manager.h
+++ b/src/network/networkd-manager.h
@@ -83,7 +83,7 @@ struct Manager {
};
int manager_new(Manager **ret);
-void manager_free(Manager *m);
+Manager* manager_free(Manager *m);
int manager_connect_bus(Manager *m);
int manager_start(Manager *m);
diff --git a/src/network/networkd-util.h b/src/network/networkd-util.h
index efeeb86eb0..1736e2b57b 100644
--- a/src/network/networkd-util.h
+++ b/src/network/networkd-util.h
@@ -47,8 +47,8 @@ sd_dhcp_lease_server_type dhcp_lease_server_type_from_string(const char *s) _pur
int kernel_route_expiration_supported(void);
-static inline void network_config_section_free(NetworkConfigSection *cs) {
- free(cs);
+static inline NetworkConfigSection* network_config_section_free(NetworkConfigSection *cs) {
+ return mfree(cs);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free);
@@ -66,13 +66,14 @@ static inline bool section_is_invalid(NetworkConfigSection *section) {
}
#define DEFINE_NETWORK_SECTION_FUNCTIONS(type, free_func) \
- static inline void free_func##_or_set_invalid(type *p) { \
+ static inline type* free_func##_or_set_invalid(type *p) { \
assert(p); \
\
if (p->section) \
p->section->invalid = true; \
else \
free_func(p); \
+ return NULL; \
} \
DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func); \
DEFINE_TRIVIAL_CLEANUP_FUNC(type*, free_func##_or_set_invalid);
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
index 7016dc1877..2e0f0a12eb 100644
--- a/src/network/tc/qdisc.c
+++ b/src/network/tc/qdisc.c
@@ -134,9 +134,9 @@ int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, uns
return 0;
}
-void qdisc_free(QDisc *qdisc) {
+QDisc* qdisc_free(QDisc *qdisc) {
if (!qdisc)
- return;
+ return NULL;
if (qdisc->network && qdisc->section)
ordered_hashmap_remove(qdisc->network->tc_by_section, qdisc->section);
@@ -144,7 +144,7 @@ void qdisc_free(QDisc *qdisc) {
network_config_section_free(qdisc->section);
free(qdisc->tca_kind);
- free(qdisc);
+ return mfree(qdisc);
}
static int qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
diff --git a/src/network/tc/qdisc.h b/src/network/tc/qdisc.h
index 2232189f4f..bf2df146a7 100644
--- a/src/network/tc/qdisc.h
+++ b/src/network/tc/qdisc.h
@@ -74,7 +74,7 @@ extern const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX];
/* For casting the various qdisc kinds into a qdisc */
#define QDISC(q) (&(q)->meta)
-void qdisc_free(QDisc *qdisc);
+QDisc* qdisc_free(QDisc *qdisc);
int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, unsigned section_line, QDisc **ret);
int qdisc_configure(Link *link, QDisc *qdisc);
diff --git a/src/network/tc/tclass.c b/src/network/tc/tclass.c
index 64bdfbb90b..d8145997f0 100644
--- a/src/network/tc/tclass.c
+++ b/src/network/tc/tclass.c
@@ -90,16 +90,16 @@ int tclass_new_static(TClassKind kind, Network *network, const char *filename, u
return 0;
}
-void tclass_free(TClass *tclass) {
+TClass* tclass_free(TClass *tclass) {
if (!tclass)
- return;
+ return NULL;
if (tclass->network && tclass->section)
ordered_hashmap_remove(tclass->network->tc_by_section, tclass->section);
network_config_section_free(tclass->section);
- free(tclass);
+ return mfree(tclass);
}
static int tclass_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
diff --git a/src/network/tc/tclass.h b/src/network/tc/tclass.h
index 8e5e52c401..fc91789f30 100644
--- a/src/network/tc/tclass.h
+++ b/src/network/tc/tclass.h
@@ -53,7 +53,7 @@ extern const TClassVTable * const tclass_vtable[_TCLASS_KIND_MAX];
/* For casting the various tclass kinds into a tclass */
#define TCLASS(t) (&(t)->meta)
-void tclass_free(TClass *tclass);
+TClass* tclass_free(TClass *tclass);
int tclass_new_static(TClassKind kind, Network *network, const char *filename, unsigned section_line, TClass **ret);
int tclass_configure(Link *link, TClass *tclass);
diff --git a/src/network/wait-online/manager.c b/src/network/wait-online/manager.c
index 8321395550..f6c8cf909f 100644
--- a/src/network/wait-online/manager.c
+++ b/src/network/wait-online/manager.c
@@ -347,21 +347,18 @@ int manager_new(Manager **ret, Hashmap *interfaces, char **ignore,
return 0;
}
-void manager_free(Manager *m) {
+Manager* manager_free(Manager *m) {
if (!m)
- return;
+ return NULL;
hashmap_free_with_destructor(m->links, link_free);
hashmap_free(m->links_by_name);
sd_event_source_unref(m->network_monitor_event_source);
sd_network_monitor_unref(m->network_monitor);
-
sd_event_source_unref(m->rtnl_event_source);
sd_netlink_unref(m->rtnl);
-
sd_event_unref(m->event);
- free(m);
- return;
+ return mfree(m);
}
diff --git a/src/network/wait-online/manager.h b/src/network/wait-online/manager.h
index f5e83532ae..9892a43dc9 100644
--- a/src/network/wait-online/manager.h
+++ b/src/network/wait-online/manager.h
@@ -32,7 +32,7 @@ struct Manager {
sd_event *event;
};
-void manager_free(Manager *m);
+Manager* manager_free(Manager *m);
int manager_new(Manager **ret, Hashmap *interfaces, char **ignore,
LinkOperationalStateRange required_operstate,
bool any, usec_t timeout);