Beispiel #1
0
bool BcmRoute::deleteLpmRoute(int unitNumber,
                              opennsl_vrf_t vrf,
                              const folly::IPAddress& prefix,
                              uint8_t prefixLength) {
  opennsl_l3_route_t rt;
  initL3RouteFromArgs(&rt, vrf, prefix, prefixLength);
  auto rc = opennsl_l3_route_delete(unitNumber, &rt);
  if (OPENNSL_FAILURE(rc)) {
    LOG(ERROR) << "Failed to delete a route entry for " << prefix << "/"
               << static_cast<int>(prefixLength)
               << " Error: " << opennsl_errmsg(rc);
    return false;
  } else {
    VLOG(3) << "deleted a route entry for " << prefix.str() << "/"
            << static_cast<int>(prefixLength);
  }
  return true;
}
/*
* Routine Description:
*    Remove Route
*
* Arguments:
*    [in] unicast_route_entry - route entry
*
* Return Values:
*    SAI_STATUS_SUCCESS on success
*    Failure status code on error
*/
sai_status_t
brcm_sai_remove_route(_In_ const sai_unicast_route_entry_t* unicast_route_entry)
{
    sai_status_t rv;
    opennsl_l3_route_t l3_rt;
    sai_uint32_t vr_id;

    BRCM_SAI_FUNCTION_ENTER(SAI_API_ROUTE);
    BRCM_SAI_SWITCH_INIT_CHECK;

    if (NULL == unicast_route_entry)
    {
        BRCM_SAI_LOG_ROUTE(SAI_LOG_ERROR, "NULL route passed\n");
        return SAI_STATUS_INVALID_PARAMETER;
    }

    opennsl_l3_route_t_init(&l3_rt);
    vr_id = BRCM_SAI_GET_OBJ_VAL(sai_uint32_t, unicast_route_entry->vr_id);
    l3_rt.l3a_vrf = vr_id;
    if (SAI_IP_ADDR_FAMILY_IPV4 == unicast_route_entry->destination.addr_family)
    {
        l3_rt.l3a_ip_mask = ntohl(unicast_route_entry->destination.mask.ip4);
        l3_rt.l3a_subnet = ntohl(unicast_route_entry->destination.addr.ip4 &
                                 unicast_route_entry->destination.mask.ip4);
    }
    else if (SAI_IP_ADDR_FAMILY_IPV6 ==
             unicast_route_entry->destination.addr_family)
    {
        memcpy(l3_rt.l3a_ip6_net, unicast_route_entry->destination.addr.ip6,
               sizeof(l3_rt.l3a_ip6_net));
        memcpy(l3_rt.l3a_ip6_mask, unicast_route_entry->destination.mask.ip6,
               sizeof(l3_rt.l3a_ip6_mask));
    }
    rv = opennsl_l3_route_delete(0, &l3_rt);
    BRCM_SAI_API_CHK(SAI_API_ROUTE, "L3 route delete", rv);

    BRCM_SAI_FUNCTION_EXIT(SAI_API_ROUTE);

    return rv;
}