[LEDE-DEV,umdns] Drop entries cached for interface we're going to delete

Message ID 20170320115450.8893-1-zajec5@gmail.com
State Accepted
Delegated to: Rafał Miłecki
Headers show

Commit Message

Rafał Miłecki March 20, 2017, 11:54 a.m.
From: Rafał Miłecki <rafal@milecki.pl>

Since we free memory with struct interface we can't keep
referencing/using it in cached records or services.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 interface.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

John Crispin March 20, 2017, 12:13 p.m. | #1
On 20/03/17 12:54, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> Since we free memory with struct interface we can't keep
> referencing/using it in cached records or services.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>

> ---
>   interface.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/interface.c b/interface.c
> index a09e7ce..cde184b 100644
> --- a/interface.c
> +++ b/interface.c
> @@ -34,6 +34,7 @@
>   #include <libubox/uloop.h>
>   #include <libubox/avl-cmp.h>
>   #include <libubox/utils.h>
> +#include "cache.h"
>   #include "interface.h"
>   #include "util.h"
>   #include "dns.h"
> @@ -519,6 +520,7 @@ iface_update_cb(struct vlist_tree *tree, struct vlist_node *node_new,
>   
>   	if (node_old) {
>   		iface = container_of(node_old, struct interface, node);
> +		cache_cleanup(iface);
>   		interface_free(iface);
>   	}
>

Patch

diff --git a/interface.c b/interface.c
index a09e7ce..cde184b 100644
--- a/interface.c
+++ b/interface.c
@@ -34,6 +34,7 @@ 
 #include <libubox/uloop.h>
 #include <libubox/avl-cmp.h>
 #include <libubox/utils.h>
+#include "cache.h"
 #include "interface.h"
 #include "util.h"
 #include "dns.h"
@@ -519,6 +520,7 @@  iface_update_cb(struct vlist_tree *tree, struct vlist_node *node_new,
 
 	if (node_old) {
 		iface = container_of(node_old, struct interface, node);
+		cache_cleanup(iface);
 		interface_free(iface);
 	}