route_t* route_find_device( char* dev_name ) { int i; int size; route_t* route; net_device_t* device; mutex_lock( route_mutex, LOCK_IGNORE_SIGNAL ); size = array_get_size(&device_routes); for ( i = 0; i < size; i++ ) { route_t* tmp; tmp = (route_t*)array_get_item( &device_routes, i ); if ( tmp->device == NULL ) { kprintf( ERROR, "route_find_device(): found device route without a valid network device!\n" ); continue; } if ( strcmp( tmp->device->name, dev_name ) == 0 ) { tmp->ref_count++; route = tmp; goto out; } } device = net_device_get(dev_name); if ( device == NULL ) { route = NULL; goto out; } route = route_create( device->ip_addr, device->netmask, NULL, RTF_UP ); if ( route == NULL ) { net_device_put(device); goto out; } /* NOTE: we don't have to put the net_device_t later as we assign the device to the newly created route entry. */ route->device = device; route_insert( &device_routes, route ); out: mutex_unlock( route_mutex ); return route; }
static void non_smb_net_cb(const msg_lvl2_t * msg, void * ctx) { if(msg == NULL) return; net_device_t * net_device = NULL; switch(operation_mode) { case OPERATION_MODE_INIT: break; case OPERATION_MODE_NORMAL: case OPERATION_MODE_CONFIGURATION: net_device = net_device_get(msg->meta.id); if((net_device != NULL) && (net_device->net_callback != NULL)) { net_device->net_callback(net_device->conf_sect, msg); } break; default: break; } }
void stat_mbuf(struct rte_mbuf *mbuf, uint8_t in, uint8_t drop) { struct net_device *ndev; ndev = net_device_get(mbuf->port); if ((ndev->flag & NET_DEV_F_DISABLE) == NET_DEV_F_DISABLE) return; if (in) { if (drop) { ndev->stat.rx.drop[rte_lcore_id()]++; } else { ndev->stat.rx.recv[rte_lcore_id()]++; } } else { if (drop) { ndev->stat.tx.drop[rte_lcore_id()]++; } else { ndev->stat.tx.xmit[rte_lcore_id()]++; } } }