VPN Issue

2013-10-23 Thread Yevhen Kyriukha
Hi!

Can anyone of developers tell the current development status of this issue
and some estimates on its fix:
https://01.org/jira/browse/CM-620

Best regards,
Yevhen
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 6/6] ipconfig: Do not remember interface name

2013-10-23 Thread Jukka Rissanen
When interface name is needed, then just get it from index.
This should minimize the race conditions when interface name is
changed.
---
 src/connman.h  |  17 +++--
 src/ipconfig.c | 193 -
 src/ipv6pd.c   |   9 +--
 src/service.c  |  35 ++-
 4 files changed, 143 insertions(+), 111 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index e323385..0e3ec47 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -275,14 +275,14 @@ struct connman_ipaddress {
 };
 
 struct connman_ipconfig_ops {
-   void (*up) (struct connman_ipconfig *ipconfig);
-   void (*down) (struct connman_ipconfig *ipconfig);
-   void (*lower_up) (struct connman_ipconfig *ipconfig);
-   void (*lower_down) (struct connman_ipconfig *ipconfig);
-   void (*ip_bound) (struct connman_ipconfig *ipconfig);
-   void (*ip_release) (struct connman_ipconfig *ipconfig);
-   void (*route_set) (struct connman_ipconfig *ipconfig);
-   void (*route_unset) (struct connman_ipconfig *ipconfig);
+   void (*up) (struct connman_ipconfig *ipconfig, const char *ifname);
+   void (*down) (struct connman_ipconfig *ipconfig, const char *ifname);
+   void (*lower_up) (struct connman_ipconfig *ipconfig, const char 
*ifname);
+   void (*lower_down) (struct connman_ipconfig *ipconfig, const char 
*ifname);
+   void (*ip_bound) (struct connman_ipconfig *ipconfig, const char 
*ifname);
+   void (*ip_release) (struct connman_ipconfig *ipconfig, const char 
*ifname);
+   void (*route_set) (struct connman_ipconfig *ipconfig, const char 
*ifname);
+   void (*route_unset) (struct connman_ipconfig *ipconfig, const char 
*ifname);
 };
 
 struct connman_ipconfig *__connman_ipconfig_create(int index,
@@ -304,7 +304,6 @@ void *__connman_ipconfig_get_data(struct connman_ipconfig 
*ipconfig);
 void __connman_ipconfig_set_data(struct connman_ipconfig *ipconfig, void 
*data);
 
 int __connman_ipconfig_get_index(struct connman_ipconfig *ipconfig);
-const char *__connman_ipconfig_get_ifname(struct connman_ipconfig *ipconfig);
 
 void __connman_ipconfig_set_ops(struct connman_ipconfig *ipconfig,
const struct connman_ipconfig_ops *ops);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 68ece54..9c29e62 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -62,7 +62,6 @@ struct connman_ipconfig {
 
 struct connman_ipdevice {
int index;
-   char *ifname;
unsigned short type;
unsigned int flags;
char *address;
@@ -234,6 +233,13 @@ static void set_ipv6_state(gchar *ifname, bool enable)
fclose(f);
 }
 
+static void set_ipv6_state_by_index(int ifindex, bool enable)
+{
+   char *ifname = connman_inet_ifname(ifindex);
+   set_ipv6_state(ifname, enable);
+   g_free(ifname);
+}
+
 static int get_ipv6_privacy(gchar *ifname)
 {
gchar *path;
@@ -295,6 +301,13 @@ static void set_ipv6_privacy(gchar *ifname, int value)
fclose(f);
 }
 
+static void set_ipv6_privacy_by_index(int ifindex, int value)
+{
+   char *ifname = connman_inet_ifname(ifindex);
+   set_ipv6_privacy(ifname, value);
+   g_free(ifname);
+}
+
 static int get_rp_filter(void)
 {
FILE *f;
@@ -360,6 +373,8 @@ bool __connman_ipconfig_ipv6_privacy_enabled(struct 
connman_ipconfig *ipconfig)
 bool __connman_ipconfig_ipv6_is_enabled(struct connman_ipconfig *ipconfig)
 {
struct connman_ipdevice *ipdevice;
+   char *ifname;
+   bool ret;
 
if (!ipconfig)
return false;
@@ -369,15 +384,19 @@ bool __connman_ipconfig_ipv6_is_enabled(struct 
connman_ipconfig *ipconfig)
if (!ipdevice)
return false;
 
-   return get_ipv6_state(ipdevice->ifname);
+   ifname = connman_inet_ifname(ipconfig->index);
+   ret = get_ipv6_state(ifname);
+   g_free(ifname);
+
+   return ret;
 }
 
 static void free_ipdevice(gpointer data)
 {
struct connman_ipdevice *ipdevice = data;
+   char *ifname = connman_inet_ifname(ipdevice->index);
 
-   connman_info("%s {remove} index %d", ipdevice->ifname,
-   ipdevice->index);
+   connman_info("%s {remove} index %d", ifname, ipdevice->index);
 
if (ipdevice->config_ipv4) {
__connman_ipconfig_unref(ipdevice->config_ipv4);
@@ -396,10 +415,10 @@ static void free_ipdevice(gpointer data)
 
g_free(ipdevice->address);
 
-   set_ipv6_state(ipdevice->ifname, ipdevice->ipv6_enabled);
-   set_ipv6_privacy(ipdevice->ifname, ipdevice->ipv6_privacy);
+   set_ipv6_state(ifname, ipdevice->ipv6_enabled);
+   set_ipv6_privacy(ifname, ipdevice->ipv6_privacy);
 
-   g_free(ipdevice->ifname);
+   g_free(ifname);
g_free(ipdevice);
 }
 
@@ -428,15 +447,20 @@ static void update_stats(struct connman_ipdevice 
*ipdevice,
struct rtnl_link_stats *stats)
 {
 

[PATCH v2 1/6] rtnl: Set the service type to unknown if the related interface can not be found

2013-10-23 Thread Jukka Rissanen
From: Chengyi Zhao 

If system can't find the related network interface in
/sys/class/net/ then ConnMan will set the type to "unknown"
to this interface.
---
 src/rtnl.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index 0d68337..ef64e30 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -139,8 +139,11 @@ static void read_uevent(struct interface_data *interface)
 
g_free(filename);
 
-   if (!f)
+   if (!f) {
+   interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+   interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
return;
+   }
 
found_devtype = false;
while (fgets(line, sizeof(line), f)) {
-- 
1.7.11.7

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 3/6] technology: Do not use interface name when removing interface

2013-10-23 Thread Jukka Rissanen
Use always the interface index and only when interface name
is needed, then fetch the name. This minimizes races when
interface name changes because of udev rules.
---
 src/connman.h| 2 +-
 src/rtnl.c   | 2 +-
 src/technology.c | 5 -
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 36d5723..eb7b95e 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -518,7 +518,7 @@ void __connman_technology_scan_stopped(struct 
connman_device *device);
 void __connman_technology_add_interface(enum connman_service_type type,
int index, const char *name, const char *ident);
 void __connman_technology_remove_interface(enum connman_service_type type,
-   int index, const char *name, const char *ident);
+   int index, const char *ident);
 void __connman_technology_notify_regdom_by_device(struct connman_device 
*device,
int result, const char *alpha2);
 
diff --git a/src/rtnl.c b/src/rtnl.c
index ef64e30..e1d057e 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -78,7 +78,7 @@ static void free_interface(gpointer data)
struct interface_data *interface = data;
 
__connman_technology_remove_interface(interface->service_type,
-   interface->index, interface->name, interface->ident);
+   interface->index, interface->ident);
 
g_free(interface->ident);
g_free(interface->name);
diff --git a/src/technology.c b/src/technology.c
index d0e9bbb..e6fe0f5 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1266,11 +1266,12 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
 }
 
 void __connman_technology_remove_interface(enum connman_service_type type,
-   int index, const char *name, const char *ident)
+   int index, const char *ident)
 {
struct connman_technology *technology;
GSList *tech_drivers;
struct connman_technology_driver *driver;
+   char *name;
 
switch (type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
@@ -1286,8 +1287,10 @@ void __connman_technology_remove_interface(enum 
connman_service_type type,
break;
}
 
+   name = connman_inet_ifname(index);
connman_info("Remove interface %s [ %s ]", name,
__connman_service_type2string(type));
+   g_free(name);
 
technology = technology_find(type);
 
-- 
1.7.11.7

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 4/6] technology: Do not use interface name when adding interface

2013-10-23 Thread Jukka Rissanen
Use always the interface index and only when interface name
is needed, then fetch the name. This minimizes races when
interface name changes because of udev rules.
---
 src/connman.h| 2 +-
 src/rtnl.c   | 2 +-
 src/technology.c | 9 +++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index eb7b95e..e323385 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -516,7 +516,7 @@ int __connman_technology_remove_rfkill(unsigned int index,
 void __connman_technology_scan_started(struct connman_device *device);
 void __connman_technology_scan_stopped(struct connman_device *device);
 void __connman_technology_add_interface(enum connman_service_type type,
-   int index, const char *name, const char *ident);
+   int index, const char *ident);
 void __connman_technology_remove_interface(enum connman_service_type type,
int index, const char *ident);
 void __connman_technology_notify_regdom_by_device(struct connman_device 
*device,
diff --git a/src/rtnl.c b/src/rtnl.c
index e1d057e..376499b 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -480,7 +480,7 @@ static void process_newlink(unsigned short type, int index, 
unsigned flags,
 */
if (interface)
__connman_technology_add_interface(interface->service_type,
-   interface->index, interface->name, interface->ident);
+   interface->index, interface->ident);
 
for (list = watch_list; list; list = list->next) {
struct watch_data *watch = list->data;
diff --git a/src/technology.c b/src/technology.c
index e6fe0f5..28f0ff4 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1221,11 +1221,12 @@ static void enable_tethering(struct connman_technology 
*technology)
 }
 
 void __connman_technology_add_interface(enum connman_service_type type,
-   int index, const char *name, const char *ident)
+   int index, const char *ident)
 {
struct connman_technology *technology;
GSList *tech_drivers;
struct connman_technology_driver *driver;
+   char *name;
 
switch (type) {
case CONNMAN_SERVICE_TYPE_UNKNOWN:
@@ -1241,13 +1242,14 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
break;
}
 
+   name = connman_inet_ifname(index);
connman_info("Adding interface %s [ %s ]", name,
__connman_service_type2string(type));
 
technology = technology_find(type);
 
if (!technology)
-   return;
+   goto out;
 
for (tech_drivers = technology->driver_list; tech_drivers;
 tech_drivers = g_slist_next(tech_drivers)) {
@@ -1263,6 +1265,9 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
 */
if (technology->tethering_persistent)
enable_tethering(technology);
+
+out:
+   g_free(name);
 }
 
 void __connman_technology_remove_interface(enum connman_service_type type,
-- 
1.7.11.7

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 2/6] vpn: Removed unused interface name variable

2013-10-23 Thread Jukka Rissanen
---
 vpn/vpn-rtnl.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/vpn/vpn-rtnl.c b/vpn/vpn-rtnl.c
index 3118da2..af24674 100644
--- a/vpn/vpn-rtnl.c
+++ b/vpn/vpn-rtnl.c
@@ -69,7 +69,6 @@ static guint update_timeout = 0;
 
 struct interface_data {
int index;
-   char *name;
char *ident;
 };
 
@@ -80,7 +79,6 @@ static void free_interface(gpointer data)
struct interface_data *interface = data;
 
g_free(interface->ident);
-   g_free(interface->name);
g_free(interface);
 }
 
@@ -318,7 +316,6 @@ static void process_newlink(unsigned short type, int index, 
unsigned flags,
if (!interface) {
interface = g_new0(struct interface_data, 1);
interface->index = index;
-   interface->name = g_strdup(ifname);
interface->ident = g_strdup(ident);
 
g_hash_table_insert(interface_list,
-- 
1.7.11.7

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 0/6] Use interface index instead of name

2013-10-23 Thread Jukka Rissanen
Hi,

v2:
- Taking Chengyi's rtnl patch into this patchset. The patch
  sets service type to unknown if the interface's /sys/class/net
  file disappears

v1:
this patchset tries to minimize the risk of race conditions
when interface name is changed. This issue was already tackled
by commit 98919ac6cbc7535309d308363a249a0cdfe0af22 but if the
rtnl messages come in wrong order, then it is possible that we
miss the interface name change.

In order to avoid this race, we only use the interface index
which cannot change and only convert to interface name when
needed.


Cheers,
Jukka


Chengyi Zhao (1):
  rtnl: Set the service type to unknown if the related interface can
not be found

Jukka Rissanen (5):
  vpn: Removed unused interface name variable
  technology: Do not use interface name when removing interface
  technology: Do not use interface name when adding interface
  rtnl: Do not remember interface name
  ipconfig: Do not remember interface name

 src/connman.h|  21 +++---
 src/ipconfig.c   | 193 +++
 src/ipv6pd.c |   9 +--
 src/rtnl.c   |  33 +-
 src/service.c|  35 ++
 src/technology.c |  14 +++-
 vpn/vpn-rtnl.c   |   3 -
 7 files changed, 174 insertions(+), 134 deletions(-)

-- 
1.7.11.7

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH v2 5/6] rtnl: Do not remember interface name

2013-10-23 Thread Jukka Rissanen
Use always the interface index and only when interface name
is needed, then fetch the name. This minimizes races when
interface name changes because of udev rules.
---
 src/rtnl.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index 376499b..80a6edc 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -65,7 +65,6 @@ static guint update_timeout = 0;
 
 struct interface_data {
int index;
-   char *name;
char *ident;
enum connman_service_type service_type;
enum connman_device_type device_type;
@@ -81,7 +80,6 @@ static void free_interface(gpointer data)
interface->index, interface->ident);
 
g_free(interface->ident);
-   g_free(interface->name);
g_free(interface);
 }
 
@@ -120,11 +118,13 @@ static bool wext_interface(char *ifname)
 
 static void read_uevent(struct interface_data *interface)
 {
-   char *filename, line[128];
+   char *filename, *name, line[128];
bool found_devtype;
FILE *f;
 
-   if (ether_blacklisted(interface->name)) {
+   name = connman_inet_ifname(interface->index);
+
+   if (ether_blacklisted(name)) {
interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
} else {
@@ -132,8 +132,7 @@ static void read_uevent(struct interface_data *interface)
interface->device_type = CONNMAN_DEVICE_TYPE_ETHERNET;
}
 
-   filename = g_strdup_printf("/sys/class/net/%s/uevent",
-   interface->name);
+   filename = g_strdup_printf("/sys/class/net/%s/uevent", name);
 
f = fopen(filename, "re");
 
@@ -142,7 +141,7 @@ static void read_uevent(struct interface_data *interface)
if (!f) {
interface->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN;
interface->device_type = CONNMAN_DEVICE_TYPE_UNKNOWN;
-   return;
+   goto out;
}
 
found_devtype = false;
@@ -181,16 +180,18 @@ static void read_uevent(struct interface_data *interface)
fclose(f);
 
if (found_devtype)
-   return;
+   goto out;
 
/* We haven't got a DEVTYPE, let's check if it's a wireless device */
-   if (wext_interface(interface->name)) {
+   if (wext_interface(name)) {
interface->service_type = CONNMAN_SERVICE_TYPE_WIFI;
interface->device_type = CONNMAN_DEVICE_TYPE_WIFI;
 
-   connman_error("%s runs an unsupported 802.11 driver",
-   interface->name);
+   connman_error("%s runs an unsupported 802.11 driver", name);
}
+
+out:
+   g_free(name);
 }
 
 enum connman_device_type __connman_rtnl_get_device_type(int index)
@@ -454,7 +455,6 @@ static void process_newlink(unsigned short type, int index, 
unsigned flags,
if (!interface) {
interface = g_new0(struct interface_data, 1);
interface->index = index;
-   interface->name = g_strdup(ifname);
interface->ident = g_strdup(ident);
 
g_hash_table_insert(interface_list,
-- 
1.7.11.7

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH v0 04/11] service: Track all active sessions

2013-10-23 Thread Patrik Flykt

Hi,

On Thu, 2013-10-10 at 16:58 +0200, Daniel Wagner wrote:
> +static GSList *session_list = NULL;

Shouldn't we go for a hash table here?

Cheers,

Patrik
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] gweb: Fix memory leak in session address

2013-10-23 Thread Patrik Flykt
On Mon, 2013-10-21 at 13:22 +0300, Jukka Rissanen wrote:
> Session address might already be set by parse_url() (called by
> do_request() function). Because of this free old address.

Applied, thanks!

Patrik
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] network: Stop DHCP for a failed network

2013-10-23 Thread Patrik Flykt
On Tue, 2013-10-08 at 15:08 +0300, Patrik Flykt wrote:
> Simply stop DHCP instead of forcing a failed DHCP service to idle.

Applied.

Patrik
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 0/5] Use interface index instead of name

2013-10-23 Thread Chengyi Zhao
2013/10/21 Jukka Rissanen 

> Hi,
>
> this patchset tries to minimize the risk of race conditions
> when interface name is changed. This issue was already tackled
> by commit 98919ac6cbc7535309d308363a249a0cdfe0af22 but if the
> rtnl messages come in wrong order, then it is possible that we
> miss the interface name change.
>
> In order to avoid this race, we only use the interface index
> which cannot change and only convert to interface name when
> needed.
>
>
> Cheers,
> Jukka
>
>
> Jukka Rissanen (5):
>   vpn: Removed unused interface name variable
>   technology: Do not use interface name when removing interface
>   technology: Do not use interface name when adding interface
>   rtnl: Do not remember interface name
>   ipconfig: Do not remember interface name
>
>  src/connman.h|  21 +++---
>  src/ipconfig.c   | 193
> +++
>  src/ipv6pd.c |   9 +--
>  src/rtnl.c   |  28 
>  src/service.c|  35 ++
>  src/technology.c |  14 +++-
>  vpn/vpn-rtnl.c   |   3 -
>  7 files changed, 170 insertions(+), 133 deletions(-)
>

Great! I really hope Upstream will apply this patchset.

Cheers,

Chengyi

>
> --
> 1.7.11.7
>
> ___
> connman mailing list
> connman@connman.net
> https://lists.connman.net/mailman/listinfo/connman
>
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman