}
static int palacios_packet_del_recver(const char * mac,
- struct v3_vm_info * vm){
+ struct v3_vm_info * vm){
return 0;
}
-static int init_raw_socket (const char * eth_dev){
+static int init_raw_socket(const char * eth_dev){
int err;
struct sockaddr_ll sock_addr;
struct ifreq if_req;
int dev_idx;
err = sock_create(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL), &(packet_state.raw_sock));
+
if (err < 0) {
printk(KERN_WARNING "Could not create a PF_PACKET Socket, err %d\n", err);
return -1;
}
- if(eth_dev == NULL){
+ if (eth_dev == NULL){
eth_dev = "eth0"; /* default "eth0" */
}
memset(&if_req, 0, sizeof(if_req));
strncpy(if_req.ifr_name, eth_dev, IFNAMSIZ); //sizeof(if_req.ifr_name));
+
err = packet_state.raw_sock->ops->ioctl(packet_state.raw_sock, SIOCGIFINDEX, (long)&if_req);
- if(err < 0){
- printk(KERN_WARNING "Palacios Packet: Unable to get index for device %s, error %d\n", if_req.ifr_name, err);
+
+ if (err < 0){
+ printk(KERN_WARNING "Palacios Packet: Unable to get index for device %s, error %d\n",
+ if_req.ifr_name, err);
dev_idx = 2; /* match ALL 2:"eth0" */
- }
- else{
+ } else {
dev_idx = if_req.ifr_ifindex;
}
sock_addr.sll_protocol = htons(ETH_P_ALL);
sock_addr.sll_ifindex = dev_idx;
- err = packet_state.raw_sock->ops->bind(packet_state.raw_sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr));
+ err = packet_state.raw_sock->ops->bind(packet_state.raw_sock,
+ (struct sockaddr *)&sock_addr,
+ sizeof(sock_addr));
+
if (err < 0){
printk(KERN_WARNING "Error binding raw packet to device %s, %d\n", eth_dev, err);
return -1;
while (!kthread_should_stop()) {
size = recv_pkt(pkt, ETHERNET_PACKET_LEN);
+
if (size < 0) {
printk(KERN_WARNING "Palacios raw packet receive error, Server terminated\n");
break;
vm = (struct v3_vm_info *)v3_htable_search(packet_state.mac_vm_cache, (addr_t)pkt);
- if(vm != NULL){
+
+ if (vm != NULL){
printk("Find destinated VM 0x%p\n", vm);
send_raw_packet_to_palacios(pkt, size, vm);
}
const char * eth_dev = NULL;
- if(packet_state.inited == 0){
+ if (packet_state.inited == 0){
packet_state.inited = 1;
- if(init_raw_socket(eth_dev) == -1){
+ if (init_raw_socket(eth_dev) == -1){
printk("Error to initiate palacios packet interface\n");
return -1;
}
}
- // REGISTER GLOBAL CONTROL to add devices...
+ // REGISTER GLOBAL CONTROL to add interfaces...
return 0;
}
#include <vnet/vnet.h>
-int palacios_vnet_init(void);
-void palacios_vnet_deinit(void);
typedef enum {UDP, TCP, RAW, NONE} vnet_brg_proto_t;
uint32_t vnet_brg_add_link(uint32_t ip, uint16_t port, vnet_brg_proto_t proto);
int vnet_brg_link_stats(uint32_t link_idx, struct nic_statistics * stats);
int vnet_brg_stats(struct vnet_brg_stats * stats);
+
+
int vnet_bridge_init(void);
void vnet_bridge_deinit(void);