Skip to content

Commit

Permalink
WIP: make compatible communication 5.0 and 6.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangle committed Nov 26, 2014
1 parent 9b9f245 commit 0ad7fc6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
5 changes: 5 additions & 0 deletions pkg/src/ASP/build/base-images/scripts/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@ def config_tipc_module():
fail_and_exit(msg1 + msg2)

def unload_tipc_module():
link_name = get_asp_link_name()
cmd = 'tipc-config -bd=eth:%s' %link_name
log.debug('disable bearer :%s ...' %cmd)
ret, output, signal, core = system(cmd)

cmd = sys_asp['unload_tipc_cmd']
ret, output, signal, core = system(cmd)
if ret:
Expand Down
18 changes: 12 additions & 6 deletions pkg/src/ASP/components/ioc/client/clTipcNotification.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,26 @@ static ClRcT clTipcReceivedPacket(ClUint32T socketType, struct msghdr *pMsgHdr)

clIocCompStatusSet(srcAddr, TIPC_PUBLISHED);

//Check version forward
ClBoolT isForward = (ntohl(userHeader.reserved) & 0x2);
ClUint32T sizeHdr = (ClUint32T)sizeof(userHeader);
if (isForward)
sizeHdr = (ClUint32T)sizeof(ClIocHeaderT);

if(userHeader.protocolType == CL_IOC_PROTO_CTL) {
clIocNodeCompsSet(srcAddr.nodeAddress, pMsgHdr->msg_iov->iov_base + sizeof(userHeader));
clIocNodeCompsSet(srcAddr.nodeAddress, pMsgHdr->msg_iov->iov_base + sizeHdr);
break;
}

memcpy((ClPtrT)&notification, pMsgHdr->msg_iov->iov_base + sizeof(userHeader), sizeof(notification));
memcpy((ClPtrT)&notification, pMsgHdr->msg_iov->iov_base + sizeHdr, sizeof(notification));
if(ntohl(notification.protoVersion) != CL_IOC_NOTIFICATION_VERSION)
{
CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Got version [%d] notification packet. Supported [%d] version\n",
ntohl(notification.protoVersion),
CL_IOC_NOTIFICATION_VERSION));
return CL_IOC_RC(CL_ERR_VERSION_MISMATCH);
}

