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

Support "default-default" entry for tables with ability to reset #551

Conversation

antoninbas
Copy link
Member

This commit introduces the following:

  • support for compile-time default entry for indirect tables; until
    now only direct tables could have compile-time default entries. Unlike
    a control-plane provided default entry, the compile-time default entry
    for indirect tables uses action + action data (not member / group
    handle)
  • ability to reset default entry to initial compile-time default entry
    (aka default-default entry). The Thrift IDL has been updated as well
    as the runtime_CLI, with support in P4 Runtime to follow.

These changes should be able to accomodate both P4_14 & P4_16 and both
bmv2 compilers.

I believe I also found a possible race condition when indirect match
tables share the same action profile and it should be fixed now.

This commit introduces the following:
  * support for compile-time default entry for indirect tables; until
  now only direct tables could have compile-time default entries. Unlike
  a control-plane provided default entry, the compile-time default entry
  for indirect tables uses action + action data (not member / group
  handle)
  * ability to reset default entry to initial compile-time default entry
  (aka default-default entry). The Thrift IDL has been updated as well
  as the runtime_CLI, with support in P4 Runtime to follow.

These changes should be able to accomodate both P4_14 & P4_16 and both
bmv2 compilers.

I believe I also found a possible race condition when indirect match
tables share the same action profile and it should be fixed now.
While implementing support for compile-time default entries for indirect
tables, I realized that the locking for action profiles was completely
wrong. I think that it has been broken since action profile sharing
support was introduced, so it must have been broken for a year...

In particular, the action profile mutex wasn't held during the action
entry execution, which means that modifying the action profile while
applying an action from the action profile on a packet could result in a
race condition and the corruption of the action data used by the action.

I found & implemented a temporary solution by adding virtual functions
to MatchTableAbstract to acquire the action profile mutex (for
MatchTable, the virtual functions return an empty lock). I'm confident I
can find a more elegant solution if I have time...
The ref count was being incremented, which means we could end up with
dangling default entries.
Instead just log an error and treat it as an error.
@codecov-io
Copy link

codecov-io commented Feb 9, 2018

Codecov Report

Merging #551 into master will increase coverage by 0.21%.
The diff coverage is 78.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #551      +/-   ##
==========================================
+ Coverage   76.15%   76.37%   +0.21%     
==========================================
  Files         109      109              
  Lines        9106     9181      +75     
==========================================
+ Hits         6935     7012      +77     
+ Misses       2171     2169       -2
Impacted Files Coverage Δ
include/bm/bm_sim/runtime_interface.h 0% <ø> (ø) ⬆️
include/bm/bm_sim/context.h 66.66% <ø> (ø) ⬆️
include/bm/bm_sim/action_entry.h 100% <ø> (ø) ⬆️
include/bm/bm_sim/switch.h 1.33% <0%> (-0.04%) ⬇️
src/bm_sim/context.cpp 34.88% <0%> (-0.93%) ⬇️
include/bm/bm_sim/action_profile.h 100% <100%> (ø) ⬆️
src/bm_sim/P4Objects.cpp 80.12% <63.63%> (+0.01%) ⬆️
include/bm/bm_sim/match_tables.h 64.51% <75%> (+0.23%) ⬆️
src/bm_sim/action_profile.cpp 74.02% <83.33%> (+0.12%) ⬆️
src/bm_sim/match_tables.cpp 82.92% <90.74%> (+5.6%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 882cb1f...43ca432. Read the comment docs.

@antoninbas
Copy link
Member Author

I found more race conditions in the action profile implementation which for some reason I have completely missed in the last year. So this PR ended-up being much more than supporting default-default entry...

@antoninbas antoninbas merged commit cbbdfb5 into master Feb 9, 2018
@antoninbas antoninbas deleted the antonin/support-default-default-entry-for-match-tables-with-reset-operation branch February 9, 2018 17:19
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