[oe-commits] [openembedded-core] 04/17: connman: fix nat-postrouting not update issue

git at git.openembedded.org git at git.openembedded.org
Sun Jan 21 09:55:40 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 918754c8e855dea07a49e30b6ff1d3e3dd7530c7
Author: Jian Liang <jianliang at tycoint.com>
AuthorDate: Fri Jan 19 14:42:11 2018 +0000

    connman: fix nat-postrouting not update issue
    
    When more than one session are created with the same
    "AllowedInterface", connman failed to update nat-
    postrouting rules when new IP address was got
    
    Signed-off-by: Jian Liang <jianliang at tycoint.com>
    Signed-off-by: André Draszik <andre.draszik at jci.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 ...ion-Keep-track-of-addr-in-fw_snat-session.patch | 112 +++++++++++++++++++++
 meta/recipes-connectivity/connman/connman_1.35.bb  |   1 +
 2 files changed, 113 insertions(+)

diff --git a/meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch b/meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch
new file mode 100644
index 0000000..f1b4d0a
--- /dev/null
+++ b/meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch
@@ -0,0 +1,112 @@
+From b5fd5945886fa1845db5c969424b63d894fe0376 Mon Sep 17 00:00:00 2001
+From: Jian Liang <jianliang at tycoint.com>
+Date: Fri, 25 Aug 2017 10:02:16 -0400
+Subject: [PATCH 1/2] session: Keep track of addr in fw_snat & session
+To: connman at lists.01.org
+Cc: wagi at monom.org
+
+When there is more than one session in fw_snat's list of sessions,
+fw_snat failed to be re-created when update-session-state is triggered
+with new IP address. This is because index alone is not sufficient to
+decide if fw_snat needs to be re-created. The solution here is to keep
+a track of IP addr and use it to avoid false lookup of fw_snat.
+
+Signed-off-by: Jian Liang <jianliang at tycoint.com>
+
+---
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=f9e27d4abfcab5c80a38e0850b5ddb26277f97c1]
+Signed-off-by: André Draszik <andre.draszik at jci.com>
+ src/session.c | 19 +++++++++++++++----
+ 1 file changed, 15 insertions(+), 4 deletions(-)
+
+diff --git a/src/session.c b/src/session.c
+index 9e3c559..965ac06 100644
+--- a/src/session.c
++++ b/src/session.c
+@@ -65,6 +65,7 @@ struct connman_session {
+ 	struct firewall_context *fw;
+ 	uint32_t mark;
+ 	int index;
++	char *addr;
+ 	char *gateway;
+ 	bool policy_routing;
+ 	bool snat_enabled;
+@@ -79,6 +80,7 @@ struct fw_snat {
+ 	GSList *sessions;
+ 	int id;
+ 	int index;
++	char *addr;
+ 	struct firewall_context *fw;
+ };
+ 
+@@ -200,7 +202,7 @@ static char *service2bearer(enum connman_service_type type)
+ 	return "";
+ }
+ 
+-static struct fw_snat *fw_snat_lookup(int index)
++static struct fw_snat *fw_snat_lookup(int index, const char *addr)
+ {
+ 	struct fw_snat *fw_snat;
+ 	GSList *list;
+@@ -208,8 +210,11 @@ static struct fw_snat *fw_snat_lookup(int index)
+ 	for (list = fw_snat_list; list; list = list->next) {
+ 		fw_snat = list->data;
+ 
+-		if (fw_snat->index == index)
++		if (fw_snat->index == index) {
++			if (g_strcmp0(addr, fw_snat->addr) != 0)
++				continue;
+ 			return fw_snat;
++		}
+ 	}
+ 	return NULL;
+ }
+@@ -224,6 +229,7 @@ static int fw_snat_create(struct connman_session *session,
+ 
+ 	fw_snat->fw = __connman_firewall_create();
+ 	fw_snat->index = index;
++	fw_snat->addr = g_strdup(addr);
+ 
+ 	fw_snat->id = __connman_firewall_enable_snat(fw_snat->fw,
+ 						index, ifname, addr);
+@@ -238,6 +244,7 @@ static int fw_snat_create(struct connman_session *session,
+ 	return 0;
+ err:
+ 	__connman_firewall_destroy(fw_snat->fw);
++	g_free(fw_snat->addr);
+ 	g_free(fw_snat);
+ 	return err;
+ }
+@@ -393,7 +400,7 @@ static void del_nat_rules(struct connman_session *session)
+ 		return;
+ 
+ 	session->snat_enabled = false;
+-	fw_snat = fw_snat_lookup(session->index);
++	fw_snat = fw_snat_lookup(session->index, session->addr);
+ 
+ 	if (!fw_snat)
+ 		return;
+@@ -420,8 +427,11 @@ static void add_nat_rules(struct connman_session *session)
+ 	if (!addr)
+ 		return;
+ 
++	g_free(session->addr);
++	session->addr = g_strdup(addr);
++
+ 	session->snat_enabled = true;
+-	fw_snat = fw_snat_lookup(index);
++	fw_snat = fw_snat_lookup(index, session->addr);
+ 	if (fw_snat) {
+ 		fw_snat_ref(session, fw_snat);
+ 		return;
+@@ -502,6 +512,7 @@ static void free_session(struct connman_session *session)
+ 	g_free(session->info);
+ 	g_free(session->info_last);
+ 	g_free(session->gateway);
++	g_free(session->addr);
+ 
+ 	g_free(session);
+ }
+-- 
+2.7.4
+
diff --git a/meta/recipes-connectivity/connman/connman_1.35.bb b/meta/recipes-connectivity/connman/connman_1.35.bb
index 950946f..e7e5d38 100644
--- a/meta/recipes-connectivity/connman/connman_1.35.bb
+++ b/meta/recipes-connectivity/connman/connman_1.35.bb
@@ -6,6 +6,7 @@ SRC_URI  = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
             file://connman \
             file://no-version-scripts.patch \
             file://includes.patch \
+            file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \
             "
 SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \
                              "

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list