aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/vapi/vapi.c4
-rw-r--r--src/vpp-api/vapi/vapi_json_parser.py36
2 files changed, 22 insertions, 18 deletions
diff --git a/src/vpp-api/vapi/vapi.c b/src/vpp-api/vapi/vapi.c
index 26c5708342f..61801fc3726 100644
--- a/src/vpp-api/vapi/vapi.c
+++ b/src/vpp-api/vapi/vapi.c
@@ -927,6 +927,7 @@ vapi_sock_client_disconnect (vapi_ctx_t ctx)
}
clib_socket_close (&ctx->client_socket);
+ clib_socket_free (&ctx->client_socket);
vapi_api_name_and_crc_free (ctx);
return VAPI_OK;
}
@@ -987,7 +988,7 @@ vapi_connect_ex (vapi_ctx_t ctx, const char *name, const char *path,
if (use_uds)
{
- if (vapi_sock_client_connect (ctx, (char *) path, name) < 0)
+ if (vapi_sock_client_connect (ctx, (char *) path, name) != VAPI_OK)
{
return VAPI_ECON_FAIL;
}
@@ -1358,6 +1359,7 @@ vapi_sock_disconnect (vapi_ctx_t ctx)
}
fail:
clib_socket_close (&ctx->client_socket);
+ clib_socket_free (&ctx->client_socket);
vapi_api_name_and_crc_free (ctx);
ctx->connected = false;
diff --git a/src/vpp-api/vapi/vapi_json_parser.py b/src/vpp-api/vapi/vapi_json_parser.py
index c06cb8cf77b..0fd0663dcab 100644
--- a/src/vpp-api/vapi/vapi_json_parser.py
+++ b/src/vpp-api/vapi/vapi_json_parser.py
@@ -26,25 +26,11 @@ class Field(object):
def __str__(self):
if self.len is None:
- return "Field(name: %s, type: %s)" % (self.name, self.type)
- elif type(self.len) == dict:
- return "Field(name: %s, type: %s, length: %s)" % (
- self.name,
- self.type,
- self.len,
- )
+ return f"Field(name: {self.name}, type: {self.type})"
elif self.len > 0:
- return "Field(name: %s, type: %s, length: %s)" % (
- self.name,
- self.type,
- self.len,
- )
+ return "Field(name: {self.name}, type: {self.type}, length: {self.len})"
else:
- return "Field(name: %s, type: %s, variable length stored in: %s)" % (
- self.name,
- self.type,
- self.nelem_field,
- )
+ return "Field(name: {self.name}, type: {self.type}, VLA length in: {self.nelem_field})"
def is_vla(self):
return self.nelem_field is not None
@@ -282,6 +268,22 @@ class StructType(Type, Struct):
"While parsing type `%s': array `%s' has "
"variable length" % (name, field[1])
)
+ elif type(field[2]) is dict:
+ # the concept of default values is broken beyond repair:
+ #
+ # if following is allowed:
+ # typedef feature1 { u32 table_id[default=0xffffffff]; }
+ # typedef feature2 { u32 hash_buckets[default=1024]; }
+ # union here_we_go { vl_api_feature1_t this; vl_api_feature2_t that; };
+ #
+ # what does it mean to set the defaults for instance of here_we_go?
+ #
+ # because of that, we parse it here, but don't do anything about it...
+ if len(field[2]) != 1 or "default" not in field[2]:
+ raise ParseError(
+ f"Don't know how to parse field `{field}' of type definition for type `{t}'"
+ )
+ p = field_class(field_name=field[1], field_type=field_type)
else:
p = field_class(
field_name=field[1], field_type=field_type, array_len=field[2]