/*
* Get the version of the peer node and update the shared memory.
*/
Expand Down Expand Up @@ -477,8 +483,8 @@ static ClRcT clTipcReceivedPacket(ClUint32T socketType, struct msghdr *pMsgHdr)
if(version >= CL_VERSION_CODE(5, 0, 0))
{

nodeInfo = (ClUint8T*)pMsgHdr->msg_iov->iov_base + sizeof(userHeader) + sizeof(notification);
nodeInfoLen = pMsgHdr->msg_iov->iov_len - sizeof(userHeader) - sizeof(notification);
nodeInfo = (ClUint8T*)pMsgHdr->msg_iov->iov_base + sizeHdr + sizeof(notification);
nodeInfoLen = pMsgHdr->msg_iov->iov_len - sizeHdr - sizeof(notification);
if(nodeInfoLen < sizeof(nodeName.length))
{
clLogError("NOTIF", "GET", "Invalid notification data received with available "
Expand Down Expand Up @@ -530,7 +536,7 @@ static ClRcT clTipcReceivedPacket(ClUint32T socketType, struct msghdr *pMsgHdr)
event = TIPC_WITHDRAWN;
clTipcMasterSegmentUpdate(compAddr);
}

clIocCompStatusSet(compAddr, event);

clLogInfo ("TIPC", "NOTIF", "Got [%s] notification for node [0x%x] commport [0x%x]",
Expand Down
30 changes: 24 additions & 6 deletions pkg/src/ASP/components/ioc/client/clTipcUserApi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ ClRcT clIocSend(ClIocCommPortHandleT commPortHandle,

#ifdef CL_TIPC_COMPRESSION
if(compressedStreamLen)
userHeader.reserved = htonl(1); /*mark compression flag*/
userHeader.reserved = htonl(0x1); /*mark compression flag*/
userHeader.pktTime = clHtonl64(pktTime);
#endif

Expand Down Expand Up @@ -1769,7 +1769,7 @@ ClRcT clIocSendSlow(ClIocCommPortHandleT commPortHandle,

#ifdef CL_TIPC_COMPRESSION
if(compressedStreamLen)
userHeader.reserved = htonl(1); /*mark compression flag*/
userHeader.reserved = htonl(0x1); /*mark compression flag*/
userHeader.pktTime = clHtonl64(pktTime);
#endif

Expand Down Expand Up @@ -2272,6 +2272,9 @@ static ClRcT __clIocReceive(ClIocCommPortHandleT commPortHdl,
userHeader.srcAddress.iocPhyAddress.nodeAddress = ntohl(userHeader.srcAddress.iocPhyAddress.nodeAddress);
userHeader.srcAddress.iocPhyAddress.portId = ntohl(userHeader.srcAddress.iocPhyAddress.portId);

//Check version forward
ClBoolT isForward = (ntohl(userHeader.reserved) & 0x2);

if(clEoWithOutCpm
||
userHeader.srcAddress.iocPhyAddress.nodeAddress != gIocLocalBladeAddress)
Expand All @@ -2283,6 +2286,10 @@ static ClRcT __clIocReceive(ClIocCommPortHandleT commPortHdl,

packetSize = bytes - ((userHeader.flag == 0)? sizeof(ClTipcHeaderT): sizeof(ClTipcFragHeaderT));

//Upper version
if (isForward)
packetSize = bytes - ((userHeader.flag == 0)? sizeof(ClIocHeaderT): sizeof(ClIocFragHeaderT));

CL_DEBUG_PRINT(CL_DEBUG_CRITICAL, ("Dropping a received packet."
"Failed to SET the staus of the packet-sender-component "
"[node 0x%x : port 0x%x]. Packet size is %d. error code 0x%x ",
Expand All @@ -2297,13 +2304,22 @@ static ClRcT __clIocReceive(ClIocCommPortHandleT commPortHdl,
{
#ifdef CL_TIPC_COMPRESSION
ClTimeT pktRecvTime = 0;
ClUint32T compressionFlag = ntohl(userHeader.reserved);
ClUint32T compressionFlag = (ntohl(userHeader.reserved) & 0x1);
ClUint8T *decompressedStream = NULL;
ClUint32T decompressedStreamLen = 0;
ClUint32T sentBytes = 0;
#endif
pBuffer = buffer + sizeof(ClTipcHeaderT);
bytes -= sizeof(ClTipcHeaderT);
//Upper version
if (isForward)
{
pBuffer = buffer + sizeof(ClIocHeaderT);
bytes -= sizeof(ClIocHeaderT);
}
else
{
pBuffer = buffer + sizeof(ClTipcHeaderT);
bytes -= sizeof(ClTipcHeaderT);
}

#ifdef CL_TIPC_COMPRESSION
sentBytes = bytes;
Expand Down Expand Up @@ -2357,8 +2373,10 @@ static ClRcT __clIocReceive(ClIocCommPortHandleT commPortHdl,
}
else
{

//TODO: isForward
ClTipcFragHeaderT userFragHeader;

memcpy((ClPtrT)&userFragHeader,(ClPtrT)buffer, sizeof(ClTipcFragHeaderT));

pBuffer = buffer + sizeof(ClTipcFragHeaderT);
Expand Down
24 changes: 23 additions & 1 deletion pkg/src/ASP/components/ioc/client/clTipcUserApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,30 @@ typedef struct
ClUint32T fragLength;
ClUint32T reserved;
} ClTipcFragHeaderT;


typedef struct
{
ClUint8T version;
ClUint8T protocolType;
ClUint8T priority;
ClUint8T flag;
ClUint32T reserved;
ClIocAddressT srcAddress;
ClIocAddressT dstAddress;
#ifdef CL_IOC_COMPRESSION
ClTimeT pktTime;
#endif
} ClIocHeaderT;


typedef struct
{
ClIocHeaderT header;
ClUint32T msgId;
ClUint32T fragOffset;
ClUint32T fragLength;
ClUint32T reserved;
} ClIocFragHeaderT;

typedef struct
{
Expand Down

0 comments on commit 0ad7fc6

Please sign in to comment.