Skip to content

ipv4: Enable support for IPv6 gateway with IPv4 routes

David Ahern netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest18 patches 6 repliesIn review
  2. v118 patches 14 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18ipv6: Add fib6_nh_init and release to stubsinclude/net/ipv6_stubs.h net/ipv6/addrconf_core.c net/ipv6/af_inet6.c+17 -00 replies
2/18ipv6: Add neighbor helpers that use the ipv6 stubinclude/net/ndisc.h net/core/filter.c+42 -40 replies
3/18net: Replace nhc_has_gw with nhc_gw_familydrivers/net/ethernet/mellanox/mlxsw/spectrum_router.c include/net/ip6_route.h include/net/ip_fib.h +7 more+35 -380 replies
4/18ipv4: Prepare rtable for IPv6 gatewaydrivers/infiniband/core/addr.c drivers/infiniband/hw/nes/nes_cm.c drivers/net/appletalk/ipddp.c +10 more+57 -450 replies
5/18ipv4: Prepare fib_config for IPv6 gatewayinclude/net/ip_fib.h net/ipv4/fib_frontend.c net/ipv4/fib_semantics.c+34 -190 replies
6/18ipv4: Add support to rtable for ipv6 gatewaydrivers/net/ethernet/mellanox/mlxsw/spectrum_span.c include/net/route.h net/ipv4/route.c +2 more+38 -80 replies
7/18ipv4: Add support to fib_config for IPv6 gatewayinclude/net/ip_fib.h net/ipv4/fib_semantics.c+27 -70 replies
8/18ipv4: Refactor fib_check_nhnet/ipv4/fib_semantics.c+125 -1095 replies
9/18ipv4: Add fib_check_nh_v6_gwnet/ipv4/fib_semantics.c+27 -00 replies
10/18neighbor: Add skip_cache argument to neigh_outputdrivers/net/vrf.c include/net/neighbour.h net/ipv4/ip_output.c +1 more+7 -60 replies
11/18ipv4: Add helpers for neigh lookup for nexthopdrivers/net/vrf.c include/net/route.h net/ipv4/ip_output.c +1 more+59 -230 replies
12/18bpf: Handle ipv6 gateway in bpf_ipv4_fib_lookupnet/core/filter.c+14 -30 replies
13/18ipv4: Handle ipv6 gateway in ipv4_confirm_neighnet/ipv4/route.c+6 -40 replies
14/18ipv4: Handle ipv6 gateway in fib_detect_deathnet/ipv4/fib_semantics.c+9 -10 replies
15/18ipv4: Handle ipv6 gateway in fib_good_nhnet/ipv4/fib_semantics.c+8 -20 replies
16/18ipv4: Flag fib_info with a fib_nh using IPv6 gatewaydrivers/net/ethernet/mellanox/mlxsw/spectrum_router.c drivers/net/ethernet/rocker/rocker_main.c include/net/ip_fib.h +1 more+20 -00 replies
17/18ipv4: Allow ipv6 gateway with ipv4 routesinclude/net/ip_fib.h net/ipv4/fib_frontend.c net/ipv4/fib_semantics.c+123 -80 replies
18/18selftests: fib_tests: Add tests for ipv6 gateway with ipv4 routetools/testing/selftests/net/fib_tests.sh+69 -10 replies

Reviews trailers per patch

9 of 18 patches have a Reviewed-by or Acked-by.

PatchIdo Schimmel
1/18R-b
2/18R-b
3/18R-b
4/18R-b
5/18R-b
6/18R-b
7/18R-b
8/18R-b R-b
9/18R-b
10/18
11/18
12/18
13/18
14/18
15/18
16/18
17/18
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes

From: David Ahern <[email protected]>

Last set of three with the end goal of enabling IPv6 gateways with IPv4 routes.

This set adds fib6_nh_init and release to the IPv6 stubs, and adds neighbor helpers that IPv4 code invokes to resolve an IPv6 address. When using an IPv6 neighbor entry the hh_cache is bypassed as it contains the wrong ethernet header for an IPv4 packet.

The nh_common nhc_has_gw was a temporary field used to convert existing code from fib{6}_nh to fib_nh_common. That field is now converted to nhc_gw_family to differentiate the address family of the gateway entry as opposed to the address family of the container of fib_nh_common.

