diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2022-10-14 10:37:53 +0200 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2022-10-14 10:41:17 +0200 |
commit | ce244039639df2685d285020a723850400b26ed4 (patch) | |
tree | bf8390ddeb644aceb44eb067002f12252ffb5fcb /ctrl/libhicnctrl/src/objects | |
parent | 12d21f032e9a67b327101c42481a546a48a6ac21 (diff) |
fix(libhicnctrl): new create/face&route command fail
Change-Id: I49d80a741672c4f9da75e36cc816fc53f37ac158
Ticket: HICN-808
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/libhicnctrl/src/objects')
-rw-r--r-- | ctrl/libhicnctrl/src/objects/connection.c | 17 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/objects/listener.c | 11 | ||||
-rw-r--r-- | ctrl/libhicnctrl/src/objects/route.c | 2 |
3 files changed, 20 insertions, 10 deletions
diff --git a/ctrl/libhicnctrl/src/objects/connection.c b/ctrl/libhicnctrl/src/objects/connection.c index 019e5dc22..0f8bafb10 100644 --- a/ctrl/libhicnctrl/src/objects/connection.c +++ b/ctrl/libhicnctrl/src/objects/connection.c @@ -45,7 +45,9 @@ int hc_connection_validate(const hc_connection_t *connection, bool allow_partial) { int has_id = 0; int has_name = 0; +#if 0 int has_interface_name = 0; +#endif int has_netdevice_type = 0; int has_type = 0; int has_family = 0; @@ -72,6 +74,7 @@ int hc_connection_validate(const hc_connection_t *connection, has_name = 1; } +#if 0 if (!isempty(connection->interface_name)) { if (!IS_VALID_INTERFACE_NAME(connection->interface_name)) { ERROR("[hc_connection_validate] Invalid interface_name specified"); @@ -79,6 +82,7 @@ int hc_connection_validate(const hc_connection_t *connection, } has_interface_name = 1; } +#endif if (connection->type != FACE_TYPE_UNDEFINED) { if (!IS_VALID_TYPE(connection->type)) { @@ -128,10 +132,11 @@ int hc_connection_validate(const hc_connection_t *connection, has_remote_port = 1; } + /* Interface name is optional */ int has_key = has_id || has_name; - int has_mandatory_attributes = has_interface_name && has_type && has_family && - has_local_addr && has_local_port && - has_remote_addr && has_remote_port; + int has_mandatory_attributes = has_type && has_family && has_local_addr && + has_local_port && has_remote_addr && + has_remote_port; int has_optional_attributes = has_netdevice_type && has_admin_state && has_state; has_optional_attributes = has_optional_attributes && has_priority && has_tags; @@ -169,8 +174,10 @@ int hc_connection_cmp(const hc_connection_t *c1, const hc_connection_t *c2) { rc = INT_CMP(c1->family, c2->family); if (rc != 0) return rc; - rc = strncmp(c1->interface_name, c2->interface_name, INTERFACE_LEN); - if (rc != 0) return rc; + if (!isempty(c1->interface_name) && !isempty(c2->interface_name)) { + rc = strncmp(c1->interface_name, c2->interface_name, INTERFACE_LEN); + if (rc != 0) return rc; + } rc = hicn_ip_address_cmp(&c1->local_addr, &c2->local_addr); if (rc != 0) return rc; diff --git a/ctrl/libhicnctrl/src/objects/listener.c b/ctrl/libhicnctrl/src/objects/listener.c index f7da6bd9c..97a2430d8 100644 --- a/ctrl/libhicnctrl/src/objects/listener.c +++ b/ctrl/libhicnctrl/src/objects/listener.c @@ -42,7 +42,9 @@ int hc_listener_validate(const hc_listener_t *listener, bool allow_partial) { int has_id = 0; int has_name = 0; +#if 0 int has_interface_name = 0; +#endif int has_type = 0; int has_family = 0; int has_local_addr = 0; @@ -62,6 +64,7 @@ int hc_listener_validate(const hc_listener_t *listener, bool allow_partial) { has_name = 1; } +#if 0 if (!isempty(listener->interface_name)) { if (!IS_VALID_INTERFACE_NAME(listener->interface_name)) { ERROR("[hc_listener_validate] Invalid interface_name specified"); @@ -69,6 +72,7 @@ int hc_listener_validate(const hc_listener_t *listener, bool allow_partial) { } has_interface_name = 1; } +#endif if (listener->type != FACE_TYPE_UNDEFINED) { if (!IS_VALID_TYPE(listener->type)) { @@ -112,9 +116,8 @@ int hc_listener_validate(const hc_listener_t *listener, bool allow_partial) { else return -1; } else { - /* name is optional */ - if (has_id && has_interface_name && has_type && has_family && - has_local_addr && has_local_port) + /* name and interface are optional */ + if (has_id && has_type && has_family && has_local_addr && has_local_port) return 0; return -1; } @@ -146,7 +149,7 @@ int hc_listener_cmp(const hc_listener_t *l1, const hc_listener_t *l2) { rc = INT_CMP(l1->local_port, l2->local_port); if (rc != 0) return rc; - return rc; + return 0; } int _hc_listener_cmp(const hc_object_t *object1, const hc_object_t *object2) { diff --git a/ctrl/libhicnctrl/src/objects/route.c b/ctrl/libhicnctrl/src/objects/route.c index 44f39bcd7..f2d0636a7 100644 --- a/ctrl/libhicnctrl/src/objects/route.c +++ b/ctrl/libhicnctrl/src/objects/route.c @@ -83,7 +83,7 @@ int hc_route_validate(const hc_route_t *route, bool allow_partial) { } if (hc_route_has_face(route)) { - if (!hc_face_validate(&route->face, allow_partial)) { + if (hc_face_validate(&route->face, allow_partial) < 0) { ERROR("[hc_route_validate] Invalid face"); return -1; } |