Commit 5d07462d authored by kfox's avatar kfox

Linux maxpayload much larger than MacOS

Close link on fragmenter initialization failure
parent b60f17e0
......@@ -87,8 +87,6 @@ typedef struct _ETHLinkData {
AthenaEthernetFragmenter *fragmenter;
} _ETHLinkData;
typedef AthenaEthernetFragmenter *(*ModuleInit)(void);
static int
_stringToEtherAddr(struct ether_addr *address, const char *buffer)
{
......@@ -933,6 +931,12 @@ _ETHOpen(AthenaTransportLinkModule *athenaTransportLinkModule, PARCURI *connecti
if (result && fragmenterName) {
struct _ETHLinkData *linkData = athenaTransportLink_GetPrivateData(result);
linkData->fragmenter = athenaEthernetFragmenter_Create(result, fragmenterName);
if (linkData->fragmenter == NULL) {
parcLog_Error(athenaTransportLinkModule_GetLogger(athenaTransportLinkModule),
"Failed to open/initialize %s fragmenter for %s", fragmenterName, linkName);
athenaTransportLink_Close(result);
return NULL;
}
}
// forced IsLocal/IsNotLocal, mainly for testing
......
......@@ -82,7 +82,8 @@ athenaEthernet_Create(PARCLog *log, const char *interface, uint16_t etherType)
}
// Get index of specified interface
struct ifreq if_idx = { 0 };
struct ifreq if_idx;
bzero(&if_idx, sizeof(struct ifreq));
strncpy(if_idx.ifr_name, interface, strlen(interface) + 1);
if (ioctl(athenaEthernet->fd, SIOCGIFINDEX, &if_idx) == -1) {
parcLog_Error(athenaEthernet->log, "SIOCGIFINDEX: %s", strerror(errno));
......@@ -103,7 +104,8 @@ athenaEthernet_Create(PARCLog *log, const char *interface, uint16_t etherType)
}
// Populate the configured physical MAC
struct ifreq if_mac = { 0 };
struct ifreq if_mac;
bzero(&if_mac, sizeof(struct ifreq));
memset(&if_mac, 0, sizeof(if_mac));
strncpy(if_mac.ifr_name, interface, strlen(interface) + 1);
if (ioctl(athenaEthernet->fd, SIOCGIFHWADDR, &if_mac) == -1) {
......@@ -148,7 +150,8 @@ athenaEthernet_GetInterfaceMAC(const char *device, struct ether_addr *ether_addr
}
// Get index of specified interface
struct ifreq ifr = { 0 };
struct ifreq ifr;
bzero(&ifr, sizeof(struct ifreq));
strcpy(ifr.ifr_name, device);
if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) {
perror("SIOCGIFHWADDR");
......@@ -196,6 +199,12 @@ athenaEthernet_Send(AthenaEthernet *athenaEthernet, struct iovec *iov, int iovcn
writeCount = writev(athenaEthernet->fd, iov, iovcnt);
if (writeCount == -1) {
parcLog_Error(athenaEthernet->log, "writev: %s", strerror(errno));
} else {
parcLog_Debug(athenaEthernet->log, "sending message (size=%d)", writeCount);
}
return writeCount;
}
......
......@@ -353,6 +353,13 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleETH_SendReceiveFragments)
myAddress.ether_addr_octet[4], myAddress.ether_addr_octet[5]);
size_t mtu = 1500; // forced MTU size for fragmentation
sprintf(linkSpecificationURI, "eth://%s/Listener/name=ETHListener/fragmenter=XXXX/mtu=%zu", device, mtu);
connectionURI = parcURI_Parse(linkSpecificationURI);
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
assertTrue(result == NULL, "athenaTransportLinkAdapter_Open failed to detect bad fragmenter");
parcURI_Release(&connectionURI);
sprintf(linkSpecificationURI, "eth://%s/Listener/name=ETHListener/fragmenter=BEFS/mtu=%zu", device, mtu);
connectionURI = parcURI_Parse(linkSpecificationURI);
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
......@@ -367,7 +374,7 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleETH_SendReceiveFragments)
parcURI_Release(&connectionURI);
// Open a link we can send messages on
sprintf(linkSpecificationURI, "eth://%s/name=ETH_1/fragmenter=BEFS", device);
sprintf(linkSpecificationURI, "eth://%s/name=ETH_1/fragmenter=BEFS/mtu=%zu", device, mtu);
connectionURI = parcURI_Parse(linkSpecificationURI);
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
......@@ -391,8 +398,11 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleETH_SendReceiveFragments)
// Try to send a large (>mtu) message
size_t numberOfFragments = 4; // four is the maximum that MacOS will queue without a reader
size_t largePayloadSize = mtu * numberOfFragments;
#ifdef __linux__
size_t largePayloadSize = 0xffdd; // Maximum payload size
#else // MacOS
size_t largePayloadSize = mtu * 4; // four is the maximum that MacOS will queue without a reader
#endif
char largePayload[largePayloadSize];
PARCBuffer *payload = parcBuffer_Wrap((void *)largePayload, largePayloadSize, 0, largePayloadSize);
ccnxInterest_SetPayload(ccnxMetaMessage, payload);
......@@ -406,7 +416,7 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleETH_SendReceiveFragments)
parcBitVector_Release(&resultVector);
ccnxMetaMessage_Release(&ccnxMetaMessage);
size_t iterations = numberOfFragments + 5;
size_t iterations = (largePayloadSize / mtu) + 5;
// Receive the large message
do {
// Allow a context switch for the sends to complete
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment