diff options
author | Jian Liang <jianliang@tycoint.com> | 2018-01-19 14:42:11 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-01-22 10:39:09 +0000 |
commit | f4335d224dc6484967ebd46352c151b13b64a939 (patch) | |
tree | 6981c4e4c8b00768c615d2e95891fda38bcc2ad1 | |
parent | dfd7f3f3f45e5405501f2d0875b377ee01fee685 (diff) | |
download | poky-f4335d224dc6484967ebd46352c151b13b64a939.tar.gz |
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
(From OE-Core rev: 918754c8e855dea07a49e30b6ff1d3e3dd7530c7)
Signed-off-by: Jian Liang <jianliang@tycoint.com>
Signed-off-by: André Draszik <andre.draszik@jci.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch | 112 | ||||
-rw-r--r-- | meta/recipes-connectivity/connman/connman_1.35.bb | 1 |
2 files changed, 113 insertions, 0 deletions
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 0000000000..f1b4d0aaa7 --- /dev/null +++ b/meta/recipes-connectivity/connman/connman/0001-session-Keep-track-of-addr-in-fw_snat-session.patch | |||
@@ -0,0 +1,112 @@ | |||
1 | From b5fd5945886fa1845db5c969424b63d894fe0376 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jian Liang <jianliang@tycoint.com> | ||
3 | Date: Fri, 25 Aug 2017 10:02:16 -0400 | ||
4 | Subject: [PATCH 1/2] session: Keep track of addr in fw_snat & session | ||
5 | To: connman@lists.01.org | ||
6 | Cc: wagi@monom.org | ||
7 | |||
8 | When there is more than one session in fw_snat's list of sessions, | ||
9 | fw_snat failed to be re-created when update-session-state is triggered | ||
10 | with new IP address. This is because index alone is not sufficient to | ||
11 | decide if fw_snat needs to be re-created. The solution here is to keep | ||
12 | a track of IP addr and use it to avoid false lookup of fw_snat. | ||
13 | |||
14 | Signed-off-by: Jian Liang <jianliang@tycoint.com> | ||
15 | |||
16 | --- | ||
17 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=f9e27d4abfcab5c80a38e0850b5ddb26277f97c1] | ||
18 | Signed-off-by: André Draszik <andre.draszik@jci.com> | ||
19 | src/session.c | 19 +++++++++++++++---- | ||
20 | 1 file changed, 15 insertions(+), 4 deletions(-) | ||
21 | |||
22 | diff --git a/src/session.c b/src/session.c | ||
23 | index 9e3c559..965ac06 100644 | ||
24 | --- a/src/session.c | ||
25 | +++ b/src/session.c | ||
26 | @@ -65,6 +65,7 @@ struct connman_session { | ||
27 | struct firewall_context *fw; | ||
28 | uint32_t mark; | ||
29 | int index; | ||
30 | + char *addr; | ||
31 | char *gateway; | ||
32 | bool policy_routing; | ||
33 | bool snat_enabled; | ||
34 | @@ -79,6 +80,7 @@ struct fw_snat { | ||
35 | GSList *sessions; | ||
36 | int id; | ||
37 | int index; | ||
38 | + char *addr; | ||
39 | struct firewall_context *fw; | ||
40 | }; | ||
41 | |||
42 | @@ -200,7 +202,7 @@ static char *service2bearer(enum connman_service_type type) | ||
43 | return ""; | ||
44 | } | ||
45 | |||
46 | -static struct fw_snat *fw_snat_lookup(int index) | ||
47 | +static struct fw_snat *fw_snat_lookup(int index, const char *addr) | ||
48 | { | ||
49 | struct fw_snat *fw_snat; | ||
50 | GSList *list; | ||
51 | @@ -208,8 +210,11 @@ static struct fw_snat *fw_snat_lookup(int index) | ||
52 | for (list = fw_snat_list; list; list = list->next) { | ||
53 | fw_snat = list->data; | ||
54 | |||
55 | - if (fw_snat->index == index) | ||
56 | + if (fw_snat->index == index) { | ||
57 | + if (g_strcmp0(addr, fw_snat->addr) != 0) | ||
58 | + continue; | ||
59 | return fw_snat; | ||
60 | + } | ||
61 | } | ||
62 | return NULL; | ||
63 | } | ||
64 | @@ -224,6 +229,7 @@ static int fw_snat_create(struct connman_session *session, | ||
65 | |||
66 | fw_snat->fw = __connman_firewall_create(); | ||
67 | fw_snat->index = index; | ||
68 | + fw_snat->addr = g_strdup(addr); | ||
69 | |||
70 | fw_snat->id = __connman_firewall_enable_snat(fw_snat->fw, | ||
71 | index, ifname, addr); | ||
72 | @@ -238,6 +244,7 @@ static int fw_snat_create(struct connman_session *session, | ||
73 | return 0; | ||
74 | err: | ||
75 | __connman_firewall_destroy(fw_snat->fw); | ||
76 | + g_free(fw_snat->addr); | ||
77 | g_free(fw_snat); | ||
78 | return err; | ||
79 | } | ||
80 | @@ -393,7 +400,7 @@ static void del_nat_rules(struct connman_session *session) | ||
81 | return; | ||
82 | |||
83 | session->snat_enabled = false; | ||
84 | - fw_snat = fw_snat_lookup(session->index); | ||
85 | + fw_snat = fw_snat_lookup(session->index, session->addr); | ||
86 | |||
87 | if (!fw_snat) | ||
88 | return; | ||
89 | @@ -420,8 +427,11 @@ static void add_nat_rules(struct connman_session *session) | ||
90 | if (!addr) | ||
91 | return; | ||
92 | |||
93 | + g_free(session->addr); | ||
94 | + session->addr = g_strdup(addr); | ||
95 | + | ||
96 | session->snat_enabled = true; | ||
97 | - fw_snat = fw_snat_lookup(index); | ||
98 | + fw_snat = fw_snat_lookup(index, session->addr); | ||
99 | if (fw_snat) { | ||
100 | fw_snat_ref(session, fw_snat); | ||
101 | return; | ||
102 | @@ -502,6 +512,7 @@ static void free_session(struct connman_session *session) | ||
103 | g_free(session->info); | ||
104 | g_free(session->info_last); | ||
105 | g_free(session->gateway); | ||
106 | + g_free(session->addr); | ||
107 | |||
108 | g_free(session); | ||
109 | } | ||
110 | -- | ||
111 | 2.7.4 | ||
112 | |||
diff --git a/meta/recipes-connectivity/connman/connman_1.35.bb b/meta/recipes-connectivity/connman/connman_1.35.bb index 950946fe76..e7e5d38d61 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 \ | |||
6 | file://connman \ | 6 | file://connman \ |
7 | file://no-version-scripts.patch \ | 7 | file://no-version-scripts.patch \ |
8 | file://includes.patch \ | 8 | file://includes.patch \ |
9 | file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \ | ||
9 | " | 10 | " |
10 | SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \ | 11 | SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \ |
11 | " | 12 | " |