Hi Gianfranco,

On 07/01/2015 04:15 PM, Gianfranco Casanova wrote:
> we have a couple of questions about “ConnMan” capability. Actually
> we are using it (succesfully) in a GENIVI based Automotive project and we

Nice to hear :)

> have now new requirements to deal with. We read a lot of posts related
> to this topic but we did not find any concreate working example.
> 
> Our issue is to make ConnMan working with two different
> applications, one using wifi and the other using ethernet at the same time.
> 
> Mainly, the matter is:
> 
> How to correctly configure and connect two applications on ConnMan
> to use different technologies and services at the same time?

The stock version of ConnMan is likely not to fulfill your requirement.
The built in autoconnect algorithm is likely to defeat your attempt.
Patrik, Tomasz, Jukka and I have discussed this topic back and forth
and we figured out that there are conflicting goals which can't be
resolved. In this case, trying to keep only one connection up vs
have two connection up all the time.

There is a way to still solve your problem. You need to write
your own session plugin. Within this plugin you can decided 
which Services needs to be online and which Session is assigned
to that Service. 

Here is a toy example how to do it

http://git.projects.genivi.org/?p=pold.git;a=blob;f=connman/0001-session_policy_pold-Add-session-plugin-for-remote-co.patch;hb=HEAD

Obviously, this hasn't anything to do with your bug report.

> Moreover, we tried to know the IP used by the two applications
> (shell), via curl ifconfig.me <http://ifconfig.me/>.
> 
> The output of this command for the first application shows an IP
> address, while the same command for the other application reports: curl:
> (56) Recv failure: Connection timed out
> 
> Why is this happening?
> 
> Thank you in advance for your answer.
> 
> Our configuration:
> 3.19.0-15-generic #15-Ubuntu SMP Thu Apr 16 23:32:01 UTC 2015 i686 i686 i686 
> GNU/Linux
> (Ubuntu 15.04 on a HP PC)
> connmand –version 1.21
> Kernel configuration: same as requested in ConnMan README.txt
> 
> Main.conf (in /etc/connman)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [General]
> PreferredTechnologies=wifi,ethernet
> SingleConnectedTechnology=false
> SessionMode=true
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Settings file (in /etc/connman)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [global]
> OfflineMode=false
> 
> [WiFi]
> Enable=true
> Tethering=false
> 
> [Bluetooth]
> Enable=false
> Tethering=false
> 
> [Wired]
> Enable=true
> Tethering=false
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> We created two users adding the following lines:
> 
> /etc/group
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> wifi:x:132:wifisession
> eth:x:133:ethsession
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> /etc/passwd
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> wifisession:x:120:132:wifisession:/home:/bin/bash
> ethsession:x:121:133:ethsession:/home:/bin/bash
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Policy files (in /var/lib/connman/session_policy_local)
> 
> wifisession.policy
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [policy_wifisession]
> uid = wifisession
> AllowedBearers = wifi
> RoamingPolicy = forbidden
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> ethsession.policy
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [policy_ethsession]
> uid = ethsession
> AllowedBearers = ethernet
> RoamingPolicy = forbidden
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Opened two terminals, connected with the newly created users on each one.

This looks all good.

> Terminal 1: wifisession user output 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> wifisession@ $ connmanctl
> connmanctl> services
> *AO Wired ethernet_68b599eda216_cable
> *A HTC Portable Hotspot 61B3 
> wifi_0024d76e6c38_48544320506f727461626c6520486f7473706f742036314233_managed_psk
> connmanctl> agent on
> Agent registered
> connmanctl> session connect

This will trigger the autoconnect algorithm to do the magic. Note
it is likely to ignore the session configuration completely. I can't
remember the details without looking at the code.

> Session /sessions/_1_263/net/connman/connmanctl13404 created
> Session Update = {
> State = connected
> Name = Wired
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0 ]
> IPv6 = [ ]
> Interface = eth0
> Bearer = ethernet
> ConnectionType = any
> AllowedBearers = [ * ]
> }
> Session /sessions/_1_263/net/connman/connmanctl13404 connected

