summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/connman
diff options
context:
space:
mode:
authorJian Liang <jianliang@tycoint.com>2018-01-19 14:42:13 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-22 10:39:09 +0000
commita54c639db0fe01b52b94a182448f879e9d5fea80 (patch)
treeb93d341ca7264f7c8c087f4ab3620a0ab06fb962 /meta/recipes-connectivity/connman
parent10e1be398b9279af50ac1c32772222a72826e3ad (diff)
downloadpoky-a54c639db0fe01b52b94a182448f879e9d5fea80.tar.gz
connman: Implement subnet route in session
Implement subnet route creation/deletion in session, e.g. default via 192.168.100.1 dev eth0 192.168.100.0/24 dev eth0 (From OE-Core rev: d6ac8a53d05124cbe34bc6673cb46091b50c7643) 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>
Diffstat (limited to 'meta/recipes-connectivity/connman')
-rw-r--r--meta/recipes-connectivity/connman/connman/0001-inet-Add-prefixlen-to-iproute_default_function.patch63
-rw-r--r--meta/recipes-connectivity/connman/connman/0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch69
-rw-r--r--meta/recipes-connectivity/connman/connman/0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch68
-rw-r--r--meta/recipes-connectivity/connman/connman/0004-session-Use-subnet-route-creation-and-deletion-APIs.patch77
-rw-r--r--meta/recipes-connectivity/connman/connman_1.35.bb4
5 files changed, 281 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/connman/connman/0001-inet-Add-prefixlen-to-iproute_default_function.patch b/meta/recipes-connectivity/connman/connman/0001-inet-Add-prefixlen-to-iproute_default_function.patch
new file mode 100644
index 0000000000..dd7b356741
--- /dev/null
+++ b/meta/recipes-connectivity/connman/connman/0001-inet-Add-prefixlen-to-iproute_default_function.patch
@@ -0,0 +1,63 @@
1From 508dc60a1f0758ebc586b6b086478a176d493086 Mon Sep 17 00:00:00 2001
2From: Jian Liang <jianliang@tycoint.com>
3Date: Thu, 5 Oct 2017 09:34:41 +0100
4Subject: [PATCH 1/4] inet: Add prefixlen to iproute_default_function
5To: connman@lists.01.org
6Cc: wagi@monom.org
7
8Add prefixlen parameter to this function in preparation for using
9it also in creating subnet route later, e.g.
10
11default via 192.168.100.1 dev eth0
12192.168.100.0/24 dev eth0
13
14Signed-off-by: Jian Liang <jianliang@tycoint.com>
15
16---
17Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=edda5b695de2ee79f02314abc9b46fdd46b388e1]
18Signed-off-by: André Draszik <andre.draszik@jci.com>
19 src/inet.c | 7 ++++---
20 1 file changed, 4 insertions(+), 3 deletions(-)
21
22diff --git a/src/inet.c b/src/inet.c
23index b887aa0..ab8aec8 100644
24--- a/src/inet.c
25+++ b/src/inet.c
26@@ -2796,7 +2796,7 @@ int __connman_inet_del_fwmark_rule(uint32_t table_id, int family, uint32_t fwmar
27 }
28
29 static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
30- const char *gateway)
31+ const char *gateway, unsigned char prefixlen)
32 {
33 struct __connman_inet_rtnl_handle rth;
34 unsigned char buf[sizeof(struct in6_addr)];
35@@ -2829,6 +2829,7 @@ static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
36 rth.req.u.r.rt.rtm_protocol = RTPROT_BOOT;
37 rth.req.u.r.rt.rtm_scope = RT_SCOPE_UNIVERSE;
38 rth.req.u.r.rt.rtm_type = RTN_UNICAST;
39+ rth.req.u.r.rt.rtm_dst_len = prefixlen;
40
41 __connman_inet_rtnl_addattr_l(&rth.req.n, sizeof(rth.req), RTA_GATEWAY,
42 buf, len);
43@@ -2860,7 +2861,7 @@ int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex,
44 {
45 /* ip route add default via 1.2.3.4 dev wlan0 table 1234 */
46
47- return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway);
48+ return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway, 0);
49 }
50
51 int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex,
52@@ -2868,7 +2869,7 @@ int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex,
53 {
54 /* ip route del default via 1.2.3.4 dev wlan0 table 1234 */
55
56- return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway);
57+ return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway, 0);
58 }
59
60 int __connman_inet_get_interface_ll_address(int index, int family,
61--
622.7.4
63
diff --git a/meta/recipes-connectivity/connman/connman/0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch b/meta/recipes-connectivity/connman/connman/0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch
new file mode 100644
index 0000000000..9c953e5d51
--- /dev/null
+++ b/meta/recipes-connectivity/connman/connman/0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch
@@ -0,0 +1,69 @@
1From 08cda4004491d3971a8b9df937426c43800d15b1 Mon Sep 17 00:00:00 2001
2From: Jian Liang <jianliang@tycoint.com>
3Date: Thu, 5 Oct 2017 09:37:06 +0100
4Subject: [PATCH 2/4] inet: Implement subnet route creation/deletion in
5 iproute_default_modify
6To: connman@lists.01.org
7Cc: wagi@monom.org
8
9- Calculate subnet address base on gateway address and prefixlen
10- Differentiate creation of routes to gateway and subnet
11
12Signed-off-by: Jian Liang <jianliang@tycoint.com>
13
14---
15Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=ff7dcf91f12a2a237feebc6e606d0a8e92975528]
16Signed-off-by: André Draszik <andre.draszik@jci.com>
17 src/inet.c | 22 +++++++++++++++++++---
18 1 file changed, 19 insertions(+), 3 deletions(-)
19
20diff --git a/src/inet.c b/src/inet.c
21index ab8aec8..0ddb030 100644
22--- a/src/inet.c
23+++ b/src/inet.c
24@@ -2802,6 +2802,9 @@ static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
25 unsigned char buf[sizeof(struct in6_addr)];
26 int ret, len;
27 int family = connman_inet_check_ipaddress(gateway);
28+ char *dst = NULL;
29+
30+ DBG("gateway %s/%u table %u", gateway, prefixlen, table_id);
31
32 switch (family) {
33 case AF_INET:
34@@ -2814,7 +2817,19 @@ static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
35 return -EINVAL;
36 }
37
38- ret = inet_pton(family, gateway, buf);
39+ if (prefixlen) {
40+ struct in_addr ipv4_subnet_addr, ipv4_mask;
41+
42+ memset(&ipv4_subnet_addr, 0, sizeof(ipv4_subnet_addr));
43+ ipv4_mask.s_addr = htonl((0xffffffff << (32 - prefixlen)) & 0xffffffff);
44+ ipv4_subnet_addr.s_addr = inet_addr(gateway);
45+ ipv4_subnet_addr.s_addr &= ipv4_mask.s_addr;
46+
47+ dst = g_strdup(inet_ntoa(ipv4_subnet_addr));
48+ }
49+
50+ ret = inet_pton(family, dst ? dst : gateway, buf);
51+ g_free(dst);
52 if (ret <= 0)
53 return -EINVAL;
54
55@@ -2831,8 +2846,9 @@ static int iproute_default_modify(int cmd, uint32_t table_id, int ifindex,
56 rth.req.u.r.rt.rtm_type = RTN_UNICAST;
57 rth.req.u.r.rt.rtm_dst_len = prefixlen;
58
59- __connman_inet_rtnl_addattr_l(&rth.req.n, sizeof(rth.req), RTA_GATEWAY,
60- buf, len);
61+ __connman_inet_rtnl_addattr_l(&rth.req.n, sizeof(rth.req),
62+ prefixlen > 0 ? RTA_DST : RTA_GATEWAY, buf, len);
63+
64 if (table_id < 256) {
65 rth.req.u.r.rt.rtm_table = table_id;
66 } else {
67--
682.7.4
69
diff --git a/meta/recipes-connectivity/connman/connman/0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch b/meta/recipes-connectivity/connman/connman/0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch
new file mode 100644
index 0000000000..56ba5c3f4b
--- /dev/null
+++ b/meta/recipes-connectivity/connman/connman/0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch
@@ -0,0 +1,68 @@
1From a9243f13d6e1aadd69bfcc27f75f69c38be51677 Mon Sep 17 00:00:00 2001
2From: Jian Liang <jianliang@tycoint.com>
3Date: Wed, 4 Oct 2017 17:30:17 +0100
4Subject: [PATCH 3/4] inet: Implement APIs for creating and deleting subnet
5 route
6To: connman@lists.01.org
7Cc: wagi@monom.org
8
9Signed-off-by: Jian Liang <jianliang@tycoint.com>
10
11---
12Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=3a15b0b7fccd053aff91da2cc68585509d0c509b]
13Signed-off-by: André Draszik <andre.draszik@jci.com>
14 src/connman.h | 4 ++++
15 src/inet.c | 14 ++++++++++++++
16 2 files changed, 18 insertions(+)
17
18diff --git a/src/connman.h b/src/connman.h
19index 21b7080..da4446a 100644
20--- a/src/connman.h
21+++ b/src/connman.h
22@@ -240,7 +240,11 @@ int __connman_inet_rtnl_addattr32(struct nlmsghdr *n, size_t maxlen,
23 int __connman_inet_add_fwmark_rule(uint32_t table_id, int family, uint32_t fwmark);
24 int __connman_inet_del_fwmark_rule(uint32_t table_id, int family, uint32_t fwmark);
25 int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex, const char *gateway);
26+int __connman_inet_add_subnet_to_table(uint32_t table_id, int ifindex,
27+ const char *gateway, unsigned char prefixlen);
28 int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex, const char *gateway);
29+int __connman_inet_del_subnet_from_table(uint32_t table_id, int ifindex,
30+ const char *gateway, unsigned char prefixlen);
31 int __connman_inet_get_address_netmask(int ifindex,
32 struct sockaddr_in *address, struct sockaddr_in *netmask);
33
34diff --git a/src/inet.c b/src/inet.c
35index 0ddb030..dcd1ab2 100644
36--- a/src/inet.c
37+++ b/src/inet.c
38@@ -2880,6 +2880,13 @@ int __connman_inet_add_default_to_table(uint32_t table_id, int ifindex,
39 return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway, 0);
40 }
41
42+int __connman_inet_add_subnet_to_table(uint32_t table_id, int ifindex,
43+ const char *gateway, unsigned char prefixlen)
44+{
45+ /* ip route add 1.2.3.4/24 dev eth0 table 1234 */
46+ return iproute_default_modify(RTM_NEWROUTE, table_id, ifindex, gateway, prefixlen);
47+}
48+
49 int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex,
50 const char *gateway)
51 {
52@@ -2888,6 +2895,13 @@ int __connman_inet_del_default_from_table(uint32_t table_id, int ifindex,
53 return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway, 0);
54 }
55
56+int __connman_inet_del_subnet_from_table(uint32_t table_id, int ifindex,
57+ const char *gateway, unsigned char prefixlen)
58+{
59+ /* ip route del 1.2.3.4/24 dev eth0 table 1234 */
60+ return iproute_default_modify(RTM_DELROUTE, table_id, ifindex, gateway, prefixlen);
61+}
62+
63 int __connman_inet_get_interface_ll_address(int index, int family,
64 void *address)
65 {
66--
672.7.4
68
diff --git a/meta/recipes-connectivity/connman/connman/0004-session-Use-subnet-route-creation-and-deletion-APIs.patch b/meta/recipes-connectivity/connman/connman/0004-session-Use-subnet-route-creation-and-deletion-APIs.patch
new file mode 100644
index 0000000000..ca213eb18b
--- /dev/null
+++ b/meta/recipes-connectivity/connman/connman/0004-session-Use-subnet-route-creation-and-deletion-APIs.patch
@@ -0,0 +1,77 @@
1From deb9372db8396da4f7cd20555ce7c9a8b3ad96bd Mon Sep 17 00:00:00 2001
2From: Jian Liang <jianliang@tycoint.com>
3Date: Fri, 6 Oct 2017 11:40:16 +0100
4Subject: [PATCH 4/4] session: Use subnet route creation and deletion APIs
5To: connman@lists.01.org
6Cc: wagi@monom.org
7
8As subnet route is address and session specific in this case, so add
9prefixlen into struct connman_session, and update it along with ipconfig.
10Then use it in subnet route related APIs.
11
12Signed-off-by: Jian Liang <jianliang@tycoint.com>
13
14---
15Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=285f25ef6cc9e4a43dab83523f3e2eab4365ac26]
16Signed-off-by: André Draszik <andre.draszik@jci.com>
17 src/session.c | 20 ++++++++++++++++----
18 1 file changed, 16 insertions(+), 4 deletions(-)
19
20diff --git a/src/session.c b/src/session.c
21index 965ac06..7b7a14b 100644
22--- a/src/session.c
23+++ b/src/session.c
24@@ -67,6 +67,7 @@ struct connman_session {
25 int index;
26 char *addr;
27 char *gateway;
28+ unsigned char prefixlen;
29 bool policy_routing;
30 bool snat_enabled;
31 };
32@@ -357,13 +358,17 @@ static void del_default_route(struct connman_session *session)
33 if (!session->gateway)
34 return;
35
36- DBG("index %d routing table %d default gateway %s",
37- session->index, session->mark, session->gateway);
38+ DBG("index %d routing table %d default gateway %s/%u",
39+ session->index, session->mark, session->gateway, session->prefixlen);
40+
41+ __connman_inet_del_subnet_from_table(session->mark,
42+ session->index, session->gateway, session->prefixlen);
43
44 __connman_inet_del_default_from_table(session->mark,
45 session->index, session->gateway);
46 g_free(session->gateway);
47 session->gateway = NULL;
48+ session->prefixlen = 0;
49 session->index = -1;
50 }
51
52@@ -383,13 +388,20 @@ static void add_default_route(struct connman_session *session)
53 if (!session->gateway)
54 session->gateway = g_strdup(inet_ntoa(addr));
55
56- DBG("index %d routing table %d default gateway %s",
57- session->index, session->mark, session->gateway);
58+ session->prefixlen = __connman_ipconfig_get_prefixlen(ipconfig);
59+
60+ DBG("index %d routing table %d default gateway %s/%u",
61+ session->index, session->mark, session->gateway, session->prefixlen);
62
63 err = __connman_inet_add_default_to_table(session->mark,
64 session->index, session->gateway);
65 if (err < 0)
66 DBG("session %p %s", session, strerror(-err));
67+
68+ err = __connman_inet_add_subnet_to_table(session->mark,
69+ session->index, session->gateway, session->prefixlen);
70+ if (err < 0)
71+ DBG("session add subnet route %p %s", session, strerror(-err));
72 }
73
74 static void del_nat_rules(struct connman_session *session)
75--
762.7.4
77
diff --git a/meta/recipes-connectivity/connman/connman_1.35.bb b/meta/recipes-connectivity/connman/connman_1.35.bb
index 4663a7e3e8..ff2118113f 100644
--- a/meta/recipes-connectivity/connman/connman_1.35.bb
+++ b/meta/recipes-connectivity/connman/connman_1.35.bb
@@ -8,6 +8,10 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
8 file://includes.patch \ 8 file://includes.patch \
9 file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \ 9 file://0001-session-Keep-track-of-addr-in-fw_snat-session.patch \
10 file://0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch \ 10 file://0001-giognutls-Fix-a-crash-using-wispr-over-TLS.patch \
11 file://0001-inet-Add-prefixlen-to-iproute_default_function.patch \
12 file://0002-inet-Implement-subnet-route-creation-deletion-in-ipr.patch \
13 file://0003-inet-Implement-APIs-for-creating-and-deleting-subnet.patch \
14 file://0004-session-Use-subnet-route-creation-and-deletion-APIs.patch \
11 " 15 "
12SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \ 16SRC_URI_append_libc-musl = " file://0002-resolve-musl-does-not-implement-res_ninit.patch \
13 " 17 "