Skip to content

Commit

Permalink
[vnetorch]: Set default VxLAN encap TTL value (#980)
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Samotiy <[email protected]>
  • Loading branch information
Volodymyr Samotiy authored and liat-grozovik committed Jul 22, 2019
1 parent 7db25f7 commit 63afbd5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
5 changes: 3 additions & 2 deletions orchagent/vnetorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,10 @@ VnetBridgeInfo VNetBitmapObject::getBridgeInfoByVni(uint32_t vni, string tunnelN
vector<sai_attribute_t> bpt_attrs;
auto* vxlan_orch = gDirectory.get<VxlanTunnelOrch*>();
auto *tunnel = vxlan_orch->getVxlanTunnel(tunnelName);

if (!tunnel->isActive())
{
tunnel->createTunnel(MAP_T::BRIDGE_TO_VNI, MAP_T::VNI_TO_BRIDGE);
tunnel->createTunnel(MAP_T::BRIDGE_TO_VNI, MAP_T::VNI_TO_BRIDGE, VXLAN_ENCAP_TTL);
}

attr.id = SAI_BRIDGE_PORT_ATTR_TYPE;
Expand Down Expand Up @@ -1448,7 +1449,7 @@ bool VNetOrch::addOperation(const Request& request)

VNetVrfObject *vrf_obj = dynamic_cast<VNetVrfObject*>(obj.get());
if (!vxlan_orch->createVxlanTunnelMap(tunnel, TUNNEL_MAP_T_VIRTUAL_ROUTER, vni,
vrf_obj->getEncapMapId(), vrf_obj->getDecapMapId()))
vrf_obj->getEncapMapId(), vrf_obj->getDecapMapId(), VXLAN_ENCAP_TTL))
{
SWSS_LOG_ERROR("VNET '%s', tunnel '%s', map create failed",
vnet_name.c_str(), tunnel.c_str());
Expand Down
1 change: 1 addition & 0 deletions orchagent/vnetorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define VNET_BITMAP_SIZE 32
#define VNET_TUNNEL_SIZE 512
#define VNET_NEIGHBOR_MAX 0xffff
#define VXLAN_ENCAP_TTL 128

extern sai_object_id_t gVirtualRouterId;

Expand Down
24 changes: 18 additions & 6 deletions orchagent/vxlanorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ create_tunnel(
sai_object_id_t tunnel_encap_id,
sai_object_id_t tunnel_decap_id,
sai_ip_address_t *src_ip,
sai_object_id_t underlay_rif)
sai_object_id_t underlay_rif,
sai_uint8_t encap_ttl=0)
{
sai_attribute_t attr;
std::vector<sai_attribute_t> tunnel_attrs;
Expand Down Expand Up @@ -264,6 +265,17 @@ create_tunnel(
tunnel_attrs.push_back(attr);
}

if (encap_ttl != 0)
{
attr.id = SAI_TUNNEL_ATTR_ENCAP_TTL_MODE;
attr.value.s32 = SAI_TUNNEL_TTL_MODE_PIPE_MODEL;
tunnel_attrs.push_back(attr);

attr.id = SAI_TUNNEL_ATTR_ENCAP_TTL_VAL;
attr.value.u8 = encap_ttl;
tunnel_attrs.push_back(attr);
}

sai_object_id_t tunnel_id;
sai_status_t status = sai_tunnel_api->create_tunnel(
&tunnel_id,
Expand Down Expand Up @@ -358,7 +370,7 @@ remove_tunnel_termination(sai_object_id_t term_table_id)
}
}

bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap)
bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap, uint8_t encap_ttl)
{
try
{
Expand All @@ -378,7 +390,7 @@ bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap)
ip = &ips;
}

ids_.tunnel_id = create_tunnel(ids_.tunnel_encap_id, ids_.tunnel_decap_id, ip, gUnderlayIfId);
ids_.tunnel_id = create_tunnel(ids_.tunnel_encap_id, ids_.tunnel_decap_id, ip, gUnderlayIfId, encap_ttl);

ip = nullptr;
if (!dst_ip_.isZero())
Expand Down Expand Up @@ -562,7 +574,7 @@ VxlanTunnelOrch::removeNextHopTunnel(string tunnelName, IpAddress& ipAddr, MacAd
}

bool VxlanTunnelOrch::createVxlanTunnelMap(string tunnelName, tunnel_map_type_t map, uint32_t vni,
sai_object_id_t encap, sai_object_id_t decap)
sai_object_id_t encap, sai_object_id_t decap, uint8_t encap_ttl)
{
SWSS_LOG_ENTER();

Expand All @@ -578,11 +590,11 @@ bool VxlanTunnelOrch::createVxlanTunnelMap(string tunnelName, tunnel_map_type_t
{
if (map == TUNNEL_MAP_T_VIRTUAL_ROUTER)
{
tunnel_obj->createTunnel(MAP_T::VRID_TO_VNI, MAP_T::VNI_TO_VRID);
tunnel_obj->createTunnel(MAP_T::VRID_TO_VNI, MAP_T::VNI_TO_VRID, encap_ttl);
}
else if (map == TUNNEL_MAP_T_BRIDGE)
{
tunnel_obj->createTunnel(MAP_T::BRIDGE_TO_VNI, MAP_T::VNI_TO_BRIDGE);
tunnel_obj->createTunnel(MAP_T::BRIDGE_TO_VNI, MAP_T::VNI_TO_BRIDGE, encap_ttl);
}
}

Expand Down
4 changes: 2 additions & 2 deletions orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class VxlanTunnel
return active_;
}

bool createTunnel(MAP_T encap, MAP_T decap);
bool createTunnel(MAP_T encap, MAP_T decap, uint8_t encap_ttl=0);
sai_object_id_t addEncapMapperEntry(sai_object_id_t obj, uint32_t vni);
sai_object_id_t addDecapMapperEntry(sai_object_id_t obj, uint32_t vni);

Expand Down Expand Up @@ -172,7 +172,7 @@ class VxlanTunnelOrch : public Orch2
}

bool createVxlanTunnelMap(string tunnelName, tunnel_map_type_t mapType, uint32_t vni,
sai_object_id_t encap, sai_object_id_t decap);
sai_object_id_t encap, sai_object_id_t decap, uint8_t encap_ttl=0);

bool removeVxlanTunnelMap(string tunnelName, uint32_t vni);

Expand Down

0 comments on commit 63afbd5

Please sign in to comment.