From 089fb2fb2d9e2a3473aa6fac91681ca8ddfffff3 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 16 Nov 2017 03:35:01 +0100 Subject: [PATCH] sender: Deplete ACLs on exit. This teaches the dccp and the http sender to empty their access control lists during shutdown, avoiding some (harmless) memory leaks at exit. --- dccp_send.c | 8 +++++++- http_send.c | 8 +++++++- send.h | 1 + send_common.c | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/dccp_send.c b/dccp_send.c index bd6c0257..0b454e79 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -80,6 +80,12 @@ static void dccp_shutdown_clients(void) dccp_shutdown_client(sc); } +static void dccp_shutdown(void) +{ + dccp_shutdown_clients(); + generic_acl_deplete(&dss->acl); +} + /** * Obtain current MPS according to RFC 4340, sec. 14. */ static int dccp_init_fec(struct sender_client *sc) { @@ -238,7 +244,7 @@ static void dccp_send_init(void) const struct sender dccp_sender = { .name = "dccp", .init = dccp_send_init, - .shutdown = dccp_shutdown_clients, + .shutdown = dccp_shutdown, .pre_select = dccp_pre_select, .post_select = dccp_post_select, .shutdown_clients = dccp_shutdown_clients, diff --git a/http_send.c b/http_send.c index fb9fd9b3..9a35fc99 100644 --- a/http_send.c +++ b/http_send.c @@ -75,6 +75,12 @@ static void http_shutdown_clients(void) shutdown_clients(hss); } +static void http_shutdown(void) +{ + http_shutdown_clients(); + generic_acl_deplete(&hss->acl); +} + static int queue_chunk_or_shutdown(struct sender_client *sc, struct sender_status *ss, const char *buf, size_t num_bytes) { @@ -264,7 +270,7 @@ static void http_send_init(void) const struct sender http_sender = { .name = "http", .init = http_send_init, - .shutdown = http_shutdown_clients, + .shutdown = http_shutdown, .pre_select = http_pre_select, .post_select = http_post_select, .send = http_send, diff --git a/send.h b/send.h index bca03b20..212fb4a1 100644 --- a/send.h +++ b/send.h @@ -190,6 +190,7 @@ void generic_com_allow(struct sender_command_data *scd, struct sender_status *ss); void generic_com_deny(struct sender_command_data *scd, struct sender_status *ss); +void generic_acl_deplete(struct list_head *acl); int generic_com_on(struct sender_status *ss, unsigned protocol); void generic_com_off(struct sender_status *ss); char *generic_sender_help(void); diff --git a/send_common.c b/send_common.c index 2088c8b4..3e8a7c0d 100644 --- a/send_common.c +++ b/send_common.c @@ -218,6 +218,22 @@ void generic_com_allow(struct sender_command_data *scd, acl_allow(scd->host, scd->netmask, &ss->acl, ss->default_deny); } +/** + * Empty the access control list of a sender. + * + * \param acl The access control list of the sender. + * + * This is called from the ->shutdown methods of the http and the dccp sender. + */ +void generic_acl_deplete(struct list_head *acl) +{ + /* + * Since default_deny is false, the ACL is considered a blacklist. A + * netmask of zero matches any IP address, so this call empties the ACL. + */ + acl_allow("0.0.0.0", 0 /* netmask */, acl, 0 /* default_deny */); +} + /** * Deny connections from the given range of IP addresses. * -- 2.39.5