summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.api54
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe.c45
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_api.c113
-rw-r--r--src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c2
4 files changed, 79 insertions, 135 deletions
diff --git a/src/vnet/lisp-gpe/lisp_gpe.api b/src/vnet/lisp-gpe/lisp_gpe.api
index 3956b97d6a1..2a79becee48 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.api
+++ b/src/vnet/lisp-gpe/lisp_gpe.api
@@ -13,6 +13,18 @@
* limitations under the License.
*/
+/** \brief LISP locator structure
+ @param is_ip4 - whether addr is IPv4 or v6
+ @param weight - locator weight
+ @param addr - IPv4/6 address
+*/
+typeonly manual_print manual_endian define lisp_gpe_locator
+{
+ u8 is_ip4;
+ u8 weight;
+ u8 addr[16];
+};
+
/** \brief add or delete lisp gpe tunnel
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -27,12 +39,11 @@
@param lcl_len - local prefix len
@param vni - virtual network identifier
@param dp_table - vrf/bridge domain id
- @param loc_num - number of locators
- @param lcl_locs - array of local locators
- @param rmt_locs - array of remote locators
@param action - negative action when 0 locators configured
+ @param loc_num - number of locators
+ @param locs - array of remote locators
*/
-define lisp_gpe_add_del_fwd_entry
+manual_print manual_endian define lisp_gpe_add_del_fwd_entry
{
u32 client_index;
u32 context;
@@ -44,10 +55,9 @@ define lisp_gpe_add_del_fwd_entry
u8 lcl_len;
u32 vni;
u32 dp_table;
- u32 loc_num;
- u8 lcl_locs[loc_num];
- u8 rmt_locs[loc_num];
u8 action;
+ u32 loc_num;
+ vl_api_lisp_gpe_locator_t locs[loc_num];
};
/** \brief Reply for gpe_fwd_entry add/del
@@ -107,37 +117,9 @@ define lisp_gpe_add_del_iface_reply
i32 retval;
};
-define lisp_gpe_tunnel_details
-{
- u32 context;
- u32 tunnels;
- u8 is_ipv6;
- u8 source_ip[16];
- u8 destination_ip[16];
- u32 encap_fib_id;
- u32 decap_fib_id;
- u32 dcap_next;
- u8 lisp_ver;
- u8 next_protocol;
- u8 flags;
- u8 ver_res;
- u8 res;
- u32 iid;
-};
-
-/** \brief Request for gpe tunnel summary status
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- */
-define lisp_gpe_tunnel_dump
-{
- u32 client_index;
- u32 context;
-};
-
/*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
- \ No newline at end of file
+
diff --git a/src/vnet/lisp-gpe/lisp_gpe.c b/src/vnet/lisp-gpe/lisp_gpe.c
index fbda8687c3b..3fd78c6a1cd 100644
--- a/src/vnet/lisp-gpe/lisp_gpe.c
+++ b/src/vnet/lisp-gpe/lisp_gpe.c
@@ -38,11 +38,15 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
ip_address_t lloc, rloc;
clib_error_t *error = 0;
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, p, w;
+ u8 reid_set = 0, leid_set = 0, is_negative = 0, dp_table_set = 0,
+ vni_set = 0;
+ u32 vni = 0, dp_table = 0, action = ~0, w;
locator_pair_t pair, *pairs = 0;
int rv;
+ memset (leid, 0, sizeof (*leid));
+ memset (reid, 0, sizeof (*reid));
+
/* Get a line of input. */
if (!unformat_user (input, unformat_line_input, line_input))
return 0;
@@ -67,46 +71,46 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
gid_address_vni (reid) = vni;
vni_set = 1;
}
- else if (unformat (line_input, "vrf %u", &vrf))
+ else if (unformat (line_input, "vrf %u", &dp_table))
{
- vrf_set = 1;
+ dp_table_set = 1;
}
- else if (unformat (line_input, "bd %u", &vrf))
+ else if (unformat (line_input, "bd %u", &dp_table))
{
- vrf_set = 1;
+ dp_table_set = 1;
}
else if (unformat (line_input, "negative action %U",
unformat_negative_mapping_action, &action))
{
is_negative = 1;
}
- else if (unformat (line_input, "loc-pair %U %U p %d w %d",
+ else if (unformat (line_input, "loc-pair %U %U w %d",
unformat_ip_address, &lloc,
- unformat_ip_address, &rloc, &p, &w))
+ unformat_ip_address, &rloc, &w))
{
pair.lcl_loc = lloc;
pair.rmt_loc = rloc;
- pair.priority = p;
pair.weight = w;
vec_add1 (pairs, pair);
}
else
{
error = unformat_parse_error (line_input);
+ vlib_cli_output (vm, "parse error: '%U'",
+ format_unformat_error, line_input);
goto done;
}
}
- unformat_free (line_input);
- if (!vni_set || !vrf_set)
+ if (!vni_set || !dp_table_set)
{
- error = clib_error_return (0, "vni and vrf must be set!");
+ vlib_cli_output (vm, "vni and vrf/bd must be set!");
goto done;
}
if (!reid_set)
{
- error = clib_error_return (0, "remote eid must be set!");
+ vlib_cli_output (vm, "remote eid must be set!");
goto done;
}
@@ -114,7 +118,7 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
{
if (~0 == action)
{
- error = clib_error_return (0, "no action set for negative tunnel!");
+ vlib_cli_output (vm, "no action set for negative tunnel!");
goto done;
}
}
@@ -122,7 +126,7 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
{
if (vec_len (pairs) == 0)
{
- error = clib_error_return (0, "expected ip4/ip6 locators.");
+ vlib_cli_output (vm, "expected ip4/ip6 locators");
goto done;
}
}
@@ -142,7 +146,7 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
a->is_add = is_add;
a->is_negative = is_negative;
a->vni = vni;
- a->table_id = vrf;
+ a->table_id = dp_table;
gid_address_copy (&a->lcl_eid, leid);
gid_address_copy (&a->rmt_eid, reid);
a->locator_pairs = pairs;
@@ -150,11 +154,12 @@ lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
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");
+ vlib_cli_output (vm, "failed to %s gpe tunnel!",
+ is_add ? "add" : "delete");
}
done:
+ unformat_free (line_input);
vec_free (pairs);
return error;
}
@@ -162,8 +167,8 @@ done:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (lisp_gpe_add_del_fwd_entry_command, static) = {
.path = "lisp gpe entry",
- .short_help = "lisp gpe entry add/del vni <vni> vrf <vrf> [leid <leid>]"
- "reid <reid> [loc-pair <lloc> <rloc> p <priority> w <weight>] "
+ .short_help = "lisp gpe entry add/del vni <vni> vrf/bd <id> [leid <leid>]"
+ "reid <reid> [loc-pair <lloc> <rloc> w <weight>] "
"[negative action <action>]",
.function = lisp_gpe_add_del_fwd_entry_command_fn,
};
diff --git a/src/vnet/lisp-gpe/lisp_gpe_api.c b/src/vnet/lisp-gpe/lisp_gpe_api.c
index 176ded501cd..93b6053203e 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_api.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_api.c
@@ -28,6 +28,11 @@
#include <vnet/vnet_msg_enum.h>
+#define vl_api_lisp_gpe_locator_pair_t_endian vl_noop_handler
+#define vl_api_lisp_gpe_locator_pair_t_print vl_noop_handler
+#define vl_api_lisp_gpe_add_del_fwd_entry_t_endian vl_noop_handler
+#define vl_api_lisp_gpe_add_del_fwd_entry_t_print vl_noop_handler
+
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#undef vl_typedefs
@@ -47,43 +52,33 @@
#define foreach_vpe_api_msg \
_(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
_(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
-_(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
-_(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump)
-
-/** Used for transferring locators via VPP API */
-/* *INDENT-OFF* */
-typedef CLIB_PACKED (struct {
- u8 is_ip4; /**< is locator an IPv4 address */
- u8 priority; /**< locator priority */
- u8 weight; /**< locator weight */
- u8 addr[16]; /**< IPv4/IPv6 address */
-}) rloc_t;
-/* *INDENT-ON* */
+_(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface)
static locator_pair_t *
-unformat_lisp_loc_pairs (void *lcl_locs, void *rmt_locs, u32 rloc_num)
+unformat_lisp_loc_pairs (void *locs, u32 rloc_num)
{
u32 i;
- locator_pair_t *pairs = 0, pair;
- rloc_t *r;
+ locator_pair_t *pairs = 0, pair, *p;
+ vl_api_lisp_gpe_locator_t *r;
for (i = 0; i < rloc_num; i++)
{
/* local locator */
- r = &((rloc_t *) lcl_locs)[i];
- memset (&pair.lcl_loc, 0, sizeof (pair.lcl_loc));
+ r = &((vl_api_lisp_gpe_locator_t *) locs)[i];
+ memset (&pair, 0, sizeof (pair));
ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
- /* remote locators */
- r = &((rloc_t *) rmt_locs)[i];
- memset (&pair.rmt_loc, 0, sizeof (pair.rmt_loc));
- ip_address_set (&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
-
- pair.priority = r->priority;
pair.weight = r->weight;
-
vec_add1 (pairs, pair);
}
+
+ for (i = rloc_num; i < rloc_num * 2; i++)
+ {
+ /* remote locators */
+ r = &((vl_api_lisp_gpe_locator_t *) locs)[i];
+ p = &pairs[i - rloc_num];
+ ip_address_set (&p->rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+ }
return pairs;
}
@@ -120,6 +115,15 @@ unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
}
static void
+ lisp_gpe_add_del_fwd_entry_t_net_to_host
+ (vl_api_lisp_gpe_add_del_fwd_entry_t * mp)
+{
+ mp->vni = clib_net_to_host_u32 (mp->vni);
+ mp->dp_table = clib_net_to_host_u32 (mp->dp_table);
+ mp->loc_num = clib_net_to_host_u32 (mp->loc_num);
+}
+
+static void
vl_api_lisp_gpe_add_del_fwd_entry_t_handler
(vl_api_lisp_gpe_add_del_fwd_entry_t * mp)
{
@@ -128,6 +132,7 @@ static void
locator_pair_t *pairs = 0;
int rv = 0;
+ lisp_gpe_add_del_fwd_entry_t_net_to_host (mp);
memset (a, 0, sizeof (a[0]));
rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
@@ -135,7 +140,12 @@ static void
rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
mp->lcl_eid, mp->lcl_len);
- pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
+ if (mp->loc_num % 2 != 0)
+ {
+ rv = -1;
+ goto send_reply;
+ }
+ pairs = unformat_lisp_loc_pairs (mp->locs, mp->loc_num / 2);
if (rv || 0 == pairs)
goto send_reply;
@@ -198,59 +208,6 @@ vl_api_lisp_gpe_add_del_iface_t_handler (vl_api_lisp_gpe_add_del_iface_t * mp)
REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
}
-static void
-send_lisp_gpe_fwd_entry_details (lisp_gpe_fwd_entry_t * lfe,
- unix_shared_memory_queue_t * q, u32 context)
-{
- vl_api_lisp_gpe_tunnel_details_t *rmp;
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
-
- rmp->tunnels = lfe - lgm->lisp_fwd_entry_pool;
-
- rmp->is_ipv6 = ip_prefix_version (&(lfe->key->rmt.ippref)) == IP6 ? 1 : 0;
- ip_address_copy_addr (rmp->source_ip,
- &ip_prefix_addr (&(lfe->key->rmt.ippref)));
- ip_address_copy_addr (rmp->destination_ip,
- &ip_prefix_addr (&(lfe->key->rmt.ippref)));
-
- rmp->encap_fib_id = htonl (0);
- rmp->decap_fib_id = htonl (lfe->eid_fib_index);
- rmp->iid = htonl (lfe->key->vni);
- rmp->context = context;
-
- vl_msg_api_send_shmem (q, (u8 *) & rmp);
-}
-
-static void
-vl_api_lisp_gpe_tunnel_dump_t_handler (vl_api_lisp_gpe_tunnel_dump_t * mp)
-{
- unix_shared_memory_queue_t *q = NULL;
- lisp_gpe_main_t *lgm = &lisp_gpe_main;
- lisp_gpe_fwd_entry_t *lfe = NULL;
-
- if (pool_elts (lgm->lisp_fwd_entry_pool) == 0)
- {
- return;
- }
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
- if (q == 0)
- {
- return;
- }
-
- /* *INDENT-OFF* */
- pool_foreach(lfe, lgm->lisp_fwd_entry_pool,
- ({
- send_lisp_gpe_fwd_entry_details(lfe, q, mp->context);
- }));
- /* *INDENT-ON* */
-}
-
/*
* lisp_gpe_api_hookup
* Add vpe's API message handlers to the table.
diff --git a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
index 26a93a87b9d..e05f0e01bee 100644
--- a/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
+++ b/src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
@@ -913,7 +913,7 @@ format_lisp_fwd_path (u8 * s, va_list ap)
{
lisp_fwd_path_t *lfp = va_arg (ap, lisp_fwd_path_t *);
- s = format (s, "priority:%d weight:%d ", lfp->priority, lfp->weight);
+ s = format (s, "weight:%d ", lfp->weight);
s = format (s, "adj:[%U]\n",
format_lisp_gpe_adjacency,
lisp_gpe_adjacency_get (lfp->lisp_adj),
807' href='#n807'>807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284