Ejemplo n.º 1
0
Archivo: switch.c Proyecto: iqm/apps
static void
make_path( routing_switch *routing_switch, uint64_t in_datapath_id, uint16_t in_port,
           uint64_t out_datapath_id, uint16_t out_port, const buffer *packet ) {
  dlist_element *hops = resolve_path( routing_switch->path_resolver, in_datapath_id, in_port, out_datapath_id, out_port );

  if ( hops == NULL ) {
    warn( "No available path found ( %#" PRIx64 ":%u -> %#" PRIx64 ":%u ).",
          in_datapath_id, in_port, out_datapath_id, out_port );
    discard_packet_in( in_datapath_id, in_port, packet );
    return;
  }

  // ask path manager to install flow entries
  size_t length = offsetof( path_manager_path, hops ) + sizeof( path_manager_hop ) * count_hops( hops );
  path_manager_path *path = xmalloc( length );
  set_match_from_packet( &path->match, OFPP_NONE, 0, packet );
  path->n_hops = count_hops( hops );
  dlist_element *e = get_first_element( hops );
  for( int i = 0; e != NULL; e = e->next, i++ ) {
    path_resolver_hop *hop = e->data;
    path->hops[ i ].datapath_id = hop->dpid;
    path->hops[ i ].in_port = hop->in_port_no;
    path->hops[ i ].out_port = hop->out_port_no;
  }
  send_message( PATH_SETUP_SERVICE_NAME, MESSENGER_PATH_SETUP_REQUEST, ( void * ) path, length );
  xfree( path );

  // send packet out to tail switch
  output_packet_from_last_switch( hops, packet );

  // free hop list
  free_hop_list( hops );
}
static void
make_path( routing_switch *routing_switch, uint64_t in_datapath_id, uint16_t in_port,
           uint64_t out_datapath_id, uint16_t out_port, const buffer *packet ) {
  dlist_element *hops = resolve_path( routing_switch->pathresolver, in_datapath_id, in_port, out_datapath_id, out_port );

  if ( hops == NULL ) {
    warn( "No available path found ( %#" PRIx64 ":%u -> %#" PRIx64 ":%u ).",
          in_datapath_id, in_port, out_datapath_id, out_port );
    discard_packet_in( in_datapath_id, in_port, packet );
    return;
  }

  // count elements
  uint32_t hop_count = count_hops( hops );

  // send flow entry from tail switch
  for ( dlist_element *e = get_last_element( hops ); e != NULL; e = e->prev, hop_count-- ) {
    uint16_t idle_timer = ( uint16_t ) ( routing_switch->idle_timeout + hop_count );
    modify_flow_entry( e->data, packet, idle_timer );
  } // for(;;)

  // send packet out for tail switch
  dlist_element *e = get_last_element( hops );
  pathresolver_hop *last_hop = e->data;
  output_packet_from_last_switch( last_hop, packet );

  // free them
  free_hop_list( hops );
}
Ejemplo n.º 3
0
static void xping (flux_t *h, uint32_t nodeid, uint32_t xnodeid, const char *svc)
{
    flux_future_t *f;
    const char *route;

    if (!(f = flux_rpc_pack (h, "req.xping", nodeid, 0,
                             "{s:i s:s}", "rank", xnodeid, "service", svc))
            || flux_rpc_get_unpack (f, "{s:s}", "route", &route) < 0)
        log_err_exit ("req.xping");
    printf ("hops=%d\n", count_hops (route));
    flux_future_destroy (f);
}
Ejemplo n.º 4
0
static void
resolve_path_replied( void *user_data, dlist_element *hops ) {
  assert( user_data != NULL );

  resolve_path_replied_params *param = user_data;
  routing_switch *routing_switch = param->routing_switch;
  buffer *original_packet = param->original_packet;

  if ( hops == NULL ) {
    warn( "No available path found." );
    free_buffer( original_packet );
    xfree( param );
    return;
  }

  original_packet->user_data = NULL;
  if ( !parse_packet( original_packet ) ) {
    warn( "Received unsupported packet" );
    free_packet( original_packet );
    free_hop_list( hops );
    xfree( param );
    return;
  }

  // count elements
  uint32_t hop_count = count_hops( hops );

  // send flow entry from tail switch
  for ( dlist_element *e  = get_last_element( hops ); e != NULL; e = e->prev, hop_count-- ) {
    uint16_t idle_timer = ( uint16_t ) ( routing_switch->idle_timeout + hop_count );
    modify_flow_entry( e->data, original_packet, idle_timer );
  } // for(;;)

  // send packet out for tail switch
  dlist_element *e = get_last_element( hops );
  pathresolver_hop *last_hop = e->data;
  output_packet_from_last_switch( last_hop, original_packet );

  // free them
  free_hop_list( hops );
  free_packet( original_packet );
  xfree( param );
}
Ejemplo n.º 5
0
static void xping (flux_t *h, uint32_t nodeid, uint32_t xnodeid, const char *svc)
{
    flux_future_t *f;
    const char *json_str;
    json_object *in = Jnew ();
    json_object *out = NULL;
    const char *route;

    Jadd_int (in, "rank", xnodeid);
    Jadd_str (in, "service", svc);
    if (!(f = flux_rpc (h, "req.xping", Jtostr (in), nodeid, 0))
            || flux_rpc_get (f, &json_str) < 0)
        log_err_exit ("req.xping");
    if (!json_str
        || !(out = Jfromstr (json_str))
        || !Jget_str (out, "route", &route))
        log_errn_exit (EPROTO, "req.xping");
    printf ("hops=%d\n", count_hops (route));
    Jput (out);
    Jput (in);
    flux_future_destroy (f);
}