Hmm, why is 'AllowedBearers = *. That should be wifi according the 
configuration.
Something wrong with the mapping of the user to the session.

> connmanctl> connect 
> wifi_0024d76e6c38_48544320506f727461626c6520486f7473706f742036314233_managed_psk

The idea of the Session API is that the application wont need to
use the Service API at all. The above call should do the trick.
Not with the builtin autoconnect though, so this makes sense for
testing.

> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0, 
> Gateway=192.168.1.1 ]
> }
> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0 ]
> }
> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0, 
> Gateway=192.168.1.1 ]
> }
> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0 ]
> }
> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0, 
> Gateway=192.168.1.1 ]
> }
> Session Update = {
> State = online
> }
> Connected 
> wifi_0024d76e6c38_48544320506f727461626c6520486f7473706f742036314233_managed_psk
> Session Update = {
> State = connected
> }
> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0 ]
> }

The notifcation stuff works at least :)

> Terminal2, ethsession user output:
> ethsession@ $ connmanctl
> connmanctl> session connect
> Session /sessions/_1_264/net/connman/connmanctl13421 created
> Session Update = {
> State = online
> Name = Wired
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0, 
> Gateway=192.168.1.1 ]
> IPv6 = [ ]
> Interface = eth0
> Bearer = ethernet
> ConnectionType = any
> AllowedBearers = [ * ]
> }
> Session /sessions/_1_264/net/connman/connmanctl13421 connected
> Session Update = {
> State = connected
> }
> Session Update = {
> IPv4 = [ Method=dhcp, Address=192.168.1.100, Netmask=255.255.255.0 ]
> }

Again AllowedBearers should be something else then *.

> From a third terminal (none of the above users is using this terminal):
> connmanctl> services
> *AO HTC Portable Hotspot 61B3 
> wifi_0024d76e6c38_48544320506f727461626c6520486f7473706f742036314233_managed_psk
> *AR Wired ethernet_68b599eda216_cable
> 
> Here we think that having WiFi “online” and ETH “Ready” is sufficient to go 
> to Internet.

Yes that should work. ConnMan allows only one 'online' Service.

> ~$ sudo iptables -t mangle -L
> Chain PREROUTING (policy ACCEPT)
> target prot opt source destination 
> 
> Chain INPUT (policy ACCEPT)
> target prot opt source destination 
> connman-INPUT all -- anywhere anywhere 
> 
> Chain FORWARD (policy ACCEPT)
> target prot opt source destination 
> 
> Chain OUTPUT (policy ACCEPT)
> target prot opt source destination 
> 
> Chain POSTROUTING (policy ACCEPT)
> target prot opt source destination 
> connman-POSTROUTING all -- anywhere anywhere 
> 
> Chain connman-INPUT (1 references)
> target prot opt source destination 
> CONNMARK all -- anywhere anywhere CONNMARK restore
> 
> Chain connman-POSTROUTING (1 references)
> target prot opt source destination 
> CONNMARK all -- anywhere anywhere CONNMARK save
> 
> ~$ sudo iptables -t filter -L
> Chain INPUT (policy ACCEPT)
> target     prot opt source               destination         
> 
> Chain FORWARD (policy ACCEPT)
> target     prot opt source               destination         
> 
> Chain OUTPUT (policy ACCEPT)
> target     prot opt source               destination        
> 

The session marking rules are missing. I would expect to see
the result of 

  ip rule add fwmark 9876 table 1234

here.

> ~$ route -n
> Kernel IP routing table
> Destination Gateway Genmask Flags Metric Ref Use Iface
> 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
> 8.8.4.4 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
> 8.8.8.8 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
> 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
> 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
> 192.168.1.1 0.0.0.0 255.255.255.255 UH 0 0 0 wlan0
> 192.168.1.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
> 
> 
> ~$ ip rule show
> 0:    from all lookup local 
> 32766:        from all lookup main 
> 32767:        from all lookup default

The routing tables are missing too.

cheers,
daniel
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to