Пример #1
0
Try<Nothing> check()
{
  // As advised in libnl, we use numeric values, instead of defined
  // macros (which creates compile time dependency), to check
  // capabilities.

  // Check NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE.
  if (nl_has_capability(2) == 0) {
    return Error(
        "Capability ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE is not available");
  }

  // Check NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE.
  if (nl_has_capability(3) == 0) {
    return Error(
        "Capability ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE is not available");
  }

  // There is a bug in libnl3-idiag from duplicating a kernel header
  // definition and running certain check logic based on it. The
  // kernel header it copies is from 3.6. Older kernels have a
  // different definition and therefore return error on certain calls.
  // TODO(chzhcn): remove this once the bug in libnl3-idiag is fixed.
  if (SK_MEMINFO_VARS == 7) {
    return Error(
        "libnl3-idiag module has a known bug on kernels older than 3.6");
  }

  return Nothing();
}
Пример #2
0
Try<Nothing> check()
{
  // As advised in libnl, we use numeric values, instead of defined
  // macros (which creates compile time dependency), to check
  // capabilities.

  // Check NL_CAPABILITY_ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE.
  if (nl_has_capability(2) == 0) {
    return Error(
        "Capability ROUTE_LINK_VETH_GET_PEER_OWN_REFERENCE is not available");
  }

  // Check NL_CAPABILITY_ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE.
  if (nl_has_capability(3) == 0) {
    return Error(
        "Capability ROUTE_LINK_CLS_ADD_ACT_OWN_REFERENCE is not available");
  }

  return Nothing();
}