Skip to content

Commit

Permalink
fix relay-reply dhcpv6 packet counter issue (sonic-net#29)
Browse files Browse the repository at this point in the history
fix Advertise packets counted as Unknown
  • Loading branch information
jcaiMR authored and qiluo-msft committed Feb 2, 2023
1 parent 677543f commit a4b15d8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,21 +567,20 @@ void relay_relay_forw(int sock, const uint8_t *msg, int32_t len, const ip6_hdr *
auto dhcp_relay_header = parse_dhcpv6_relay(msg);
current_position += sizeof(struct dhcpv6_relay_msg);

auto position = current_position + sizeof(struct dhcpv6_option);
auto dhcpv6msg = parse_dhcpv6_hdr(position);

while ((current_position - msg) < len) {
auto option = parse_dhcpv6_opt(current_position, &tmp);
current_position = tmp;
if (current_position - msg > len || ntohs(option->option_length) > sizeof(buffer) - (current_buffer_position - buffer)) {
break;
}
switch (ntohs(option->option_code)) {
case OPTION_RELAY_MSG:
memcpy(current_buffer_position, ((uint8_t *)option) + sizeof(struct dhcpv6_option), ntohs(option->option_length));
case OPTION_RELAY_MSG: {
uint8_t *dhcpv6_position = ((uint8_t *)option) + sizeof(struct dhcpv6_option);
type = parse_dhcpv6_hdr(dhcpv6_position)->msg_type;
memcpy(current_buffer_position, dhcpv6_position, ntohs(option->option_length));
current_buffer_position += ntohs(option->option_length);
type = dhcpv6msg->msg_type;
break;
}
default:
break;
}
Expand Down

0 comments on commit a4b15d8

Please sign in to comment.