Permalink
Browse files

Decrease hop limit early to prevent router advertizement schenanigans…

…. -- second try
  • Loading branch information...
1 parent 8dd271a commit 650c7f929fb4277527666472fdfab5d3ace80a58 Caleb James DeLisle committed Dec 12, 2012
Showing with 12 additions and 7 deletions.
  1. +12 −7 net/Ducttape.c
View
19 net/Ducttape.c
@@ -287,6 +287,11 @@ static inline uint8_t incomingForMe(struct Message* message,
return Error_UNDELIVERABLE;
}
+ // prevent router advertizement schenanigans
+ if (context->ip6Header->hopLimit == 255) {
+ context->ip6Header->hopLimit--;
+ }
+
// Now write a message to the TUN device.
// Need to move the ipv6 header forward up to the content because there's a crypto header
// between the ipv6 header and the content which just got eaten.
@@ -571,13 +576,6 @@ static inline int core(struct Message* message, struct Ducttape_pvt* context)
{
context->ip6Header = (struct Headers_IP6Header*) message->bytes;
- if (context->ip6Header->hopLimit == 0) {
- Log_debug(context->logger, "dropped message because hop limit has been exceeded.\n");
- // TODO: send back an error message in response.
- return Error_UNDELIVERABLE;
- }
- context->ip6Header->hopLimit--;
-
if (isForMe(message, context)) {
Message_shift(message, -Headers_IP6Header_SIZE);
@@ -616,6 +614,13 @@ static inline int core(struct Message* message, struct Ducttape_pvt* context)
}
}
+ if (context->ip6Header->hopLimit == 0) {
+ Log_debug(context->logger, "dropped message because hop limit has been exceeded.\n");
+ // TODO: send back an error message in response.
+ return Error_UNDELIVERABLE;
+ }
+ context->ip6Header->hopLimit--;
+
struct Node* nextHop = context->forwardTo;
context->forwardTo = NULL;
if (!nextHop) {

0 comments on commit 650c7f9

Please sign in to comment.