* Can-utils and mininet :
@ 2017-03-24 21:31 Halba, Khalid (IntlAssoc)
2017-03-25 15:03 ` Oliver Hartkopp
0 siblings, 1 reply; 8+ messages in thread
From: Halba, Khalid (IntlAssoc) @ 2017-03-24 21:31 UTC (permalink / raw)
To: linux-can; +Cc: Mahmoudi, Charif (IntlAssoc)
Hi All,
I am trying to use can-utils inside mininet but I get an error whenever I try to run a can-utils application.
I did the following :
1- Creating 2 hosts and 1 switch in mininet :
sudo mn --switch ovsk --mac --topo single,2
2- on host 1 and host 2 I did the following :
sudo apt-get install can-utils
sudo modprobe can
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
sudo ifconfig vcan0 up
3- on host 1 I did the ifconfig and here is the output :
mininet> h1 ifconfig
h1-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:01
inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::200:ff:fe00:1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:107 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19261 (19.2 KB) TX bytes:738 (738.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
vcan0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
As you can see the vcan0 is UP and running
4: the can modules are also loaded
mininet> h1 lsmod |grep can
vcan 16384 0
can_raw 20480 0
can 45056 1 can_raw
5- when I try to run the candump command the following error shows up :
mininet> h1 candump vcan0
socket: Address family not supported by protocol
6- Errors also happen when I run the cansend command
mininet> h1 cansend vcan0 123#112233
Wrong CAN-frame format! Try:
<can_id>#{R|data} for CAN 2.0 frames
<can_id>##<flags>{data} for CAN FD frames
<can_id> can have 3 (SFF) or 8 (EFF) hex chars
{data} has 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')
<flags> a single ASCII Hex value (0 .. F) which defines canfd_frame.flags
e.g. 5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311
1F334455#1122334455667788 / 123#R for remote transmission request.
Did anyone tried to run canutils and he was successful ?
Thank you.
Khalid.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can-utils and mininet :
2017-03-24 21:31 Can-utils and mininet : Halba, Khalid (IntlAssoc)
@ 2017-03-25 15:03 ` Oliver Hartkopp
2017-03-25 17:57 ` Oliver Hartkopp
2017-03-26 10:56 ` Mario Kicherer
0 siblings, 2 replies; 8+ messages in thread
From: Oliver Hartkopp @ 2017-03-25 15:03 UTC (permalink / raw)
To: Halba, Khalid (IntlAssoc), linux-can
Cc: Mahmoudi, Charif (IntlAssoc), Mario Kicherer
Hi Khalid,
On 03/24/2017 10:31 PM, Halba, Khalid (IntlAssoc) wrote:
> I am trying to use can-utils inside mininet but I get an error whenever I try to run a can-utils application.
>
> I did the following :
>
> 1- Creating 2 hosts and 1 switch in mininet :
>
> sudo mn --switch ovsk --mac --topo single,2
(..)
> Did anyone tried to run canutils and he was successful ?
I just had to 'google' for myself to learn about 'mininet':
https://sreeninet.wordpress.com/2014/11/30/mininet-internals-and-network-namespaces/
"1 of the key concepts used in Mininet is Network namespaces which is
also the basis for Linux containers."
The CAN subsystem of the Linux kernel is currently not namespace aware.
Mario Kicherer posted a patch to implement namespaces in parts of the
CAN networklayer:
http://marc.info/?l=linux-can&m=148767639224547&w=2
So additionally to Mario's patch the virtual CAN driver has to be made
namespace aware to make initial tests with mininet.
Are you interested to work on this stuff?
Regards,
Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can-utils and mininet :
2017-03-25 15:03 ` Oliver Hartkopp
@ 2017-03-25 17:57 ` Oliver Hartkopp
2017-04-27 15:26 ` Halba, Khalid (IntlAssoc)
2017-03-26 10:56 ` Mario Kicherer
1 sibling, 1 reply; 8+ messages in thread
From: Oliver Hartkopp @ 2017-03-25 17:57 UTC (permalink / raw)
To: Halba, Khalid (IntlAssoc), Mario Kicherer
Cc: linux-can, Mahmoudi, Charif (IntlAssoc)
Answering myself ...
On 03/25/2017 04:03 PM, Oliver Hartkopp wrote:
> Mario Kicherer posted a patch to implement namespaces in parts of the
> CAN networklayer:
>
> http://marc.info/?l=linux-can&m=148767639224547&w=2
>
> So additionally to Mario's patch the virtual CAN driver has to be made
> namespace aware to make initial tests with mininet.
I applied Mario's patch for a test.
Then I followed
http://blog.scottlowe.org/2013/09/04/introducing-linux-network-namespaces/
and moved my already existing vcan0 virtual CAN interface to the
namespace 'blue':
# ip netns add blue
# ip link set dev vcan0 netns blue
From now vcan0 is not visible from 'ip link show' anymore.
But it is visible in the namespace 'blue':
# ip netns exec blue ip link list
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group
default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
6: vcan0: <NOARP> mtu 72 qdisc noop state DOWN mode DEFAULT group
default qlen 1000
link/can
# ip netns exec blue cangen vcan0
write: Network is down
Obviously the move to the namespace puts the interface 'down', so ...
# ip netns exec blue ifconfig vcan0 up
And then executed
# ip netns exec blue cangen vcan0
And in another terminal
# ip netns exec blue candump any
Which shows the traffic on vcan0 in namespace blue - cool! Tnx Mario!
As vcan does not create two connected peers as veth I would suggest to
use can-gw to connect (and modify/filter) CAN traffic between CAN
interfaces inside/outside of namespaces.
Regards,
Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can-utils and mininet :
2017-03-25 15:03 ` Oliver Hartkopp
2017-03-25 17:57 ` Oliver Hartkopp
@ 2017-03-26 10:56 ` Mario Kicherer
2017-03-26 17:35 ` Oliver Hartkopp
2017-03-27 18:29 ` Halba, Khalid (IntlAssoc)
1 sibling, 2 replies; 8+ messages in thread
From: Mario Kicherer @ 2017-03-26 10:56 UTC (permalink / raw)
To: Oliver Hartkopp, Halba, Khalid (IntlAssoc), linux-can
Cc: Mahmoudi, Charif (IntlAssoc)
Hi Oliver and Khalid,
I am interested in virtual CAN interface pairs and I would develop a
patch. But first, I would like to know if my initial patch will be
accepted. Unfortunately, I did not receive any feedback so far.
Best regards,
Mario
On 25.03.2017 16:03, Oliver Hartkopp wrote:
> Hi Khalid,
>
> On 03/24/2017 10:31 PM, Halba, Khalid (IntlAssoc) wrote:
>> I am trying to use can-utils inside mininet but I get an error
>> whenever I try to run a can-utils application.
>>
>> I did the following :
>>
>> 1- Creating 2 hosts and 1 switch in mininet :
>>
>> sudo mn --switch ovsk --mac --topo single,2
>
> (..)
>
>> Did anyone tried to run canutils and he was successful ?
>
> I just had to 'google' for myself to learn about 'mininet':
>
> https://sreeninet.wordpress.com/2014/11/30/mininet-internals-and-network-namespaces/
>
>
> "1 of the key concepts used in Mininet is Network namespaces which is
> also the basis for Linux containers."
>
> The CAN subsystem of the Linux kernel is currently not namespace aware.
>
> Mario Kicherer posted a patch to implement namespaces in parts of the
> CAN networklayer:
>
> http://marc.info/?l=linux-can&m=148767639224547&w=2
>
> So additionally to Mario's patch the virtual CAN driver has to be made
> namespace aware to make initial tests with mininet.
>
> Are you interested to work on this stuff?
>
> Regards,
> Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can-utils and mininet :
2017-03-26 10:56 ` Mario Kicherer
@ 2017-03-26 17:35 ` Oliver Hartkopp
2017-03-27 18:29 ` Halba, Khalid (IntlAssoc)
1 sibling, 0 replies; 8+ messages in thread
From: Oliver Hartkopp @ 2017-03-26 17:35 UTC (permalink / raw)
To: Mario Kicherer
Cc: Halba, Khalid (IntlAssoc), linux-can, Mahmoudi, Charif (IntlAssoc)
Hi Mario,
On 03/26/2017 12:56 PM, Mario Kicherer wrote:
> I am interested in virtual CAN interface pairs and I would develop a
> patch.
IMHO I doesn't make sense to create vcan interface pairs as done by the
veth driver in linux/drivers/net/veth.c.
E.g. we can move real CAN interfaces to namespaces too, which could make
sense on some setups:
# ip link set dev can0 netns blue
That's why I wonder whether we could just use can-gw with an extended
cangw tool. Are you aware of cangw and its functionality??
(see help text with 'cangw -?')
My suggestion would be to extend can-gw in a way that you can provide
the namespace name to CAN interfaces, when (and only when) cangw is used
from default/global namespace.
When cangw is executed inside a namespace it can only access the CAN
interfaces belonging to that namespace.
So inside the default/global namespace we could connect CAN interfaces
like this:
# cangw -A -s can0 -d vcan0@blue -e
# cangw -A -s vcan0@blue -d can0 -e
The good thing with cangw would be the possibility to filter for
(multiple) CAN IDs and/or to be able to modify the routed CAN frames,
e.g. to alter CAN Identifiers with binary operations.
> But first, I would like to know if my initial patch will be
> accepted. Unfortunately, I did not receive any feedback so far.
I hoped someone else would also try your patch :-)
IMO the patch goes into the right direction and it fits for the initial
step. Of course CAN_BCM and CAN_GW would need to be supported too (see
above).
Best regards,
Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Can-utils and mininet :
2017-03-26 10:56 ` Mario Kicherer
2017-03-26 17:35 ` Oliver Hartkopp
@ 2017-03-27 18:29 ` Halba, Khalid (IntlAssoc)
1 sibling, 0 replies; 8+ messages in thread
From: Halba, Khalid (IntlAssoc) @ 2017-03-27 18:29 UTC (permalink / raw)
To: Mario Kicherer, Oliver Hartkopp, linux-can; +Cc: Mahmoudi, Charif (IntlAssoc)
Hi Mario, Oliver.
Thank you for your feedback and your responsiveness.
I will look at Mario's Patch and give you a feedback before this Friday.
I will also look at namespace compatibility between the CAN utils and Mininet and how it can fit in solving the issue I described.
I think that Implementing can-utils in mininet will be helpful in simulating vehicular networks scenarios.
Khalid.
-----Original Message-----
From: Mario Kicherer [mailto:dev@kicherer.org]
Sent: Sunday, March 26, 2017 6:56 AM
To: Oliver Hartkopp <socketcan@hartkopp.net>; Halba, Khalid (IntlAssoc) <khalid.halba@nist.gov>; linux-can@vger.kernel.org
Cc: Mahmoudi, Charif (IntlAssoc) <charif.mahmoudi@nist.gov>
Subject: Re: Can-utils and mininet :
Hi Oliver and Khalid,
I am interested in virtual CAN interface pairs and I would develop a patch. But first, I would like to know if my initial patch will be accepted. Unfortunately, I did not receive any feedback so far.
Best regards,
Mario
On 25.03.2017 16:03, Oliver Hartkopp wrote:
> Hi Khalid,
>
> On 03/24/2017 10:31 PM, Halba, Khalid (IntlAssoc) wrote:
>> I am trying to use can-utils inside mininet but I get an error
>> whenever I try to run a can-utils application.
>>
>> I did the following :
>>
>> 1- Creating 2 hosts and 1 switch in mininet :
>>
>> sudo mn --switch ovsk --mac --topo single,2
>
> (..)
>
>> Did anyone tried to run canutils and he was successful ?
>
> I just had to 'google' for myself to learn about 'mininet':
>
> https://sreeninet.wordpress.com/2014/11/30/mininet-internals-and-netwo
> rk-namespaces/
>
>
> "1 of the key concepts used in Mininet is Network namespaces which is
> also the basis for Linux containers."
>
> The CAN subsystem of the Linux kernel is currently not namespace aware.
>
> Mario Kicherer posted a patch to implement namespaces in parts of the
> CAN networklayer:
>
> http://marc.info/?l=linux-can&m=148767639224547&w=2
>
> So additionally to Mario's patch the virtual CAN driver has to be made
> namespace aware to make initial tests with mininet.
>
> Are you interested to work on this stuff?
>
> Regards,
> Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Can-utils and mininet :
2017-03-25 17:57 ` Oliver Hartkopp
@ 2017-04-27 15:26 ` Halba, Khalid (IntlAssoc)
2017-04-27 16:01 ` Oliver Hartkopp
0 siblings, 1 reply; 8+ messages in thread
From: Halba, Khalid (IntlAssoc) @ 2017-04-27 15:26 UTC (permalink / raw)
To: Oliver Hartkopp, Mario Kicherer; +Cc: linux-can, Mahmoudi, Charif (IntlAssoc)
Hi Oliver , Mario
It took me some time to understand namespaces and linux kernel patching .
I just applied Mario's patch as well and it works as expected !.
I can run can-utils on a different namespace now. Thanks.
The kernel files I used are the ones in this directory :
https://kernel.googlesource.com/pub/scm/linux/kernel/git/mkl/linux-can/+/master/net/can/
af_can.c
af_can.h
bcm.c
gw.c
proc.c
raw.c
And the other files in the master branch that are mentioned in the patch file.
However , Mininet now fails to start. The error I get when I try to run the default topology is the following :
//*** Adding links:
//--------------------------------------------------------------------------------
//Caught exception. Cleaning up...
//Exception: Error creating interface pair (h1-eth0,s1-eth1): RTNETLINK answers: Operation not supported
That's what I am currently troubleshooting.
Regards,
Khalid.
-----Original Message-----
From: linux-can-owner@vger.kernel.org [mailto:linux-can-owner@vger.kernel.org] On Behalf Of Oliver Hartkopp
Sent: Saturday, March 25, 2017 1:58 PM
To: Halba, Khalid (IntlAssoc) <khalid.halba@nist.gov>; Mario Kicherer <dev@kicherer.org>
Cc: linux-can@vger.kernel.org; Mahmoudi, Charif (IntlAssoc) <charif.mahmoudi@nist.gov>
Subject: Re: Can-utils and mininet :
Answering myself ...
On 03/25/2017 04:03 PM, Oliver Hartkopp wrote:
> Mario Kicherer posted a patch to implement namespaces in parts of the
> CAN networklayer:
>
> http://marc.info/?l=linux-can&m=148767639224547&w=2
>
> So additionally to Mario's patch the virtual CAN driver has to be made
> namespace aware to make initial tests with mininet.
I applied Mario's patch for a test.
Then I followed
http://blog.scottlowe.org/2013/09/04/introducing-linux-network-namespaces/
and moved my already existing vcan0 virtual CAN interface to the namespace 'blue':
# ip netns add blue
# ip link set dev vcan0 netns blue
From now vcan0 is not visible from 'ip link show' anymore.
But it is visible in the namespace 'blue':
# ip netns exec blue ip link list
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
6: vcan0: <NOARP> mtu 72 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/can
# ip netns exec blue cangen vcan0
write: Network is down
Obviously the move to the namespace puts the interface 'down', so ...
# ip netns exec blue ifconfig vcan0 up
And then executed
# ip netns exec blue cangen vcan0
And in another terminal
# ip netns exec blue candump any
Which shows the traffic on vcan0 in namespace blue - cool! Tnx Mario!
As vcan does not create two connected peers as veth I would suggest to use can-gw to connect (and modify/filter) CAN traffic between CAN interfaces inside/outside of namespaces.
Regards,
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Can-utils and mininet :
2017-04-27 15:26 ` Halba, Khalid (IntlAssoc)
@ 2017-04-27 16:01 ` Oliver Hartkopp
0 siblings, 0 replies; 8+ messages in thread
From: Oliver Hartkopp @ 2017-04-27 16:01 UTC (permalink / raw)
To: Halba, Khalid (IntlAssoc)
Cc: Mario Kicherer, linux-can, Mahmoudi, Charif (IntlAssoc)
Hi Khalid,
On 04/27/2017 05:26 PM, Halba, Khalid (IntlAssoc) wrote:
> It took me some time to understand namespaces and linux kernel patching .
> I just applied Mario's patch as well and it works as expected !.
> I can run can-utils on a different namespace now. Thanks.
> The kernel files I used are the ones in this directory :
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/mkl/linux-can/+/master/net/can/
The namespace support has now been completed and is available in Dave
Miller's net-next tree for Linux 4.12 upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
This reository contains this latest patch set for the CAN subsystem:
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/log?id=5e64ebc1c242523b491b5b5e5eba59243bb970cb
So using the net-next tree is the best choice for testing now.
> However , Mininet now fails to start. The error I get when I try to run the default topology is the following :
>
> //*** Adding links:
> //--------------------------------------------------------------------------------
> //Caught exception. Cleaning up...
> //Exception: Error creating interface pair (h1-eth0,s1-eth1): RTNETLINK answers: Operation not supported
>
> That's what I am currently troubleshooting.
Ah. You can not use veth to create the interface pair :-)
Ethernet interfaces do not work for CAN.
And for that reason ... tada! ... we have vxcan now!
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=a8f820a380a2a06fc4fe1a54159067958f800929
See the Kconfig change in this commit which is in net-next too.
Unfortunately you have to patch the 'ip' tool from the iproute2 package
to be able to create vxcan pairs.
So you need to download
https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git
and then apply this patch:
http://marc.info/?l=linux-can&m=149311080629207&w=2
Finally you can create e.g. this pair
# ./ip link add rootcan type vxcan peer name bluecan
# ./ip link set dev bluecan netns blue
And then you have a CAN tunnel interface pair with the rootcan interface
in the initial namespace and the bluecan interface in the 'blue' namespace.
Regards,
Oliver
> -----Original Message-----
> From: linux-can-owner@vger.kernel.org [mailto:linux-can-owner@vger.kernel.org] On Behalf Of Oliver Hartkopp
> Sent: Saturday, March 25, 2017 1:58 PM
> To: Halba, Khalid (IntlAssoc) <khalid.halba@nist.gov>; Mario Kicherer <dev@kicherer.org>
> Cc: linux-can@vger.kernel.org; Mahmoudi, Charif (IntlAssoc) <charif.mahmoudi@nist.gov>
> Subject: Re: Can-utils and mininet :
>
> Answering myself ...
>
> On 03/25/2017 04:03 PM, Oliver Hartkopp wrote:
>
>> Mario Kicherer posted a patch to implement namespaces in parts of the
>> CAN networklayer:
>>
>> http://marc.info/?l=linux-can&m=148767639224547&w=2
>>
>> So additionally to Mario's patch the virtual CAN driver has to be made
>> namespace aware to make initial tests with mininet.
>
> I applied Mario's patch for a test.
>
> Then I followed
>
> http://blog.scottlowe.org/2013/09/04/introducing-linux-network-namespaces/
>
> and moved my already existing vcan0 virtual CAN interface to the namespace 'blue':
>
> # ip netns add blue
> # ip link set dev vcan0 netns blue
>
> From now vcan0 is not visible from 'ip link show' anymore.
>
> But it is visible in the namespace 'blue':
>
> # ip netns exec blue ip link list
> 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> 6: vcan0: <NOARP> mtu 72 qdisc noop state DOWN mode DEFAULT group default qlen 1000
> link/can
>
> # ip netns exec blue cangen vcan0
> write: Network is down
>
> Obviously the move to the namespace puts the interface 'down', so ...
> # ip netns exec blue ifconfig vcan0 up
>
> And then executed
> # ip netns exec blue cangen vcan0
>
> And in another terminal
> # ip netns exec blue candump any
>
> Which shows the traffic on vcan0 in namespace blue - cool! Tnx Mario!
>
> As vcan does not create two connected peers as veth I would suggest to use can-gw to connect (and modify/filter) CAN traffic between CAN interfaces inside/outside of namespaces.
>
> Regards,
> Oliver
>
>
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-04-27 16:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 21:31 Can-utils and mininet : Halba, Khalid (IntlAssoc)
2017-03-25 15:03 ` Oliver Hartkopp
2017-03-25 17:57 ` Oliver Hartkopp
2017-04-27 15:26 ` Halba, Khalid (IntlAssoc)
2017-04-27 16:01 ` Oliver Hartkopp
2017-03-26 10:56 ` Mario Kicherer
2017-03-26 17:35 ` Oliver Hartkopp
2017-03-27 18:29 ` Halba, Khalid (IntlAssoc)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.