[<prev] [next>] [day] [month] [year] [list]
Message-ID: <DM5PR20MB20556E23BCBFA74B17B29BC9AED09@DM5PR20MB2055.namprd20.prod.outlook.com>
Date: Thu, 19 May 2022 06:11:20 +0000
From: "Magesh M P" <magesh@...itizethings.com>
To: David Ahern <dsahern@...il.com>,
"stephen@...workplumber.org" <stephen@...workplumber.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: gateway field missing in netlink message
Hi Dave/Steve,
Thanks for your support....
The Linux kernel is sending the route information with dual gateways properly to the netlink listener in the vpp stack.
The following parser logic is used in netlink listener to retrieve the two gateways in RTA_MULTIPATH attribute
if (route_attribute->rta_type == RTA_MULTIPATH)
{
printf("AMG - RTA_MULTIPATH\n");
/* Get RTA_MULTIPATH data */
struct rtnexthop *nhptr = (struct rtnexthop*) RTA_DATA(route_attribute);
int rtnhp_len = RTA_PAYLOAD(route_attribute);
/* Is the message complete? */
if (rtnhp_len < (int) sizeof(*nhptr) ||
nhptr->rtnh_len > rtnhp_len)
{
continue;
}
/* Get the size of the attributes */
unsigned int attrlen = rtnhp_len - sizeof(struct rtnexthop);
if (attrlen)
{
/* Retrieve attributes */
struct rtattr *attr = RTNH_DATA(nhptr);
int len = RTA_PAYLOAD(route_attribute);
struct rtnexthop *nh = RTA_DATA(route_attribute);
for(;;)
{
if (len < sizeof(*nh))
{
printf("BREAK -attr->rta_len[%u]\n", len);
break;
}
if (nh->rtnh_len > len)
{
printf("BREAK2 -attr->rta_len[%u]\n", len);
break;
}
printf("RTA_MULTIPATH - attr=[%p] attr->rta_len=[%u]attr->rta_type=[%u] DATA=[%p]\n", attr, attr->rta_len, attr->rta_type, RTA_DATA(attr));
if (nh->rtnh_len > sizeof(*nh))
{
unsigned short type;
unsigned int len_nh=nh->rtnh_len - sizeof(*nh);
struct rtattr* attr2=RTNH_DATA(nh);
while (RTA_OK(attr2, len_nh))
{
type = attr2->rta_type & ~0;
if ((type <= RTA_MAX))
{
attr = attr2;
}
attr2 = RTA_NEXT(attr2, len_nh);
}
}
if (attr->rta_type == RTA_GATEWAY)
{
/* Next hops from RTA_MULTIPATH are
* contained in RTA_GATEWAY attributes!
*/
inet_ntop(AF_INET, RTA_DATA(attr), gateway_address, sizeof(gateway_address));
printf("GATEWAY: route to destination --> %s/%d proto %d and gateway %s\n", destination_address, route_netmask, route_protocol, gateway_address);
}
len -= NLMSG_ALIGN(nh->rtnh_len);
nh = RTNH_NEXT(nh);
}
}
}
Powered by blists - more mailing lists