Wednesday, May 18, 2016

Patch to make mTCP running in VM environment to send packet between VM and physical server across switches

when running mTCP in VM environment like in VMware ESXi, KVM...the source MAC is zero see https://github.com/eunyoung14/mtcp/issues/51, this could result in packet being dropped, following patches avoid adding DPDK PMD driver for mTCP to save the porting effort.




 diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c
 index ad3e01d..83e0893 100644
 --- a/mtcp/src/io_module.c
 +++ b/mtcp/src/io_module.c
 @@ -63,6 +63,22 @@ GetNumQueues()
     return queue_cnt;
  }
  /*----------------------------------------------------------------------------*/
 +
 +static int GetPortIndex(char *dev_name)
 +{
 +    char *p = dev_name;
 +    long val = -1;
 +    while (*p) { // While there are more characters to process...
 +        if (isdigit(*p)) { // Upon finding a digit, ...
 +            val = strtol(p, &p, 10); // Read a number, ...
 +        } else {
 +            p++;
 +        }
 +    }
 +    return (int)val;
 +}
 +
 +
  int
  SetInterfaceInfo(char* dev_name_list)
  {
 @@ -243,9 +259,10 @@ SetInterfaceInfo(char* dev_name_list)
                     CONFIG.eths[eidx].ip_addr = *(uint32_t *)&sin;
                 }
 -                if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0 ) {
 +                if(strstr(iter_if->ifa_name, "dpdk") != NULL) {
 +                    ret = GetPortIndex(iter_if->ifa_name);
                     for (j = 0; j < ETH_ALEN; j ++) {
 -                        CONFIG.eths[eidx].haddr[j] = ifr.ifr_addr.sa_data[j];
 +                        CONFIG.eths[eidx].haddr[j] = ports_eth_addr[ret].addr_bytes[j];
                     }
                 }

No comments:

Post a Comment

Followers