Skip to contentSkip to conversation

connman: add a few backported patches

PATCH New André Draszik 1 participant 4 messages Jan 19, 2018

lore
Share & tools
lore
#0 lore raw

cover connman: add a few backported patches

The following patches backport a few connman fixes, as connman hasn't seen a new release since August 2017.

Cheers,
Andre'

#1 lore raw

PATCH 1/3 connman: fix nat-postrouting not update issue

From: Jian Liang <[email protected]>

When more than one session are created with the same "AllowedInterface", connman failed to update nat- postrouting rules when new IP address was got

---
 ...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(+)
 create mode 100644 meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch
meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch new file +112 -0
new file mode 100644
index 0000000000..f1b4d0aaa7
@@ -0,0 +1,112 @@
+From b5fd5945886fa1845db5c969424b63d894fe0376 Mon Sep 17 00:00:00 2001
+From: Jian Liang <[email protected]>
+Date: Fri, 25 Aug 2017 10:02:16 -0400
+Subject: [PATCH 1/2] session: Keep track of addr in fw_snat & session
+To: [email protected]
+Cc: [email protected]
+
+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 <[email protected]>
+
+---
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=f9e27d4abfcab5c80a38e0850b5ddb26277f97c1]
+Signed-off-by: André Draszik <[email protected]>
+ 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
+
meta/recipes-connectivity/connman/connman_1.35.bb +1 -0
index 950946fe76..e7e5d38d61 100644
@@ -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 \
                              "
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/3 connman: Fix a crash using wispr over TLS

In reply to André Draszik

From: Jian Liang <[email protected]>

This is happened when doing wispr against a HTTPS URL rather than the default one, i.e.
http://ipv4.connman.net/online/status.html

When gnutls_channel is instantiated, the gnutls_channel->established has to be initiated as FALSE. Otherwise, check_handshake function won't work. A random initial value 1 of gnutls_channel->established will make check_handshake return G_IO_STATUS_NORMAL, when the channel is actually not ready to be used. The observed behaviours are,

- wispr is getting random errors in wispr_portal_web_result
- ConnMan crashes on exit after those random errors
- when wispr is luckly working, ConnMan doesn't crash on exit

---
 ...iognutls-Fix-a-crash-using-wispr-over-TLS.patch | 41 ++++++++++++++++++++++
 meta/recipes-connectivity/connman/connman_1.35.bb  |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-connectivity/connman/connman/0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch
meta/recipes-connectivity/connman/connman/0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch new file +41 -0
new file mode 100644
index 0000000000..f9080d4ba9
@@ -0,0 +1,41 @@
+From 929fc9b7068100444e0ffcccd25841f78791e619 Mon Sep 17 00:00:00 2001
+From: Jian Liang <[email protected]>
+Date: Fri, 15 Sep 2017 06:40:08 -0400
+Subject: [PATCH] gweb: Fix a crash using wispr over TLS
+To: [email protected]
+Cc: [email protected]
+
+When gnutls_channel is instantiated, the gnutls_channel->established
+has to be initiated as FALSE. Otherwise, check_handshake function
+won't work. A random initial value 1 of gnutls_channel->established
+will make check_handshake return G_IO_STATUS_NORMAL, when the channel
+is actually not ready to be used. The observed behaviours are,
+
+- wispr is getting random errors in wispr_portal_web_result
+- ConnMan crashes on exit after those random errors
+- when wispr is luckly working, ConnMan doesn't crash on exit
+
+Signed-off-by: Jian Liang <[email protected]>
+
+---
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=73e53f3bd9e7debae86341f1eee7b97862a56a5e]
+Signed-off-by: André Draszik <[email protected]>
+ gweb/giognutls.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gweb/giognutls.c b/gweb/giognutls.c
+index 09dc9e7..c029a8b 100644
+--- a/gweb/giognutls.c
++++ b/gweb/giognutls.c
+@@ -421,7 +421,7 @@ GIOChannel *g_io_channel_gnutls_new(int fd)
+ 
+ 	DBG("");
+ 
+-	gnutls_channel = g_new(GIOGnuTLSChannel, 1);
++	gnutls_channel = g_new0(GIOGnuTLSChannel, 1);
+ 
+ 	channel = (GIOChannel *) gnutls_channel;
+ 
+-- 
+2.7.4
+
meta/recipes-connectivity/connman/connman_1.35.bb +1 -0
index e7e5d38d61..4663a7e3e8 100644
@@ -7,6 +7,7 @@ SRC_URI  = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
             file://no-version-scripts.patch \
             file://includes.patch \
             file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \
+            file://0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch \
             "
 SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \
                              "
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 connman: Implement subnet route in session

In reply to André Draszik

From: Jian Liang <[email protected]>

