Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ovsp4rt] Update C++ API functions to return absl::Status #734

Merged
merged 5 commits into from
Jan 9, 2025

Conversation

ffoulkes
Copy link
Contributor

@ffoulkes ffoulkes commented Jan 9, 2025

  • Modified the functions in the internal C++ API to return absl::Status, allowing test programs to verify whether the function encountered an error.
  • Modified the C API wrappers to ignore the returned Status explicitly. The public APIs currently have a void return type.

These changes only apply when BUILD_CLIENT is enabled.

Note

Issue #618 proposes that the public APIs should return status. The Status returned by the core APIs will give them the means to do so, should we decide to implement this change.

- Renamed the functions in the internal C++ API from
  ConfigEntry to DoConfigEntry, to keep them from being
  confused with ConfigTableEntry functions.

The conventions are:

- A PrepareTableEntry function populates the fields of a
  TableEntry.

- A ConfigTableEntry function initializes a WriteRequest,
  prepares the TableEntry, and sends the request to the
  P4Runtime server.

- A GetTableEntry function initializes a ReadRequest,
  prepares the TableEntry, sends the request to the
  P4Runtime server, and returns the response.

- A DoConfigEntry function implements the core logic of
  an ovsp4rt_table_entry C API. It may make one or more
  ConfigTableEntry or GetTableEntry calls.

Signed-off-by: Derek Foster <[email protected]>
- Modified the functions in the internal C++ API to return
  absl::Status. Explicitly ignored return status in the C
  API wrappers. Status is currently for use in testing.

  Note that issue #618 proposes that public APIs should
  return status.

- Moved ovsp4rt_str_to_tunnel_type() to a separate source
  file for C api functions that are not wrappers.

Signed-off-by: Derek Foster <[email protected]>
@ffoulkes ffoulkes changed the title [ovsp4rt] Update internal API functions to return status (DRAFT) [ovsp4rt] Update internal API functions to return status Jan 9, 2025
@ffoulkes ffoulkes changed the title [ovsp4rt] Update internal API functions to return status [ovsp4rt] Update internal API functions to return absl::Status Jan 9, 2025
@ffoulkes ffoulkes changed the title [ovsp4rt] Update internal API functions to return absl::Status [ovsp4rt] Update C++ API functions to return absl::Status Jan 9, 2025
// Ignore errors (why?)
}
// Ignore errors (why?)
(void)ConfigFdbTunnelTableEntry(client, learn_info, p4info, insert_entry);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the (void) addition to suppress compiler warnings?

Copy link
Contributor Author

@ffoulkes ffoulkes Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is also a way of telling the reader that we are ignoring the value returned by the function.

The comment is shorthand for "the original developer did this, and it's probably a defect; but we don't know that for sure, and we either don't have the time or are too scared to change it right now. We will, however, leave this comment as a sort of a 'danger, thin ice' warning, for the benefit of future developers." It's kind of like inserting [sic] into a document you're editing.🙄

Copy link
Collaborator

@5abeel 5abeel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ffoulkes ffoulkes merged commit b79ae6a into main Jan 9, 2025
10 checks passed
@ffoulkes ffoulkes deleted the return-api-status branch January 9, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants