static void
delete_flows_of( uint64_t datapath_id, uint16_t port_no ) {
  struct ofp_match match;

  memset( &match, 0, sizeof( struct ofp_match ) );
  match.wildcards = OFPFW_ALL;
  buffer *flow_mod = create_flow_mod( get_transaction_id(), match, get_cookie(),
                                      OFPFC_DELETE, 0, 0, 0, 0, port_no, 0, NULL );
  send_openflow_message( datapath_id, flow_mod );
  free_buffer( flow_mod );

  memset( &match, 0, sizeof( struct ofp_match ) );
  match.wildcards = OFPFW_ALL;
  match.wildcards &= ( uint32_t ) ~OFPFW_IN_PORT;
  match.in_port = port_no;
  teardown_path_by_match( match );
}
Exemplo n.º 2
0
static void
port_status_updated( void *user_data, const topology_port_status *status ) {
  assert( user_data != NULL );
  assert( status != NULL );

  sliceable_switch *sliceable_switch = user_data;
  if ( sliceable_switch->second_stage_down == false ) {
    return;
  }

  debug( "Port status updated: dpid:%#" PRIx64 ", port:%u(%s), %s, %s",
         status->dpid, status->port_no, status->name,
         ( status->status == TD_PORT_UP ? "up" : "down" ),
         ( status->external == TD_PORT_EXTERNAL ? "external" : "internal or inactive" ) );

  if ( status->port_no > OFPP_MAX && status->port_no != OFPP_LOCAL ) {
    warn( "Ignore this update ( port = %u )", status->port_no );
    return;
  }

  port_info *p = lookup_port( sliceable_switch->switches, status->dpid, status->port_no );

  delete_fdb_entries( sliceable_switch->fdb, status->dpid, status->port_no );

  if ( status->status == TD_PORT_UP ) {
    if ( p != NULL ) {
      update_port( p, status->external );
      return;
    }
    add_port( &sliceable_switch->switches, status->dpid, status->port_no, status->name, status->external );
  }
  else {
    if ( p == NULL ) {
      debug( "Ignore this update (not found nor already deleted)" );
      return;
    }
    delete_port( &sliceable_switch->switches, p );
    struct ofp_match match;
    memset( &match, 0, sizeof( struct ofp_match ) );
    match.wildcards = OFPFW_ALL;
    match.wildcards &= ~OFPFW_IN_PORT;
    match.in_port = status->port_no;
    teardown_path_by_match( match );
  }
}