[U-Boot] [RFC PATCH v4 21/23] sandbox: eth: Add a bridge to a real network for sandbox
Simon Glass
sjg at chromium.org
Mon Mar 2 16:48:27 CET 2015
Hi Joe,
On 2 March 2015 at 00:17, Joe Hershberger <joe.hershberger at gmail.com> wrote:
> On Sun, Mar 1, 2015 at 12:07 PM, Simon Glass <sjg at chromium.org> wrote:
>>
>> On 24 February 2015 at 17:02, Joe Hershberger <joe.hershberger at ni.com>
>> wrote:
>> > Implement a bridge between u-boot's network stack and Linux's raw packet
>> > API allowing the sandbox to send and receive packets using the host
>> > machine's network interface.
>> >
>> > This raw Ethernet API requires elevated privileges. You can either run
>> > as root, or you can add the capability needed like so:
>> >
>> > sudo /sbin/setcap "CAP_NET_RAW+ep" u-boot
>> >
>> > Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
>>
>> Reviewed-by: Simon Glass <sjg at chromium.org>
>>
>> A few nits below.
[snip]
>> >
>> > +Linux RAW Networking Bridge
>> > +---------------------------
>> > +
>> > +The sandbox_eth_raw driver bridges traffic between the bottom of the
>> > network
>> > +stack and the RAW sockets API in Linux. This allows much of the u-boot
>> > network
>> > +functionality to be tested in sandbox against real network traffic.
>> > +
>> > +The RAW sockets Ethernet API requires elevated privileges in Linux. You
>> > can
>> > +either run as root, or you can add the capability needed like so:
>> > +
>> > +sudo /sbin/setcap "CAP_NET_RAW+ep" u-boot
>>
>> This is so cool.
>
> :D
>
>> Can you give some examples here? For me, ping seems to work, but I
>> can't use bootp. Is that what the raw mode is for? How do I enable it?
>> I tried setting ethact but am not sure what I am doing.
>
> Sorry it's not clear. I'll update it, but if you want to play with it in the
> mean time, I'll explain here. But first, what were the symptoms where you
> say you couldn't use bootp?
>
> This patch only supports the RAW AF_PACKET API. This is needed to get
> access to the lowest level of the network stack in Linux. This means that
> all of the Ethernet frame is included. This allows the u-boot network stack
> to be fully used. In other words, nothing about the Linux network stack is
> involved in forming the packets that end up on the wire. To receive the
> responses to packets sent from u-boot the network interface has to be set to
> promiscuous mode so that the network card won't filter out packets not
> destined for its configured (on Linux) MAC address.
>
> The device tree as added by this patch should be everything you need to use
> eth0 on the host machine.
>
> To contrast, the patch that adds support for the 'lo' interface cannot use
> the RAW AF_PACKET API because the lo interface doesn't support
> Ethernet-level traffic. It is a higher-level interface that is expected only
> to be used at the AF_INET level of the API. As such, the most raw we can get
> on that interface is the RAW AF_INET API on UDP. This allows us to set the
> IP_HDRINCL option to include everything except the Ethernet header in the
> packets we send and receive.
>
> There is no decision to make. The local code path will only work on the 'lo'
> interface and the not-local code path will only work on non-'lo' interface.
> This check is explicit in sb_eth_raw_start().
>
>> Useful examples would be:
>>
>> - ping
>> - bootp
>> - tftpboot
>
> I have tested all 3 of these with just the device tree included in this
> patch. All that you need to do is set the eth1addr to something. Set ethact
> to "eth1".
>
> You can then use dhcp (typically need to set autoload to no first) or set a
> static IP. Then you can ping or tftp.
>
> If you set ethact to eth5 (the localhost interface in the device tree in the
> 'lo' support patch) then don't expect ping to work, but you should be able
> to tftpboot from the local TFTP server.
>
>> and how to use raw/normal device.
>
> I hope this is clear above.
>
OK the ethact might have been what I was missing. Anyway I'll wait
until you update the README and try again.
Regards,
Simon
More information about the U-Boot
mailing list