From: Lei Xia Date: Tue, 10 Nov 2009 20:24:32 +0000 (-0600) Subject: Merge branch 'devel' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=00873eb2dcc088d5b7470e25ab24b43560335a05;hp=be31ae90ff05da4b33a8389b6814f094a7385cd9 Merge branch 'devel' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios/palacios into devel --- diff --git a/palacios/include/devices/vnet.h b/palacios/include/devices/vnet.h index f76dbd1..2c043c3 100644 --- a/palacios/include/devices/vnet.h +++ b/palacios/include/devices/vnet.h @@ -56,24 +56,6 @@ struct ethAddr{ #define HANDLER_SUCCESS 0 */ -#define ANY "any" -#define NOT "not" -#define NONE "none" -#define EMPTY "empty" - -#define ANY_TYPE 0 -#define NOT_TYPE 1 -#define NONE_TYPE 2 -#define EMPTY_TYPE 3 - -#define INTERFACE "INTERFACE" -#define EDGE "EDGE" -#define ANY_SRC "ANY" - -#define INTERFACE_TYPE 0 -#define EDGE_TYPE 1 -#define ANY_SRC_TYPE 2 - //the routing entry struct routing { char src_mac[6]; diff --git a/palacios/src/devices/vnet.c b/palacios/src/devices/vnet.c index d8c64f3..823b83a 100644 --- a/palacios/src/devices/vnet.c +++ b/palacios/src/devices/vnet.c @@ -25,13 +25,31 @@ #include +#define ANY "any" +#define NOT "not" +#define NONE "none" +#define EMPTY "empty" + +#define ANY_TYPE 0 +#define NOT_TYPE 1 +#define NONE_TYPE 2 +#define EMPTY_TYPE 3 + +#define INTERFACE "INTERFACE" +#define EDGE "EDGE" +#define ANY_SRC "ANY" + +#define INTERFACE_TYPE 0 +#define EDGE_TYPE 1 +#define ANY_SRC_TYPE 2 + struct raw_ethernet_pkt { int size; int type; // vm or link type: INTERFACE|EDGE char data[ETHERNET_PACKET_LEN]; }; -char *vnet_version = "0.9"; +//static char *vnet_version = "0.9"; static int vnet_server = 0; static bool use_tcp = false; @@ -42,22 +60,22 @@ static uint_t vnet_udp_port = 22; #define MAX_DEVICES 16 -struct topology g_links[MAX_LINKS]; -int g_num_links; //The current number of links -int g_first_link; -int g_last_link; +static struct topology g_links[MAX_LINKS]; +static int g_num_links; //The current number of links +static int g_first_link; +static int g_last_link; -struct routing g_routes[MAX_ROUTES]; -int g_num_routes; //The current number of routes -int g_first_route; -int g_last_route; +static struct routing g_routes[MAX_ROUTES]; +static int g_num_routes; //The current number of routes +static int g_first_route; +static int g_last_route; -struct device_list g_devices[MAX_DEVICES]; -int g_num_devices; -int g_first_device; -int g_last_device; +static struct device_list g_devices[MAX_DEVICES]; +static int g_num_devices; +static int g_first_device; +static int g_last_device; -SOCK g_udp_sockfd; +static SOCK g_udp_sockfd; static struct gen_queue * g_inpkt_q;//packet receiving queue @@ -181,7 +199,7 @@ struct route_cache_entry // This is the hash value, Format: 0: num_matched_rout int *matches; }; -struct hashtable *g_route_cache; //Header of the route cache +static struct hashtable *g_route_cache; //Header of the route cache static uint_t hash_from_key_fn(addr_t hashkey) { @@ -256,7 +274,7 @@ static int add_route_to_cache(route_hashkey_t hashkey, int num_matched_r, int *m new_entry->num_matched_routes = num_matched_r; int i; - new_entry->matches = (int *)V3_Malloc(num_matched_r*sizeof(int)); // TODO: Here need to consider where to release the memory when clear cache; + new_entry->matches = (int *)V3_Malloc(num_matched_r*sizeof(int)); if (new_entry->matches == NULL){ PrintError("Vnet: Malloc fails\n"); @@ -355,7 +373,7 @@ static inline void mac_to_string(char address[6], char * buf) { buf[17] = 0; } -/* +#if 0 static void ip_to_string(ulong_t addr, char * buf) { uint32_t addr_st; char * tmp_str; @@ -365,7 +383,7 @@ static void ip_to_string(ulong_t addr, char * buf) { memcpy(buf, tmp_str, strlen(tmp_str)); } -*/ +#endif int find_link_by_fd(SOCK sock) { int i; @@ -411,7 +429,6 @@ int vnet_add_link_entry(unsigned long dest, int type, int data_port, SOCK fd) { } -// TODO: What is this used for? int add_sock(struct sock_list *socks, int len, int *first_sock, int *last_sock, SOCK fd) { int i; @@ -698,10 +715,10 @@ static void store_topologies(SOCK fd) int dest_mac_qual = ANY_TYPE; uint_t dest; #ifndef VNET_SERVER - dest = (0 | 172 << 24 | 23 << 16 | 1 ); //this is in_addr.s_addr - PrintDebug("VNET: store_topologies. NO VNET_SERVER, dest = %x\n", dest); -#elif - dest = (0 | 172 << 24 | 23 << 16 | 2 ); //this is in_addr.s_addr + dest = (0 | 172 << 24 | 23 << 16 | 1 ); + PrintDebug("VNET: store_topologies. NOT VNET_SERVER, dest = %x\n", dest); +#else + dest = (0 | 172 << 24 | 23 << 16 | 2 ); PrintDebug("VNET: store_topologies. VNET_SERVER, dest = %x\n", dest); #endif @@ -1204,9 +1221,9 @@ static int process_udpdata() continue; } - PrintDebug("Vnet: route_thread: socket: %d. ready to receive from ip %x, port [%d] or from VMs\n", link_sock, (uint_t)dest, remote_port); + PrintDebug("Vnet: route_thread: socket: [%d]. ready to receive from ip [%x], port [%d] or from VMs\n", link_sock, (uint_t)dest, remote_port); pt->size = V3_RecvFrom_IP( link_sock, dest, remote_port, pt->data, length); - PrintDebug("Vnet: route_thread: socket: %d receive from ip %x, port [%d]\n", link_sock, (uint_t)dest, remote_port); + PrintDebug("Vnet: route_thread: socket: [%d] receive from ip [%x], port [%d]\n", link_sock, (uint_t)dest, remote_port); if (pt->size <= 0){ PrintDebug("Vnet: process_udp: receiving packet from UDP fails\n");