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

SAI NAT aging notification #1365

Merged
merged 1 commit into from
Feb 28, 2022
Merged

SAI NAT aging notification #1365

merged 1 commit into from
Feb 28, 2022

Conversation

arvbb
Copy link
Contributor

@arvbb arvbb commented Dec 20, 2021

In the Hit Bit query mechanism described in https://github.com/opencomputeproject/SAI/blob/master/doc/NAT/SAI-NAT-API.md, the NOS periodically polls the NAT entries for aging out unused entries. In a highly scaled environment with tens of thousands of NAT entries programmed, the frequent polling for aging out is not performant. An alternative is to use a callback from SAI to notify NOS about the NAT entries that are aged out after a certain time.

The NOS registers a callback named sai_nat_event_notification_fn through the switch attribute SAI_SWITCH_ATTR_NAT_EVENT_NOTIFY.

The NOS then create/sets the NAT entry with the optional attribute SAI_NAT_ENTRY_ATTR_AGING_TIME.

nat_entry_attr[0].id = SAI_NAT_ENTRY_ATTR_AGING_TIME;
nat_entry_attr[0].value.u32 = aging_time; // in seconds

If the attribute is not added the NAT entry does not age out. If the aging time is specified as 0, the NAT entry does not age out. The aging time configured can be queried using a GET request of this attribute.

Once the NAT entry ages out, SAI notifies NOS using sai_nat_event_notification_fn callback. This callback provides events of type sai_nat_event_notification_data_t which has information about the specific NAT entries that got aged out. The NOS uses the NAT entry information to delete these NAT entries.

Signed-off-by: Arvind Bhat <arvind.bhat@intel.com>
@arvbb
Copy link
Contributor Author

arvbb commented Jan 21, 2022

Updating after review in SAI meeting on Jan 20, 2022:

  1. A query mechanism can be used to check if a specific SAI implementation supports the NAT aging mechanism. The NOS can then query using sai_query_attribute_capability() API as follows:

    sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_NAT_ENTRY, SAI_NAT_ENTRY_ATTR_AGING_TIME, &capability);

  The returned 'capability' would indicate if SAI supports NAT aging

  1. NOS can use an optional switch attribute SAI_SWITCH_ATTR_NAT_EVENT_NOTIFY_INTERVAL to inform SAI on frequency of invoking the sai_nat_event_notification_fn callback.

  If this attribute is not specified or if attribute set to 0 (i.e. default), SAI notifies NOS as soon as NAT entry is aged out.
  SAI can still do bulking of notifications even when this interval is 0.

/**
 * @brief NAT event notification callback timeout in seconds
 *
 * SAI to notify NOS through the sai_nat_event_notification_fn callback at specified duration
 *
 * @type sai_uint32_t
 * @flags CREATE_AND_SET
 * @default 0
 */
SAI_SWITCH_ATTR_NAT_EVENT_NOTIFY_INTERVAL,

@rlhui
Copy link
Collaborator

rlhui commented Feb 3, 2022

@JaiOCP , @marian-pritsak - please help review/approve?

Copy link

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

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

lgtm

@rlhui
Copy link
Collaborator

rlhui commented Feb 28, 2022

@JaiOCP - reminder to please review/approve this. Thanks.

Copy link
Contributor

@JaiOCP JaiOCP left a comment

Choose a reason for hiding this comment

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

Looks Good

@rlhui rlhui merged commit 5f44a9b into opencomputeproject:master Feb 28, 2022
kcudnik pushed a commit to sonic-net/sonic-sairedis that referenced this pull request Oct 6, 2022
The sairedis changes related to the SAI here: opencomputeproject/SAI#1365
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
The sairedis changes related to the SAI here: opencomputeproject/SAI#1365
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.

5 participants