summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/gre/node.c5
-rw-r--r--src/vnet/interface.c42
-rw-r--r--src/vnet/interface_api.c4
-rw-r--r--src/vnet/interface_cli.c19
-rw-r--r--src/vnet/interface_funcs.h4
5 files changed, 67 insertions, 7 deletions
diff --git a/src/vnet/gre/node.c b/src/vnet/gre/node.c
index 92523069f05..fdd3118bf3c 100644
--- a/src/vnet/gre/node.c
+++ b/src/vnet/gre/node.c
@@ -301,6 +301,9 @@ gre_input (vlib_main_t * vm,
vnet_buffer (b[1])->sw_if_index[VLIB_RX] = tun_sw_if_index[1];
}
+ vnet_buffer (b[0])->sw_if_index[VLIB_TX] = (u32) ~0;
+ vnet_buffer (b[1])->sw_if_index[VLIB_TX] = (u32) ~0;
+
if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
gre_trace (vm, node, b[0], tun_sw_if_index[0], ip6[0], ip4[0],
is_ipv6);
@@ -411,6 +414,8 @@ gre_input (vlib_main_t * vm,
vnet_buffer (b[0])->sw_if_index[VLIB_RX] = tun_sw_if_index[0];
}
+ vnet_buffer (b[0])->sw_if_index[VLIB_TX] = (u32) ~0;
+
if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
gre_trace (vm, node, b[0], tun_sw_if_index[0], ip6[0], ip4[0],
is_ipv6);
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
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index a1450bd1906..9b606dd6265 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -682,8 +682,8 @@ static void vl_api_sw_interface_set_unnumbered_t_handler
goto done;
}
- vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
- sw_if_index, mp->is_add);
+ rv = vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
+ sw_if_index, mp->is_add);
done:
REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
}
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 73b275785b8..68431860183 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -976,8 +976,23 @@ set_unnumbered (vlib_main_t * vm,
return clib_error_return (0, "When enabling unnumbered specify the"
" IP enabled interface that it uses");
- vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
- inherit_from_sw_if_index, enable);
+ int rv = vnet_sw_interface_update_unnumbered (
+ unnumbered_sw_if_index, inherit_from_sw_if_index, enable);
+
+ switch (rv)
+ {
+ case 0:
+ break;
+
+ case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
+ return clib_error_return (
+ 0,
+ "When enabling unnumbered both interfaces must be in the same tables");
+
+ default:
+ return clib_error_return (
+ 0, "vnet_sw_interface_update_unnumbered returned %d", rv);
+ }
return (NULL);
}
diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h
index 14168406377..3db5a2d8c11 100644
--- a/src/vnet/interface_funcs.h
+++ b/src/vnet/interface_funcs.h
@@ -430,8 +430,8 @@ void vnet_sw_interface_set_protocol_mtu (vnet_main_t * vnm, u32 sw_if_index,
u32 mtu[]);
/* update the unnumbered state of an interface */
-void vnet_sw_interface_update_unnumbered (u32 sw_if_index,
- u32 ip_sw_if_index, u8 enable);
+int vnet_sw_interface_update_unnumbered (u32 sw_if_index, u32 ip_sw_if_index,
+ u8 enable);
int vnet_sw_interface_stats_collect_enable_disable (u32 sw_if_index,
u8 enable);