-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot ping to link-local ipv6 interface address of the switch. #774
Changes from 4 commits
b7b15e3
fdc096f
1a8f7ae
8582fa2
860c2e1
d593cc0
a584755
876fa05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,83 @@ RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) : | |
m_syncdRoutes[v6_default_ip_prefix] = IpAddresses(); | ||
|
||
SWSS_LOG_NOTICE("Create IPv6 default route with packet action drop"); | ||
|
||
/* All the interfaces have the same MAC address and hence the same | ||
* auto-generated link-local ipv6 address with eui64 interface-id. | ||
* Hence add a single /128 route entry for the link-local interface | ||
* address pointing to the CPU port. | ||
*/ | ||
addLinkLocalRouteToMe(gVirtualRouterId); | ||
|
||
/* TODO: Add the link-local /128 route to cpu in every VRF created from | ||
* vrforch::addOperation. */ | ||
} | ||
|
||
std::string RouteOrch::getLinkLocalEui64Addr(void) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
string ipPrefix; | ||
const uint8_t *gmac = gMacAddress.getMac(); | ||
|
||
uint8_t eui64_interface_id[EUI64_INTF_ID_LEN]; | ||
char ipv6_ll_addr[IP6_ADDR_STR_LEN] = {0}; | ||
|
||
eui64_interface_id[0] = gmac[0] ^ 0x02; | ||
eui64_interface_id[1] = gmac[1]; | ||
eui64_interface_id[2] = gmac[2]; | ||
eui64_interface_id[3] = 0xff; | ||
eui64_interface_id[4] = 0xfe; | ||
eui64_interface_id[5] = gmac[3]; | ||
eui64_interface_id[6] = gmac[4]; | ||
eui64_interface_id[7] = gmac[5]; | ||
|
||
snprintf(ipv6_ll_addr, IP6_ADDR_STR_LEN, "fe80::%02x%02x:%02x%02x:%02x%02x:%02x%02x", | ||
eui64_interface_id[0], eui64_interface_id[1], eui64_interface_id[2], | ||
eui64_interface_id[3], eui64_interface_id[4], eui64_interface_id[5], | ||
eui64_interface_id[6], eui64_interface_id[7]); | ||
|
||
ipPrefix = string(ipv6_ll_addr); | ||
|
||
return ipPrefix; | ||
} | ||
|
||
void RouteOrch::addLinkLocalRouteToMe(sai_object_id_t vrf_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed the comment. |
||
{ | ||
/* Link-local IPv6 address autogenerated by kernel with eui64 interface-id | ||
* derived from the MAC address of the host interface. | ||
*/ | ||
IpPrefix linklocal_prefix = getLinkLocalEui64Addr(); | ||
|
||
sai_route_entry_t unicast_route_entry; | ||
unicast_route_entry.switch_id = gSwitchId; | ||
unicast_route_entry.vr_id = vrf_id; | ||
copy(unicast_route_entry.destination, linklocal_prefix.getIp()); | ||
|
||
sai_attribute_t attr; | ||
vector<sai_attribute_t> attrs; | ||
|
||
attr.id = SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION; | ||
attr.value.s32 = SAI_PACKET_ACTION_FORWARD; | ||
attrs.push_back(attr); | ||
|
||
Port cpu_port; | ||
gPortsOrch->getCpuPort(cpu_port); | ||
|
||
attr.id = SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID; | ||
attr.value.oid = cpu_port.m_port_id; | ||
attrs.push_back(attr); | ||
|
||
sai_status_t status = sai_route_api->create_route_entry(&unicast_route_entry, (uint32_t)attrs.size(), attrs.data()); | ||
if (status != SAI_STATUS_SUCCESS) | ||
{ | ||
SWSS_LOG_ERROR("Failed to create link local ipv6 host route %s to cpu, rv:%d", | ||
linklocal_prefix.getIp().to_string().c_str(), status); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. throw runtime_error here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed the comment. |
||
|
||
gCrmOrch->incCrmResUsedCounter(CrmResourceType::CRM_IPV6_ROUTE); | ||
|
||
SWSS_LOG_NOTICE("Created link local ipv6 host route %s to cpu", linklocal_prefix.to_string().c_str()); | ||
} | ||
|
||
bool RouteOrch::hasNextHopGroup(const IpAddresses& ipAddresses) const | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,11 @@ | |
/* Maximum next hop group number */ | ||
#define NHGRP_MAX_SIZE 128 | ||
|
||
/* Length of the Interface Id value in EUI64 format */ | ||
#define EUI64_INTF_ID_LEN 8 | ||
|
||
#define IP6_ADDR_STR_LEN 40 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed the comment. |
||
|
||
typedef std::map<IpAddress, sai_object_id_t> NextHopGroupMembers; | ||
|
||
struct NextHopGroupEntry | ||
|
@@ -84,6 +89,9 @@ class RouteOrch : public Orch, public Subject | |
bool addRoute(IpPrefix, IpAddresses); | ||
bool removeRoute(IpPrefix); | ||
|
||
std::string getLinkLocalEui64Addr(void); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this function called? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now called in routeorch initializing code. Please check the latest code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jipanyang Could you please review the latest changes? |
||
void addLinkLocalRouteToMe(sai_object_id_t vrf_id); | ||
|
||
void doTask(Consumer& consumer); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to use consistent naming convention for variables.
ip_prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed the comment.