mbox series

[v4,00/17] IPv6 support

Message ID 20220908115905.70928-1-v.v.mitrofanov@yadro.com
Headers show
Series IPv6 support | expand

Message

Vyacheslav V. Mitrofanov Sept. 8, 2022, 11:58 a.m. UTC
This patch set adds basic IPv6 support to U-boot.
It is based on Chris's Packham patches
(https://lists.denx.de/pipermail/u-boot/2017-January/279366.html)
Chris's patches were taken as base. There were efforts to launch it on
HiFive SiFive Unmatched board but the board didn't work well. The code was
refactored, fixed some bugs as CRC for little-endian, some parts were implemented in
our own way, something was taken from Linux. Finally we did manual tests and the
board worked well.

Testing was done on HiFive SiFive Unmatched board (RISC-V)

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>

---
Changes in v2:
 - Split big patches into smaller
 - If an address in tftpboot is IPv6 than use IPv6 to boot
 - Add tests

Changes in v3:
 - Added functions and structures description in whole patch-series
 - Removed memory allocation in on_ip6addr()
 - Some functions got return code from errno.h
 - Add to string_to_ip6() length parameter to avoid obligatory null termination
 - Add a lot of small decorative cnages

Changes in v4:
 - Fixed funcs and structures style description
 - Added omitted tags 

Viacheslav Mitrofanov (17):
  net: ipv6: Add IPv6 basic primitives
  net: ipv6: Add IPv6 build options
  net: ipv6: Add callbacks declarations to get access to IPv6 variables
  net: ipv6: Add Neighbor Discovery Protocol (NDP)
  net: ipv6: Add string_to_ip6 converter
  net: ipv6: Enable IPv6 typeconversion specifier
  net: ipv6: Add ip6addr, gatewayip6, serverip6 variables callbacks
  net: ipv6: Add implementation of main IPv6 functions
  net: ipv6: Incorporate IPv6 support into u-boot net subsystem
  net: tftp: Add IPv6 support for tftpboot
  net: ping6: Add ping6 command
  test: dm: eth: Add string_to_ip6 test
  test: dm: eth: Add csum_ipv6_magic test
  test: dm: eth: Add ip6_addr_in_subnet test
  test: dm: eth: Add ip6_make_snma test
  test: dm: eth: Add ip6_make_lladdr test
  test/py: add a ping6 test

 cmd/Kconfig               |   7 +
 cmd/net.c                 |  61 ++++++
 include/env_callback.h    |  10 +
 include/env_flags.h       |  10 +
 include/ndisc.h           | 102 +++++++++
 include/net.h             |   4 +-
 include/net6.h            | 432 ++++++++++++++++++++++++++++++++++++
 lib/net_utils.c           | 109 ++++++++++
 lib/vsprintf.c            |   7 +-
 net/Kconfig               |  10 +
 net/Makefile              |   3 +
 net/ndisc.c               | 289 +++++++++++++++++++++++++
 net/net.c                 |  53 ++++-
 net/net6.c                | 445 ++++++++++++++++++++++++++++++++++++++
 net/ping6.c               | 118 ++++++++++
 net/tftp.c                |  63 +++++-
 test/dm/eth.c             | 146 +++++++++++++
 test/py/tests/test_net.py |  15 ++
 18 files changed, 1865 insertions(+), 19 deletions(-)
 create mode 100644 include/ndisc.h
 create mode 100644 include/net6.h
 create mode 100644 net/ndisc.c
 create mode 100644 net/net6.c
 create mode 100644 net/ping6.c

Comments

Vyacheslav V. Mitrofanov Sept. 11, 2022, 6:04 a.m. UTC | #1
On Thu, 2022-09-08 at 14:58 +0300, Viacheslav Mitrofanov wrote:
> This patch set adds basic IPv6 support to U-boot.
> It is based on Chris's Packham patches
> (https://lists.denx.de/pipermail/u-boot/2017-January/279366.html)
> Chris's patches were taken as base. There were efforts to launch it
> on
> HiFive SiFive Unmatched board but the board didn't work well. The
> code was
> refactored, fixed some bugs as CRC for little-endian, some parts were
> implemented in
> our own way, something was taken from Linux. Finally we did manual
> tests and the
> board worked well.
> 
> Testing was done on HiFive SiFive Unmatched board (RISC-V)
> 
> Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
> 
> ---
> Changes in v2:
>  - Split big patches into smaller
>  - If an address in tftpboot is IPv6 than use IPv6 to boot
>  - Add tests
> 
> Changes in v3:
>  - Added functions and structures description in whole patch-series
>  - Removed memory allocation in on_ip6addr()
>  - Some functions got return code from errno.h
>  - Add to string_to_ip6() length parameter to avoid obligatory null
> termination
>  - Add a lot of small decorative cnages
> 
> Changes in v4:
>  - Fixed funcs and structures style description
>  - Added omitted tags 
> 
> Viacheslav Mitrofanov (17):
>   net: ipv6: Add IPv6 basic primitives
>   net: ipv6: Add IPv6 build options
>   net: ipv6: Add callbacks declarations to get access to IPv6
> variables
>   net: ipv6: Add Neighbor Discovery Protocol (NDP)
>   net: ipv6: Add string_to_ip6 converter
>   net: ipv6: Enable IPv6 typeconversion specifier
>   net: ipv6: Add ip6addr, gatewayip6, serverip6 variables callbacks
>   net: ipv6: Add implementation of main IPv6 functions
>   net: ipv6: Incorporate IPv6 support into u-boot net subsystem
>   net: tftp: Add IPv6 support for tftpboot
>   net: ping6: Add ping6 command
>   test: dm: eth: Add string_to_ip6 test
>   test: dm: eth: Add csum_ipv6_magic test
>   test: dm: eth: Add ip6_addr_in_subnet test
>   test: dm: eth: Add ip6_make_snma test
>   test: dm: eth: Add ip6_make_lladdr test
>   test/py: add a ping6 test
> 
>  cmd/Kconfig               |   7 +
>  cmd/net.c                 |  61 ++++++
>  include/env_callback.h    |  10 +
>  include/env_flags.h       |  10 +
>  include/ndisc.h           | 102 +++++++++
>  include/net.h             |   4 +-
>  include/net6.h            | 432 ++++++++++++++++++++++++++++++++++++
>  lib/net_utils.c           | 109 ++++++++++
>  lib/vsprintf.c            |   7 +-
>  net/Kconfig               |  10 +
>  net/Makefile              |   3 +
>  net/ndisc.c               | 289 +++++++++++++++++++++++++
>  net/net.c                 |  53 ++++-
>  net/net6.c                | 445
> ++++++++++++++++++++++++++++++++++++++
>  net/ping6.c               | 118 ++++++++++
>  net/tftp.c                |  63 +++++-
>  test/dm/eth.c             | 146 +++++++++++++
>  test/py/tests/test_net.py |  15 ++
>  18 files changed, 1865 insertions(+), 19 deletions(-)
>  create mode 100644 include/ndisc.h
>  create mode 100644 include/net6.h
>  create mode 100644 net/ndisc.c
>  create mode 100644 net/net6.c
>  create mode 100644 net/ping6.c
> 

Many thanks, Simon, for your reviewing!
A really appreciate this!

Thanks, Viacheslav.
Tom Rini Nov. 28, 2022, 3:34 p.m. UTC | #2
On Thu, Sep 08, 2022 at 02:58:48PM +0300, Viacheslav Mitrofanov wrote:

> This patch set adds basic IPv6 support to U-boot.
> It is based on Chris's Packham patches
> (https://lists.denx.de/pipermail/u-boot/2017-January/279366.html)
> Chris's patches were taken as base. There were efforts to launch it on
> HiFive SiFive Unmatched board but the board didn't work well. The code was
> refactored, fixed some bugs as CRC for little-endian, some parts were implemented in
> our own way, something was taken from Linux. Finally we did manual tests and the
> board worked well.
> 
> Testing was done on HiFive SiFive Unmatched board (RISC-V)
> 
> Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
> ---
> Changes in v2:
>  - Split big patches into smaller
>  - If an address in tftpboot is IPv6 than use IPv6 to boot
>  - Add tests
> 
> Changes in v3:
>  - Added functions and structures description in whole patch-series
>  - Removed memory allocation in on_ip6addr()
>  - Some functions got return code from errno.h
>  - Add to string_to_ip6() length parameter to avoid obligatory null termination
>  - Add a lot of small decorative cnages
> 
> Changes in v4:
>  - Fixed funcs and structures style description
>  - Added omitted tags 

Testing this locally in sandbox I see:
FAILED test/py/tests/test_ut.py::test_ut[ut_dm_dm_test_csum_ipv6_magic] - AssertionError: as...
FAILED test/py/tests/test_ut.py::test_ut[ut_dm_dm_test_ip6_addr_in_subnet] - AssertionError:...
FAILED test/py/tests/test_ut.py::test_ut[ut_dm_dm_test_ip6_make_lladdr] - assert False
FAILED test/py/tests/test_ut.py::test_ut[ut_dm_dm_test_ip6_make_snma] - assert False
FAILED test/py/tests/test_ut.py::test_ut[ut_dm_dm_test_string_to_ip6] - AssertionError: asse...
and this happens in CI as well:
https://source.denx.de/u-boot/u-boot/-/pipelines/14245
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=5432&view=results

If you can't replicate the failures locally you should be able to
trigger CI:
https://u-boot.readthedocs.io/en/latest/develop/ci_testing.html

Thanks for pushing this along!
Vyacheslav V. Mitrofanov Nov. 29, 2022, 8:35 a.m. UTC | #3
Hello Tom!
I tested this problem and I think it is necessary to set CONFIG_IPV6.
Without that option tests fail.

Thanks!
Vyacheslav V. Mitrofanov Nov. 29, 2022, 8:39 a.m. UTC | #4
Tom, maybe it is better to change configs add ifdefs or do sth else to exclude them from the build if IPV6 is not configured?

Thanks!
Tom Rini Nov. 29, 2022, 1:49 p.m. UTC | #5
On Tue, Nov 29, 2022 at 08:39:36AM +0000, Vyacheslav Mitrofanov V wrote:

> Tom, maybe it is better to change configs add ifdefs or do sth else to exclude them from the build if IPV6 is not configured?

There's two parts to this, yes.  Sandbox needs to enable ipv6 so that
the tests are run, and the tests need to be be appropriately ifdef'd so
that they don't try and be run on platforms without ipv6.
Vyacheslav V. Mitrofanov Nov. 29, 2022, 1:53 p.m. UTC | #6
I'll fix it soon and send new patchset!

Thanks!
Peter Robinson Dec. 1, 2022, 1:03 p.m. UTC | #7
Hi Tom and others,

> > Tom, maybe it is better to change configs add ifdefs or do sth else to exclude them from the build if IPV6 is not configured?
>
> There's two parts to this, yes.  Sandbox needs to enable ipv6 so that
> the tests are run, and the tests need to be be appropriately ifdef'd so
> that they don't try and be run on platforms without ipv6.

I was wondering with the need to support IPv6, http and tls and the
various components whether we wouldn't just be better off using LwIP
[1][2]>, it gives us basically everything we need for IPv6, HTTP boot
and other things we need, and is used on microcontrollers (I came
across it recently when playing with micropython) so it's small. I
feel it would save a lot of time maintaining an independent IP stack
and being used a cross a bunch of different projects is quite widely
used/developed. Thoughts?

Peter

[1] https://savannah.nongnu.org/forum/forum.php?forum_id=9248
[2] https://en.wikipedia.org/wiki/LwIP
Vyacheslav V. Mitrofanov Dec. 2, 2022, 7:13 a.m. UTC | #8
Hello, Peter!
I see your point and I think that you are right in some aspects. LwIP like other stacks can be used instead of built-in stack but it is necessary to make quite a big work to port it, write tests and so on. It is bigger than my tiny patches.

I'm not against the situation when someone do that work and port other stack. But I think it is better to give people IPv6 right now than wait it again.