Skip to content

Commit

Permalink
allow SAI_ROUTE_ATTR_NEXT_HOP_ID point to SAI_NULL_OBJECT_ID by defau…
Browse files Browse the repository at this point in the history
…lt (#253)

* allow SAI_ROUTE_ATTR_NEXT_HOP_ID point to SAI_NULL_OBJECT_ID by default

When SAI_ROUTE_ATTR_NEXT_HOP_ID = SAI_NULL_OBJECT_ID, packet is dropped.
This allows user to change packet action from DROP to FORWARD using set API.
Otherwise, the behavior transition from DROP to FORWARD is undefined.

* add sanity check to all SAI_NULL_OBJECT_ID as default
  • Loading branch information
lguohan authored Oct 24, 2016
1 parent 4e8ba80 commit 25c0020
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion inc/sairoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,23 @@ typedef enum _sai_route_entry_attr_t
* @brief Next hop or next hop group id for the packet, or a router interface
* in case of directly reachable route, or the CPU port in case of IP2ME route
*
* The next hop id is only effective when the packet action is one of the following:
* FORWARD, COPY, LOG, TRANSIT
*
* The next hop id can be a generic next hop object, such as next hop, next
* hop group. Directly reachable routes are the IP subnets that are
* directly attached to the router. For such routes, fill the router
* interface id to which the subnet is attached. IP2ME route adds a local
* router IP address. For such routes, fill the CPU port
* (#SAI_SWITCH_ATTR_CPU_PORT).
*
* When it is SAI_NULL_OBJECT_ID, then packet will be dropped.
*
* @type sai_object_id_t
* @objects SAI_OBJECT_TYPE_NEXT_HOP, SAI_OBJECT_TYPE_NEXT_HOP_GROUP, SAI_OBJECT_TYPE_ROUTER_INTERFACE, SAI_OBJECT_TYPE_PORT
* @flags MANDATORY_ON_CREATE | CREATE_AND_SET
* @default SAI_NULL_OBJECT_ID
* @flags CREATE_AND_SET
* @allownull true
*/
SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID,

Expand Down
6 changes: 6 additions & 0 deletions meta/parse.pl
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ sub ProcessDefaultValueType

return "SAI_DEFAULT_VALUE_TYPE_NONE" if not defined $default;

return "SAI_DEFAULT_VALUE_TYPE_CONST" if $default =~ /^SAI_NULL_OBJECT_ID$/;

return "SAI_DEFAULT_VALUE_TYPE_CONST" if $default =~ /^(true|false|const|\d+|SAI_\w+)$/ and not $default =~ /_ATTR_|SAI_OBJECT_TYPE_/;

return "SAI_DEFAULT_VALUE_TYPE_INHERIT" if $default =~ /^inherit SAI_\w+$/ and $default =~ /_ATTR_/;
Expand Down Expand Up @@ -904,6 +906,10 @@ sub ProcessDefaultValue
{
WriteSource "$val = { .booldata = $default };";
}
elsif ($default =~ /^SAI_NULL_OBJECT_ID$/ and $type =~ /^sai_object_id_t$/)
{
WriteSource "$val = { .oid = $default };";
}
elsif ($default =~ /^SAI_\w+$/ and $type =~ /^sai_\w+_t$/ and not defined $VALUE_TYPES{$type})
{
WriteSource "$val = { .s32 = $default };";
Expand Down

0 comments on commit 25c0020

Please sign in to comment.