Implement subnet route creation/deletion in session, e.g.

default via 192.168.100.1 dev eth0
192.168.100.0/24 dev eth0

---
 ...Add-prefixlen-to-iproute_default_function.patch | 63 ++++++++++++++++++
 ...ent-subnet-route-creation-deletion-in-ipr.patch | 69 +++++++++++++++++++
 ...ent-APIs-for-creating-and-deleting-subnet.patch | 68 +++++++++++++++++++
 ...e-subnet-route-creation-and-deletion-APIs.patch | 77 ++++++++++++++++++++++
 meta/recipes-connectivity/connman/connman_1.35.bb  |  4 ++
 5 files changed, 281 insertions(+)
 create mode 100644 meta/recipes-connectivity/connman/connman/0001-inet-Add-prefixlen-to-iproute_default_function.patch
 create mode 100644 meta/recipes-connectivity/connman/connman/0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch
 create mode 100644 meta/recipes-connectivity/connman/connman/0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch
 create mode 100644 meta/recipes-connectivity/connman/connman/0004-session-Use-subnet-route-creation-and-deletion-APIs.patch
meta/recipes-connectivity/connman/connman/0001-inet-Add-prefixlen-to-iproute_default_function.patch new file +63 -0
new file mode 100644
index 0000000000..dd7b356741
@@ -0,0 +1,63 @@
+From 508dc60a1f0758ebc586b6b086478a176d493086 Mon Sep 17 00:00:00 2001
+From: Jian Liang <[email protected]>
+Date: Thu, 5 Oct 2017 09:34:41 +0100
+Subject: [PATCH 1/4] inet: Add prefixlen to iproute_default_function
+To: [email protected]
+Cc: [email protected]
+
+Add prefixlen parameter to this function in preparation for using
+it also in creating subnet route later, e.g.
+
+default via 192.168.100.1 dev eth0
+192.168.100.0/24 dev eth0
+
+Signed-off-by: Jian Liang <[email protected]>
+
+---
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=edda5b695de2ee79f02314abc9b46fdd46b388e1]
+Signed-off-by: André Draszik <[email protected]>
+ src/inet.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/inet.c b/src/inet.c
+index b887aa0..ab8aec8 100644
+--- a/src/inet.c
++++ b/src/inet.c
+@@ -2796,7 +2796,7 @@ int __connman_inet_del_fwmark_rule(uint32_t table_id, int family, uint32_t fwmar
+ }
+ 
+ static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
+-			const char *gateway)
++			const char *gateway, unsigned char prefixlen)
+ {
+ 	struct __connman_inet_rtnl_handle rth;
+ 	unsigned char buf[sizeof(struct in6_addr)];
+@@ -2829,6 +2829,7 @@ static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
+ 	rth.req.u.r.rt.rtm_protocol = RTPROT_BOOT;
+ 	rth.req.u.r.rt.rtm_scope = RT_SCOPE_UNIVERSE;
+ 	rth.req.u.r.rt.rtm_type = RTN_UNICAST;
++	rth.req.u.r.rt.rtm_dst_len = prefixlen;
+ 
+ 	__connman_inet_rtnl_addattr_l(&rth.req.n, sizeof(rth.req), RTA_GATEWAY,
+ 								buf, len);
+@@ -2860,7 +2861,7 @@ int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex,
+ {
+ 	/* ip route add default via 1.2.3.4 dev wlan0 table 1234 */
+ 
+-	return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway);
++	return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway, 0);
+ }
+ 
+ int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex,
+@@ -2868,7 +2869,7 @@ int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex,
+ {
+ 	/* ip route del default via 1.2.3.4 dev wlan0 table 1234 */
+ 
+-	return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway);
++	return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway, 0);
+ }
+ 
+ int __connman_inet_get_interface_ll_address(int index, int family,
+-- 
+2.7.4
+
meta/recipes-connectivity/connman/connman/0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch new file +69 -0

69 lines not on this page · raw message

meta/recipes-connectivity/connman/connman/0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch new file +68 -0

68 lines not on this page · raw message

meta/recipes-connectivity/connman/connman/0004-session-Use-subnet-route-creation-and-deletion-APIs.patch new file +77 -0

77 lines not on this page · raw message

meta/recipes-connectivity/connman/connman_1.35.bb +4 -0
index 4663a7e3e8..ff2118113f 100644
@@ -8,6 +8,10 @@ SRC_URI  = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
             file://includes.patch \
             file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \
             file://0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch \
+            file://0001-inet-Add-prefixlen-to-iproute_default_function.patch \
+            file://0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch \
+            file://0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch \
+            file://0004-session-Use-subnet-route-creation-and-deletion-APIs.patch \
             "
 SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \
                              "
Signature · 1 line
2.15.1