summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.c57
-rw-r--r--vnet/vnet/lisp-cp/lisp_types.h3
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe.c132
3 files changed, 141 insertions, 51 deletions
diff --git a/vnet/vnet/lisp-cp/lisp_types.c b/vnet/vnet/lisp-cp/lisp_types.c
index 62900ec795c..c1c959c55a1 100644
--- a/vnet/vnet/lisp-cp/lisp_types.c
+++ b/vnet/vnet/lisp-cp/lisp_types.c
@@ -198,25 +198,54 @@ unformat_gid_address (unformat_input_t * input, va_list * args)
ip_prefix_t ippref;
memset (&ippref, 0, sizeof (ippref));
- memset (a, 0, sizeof (a[0]));
+ memset(a, 0, sizeof(a[0]));
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ if (unformat (input, "%U", unformat_ip_prefix, &ippref))
{
- if (unformat (input, "%U", unformat_ip_prefix, &ippref))
- {
- clib_memcpy (&gid_address_ippref(a), &ippref, sizeof (ippref));
- gid_address_type(a) = GID_ADDR_IP_PREFIX;
- }
- else if (unformat (input, "%U", unformat_mac_address, mac))
+ clib_memcpy (&gid_address_ippref(a), &ippref, sizeof(ippref));
+ gid_address_type(a) = GID_ADDR_IP_PREFIX;
+ }
+ else if (unformat (input, "%U", unformat_mac_address, mac))
+ {
+ clib_memcpy (gid_address_mac(a), mac, sizeof(mac));
+ gid_address_type(a) = GID_ADDR_MAC;
+ }
+ else if (unformat (input, "[%d]", &vni))
+ gid_address_vni(a) = vni;
+ else
+ return 0;
+
+ return 1;
+}
+
+uword
+unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
+{
+ u32 * action = va_arg(*args, u32 *);
+ u8 * s = 0;
+
+ if (unformat (input, "%s", &s))
+ {
+ int len = vec_len(s);
+ clib_warning ("len = %d", len);
+ if (!strcmp ((char *) s, "no-action"))
+ action[0] = ACTION_NONE;
+ if (!strcmp ((char *) s, "natively-forward"))
+ action[0] = ACTION_NATIVELY_FORWARDED;
+ if (!strcmp ((char *) s, "send-map-request"))
+ action[0] = ACTION_SEND_MAP_REQUEST;
+ else if (!strcmp ((char *) s, "drop"))
+ action[0] = ACTION_DROP;
+ else
{
- clib_memcpy (gid_address_mac(a), mac, sizeof (mac));
- gid_address_type(a) = GID_ADDR_MAC;
+ clib_warning("invalid action: '%s'", s);
+ action[0] = ACTION_DROP;
+ return 0;
}
- else if (unformat (input, "[%d]", &vni))
- gid_address_vni(a) = vni;
- else
- return 0;
}
+ else
+ return 0;
+
return 1;
}
diff --git a/vnet/vnet/lisp-cp/lisp_types.h b/vnet/vnet/lisp-cp/lisp_types.h
index f7225908dd6..ef86f71bdf3 100644
--- a/vnet/vnet/lisp-cp/lisp_types.h
+++ b/vnet/vnet/lisp-cp/lisp_types.h
@@ -244,4 +244,7 @@ typedef struct
u8 local;
} mapping_t;
+uword
+unformat_negative_mapping_action (unformat_input_t * input, va_list * args);
+
#endif /* VNET_LISP_GPE_LISP_TYPES_H_ */
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe.c b/vnet/vnet/lisp-gpe/lisp_gpe.c
index 7ed21abfab7..c1ae5c42445 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe.c
+++ b/vnet/vnet/lisp-gpe/lisp_gpe.c
@@ -318,15 +318,13 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
{
unformat_input_t _line_input, * line_input = &_line_input;
u8 is_add = 1;
- ip_address_t slocator, dlocator, *slocators = 0, *dlocators = 0;
- ip_prefix_t * prefp;
- gid_address_t * eids = 0, eid;
+ ip_address_t lloc, rloc, *llocs = 0, *rlocs = 0;
clib_error_t * error = 0;
- u32 i;
+ gid_address_t _reid, * reid = &_reid, _leid, * leid = &_leid;
+ u8 reid_set = 0, leid_set = 0, is_negative = 0, vrf_set = 0, vni_set = 0;
+ u32 vni, vrf, action = ~0;
int rv;
- prefp = &gid_address_ippref(&eid);
-
/* Get a line of input. */
if (! unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -337,14 +335,38 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
is_add = 0;
else if (unformat (line_input, "add"))
is_add = 1;
- else if (unformat (line_input, "eid %U slocator %U dlocator %U",
- unformat_ip_prefix, prefp,
- unformat_ip_address, &slocator,
- unformat_ip_address, &dlocator))
+ else if (unformat (line_input, "leid %U",
+ unformat_gid_address, leid))
+ {
+ leid_set = 1;
+ }
+ else if (unformat (line_input, "reid %U",
+ unformat_gid_address, reid))
+ {
+ reid_set = 1;
+ }
+ else if (unformat (line_input, "vni %u", &vni))
+ {
+ gid_address_vni (leid) = vni;
+ gid_address_vni (reid) = vni;
+ vni_set = 1;
+ }
+ else if (unformat (line_input, "vrf %u", &vrf))
+ {
+ vrf_set = 1;
+ }
+ else if (unformat (line_input, "negative action %U",
+ unformat_negative_mapping_action, &action))
{
- vec_add1 (eids, eid);
- vec_add1 (slocators, slocator);
- vec_add1 (dlocators, dlocator);
+ is_negative = 1;
+ }
+ else if (unformat (line_input, "lloc %U rloc %U",
+ unformat_ip_address, &lloc,
+ unformat_ip_address, &rloc))
+ {
+ /* TODO: support p and w */
+ vec_add1 (llocs, lloc);
+ vec_add1 (rlocs, rloc);
}
else
{
@@ -354,48 +376,84 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
}
unformat_free (line_input);
- if (vec_len (eids) + vec_len (slocators) == 0)
+ if (!vni_set || !vrf_set)
{
- error = clib_error_return (0, "expected ip4/ip6 eids/locators.");
+ error = clib_error_return(0, "vni and vrf must be set!");
goto done;
}
- if (vec_len (eids) != vec_len (slocators))
+ if (!reid_set)
{
- error = clib_error_return (0, "number of eids not equal to that of "
- "locators.");
+ error = clib_error_return(0, "remote eid must be set!");
goto done;
}
- for (i = 0; i < vec_len(eids); i++)
+ if (is_negative)
{
- vnet_lisp_gpe_add_del_fwd_entry_args_t a;
- memset (&a, 0, sizeof(a));
-
- a.is_add = is_add;
- a.deid = eids[i];
- a.slocator = slocators[i];
- a.dlocator = dlocators[i];
- rv = vnet_lisp_gpe_add_del_fwd_entry (&a, 0);
- if (0 != rv)
+ if (~0 == action)
{
- error = clib_error_return(0, "failed to %s gpe maptunnel!",
- is_add ? "add" : "delete");
- break;
+ error = clib_error_return(0, "no action set for negative tunnel!");
+ goto done;
+ }
+ }
+ else
+ {
+ if (vec_len (llocs) == 0)
+ {
+ error = clib_error_return (0, "expected ip4/ip6 locators.");
+ goto done;
}
+
+ if (vec_len (llocs) != 1)
+ {
+ error = clib_error_return (0, "multihoming not supported for now!");
+ goto done;
+ }
+ }
+
+
+
+ if (!leid_set)
+ {
+ /* if leid not set, make sure it's the same AFI like reid */
+ gid_address_type(leid) = gid_address_type(reid);
+ if (GID_ADDR_IP_PREFIX == gid_address_type (reid))
+ gid_address_ip_version(leid) = gid_address_ip_version(reid);
+ }
+
+ /* add fwd entry */
+ vnet_lisp_gpe_add_del_fwd_entry_args_t _a, * a = &_a;
+ memset (a, 0, sizeof(a[0]));
+
+ a->is_add = is_add;
+ a->vni = vni;
+ a->table_id = vrf;
+ gid_address_copy(&a->seid, leid);
+ gid_address_copy(&a->deid, reid);
+
+ if (!is_negative)
+ {
+ a->slocator = llocs[0];
+ a->dlocator = rlocs[0];
+ }
+
+ rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
+ if (0 != rv)
+ {
+ error = clib_error_return(0, "failed to %s gpe tunnel!",
+ is_add ? "add" : "delete");
}
done:
- vec_free(eids);
- vec_free(slocators);
- vec_free(dlocators);
+ vec_free(llocs);
+ vec_free(rlocs);
return error;
}
VLIB_CLI_COMMAND (lisp_gpe_add_del_fwd_entry_command, static) = {
- .path = "lisp gpe maptunnel",
- .short_help = "lisp gpe maptunnel eid <eid> sloc <src-locator> "
- "dloc <dst-locator> [del]",
+ .path = "lisp gpe tunnel",
+ .short_help = "lisp gpe tunnel add/del vni <vni> vrf <vrf> [leid <leid>]"
+ "reid <reid> [lloc <sloc> rloc <rloc>] [negative action <action>]",
.function = lisp_gpe_add_del_fwd_entry_command_fn,
};