Skip to content

Commit

Permalink
orchagent: Adding IP2Me route (sonic-net#63)
Browse files Browse the repository at this point in the history
* Trapping ip2me traffic to CPU
  • Loading branch information
hrachyam authored and Shuotian Cheng committed Aug 31, 2016
1 parent 70487a0 commit 53b5a98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
14 changes: 11 additions & 3 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,22 @@ void IntfsOrch::doTask(Consumer &consumer)
SWSS_LOG_NOTICE("Create subnet route pre:%s\n", ip_prefix.to_string().c_str());
}

vector<sai_attribute_t> ip2me_attrs;
sai_attribute_t ip2me_attr;
ip2me_attr.id = SAI_ROUTE_ATTR_PACKET_ACTION;
ip2me_attr.value.s32 = SAI_PACKET_ACTION_FORWARD;
ip2me_attrs.push_back(ip2me_attr);

ip2me_attr.id = SAI_ROUTE_ATTR_NEXT_HOP_ID;
ip2me_attr.value.oid = m_portsOrch->getCpuPort();
ip2me_attrs.push_back(ip2me_attr);

unicast_route_entry.vr_id = gVirtualRouterId;
unicast_route_entry.destination.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
unicast_route_entry.destination.addr.ip4 = ip_prefix.getIp().getV4Addr();
unicast_route_entry.destination.mask.ip4 = 0xFFFFFFFF;

attr.id = SAI_ROUTE_ATTR_PACKET_ACTION;
attr.value.s32 = SAI_PACKET_ACTION_TRAP;
status = sai_route_api->create_route(&unicast_route_entry, 1, &attr);
status = sai_route_api->create_route(&unicast_route_entry, ip2me_attrs.size(), ip2me_attrs.data());
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to create packet action trap route ip:%s %d\n", ip_prefix.getIp().to_string().c_str(), status);
Expand Down
5 changes: 5 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ void PortsOrch::setPort(string alias, Port p)
m_portList[alias] = p;
}

sai_object_id_t PortsOrch::getCpuPort()
{
return m_cpuPort;
}

bool PortsOrch::setPortAdminStatus(sai_object_id_t id, bool up)
{
SWSS_LOG_ENTER();
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PortsOrch : public Orch

bool getPort(string alias, Port &port);
void setPort(string alias, Port port);
sai_object_id_t getCpuPort();

private:
Table *m_counterTable;
Expand Down

0 comments on commit 53b5a98

Please sign in to comment.