diff options
author | Stanislav Zaikin <zstaseg@gmail.com> | 2021-07-15 16:27:29 +0200 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2021-07-28 08:25:38 +0000 |
commit | 328b5dadb35916e8147237f2339dd5f4c38912fc (patch) | |
tree | fba6fb6990a21baa5ad5b830ba5a4a21a87b2dcc /src/vnet/interface.c | |
parent | a44a0c038f5aee70876e240d7a59aaeb79debc4c (diff) |
gre: set proper fib index for unnumbered interfaces, unset fib index before forwarding gre payload
This commit introduces 2 fixes:
1) After GRE decapsulation sw_if_index[VLIB_TX] is set as fib index of GRE tunnel.
But since GRE tunnel can work on v4 endpoints and have v6 payload, we need to reset it.
In case we get IPv6 packet inside IPv4 GRE tunnel (or vice-versa) fib index can be (and usually is) invalid.
2) Check that ip-table and ip6-table are the same when setting interface as an unnumbered one.
Also, fix for the pipe test include setting the right unnumbered interface for the pipes
Type: fix
Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
Change-Id: Id13d239cfdd21e0db6b1c9725f01c40d4af4d800
Diffstat (limited to 'src/vnet/interface.c')
-rw-r--r-- | src/vnet/interface.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c index 44ea52a870d..e79722d0461 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -1610,20 +1610,58 @@ vnet_hw_interface_change_mac_address (vnet_main_t * vnm, u32 hw_if_index, (vnm, hw_if_index, mac_address); } +static int +vnet_sw_interface_check_table_same (u32 unnumbered_sw_if_index, + u32 ip_sw_if_index) +{ + vec_validate (ip4_main.fib_index_by_sw_if_index, unnumbered_sw_if_index); + vec_validate (ip4_main.mfib_index_by_sw_if_index, unnumbered_sw_if_index); + vec_validate (ip6_main.fib_index_by_sw_if_index, unnumbered_sw_if_index); + vec_validate (ip6_main.mfib_index_by_sw_if_index, unnumbered_sw_if_index); + + vec_validate (ip4_main.fib_index_by_sw_if_index, ip_sw_if_index); + vec_validate (ip4_main.mfib_index_by_sw_if_index, ip_sw_if_index); + vec_validate (ip6_main.fib_index_by_sw_if_index, ip_sw_if_index); + vec_validate (ip6_main.mfib_index_by_sw_if_index, ip_sw_if_index); + + if (ip4_main.fib_index_by_sw_if_index[unnumbered_sw_if_index] != + ip4_main.fib_index_by_sw_if_index[ip_sw_if_index]) + return VNET_API_ERROR_UNEXPECTED_INTF_STATE; + + if (ip4_main.mfib_index_by_sw_if_index[unnumbered_sw_if_index] != + ip4_main.mfib_index_by_sw_if_index[ip_sw_if_index]) + return VNET_API_ERROR_UNEXPECTED_INTF_STATE; + + if (ip6_main.fib_index_by_sw_if_index[unnumbered_sw_if_index] != + ip6_main.fib_index_by_sw_if_index[ip_sw_if_index]) + return VNET_API_ERROR_UNEXPECTED_INTF_STATE; + + if (ip6_main.mfib_index_by_sw_if_index[unnumbered_sw_if_index] != + ip6_main.mfib_index_by_sw_if_index[ip_sw_if_index]) + return VNET_API_ERROR_UNEXPECTED_INTF_STATE; + + return 0; +} + /* update the unnumbered state of an interface*/ -void +int vnet_sw_interface_update_unnumbered (u32 unnumbered_sw_if_index, u32 ip_sw_if_index, u8 enable) { vnet_main_t *vnm = vnet_get_main (); vnet_sw_interface_t *si; u32 was_unnum; + int rv = 0; si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index); was_unnum = (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED); if (enable) { + rv = vnet_sw_interface_check_table_same (unnumbered_sw_if_index, + ip_sw_if_index); + if (rv != 0) + return rv; si->flags |= VNET_SW_INTERFACE_FLAG_UNNUMBERED; si->unnumbered_sw_if_index = ip_sw_if_index; @@ -1660,6 +1698,8 @@ vnet_sw_interface_update_unnumbered (u32 unnumbered_sw_if_index, ip4_sw_interface_enable_disable (unnumbered_sw_if_index, enable); ip6_sw_interface_enable_disable (unnumbered_sw_if_index, enable); } + + return 0; } vnet_l3_packet_type_t |