Skip to content

Commit

Permalink
Merge pull request #80 from ipdk-io/ipv6_ecmp_fix
Browse files Browse the repository at this point in the history
Fix IPv6 ECMP and l2_fwd_rx table population
  • Loading branch information
n-sandeep authored Jan 16, 2024
2 parents 2b1dc36 + 955a5d9 commit 5655335
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
20 changes: 17 additions & 3 deletions switchlink/sai/switchlink_handle_neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,23 @@ static int delete_neighbor(const switchlink_db_neigh_info_t* neigh_info) {
sai_neighbor_entry_t neighbor_entry;
memset(&neighbor_entry, 0, sizeof(neighbor_entry));
neighbor_entry.rif_id = neigh_info->intf_h;
neighbor_entry.ip_address.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
neighbor_entry.ip_address.addr.ip4 =
htonl(neigh_info->ip_addr.ip.v4addr.s_addr);

if (neigh_info->ip_addr.family == AF_INET) {
neighbor_entry.ip_address.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
neighbor_entry.ip_address.addr.ip4 =
htonl(neigh_info->ip_addr.ip.v4addr.s_addr);
krnlmon_log_info("Delete a neighbor entry: 0x%x",
neigh_info->ip_addr.ip.v4addr.s_addr);
} else {
neighbor_entry.ip_address.addr_family = SAI_IP_ADDR_FAMILY_IPV6;
memcpy(neighbor_entry.ip_address.addr.ip6, &(neigh_info->ip_addr.ip.v6addr),
sizeof(sai_ip6_t));
krnlmon_log_info("Delete a neighbor entry: 0x%x:0x%x:0x%x:0x%x",
neigh_info->ip_addr.ip.v6addr.__in6_u.__u6_addr32[0],
neigh_info->ip_addr.ip.v6addr.__in6_u.__u6_addr32[1],
neigh_info->ip_addr.ip.v6addr.__in6_u.__u6_addr32[2],
neigh_info->ip_addr.ip.v6addr.__in6_u.__u6_addr32[3]);
}

status = sai_neigh_api->remove_neighbor_entry(&neighbor_entry);
return ((status == SAI_STATUS_SUCCESS) ? 0 : -1);
Expand Down
6 changes: 5 additions & 1 deletion switchlink/switchlink_neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ void switchlink_process_neigh_msg(const struct nlmsghdr* nlmsg, int msgtype) {
if (nbh->ndm_family == AF_INET) {
ipaddr.ip.v4addr.s_addr = ntohl(nla_get_u32(attr));
ipaddr.prefix_len = 32;
} else {
} else if (nbh->ndm_family == AF_INET6) {
memcpy(&(ipaddr.ip.v6addr), nla_data(attr), nla_len(attr));
ipaddr.prefix_len = 128;
} else {
krnlmon_log_error("Invalid NDM family type, for attribute %d\n",
attr_type);
return;
}
} else {
krnlmon_log_debug(
Expand Down
2 changes: 2 additions & 0 deletions switchlink/switchlink_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ static switchlink_handle_t process_ecmp(uint8_t family, struct nlattr* attr,
gateway.ip.v4addr.s_addr = ntohl(*((uint32_t*)RTA_DATA(rta)));
gateway.prefix_len = 32;
} else {
memcpy(&(gateway.ip.v6addr), (struct in6_addr*)RTA_DATA(rta),
sizeof(struct in6_addr));
gateway.prefix_len = 128;
}

Expand Down

0 comments on commit 5655335

Please sign in to comment.