Existing code for rtable and fib_config is refactored to prepare for a v6 address and then support is added. From there various miscellaneous functions are updated to handle a v6 gateway - from validating the v6 address to lookups in bpf code to verifying the nexthop state.

Offload drivers - mlxsw and rocker - are modified to detect the v6 gateway and reject the route as 'unsupported'. e.g.,

    $ ip ro add 172.16.101.0/24 via inet6 fe80::202:ff:fe00:b dev swp1s0
    Error: mlxsw_spectrum: IPv6 gateway with IPv4 route is not supported.

This can be removed in time once support is added to each.

With the infrastructure changes in place, patch 17 enables it by adding support for RTA_VIA to IPv4. RTA_VIA can be used for IPv4 addresses as well. Only one of RTA_VIA and RTA_GATEWAY can be passed in a request.

Patch 18 adds a few test cases to fib_tests.sh.

v2
- comments from Ido - fixed typos as noted and updated messages
- add commit message to patch 1
- In patch 9, ipv4: Add fib_check_nh_v6_gw, moved the call to fib6_nh_release under the 'if (!err)' check as the intention is that release should not be called if init fails.

David Ahern (18):
ipv6: Add fib6_nh_init and release to stubs
ipv6: Add neighbor helpers that use the ipv6 stub
net: Replace nhc_has_gw with nhc_gw_family
ipv4: Prepare rtable for IPv6 gateway
ipv4: Prepare fib_config for IPv6 gateway
ipv4: Add support to rtable for ipv6 gateway
ipv4: Add support to fib_config for IPv6 gateway
ipv4: Refactor fib_check_nh
ipv4: Add fib_check_nh_v6_gw
neighbor: Add skip_cache argument to neigh_output
ipv4: Add helpers for neigh lookup for nexthop
bpf: Handle ipv6 gateway in bpf_ipv4_fib_lookup
ipv4: Handle ipv6 gateway in ipv4_confirm_neigh
ipv4: Handle ipv6 gateway in fib_detect_death
ipv4: Handle ipv6 gateway in fib_good_nh
ipv4: Flag fib_info with a fib_nh using IPv6 gateway
ipv4: Allow ipv6 gateway with ipv4 routes
selftests: fib_tests: Add tests for ipv6 gateway with ipv4 route

 drivers/infiniband/core/addr.c                     |   2 +-
 drivers/infiniband/hw/nes/nes_cm.c                 |   2 +-
 drivers/net/appletalk/ipddp.c                      |   6 +-
 .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c    |   2 +-
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  |  12 +-
 .../net/ethernet/mellanox/mlxsw/spectrum_span.c    |   6 +-
 drivers/net/ethernet/rocker/rocker_main.c          |   9 +
 drivers/net/vrf.c                                  |  12 +-
 include/net/ip6_route.h                            |   2 +-
 include/net/ip_fib.h                               |  18 +-
 include/net/ipv6_stubs.h                           |   6 +
 include/net/ndisc.h                                |  40 ++
 include/net/neighbour.h                            |   5 +-
 include/net/route.h                                |  43 +-
 include/trace/events/fib.h                         |   4 +-
 net/atm/clip.c                                     |   4 +-
 net/core/filter.c                                  |  25 +-
 net/ipv4/fib_frontend.c                            |  68 +++-
 net/ipv4/fib_semantics.c                           | 432 ++++++++++++++-------
 net/ipv4/inet_connection_sock.c                    |   4 +-
 net/ipv4/ip_forward.c                              |   2 +-
 net/ipv4/ip_output.c                               |  13 +-
 net/ipv4/route.c                                   | 112 ++++--
 net/ipv4/xfrm4_policy.c                            |   7 +-
 net/ipv6/addrconf.c                                |   2 +-
 net/ipv6/addrconf_core.c                           |   9 +
 net/ipv6/af_inet6.c                                |   2 +
 net/ipv6/ip6_fib.c                                 |   2 +-
 net/ipv6/ip6_output.c                              |   2 +-
 net/ipv6/route.c                                   |  18 +-
 net/mpls/mpls_iptunnel.c                           |  12 +-
 tools/testing/selftests/net/fib_tests.sh           |  70 +++-
 32 files changed, 696 insertions(+), 257 deletions(-)
Signature · 1 line
2.11.0