Ejemplo n.º 1
0
/* Allocate datapath manager. */
struct dpmgr *
dpmgr_alloc(void) {
  struct dpmgr *dpmgr;

  dpmgr = (struct dpmgr *)calloc(1, sizeof(struct dpmgr));
  if (dpmgr == NULL) {
    return NULL;
  }

  dpmgr->ports = ports_alloc();
  if (dpmgr->ports == NULL) {
    return NULL;
  }

  TAILQ_INIT(&dpmgr->bridge_list);

#if defined(HAVE_DPDK)
  rte_rwlock_init(&dpmgr_lock);
#endif /* HAVE_DPDK */

  init_flow_timer();

  dpmgr_singleton = dpmgr;

  return dpmgr;
}
Ejemplo n.º 2
0
void
test_ports_alloc(void) {
    struct vector *ports;

    ports = ports_alloc();
    TEST_ASSERT_NOT_NULL_MESSAGE(ports, "ports_alloc error");
    ports_free(ports);
}
Ejemplo n.º 3
0
void
setUp(void) {
  TEST_ASSERT_NULL(dpmgr);
  TEST_ASSERT_NULL(bridge);
  TEST_ASSERT_NULL(flowdb);
  TEST_ASSERT_NULL(ports);
  TEST_ASSERT_NULL(group_table);

  TEST_ASSERT_NOT_NULL(dpmgr = dpmgr_alloc());
  TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == dpmgr_bridge_add(dpmgr, bridge_name,
                   dpid));
  TEST_ASSERT_NOT_NULL(bridge = dpmgr_bridge_lookup(dpmgr, bridge_name));
  TEST_ASSERT_NOT_NULL(flowdb = bridge->flowdb);
  TEST_ASSERT_NOT_NULL(ports = ports_alloc());
  TEST_ASSERT_NOT_NULL(group_table = group_table_alloc(bridge));
}
Ejemplo n.º 4
0
void
test_port_add(void) {
    struct vector *ports;
    struct port port;
    lagopus_result_t rv;

    ports = ports_alloc();
    TEST_ASSERT_NOT_NULL_MESSAGE(ports, "ports_alloc error");

    strncpy(port.ofp_port.name, "port1", sizeof(port.ofp_port.name));
    port.ofp_port.port_no = 1;
    port.ifindex = 120;
    port.type = LAGOPUS_PORT_TYPE_NULL;
    rv = port_add(ports, &port);

    TEST_ASSERT_EQUAL_MESSAGE(rv, LAGOPUS_RESULT_OK, "port_add error");
}