diff options
author | Neale Ranns <nranns@cisco.com> | 2017-02-13 23:20:04 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-03-03 17:11:26 +0000 |
commit | 4008ac998f43265451281cb6e759cd6184e50bed (patch) | |
tree | 7129722f04fac33d79f90b36ca91be2a3aa94eaa /src/vnet/interface_api.c | |
parent | 7112c542eac53d28861062b13b602a2817dc4052 (diff) |
Changing the IP table for an interface is an error if the interface already has an address configured (VPP-601)
Change-Id: I311fc264f73dd3b2b3ce9d7d1c33cd0515b36c4a
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/interface_api.c')
-rw-r--r-- | src/vnet/interface_api.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index 60cd6d40368..f94928b6dad 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -25,6 +25,7 @@ #include <vnet/ethernet/ethernet.h> #include <vnet/ip/ip.h> #include <vnet/fib/fib_table.h> +#include <vnet/mfib/mfib_table.h> #include <vnet/l2/l2_vtr.h> #include <vnet/vnet_msg_enum.h> #include <vnet/fib/fib_api.h> @@ -318,6 +319,7 @@ vl_api_sw_interface_set_table_t_handler (vl_api_sw_interface_set_table_t * mp) u32 table_id = ntohl (mp->vrf_id); u32 sw_if_index = ntohl (mp->sw_if_index); vl_api_sw_interface_set_table_reply_t *rmp; + CLIB_UNUSED (ip_interface_address_t * ia); u32 fib_index; VALIDATE_SW_IF_INDEX (mp); @@ -326,21 +328,51 @@ vl_api_sw_interface_set_table_t_handler (vl_api_sw_interface_set_table_t * mp) if (mp->is_ipv6) { + /* *INDENT-OFF* */ + foreach_ip_interface_address (&ip6_main.lookup_main, + ia, sw_if_index, + 1 /* honor unnumbered */ , + ({ + rv = VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE; + goto done; + })); + /* *INDENT-ON* */ + fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6, table_id); vec_validate (ip6_main.fib_index_by_sw_if_index, sw_if_index); ip6_main.fib_index_by_sw_if_index[sw_if_index] = fib_index; + fib_index = mfib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6, + table_id); + vec_validate (ip6_main.mfib_index_by_sw_if_index, sw_if_index); + ip6_main.mfib_index_by_sw_if_index[sw_if_index] = fib_index; } else { + /* *INDENT-OFF* */ + foreach_ip_interface_address (&ip4_main.lookup_main, + ia, sw_if_index, + 1 /* honor unnumbered */ , + ({ + rv = VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE; + goto done; + })); + /* *INDENT-ON* */ fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4, table_id); vec_validate (ip4_main.fib_index_by_sw_if_index, sw_if_index); ip4_main.fib_index_by_sw_if_index[sw_if_index] = fib_index; + + fib_index = mfib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4, + table_id); + vec_validate (ip4_main.mfib_index_by_sw_if_index, sw_if_index); + ip4_main.mfib_index_by_sw_if_index[sw_if_index] = fib_index; } + +done: stats_dsunlock (); BAD_SW_IF_INDEX_LABEL; |