]> code.ossystems Code Review - openembedded-core.git/blob
ca213eb18b4326d33cb0ec72f68498deda2cd2e8
[openembedded-core.git] /
1 From deb9372db8396da4f7cd20555ce7c9a8b3ad96bd Mon Sep 17 00:00:00 2001
2 From: Jian Liang <jianliang@tycoint.com>
3 Date: Fri, 6 Oct 2017 11:40:16 +0100
4 Subject: [PATCH 4/4] session: Use subnet route creation and deletion APIs
5 To: connman@lists.01.org
6 Cc: wagi@monom.org
7
8 As subnet route is address and session specific in this case, so add
9 prefixlen into struct connman_session, and update it along with ipconfig.
10 Then use it in subnet route related APIs.
11
12 Signed-off-by: Jian Liang <jianliang@tycoint.com>
13
14 ---
15 Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=285f25ef6cc9e4a43dab83523f3e2eab4365ac26]
16 Signed-off-by: AndrĂ© Draszik <andre.draszik@jci.com>
17  src/session.c | 20 ++++++++++++++++----
18  1 file changed, 16 insertions(+), 4 deletions(-)
19
20 diff --git a/src/session.c b/src/session.c
21 index 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 -- 
76 2.7.4
77