Skip to content

Commit

Permalink
Route label bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdelisle committed Jan 12, 2012
1 parent 88e4311 commit 0bcab50
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions switch/SwitchCore.c
Expand Up @@ -131,8 +131,7 @@ static uint8_t receiveMessage(struct Message* message, struct Interface* iface)
uint32_t bits = NumberCompress_bitsUsedForLabel(label);
const uint32_t sourceIndex = sourceIf - core->interfaces;
const uint32_t destIndex = NumberCompress_getDecompressed(label, bits);
const uint32_t sourceBits =
(sourceIndex == 1) ? 2 : NumberCompress_bitsUsedForNumber(sourceIndex);
const uint32_t sourceBits = NumberCompress_bitsUsedForNumber(sourceIndex);

if (sourceBits > bits) {
// If the destination index is this router, don't drop the packet since there no
Expand Down Expand Up @@ -198,9 +197,12 @@ static uint8_t receiveMessage(struct Message* message, struct Interface* iface)
return Error_NONE;
}

header->label_be =
Endian_hostToBigEndian64(
(label >> bits) | Bits_bitReverse64(NumberCompress_getCompressed(sourceIndex, bits)));
// Sending from the router is a special case, all from-router messages have same label.
uint64_t sourceLabel = (sourceIndex == 1)
? Bits_bitReverse64(NumberCompress_getCompressed(1, 2))
: Bits_bitReverse64(NumberCompress_getCompressed(sourceIndex, bits));

header->label_be = Endian_hostToBigEndian64((label >> bits) | sourceLabel);

const uint16_t err = sendMessage(&core->interfaces[destIndex], message, sourceIf->core->logger);
if (err) {
Expand Down

0 comments on commit 0bcab50

Please sign in to comment.