diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2016-09-28 14:27:59 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2016-09-30 08:42:28 +0000 |
commit | 2fdaece0876465d6980ac6922099502a84e1e029 (patch) | |
tree | 9455ebf752f02762813cc3b4990e188d6a75a74b | |
parent | 101759c0d67defc91e50221952de6a29071f743c (diff) |
VPP-450 Fix adding LISP adjacencies via CLI
Change-Id: If90c9c630629e727fffc5d450516045a04433661
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r-- | vnet/vnet/lisp-cp/control.c | 105 | ||||
-rw-r--r-- | vnet/vnet/lisp-cp/control.h | 8 | ||||
-rw-r--r-- | vpp-api-test/vat/api_format.c | 87 | ||||
-rw-r--r-- | vpp/vpp-api/api.c | 10 | ||||
-rw-r--r-- | vpp/vpp-api/custom_dump.c | 6 | ||||
-rw-r--r-- | vpp/vpp-api/vpe.api | 12 |
6 files changed, 103 insertions, 125 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c index 2e89286ddc4..940d5893e67 100644 --- a/vnet/vnet/lisp-cp/control.c +++ b/vnet/vnet/lisp-cp/control.c @@ -245,8 +245,8 @@ dp_del_fwd_entry (lisp_cp_main_t * lcm, u32 src_map_index, u32 dst_map_index) u32 sw_if_index; a->is_add = 0; a->locator_pairs = fe->locator_pairs; - a->vni = gid_address_vni (&fe->deid); - gid_address_copy (&a->rmt_eid, &fe->deid); + a->vni = gid_address_vni (&fe->reid); + gid_address_copy (&a->rmt_eid, &fe->reid); vnet_lisp_gpe_add_del_fwd_entry (a, &sw_if_index); @@ -453,7 +453,7 @@ dp_add_fwd_entry (lisp_cp_main_t * lcm, u32 src_map_index, u32 dst_map_index) /* add tunnel to fwd entry table XXX check return value from DP insertion */ pool_get (lcm->fwd_entry_pool, fe); fe->locator_pairs = a->locator_pairs; - gid_address_copy (&fe->deid, &a->rmt_eid); + gid_address_copy (&fe->reid, &a->rmt_eid); hash_set (lcm->fwd_entry_by_mapping_index, dst_map_index, fe - lcm->fwd_entry_pool); } @@ -1032,7 +1032,7 @@ int vnet_lisp_add_del_adjacency (vnet_lisp_add_del_adjacency_args_t * a) { lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); - return lisp_add_del_adjacency (lcm, &a->seid, &a->deid, a->is_add); + return lisp_add_del_adjacency (lcm, &a->leid, &a->reid, a->is_add); } /** @@ -1178,26 +1178,23 @@ lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input, unformat_input_t _line_input, *line_input = &_line_input; vnet_lisp_add_del_adjacency_args_t _a, *a = &_a; u8 is_add = 1; - locator_t rloc, *rlocs = 0; - ip_prefix_t *deid_ippref, *seid_ippref; - gid_address_t seid, deid; - u8 *dmac = gid_address_mac (&deid); - u8 *smac = gid_address_mac (&seid); - u8 deid_set = 0, seid_set = 0; - u8 *s = 0; - u32 vni, action = ~0; + ip_prefix_t *reid_ippref, *leid_ippref; + gid_address_t leid, reid; + u8 *dmac = gid_address_mac (&reid); + u8 *smac = gid_address_mac (&leid); + u8 reid_set = 0, leid_set = 0; + u32 vni; int rv; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; - memset (&deid, 0, sizeof (deid)); - memset (&seid, 0, sizeof (seid)); - memset (&rloc, 0, sizeof (rloc)); + memset (&reid, 0, sizeof (reid)); + memset (&leid, 0, sizeof (leid)); - seid_ippref = &gid_address_ippref (&seid); - deid_ippref = &gid_address_ippref (&deid); + leid_ippref = &gid_address_ippref (&leid); + reid_ippref = &gid_address_ippref (&reid); while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -1205,32 +1202,32 @@ lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input, is_add = 0; else if (unformat (line_input, "add")) ; - else if (unformat (line_input, "deid %U", - unformat_ip_prefix, deid_ippref)) + else if (unformat (line_input, "reid %U", + unformat_ip_prefix, reid_ippref)) { - gid_address_type (&deid) = GID_ADDR_IP_PREFIX; - deid_set = 1; + gid_address_type (&reid) = GID_ADDR_IP_PREFIX; + reid_set = 1; } - else if (unformat (line_input, "deid %U", unformat_mac_address, dmac)) + else if (unformat (line_input, "reid %U", unformat_mac_address, dmac)) { - gid_address_type (&deid) = GID_ADDR_MAC; - deid_set = 1; + gid_address_type (&reid) = GID_ADDR_MAC; + reid_set = 1; } else if (unformat (line_input, "vni %u", &vni)) { - gid_address_vni (&seid) = vni; - gid_address_vni (&deid) = vni; + gid_address_vni (&leid) = vni; + gid_address_vni (&reid) = vni; } - else if (unformat (line_input, "seid %U", - unformat_ip_prefix, seid_ippref)) + else if (unformat (line_input, "leid %U", + unformat_ip_prefix, leid_ippref)) { - gid_address_type (&seid) = GID_ADDR_IP_PREFIX; - seid_set = 1; + gid_address_type (&leid) = GID_ADDR_IP_PREFIX; + leid_set = 1; } - else if (unformat (line_input, "seid %U", unformat_mac_address, smac)) + else if (unformat (line_input, "leid %U", unformat_mac_address, smac)) { - gid_address_type (&seid) = GID_ADDR_MAC; - seid_set = 1; + gid_address_type (&leid) = GID_ADDR_MAC; + leid_set = 1; } else { @@ -1239,39 +1236,24 @@ lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input, } } - if (!deid_set) + if (!reid_set || !leid_set) { - clib_warning ("missing deid!"); + clib_warning ("missing remote or local eid!"); goto done; } - if (GID_ADDR_IP_PREFIX == gid_address_type (&deid)) - { - /* if seid not set, make sure the ip version is the same as that - * of the deid. This ensures the seid to be configured will be - * either 0/0 or ::/0 */ - if (!seid_set) - ip_prefix_version (seid_ippref) = ip_prefix_version (deid_ippref); - - if (is_add && - (ip_prefix_version (deid_ippref) - != ip_prefix_version (seid_ippref))) - { - clib_warning ("source and destination EIDs are not" - " in the same IP family!"); - goto done; - } - } - - if (is_add && (~0 == action) && 0 == vec_len (rlocs)) + if ((gid_address_type (&leid) != gid_address_type (&reid)) + || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX + && ip_prefix_version (reid_ippref) + != ip_prefix_version (leid_ippref))) { - clib_warning ("no action set for negative map-reply!"); - goto done; + clib_warning ("remote and local EIDs are of different types!"); + return error; } memset (a, 0, sizeof (a[0])); - gid_address_copy (&a->seid, &deid); - gid_address_copy (&a->deid, &seid); + gid_address_copy (&a->leid, &leid); + gid_address_copy (&a->reid, &reid); a->is_add = is_add; rv = vnet_lisp_add_del_adjacency (a); @@ -1281,17 +1263,14 @@ lisp_add_del_adjacency_command_fn (vlib_main_t * vm, unformat_input_t * input, done: unformat_free (line_input); - if (s) - vec_free (s); return error; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (lisp_add_del_adjacency_command) = { .path = "lisp adjacency", - .short_help = "lisp adjacency add|del vni <vni>" - "deid <dest-eid> seid <src-eid> [action <no-action|natively-forward|" - "send-map-request|drop>] rloc <dst-locator> [rloc <dst-locator> ... ]", + .short_help = "lisp adjacency add|del vni <vni> reid <remote-eid> " + "leid <local-eid>", .function = lisp_add_del_adjacency_command_fn, }; /* *INDENT-ON* */ diff --git a/vnet/vnet/lisp-cp/control.h b/vnet/vnet/lisp-cp/control.h index 1c8abfb359b..d9dc81d1a78 100644 --- a/vnet/vnet/lisp-cp/control.h +++ b/vnet/vnet/lisp-cp/control.h @@ -37,8 +37,8 @@ typedef struct typedef struct { - gid_address_t seid; - gid_address_t deid; + gid_address_t leid; + gid_address_t reid; locator_pair_t *locator_pairs; } fwd_entry_t; @@ -217,8 +217,8 @@ vnet_lisp_add_del_mapping (gid_address_t * deid, locator_t * dlocs, u8 action, typedef struct { - gid_address_t deid; - gid_address_t seid; + gid_address_t reid; + gid_address_t leid; u8 is_add; } vnet_lisp_add_del_adjacency_args_t; diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c index 0f93af51421..0a15ed7b9ad 100644 --- a/vpp-api-test/vat/api_format.c +++ b/vpp-api-test/vat/api_format.c @@ -13021,15 +13021,15 @@ api_lisp_add_del_adjacency (vat_main_t * vam) vl_api_lisp_add_del_adjacency_t *mp; f64 timeout = ~0; u32 vni = 0; - ip4_address_t seid4, deid4; - ip6_address_t seid6, deid6; - u8 deid_mac[6] = { 0 }; - u8 seid_mac[6] = { 0 }; - u8 deid_type, seid_type; - u32 seid_len = 0, deid_len = 0, len; + ip4_address_t leid4, reid4; + ip6_address_t leid6, reid6; + u8 reid_mac[6] = { 0 }; + u8 leid_mac[6] = { 0 }; + u8 reid_type, leid_type; + u32 leid_len = 0, reid_len = 0, len; u8 is_add = 1; - seid_type = deid_type = (u8) ~ 0; + leid_type = reid_type = (u8) ~ 0; /* Parse args required to build the message */ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) @@ -13042,39 +13042,39 @@ api_lisp_add_del_adjacency (vat_main_t * vam) { is_add = 1; } - else if (unformat (input, "deid %U/%d", unformat_ip4_address, - &deid4, &len)) + else if (unformat (input, "reid %U/%d", unformat_ip4_address, + &reid4, &len)) { - deid_type = 0; /* ipv4 */ - deid_len = len; + reid_type = 0; /* ipv4 */ + reid_len = len; } - else if (unformat (input, "deid %U/%d", unformat_ip6_address, - &deid6, &len)) + else if (unformat (input, "reid %U/%d", unformat_ip6_address, + &reid6, &len)) { - deid_type = 1; /* ipv6 */ - deid_len = len; + reid_type = 1; /* ipv6 */ + reid_len = len; } - else if (unformat (input, "deid %U", unformat_ethernet_address, - deid_mac)) + else if (unformat (input, "reid %U", unformat_ethernet_address, + reid_mac)) { - deid_type = 2; /* mac */ + reid_type = 2; /* mac */ } - else if (unformat (input, "seid %U/%d", unformat_ip4_address, - &seid4, &len)) + else if (unformat (input, "leid %U/%d", unformat_ip4_address, + &leid4, &len)) { - seid_type = 0; /* ipv4 */ - seid_len = len; + leid_type = 0; /* ipv4 */ + leid_len = len; } - else if (unformat (input, "seid %U/%d", unformat_ip6_address, - &seid6, &len)) + else if (unformat (input, "leid %U/%d", unformat_ip6_address, + &leid6, &len)) { - seid_type = 1; /* ipv6 */ - seid_len = len; + leid_type = 1; /* ipv6 */ + leid_len = len; } - else if (unformat (input, "seid %U", unformat_ethernet_address, - seid_mac)) + else if (unformat (input, "leid %U", unformat_ethernet_address, + leid_mac)) { - seid_type = 2; /* mac */ + leid_type = 2; /* mac */ } else if (unformat (input, "vni %d", &vni)) { @@ -13087,38 +13087,38 @@ api_lisp_add_del_adjacency (vat_main_t * vam) } } - if ((u8) ~ 0 == deid_type) + if ((u8) ~ 0 == reid_type) { errmsg ("missing params!"); return -99; } - if (seid_type != deid_type) + if (leid_type != reid_type) { - errmsg ("source and destination EIDs are of different types!"); + errmsg ("remote and local EIDs are of different types!"); return -99; } M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency); mp->is_add = is_add; mp->vni = htonl (vni); - mp->seid_len = seid_len; - mp->deid_len = deid_len; - mp->eid_type = deid_type; + mp->leid_len = leid_len; + mp->reid_len = reid_len; + mp->eid_type = reid_type; switch (mp->eid_type) { case 0: - clib_memcpy (mp->seid, &seid4, sizeof (seid4)); - clib_memcpy (mp->deid, &deid4, sizeof (deid4)); + clib_memcpy (mp->leid, &leid4, sizeof (leid4)); + clib_memcpy (mp->reid, &reid4, sizeof (reid4)); break; case 1: - clib_memcpy (mp->seid, &seid6, sizeof (seid6)); - clib_memcpy (mp->deid, &deid6, sizeof (deid6)); + clib_memcpy (mp->leid, &leid6, sizeof (leid6)); + clib_memcpy (mp->reid, &reid6, sizeof (reid6)); break; case 2: - clib_memcpy (mp->seid, seid_mac, 6); - clib_memcpy (mp->deid, deid_mac, 6); + clib_memcpy (mp->leid, leid_mac, 6); + clib_memcpy (mp->reid, reid_mac, 6); break; default: errmsg ("unknown EID type %d!", mp->eid_type); @@ -15746,9 +15746,8 @@ _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \ "rloc <locator> p <prio> " \ "w <weight> [rloc <loc> ... ] " \ "action <action> [del-all]") \ -_(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \ - "<src-eid> rloc <locator> p <prio> w <weight>"\ - "[rloc <loc> ... ] action <action>") \ +_(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \ + "<local-eid>") \ _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \ _(lisp_map_request_mode, "src-dst|dst-only") \ _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \ diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 6bf5fed71f3..a1c016d41fa 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -5465,7 +5465,7 @@ static void if (!mp->is_add) { vnet_lisp_add_del_adjacency_args_t _a, *a = &_a; - gid_address_copy (&a->deid, eid); + gid_address_copy (&a->reid, eid); a->is_add = 0; rv = vnet_lisp_add_del_adjacency (a); if (rv) @@ -5497,10 +5497,10 @@ vl_api_lisp_add_del_adjacency_t_handler (vl_api_lisp_add_del_adjacency_t * mp) int rv = 0; memset (a, 0, sizeof (a[0])); - rv = unformat_lisp_eid_api (&a->seid, clib_net_to_host_u32 (mp->vni), - mp->eid_type, mp->seid, mp->seid_len); - rv |= unformat_lisp_eid_api (&a->deid, clib_net_to_host_u32 (mp->vni), - mp->eid_type, mp->deid, mp->deid_len); + rv = unformat_lisp_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni), + mp->eid_type, mp->leid, mp->leid_len); + rv |= unformat_lisp_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni), + mp->eid_type, mp->reid, mp->reid_len); if (rv) goto send_reply; diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c index a5ccd5d2732..dc0dfa1621b 100644 --- a/vpp/vpp-api/custom_dump.c +++ b/vpp/vpp-api/custom_dump.c @@ -2467,9 +2467,9 @@ static void *vl_api_lisp_add_del_adjacency_t_print s = format (s, "%s ", mp->is_add ? "add" : "del"); s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni)); - s = format (s, "deid %U seid %U ", - format_lisp_flat_eid, mp->eid_type, mp->deid, mp->deid_len, - format_lisp_flat_eid, mp->eid_type, mp->seid, mp->seid_len); + s = format (s, "reid %U leid %U ", + format_lisp_flat_eid, mp->eid_type, mp->reid, mp->reid_len, + format_lisp_flat_eid, mp->eid_type, mp->leid, mp->leid_len); FINISH; } diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api index 5bed86a80a9..d42eee877f2 100644 --- a/vpp/vpp-api/vpe.api +++ b/vpp/vpp-api/vpe.api @@ -2737,8 +2737,8 @@ define lisp_add_del_remote_mapping_reply 0 : ipv4 1 : ipv6 2 : mac - @param deid - destination EID - @param seid - source EID + @param reid - remote EID + @param leid - local EID */ define lisp_add_del_adjacency { @@ -2747,10 +2747,10 @@ define lisp_add_del_adjacency u8 is_add; u32 vni; u8 eid_type; - u8 deid[16]; - u8 seid[16]; - u8 deid_len; - u8 seid_len; + u8 reid[16]; + u8 leid[16]; + u8 reid_len; + u8 leid_len; }; /** \brief Reply for lisp_add_del_adjacency |