Esempio n. 1
0
void
setUp(void) {
  datastore_bridge_info_t info;

  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
  memset(&info, 0, sizeof(info));
  info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  TEST_ASSERT_EQUAL(dp_bridge_create("br0", &info), LAGOPUS_RESULT_OK);
}
Esempio n. 2
0
void
setUp(void) {
  datastore_bridge_info_t info;

  memset(&info, 0, sizeof(info));
  info.dpid = dpid;
  info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  TEST_ASSERT_NULL(bridge);
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
  TEST_ASSERT_EQUAL(dp_bridge_create(bridge_name, &info), LAGOPUS_RESULT_OK);
  bridge = dp_bridge_lookup(bridge_name);
  TEST_ASSERT_NOT_NULL(bridge);
}
Esempio n. 3
0
lagopus_result_t
dataplane_initialize(int argc,
                     const char *const argv[],
                     __UNUSED void *extarg,
                     lagopus_thread_t **thdptr) {
#ifdef HAVE_DPDK
  static struct dataplane_arg dparg;
#endif /* HAVE_DPDK */
  static struct dataplane_arg sockarg;
  static struct dataplane_arg timerarg;
  lagopus_result_t nb_ports;

  nb_ports = lagopus_dataplane_init(argc, argv);
  if (nb_ports < 0) {
    lagopus_msg_fatal("lagopus_dataplane_init failed\n");
    return nb_ports;
  }
  dp_api_init();
#ifdef HAVE_DPDK
  if (rawsocket_only_mode != true) {
    dparg.threadptr = &dpdk_thread;
    dparg.lock = &dpdk_lock;
    lagopus_thread_create(&dpdk_thread, dpdk_thread_loop,
                          dp_finalproc, dp_freeproc, "dataplane", &dparg);

    if (lagopus_mutex_create(&dpdk_lock) != LAGOPUS_RESULT_OK) {
      lagopus_exit_fatal("lagopus_mutex_create");
    }
  }
#endif /* HAVE_DPDK */

  lagopus_meter_init();
  lagopus_register_action_hook = lagopus_set_action_function;
  lagopus_register_instruction_hook = lagopus_set_instruction_function;
  flowinfo_init();

  timerarg.threadptr = &timer_thread;
  timerarg.lock = &timer_lock;
  timerarg.running = NULL;
  timerthread_initialize(&timerarg);

  sockarg.threadptr = &sock_thread;
  sockarg.lock = &sock_lock;
  sockarg.running = NULL;
  sockthread_initialize(&sockarg);

  *thdptr = &sock_thread;

  return LAGOPUS_RESULT_OK;
}
void
setUp(void) {
  size_t s;
  char buf[128];

  dpid_base = 0;
  printf("dpid_base = 0x%llx (%llu)\n", (unsigned long long)dpid_base,
         (unsigned long long)dpid_base);

  for (s = 0; s < ARRAY_LEN(bridge); s++) {
    TEST_ASSERT_NULL(bridge_name[s]);
    TEST_ASSERT_NULL(bridge[s]);
    TEST_ASSERT_NULL(flowdb[s]);
  }
  for (s = 0; s < ARRAY_LEN(port_name); s++) {
    TEST_ASSERT_NULL(port_name[s]);
  }
  for (s = 0; s < ARRAY_LEN(ifname); s++) {
    TEST_ASSERT_NULL(ifname[s]);
  }

  /* Make the bridge names and port configurations. */
  for (s = 0; s < ARRAY_LEN(bridge); s++) {
    snprintf(buf, sizeof(buf), bridge_name_format, (int)s);
    bridge_name[s] = strdup(buf);
    snprintf(buf, sizeof(buf), port_name_format, TEST_PORT_IFINDEX(s));
    port_name[s] = strdup(buf);
    snprintf(buf, sizeof(buf), ifname_format, TEST_PORT_IFINDEX(s));
    ifname[s] = strdup(buf);
  }

  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
  for (s = 0; s < ARRAY_LEN(bridge); s++) {
    datastore_bridge_info_t info;
    memset(&info, 0, sizeof(info));
    info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
    info.dpid = TEST_DPID(s);
    TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == dp_bridge_create(bridge_name[s],
                     &info));
    TEST_ASSERT_NOT_NULL(bridge[s] = dp_bridge_lookup(bridge_name[s]));
    TEST_ASSERT_NOT_NULL(flowdb[s] = bridge[s]->flowdb);
  }
}
Esempio n. 5
0
void
setUp(void) {

  /* Event manager allocation. */
  /* init datapath. */
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);

  /* interface. */
  interface_info.type = DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK;
  interface_info.eth_rawsock.port_number = 0;
  interface_info.eth_dpdk_phy.device = strdup("eth0");
  if (interface_info.eth_dpdk_phy.device == NULL) {
    TEST_FAIL_MESSAGE("device is NULL.");
  }
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_interface_create(interface_name));
  dp_interface_info_set(interface_name, &interface_info);

  /* port. */
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_create(port_name));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_interface_set(port_name, interface_name));

  /* bridge. */
  bridge_info.dpid = dpid;
  bridge_info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  bridge_info.max_buffered_packets = UINT32_MAX;
  bridge_info.max_ports = UINT16_MAX;
  bridge_info.max_tables = UINT8_MAX;
  bridge_info.max_flows = UINT32_MAX;
  bridge_info.capabilities = UINT64_MAX;
  bridge_info.action_types = UINT64_MAX;
  bridge_info.instruction_types = UINT64_MAX;
  bridge_info.reserved_port_types = UINT64_MAX;
  bridge_info.group_types = UINT64_MAX;
  bridge_info.group_capabilities = UINT64_MAX;
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_create(bridge_name, &bridge_info));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_port_set(bridge_name, port_name, 0));
}
void
setUp(void) {
  datastore_bridge_info_t info;
  struct ofp_error err;

  TEST_ASSERT_NULL(bridge);
  TEST_ASSERT_NULL(flowdb);

  memset(&info, 0, sizeof(info));
  info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
  TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == dp_bridge_create(bridge_name, &info));
  TEST_ASSERT_NOT_NULL(bridge = dp_bridge_lookup(bridge_name));
  TEST_ASSERT_NOT_NULL(flowdb = bridge->flowdb);

  TAILQ_INIT(&features_list);
  memset(&err, 0, sizeof(err));
  TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == flowdb_get_table_features(flowdb,
                   &features_list, &err));
}
Esempio n. 7
0
void
setUp(void) {
  datastore_bridge_info_t info;

  TEST_ASSERT_NULL(bridge);
  TEST_ASSERT_NULL(flowdb);
  TEST_ASSERT_NULL(ports);
  TEST_ASSERT_NULL(group_table);

  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
  memset(&info, 0, sizeof(info));
  info.dpid = dpid;
  info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  TEST_ASSERT_TRUE(LAGOPUS_RESULT_OK == dp_bridge_create(bridge_name, &info));
  TEST_ASSERT_NOT_NULL(bridge = dp_bridge_lookup(bridge_name));
  TEST_ASSERT_NOT_NULL(flowdb = bridge->flowdb);
  TEST_ASSERT_EQUAL(lagopus_hashmap_create(&ports,
                                           LAGOPUS_HASHMAP_TYPE_ONE_WORD,
                                           NULL), LAGOPUS_RESULT_OK);
  TEST_ASSERT_NOT_NULL(group_table = group_table_alloc(bridge));
}
Esempio n. 8
0
void
setUp(void) {
    TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);
}
Esempio n. 9
0
void
setUp(void) {
  dp_api_init();
}
Esempio n. 10
0
struct channel *
create_data_channel(void) {
  static uint8_t cnt;
  char buf[256];
  struct channel *channel;
  lagopus_session_t session;
  struct addrunion addr;
  uint64_t dpid = 0xabc;

  if (s_is_init == false) {
    s_is_init = true;

    /* init dataplane. */
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, dp_api_init());

    /* interface. */
    s_interface_info.type = DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK;
    s_interface_info.eth_rawsock.port_number = 0;
    s_interface_info.eth_dpdk_phy.device = strdup("eth0");
    if (s_interface_info.eth_dpdk_phy.device == NULL) {
      TEST_FAIL_MESSAGE("device is NULL.");
    }
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_interface_create(interface_name));
    dp_interface_info_set(interface_name, &s_interface_info);

    /* port. */
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_port_create(port_name));
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_port_interface_set(port_name, interface_name));

    /* bridge. */
    ofp_bridgeq_mgr_initialize(NULL);
    s_bridge_info.dpid = dpid;
    s_bridge_info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
    s_bridge_info.max_buffered_packets = UINT32_MAX;
    s_bridge_info.max_ports = UINT16_MAX;
    s_bridge_info.max_tables = UINT8_MAX;
    s_bridge_info.max_flows = UINT32_MAX;
    s_bridge_info.capabilities = UINT64_MAX;
    s_bridge_info.action_types = UINT64_MAX;
    s_bridge_info.instruction_types = UINT64_MAX;
    s_bridge_info.reserved_port_types = UINT64_MAX;
    s_bridge_info.group_types = UINT64_MAX;
    s_bridge_info.group_capabilities = UINT64_MAX;
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_bridge_create(bridge_name, &s_bridge_info));
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      dp_bridge_port_set(bridge_name, port_name, 0));
    TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                      ofp_bridgeq_mgr_bridge_register(
                          dpid,
                          bridge_name,
                          &s_bridge_info,
                          &s_queue_info));
    channel_mgr_initialize();
  }

  snprintf(buf, sizeof(buf), "127.0.0.%u", cnt++);//XXX
  addrunion_ipv4_set(&addr, buf);
  channel_mgr_channel_add(bridge_name, dpid, &addr);
  channel_mgr_channel_lookup(bridge_name, &addr, &channel);


  session = channel_session_get(channel);
  session_write_set(session, s_write_tcp);
  session_sockfd_set(session, 3);

  channel_version_set(channel, 0x04);
  channel_xid_set(channel, s_xid);

  return channel;
}
Esempio n. 11
0
void
setUp(void) {
  struct sockaddr_storage so = {0,0,{0}};
  struct sockaddr_in *sin = (struct sockaddr_in *)&so;
  struct sockaddr_in6 *sin6;

  if (s4 != -1) {
    return;
  }

  sin->sin_family = AF_INET;
  sin->sin_port = htons(10022);
  sin->sin_addr.s_addr = INADDR_ANY;

  s4 = socket(AF_INET, SOCK_STREAM, 0);
  if (s4 < 0) {
    perror("socket");
    exit(1);
  }

  if (bind(s4, (struct sockaddr *) sin, sizeof(*sin)) < 0) {
    perror("bind");
    exit(1);
  }

  if (listen(s4, 5) < 0) {
    perror("listen");
    exit(1);
  }

  sin6 = (struct sockaddr_in6 *)&so;
  sin6->sin6_family = AF_INET6;
  sin6->sin6_port = htons(10023);
  sin6->sin6_addr = in6addr_any;

  s6 = socket(AF_INET6, SOCK_STREAM, 0);
  if (s6 < 0) {
    perror("socket");
    exit(1);
  }

  if (bind(s6, (struct sockaddr *) sin6, sizeof(*sin6)) < 0) {
    perror("bind");
    exit(1);
  }

  if (listen(s6, 5) < 0) {
    perror("listen");
    exit(1);
  }

  /* init datapath. */
  TEST_ASSERT_EQUAL(dp_api_init(), LAGOPUS_RESULT_OK);

  /* interface. */
  interface_info.type = DATASTORE_INTERFACE_TYPE_ETHERNET_RAWSOCK;
  interface_info.eth_rawsock.port_number = 0;
  interface_info.eth_dpdk_phy.device = strdup("eth0");
  if (interface_info.eth_dpdk_phy.device == NULL) {
    TEST_FAIL_MESSAGE("device is NULL.");
  }
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_interface_create(interface_name));
  dp_interface_info_set(interface_name, &interface_info);

  /* port. */
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_create(port_name));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_port_interface_set(port_name, interface_name));

  /* bridge. */
  bridge_info.dpid = dpid;
  bridge_info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
  bridge_info.max_buffered_packets = UINT32_MAX;
  bridge_info.max_ports = UINT16_MAX;
  bridge_info.max_tables = UINT8_MAX;
  bridge_info.max_flows = UINT32_MAX;
  bridge_info.capabilities = UINT64_MAX;
  bridge_info.action_types = UINT64_MAX;
  bridge_info.instruction_types = UINT64_MAX;
  bridge_info.reserved_port_types = UINT64_MAX;
  bridge_info.group_types = UINT64_MAX;
  bridge_info.group_capabilities = UINT64_MAX;
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_create(bridge_name, &bridge_info));
  TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK,
                    dp_bridge_port_set(bridge_name, port_name, 0));


  printf("setup end\n");
}
Esempio n. 12
0
void
setUp(void) {
  dp_api_init();
  TEST_ASSERT_EQUAL(dp_interface_create("if1"), LAGOPUS_RESULT_OK);
  TEST_ASSERT_EQUAL(dp_port_create("port1"), LAGOPUS_RESULT_OK);
}