netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gateway field missing in netlink message
@ 2022-05-04  6:46 Magesh  M P
  2022-05-04 22:31 ` David Ahern
  0 siblings, 1 reply; 14+ messages in thread
From: Magesh  M P @ 2022-05-04  6:46 UTC (permalink / raw)
  To: netdev

Hi

I am trying to configure dual gateways with ip route command.

Ip route show command shows the dual gateway information.

I got a vpp stack that is running. The communication of route entries between Linux kernel and vpp stack is through netlink messages.

On parsing the netlink message for the route entry with dual gateways, we see that the message carries only single gateway. Is this a known bug ? Please suggest a solution to resolve this.

Regards
Magesh


^ permalink raw reply	[flat|nested] 14+ messages in thread
* gateway field missing in netlink message
@ 2022-05-12  6:33 Magesh  M P
  0 siblings, 0 replies; 14+ messages in thread
From: Magesh  M P @ 2022-05-12  6:33 UTC (permalink / raw)
  To: stephen, David Ahern, netdev

Hi Dave/Steve

There is nothing to do with VPP code here.

There is a netlink related file librtnl/netns.c which calls function rtnl_parse_rtattr() which is not handling RTA_MULTIPATH. This function is called when netlink message is received from the kernel.

netns.c is netlink library file.

Any idea to look for the latest code in netns.c to handle RTA_MULTIPATH ?

I added code but I could see only one gateway RTA_GATEWAY inside RTA_MULTIPATH. 

Regards
Magesh

^ permalink raw reply	[flat|nested] 14+ messages in thread
* gateway field missing in netlink message
@ 2022-05-19  6:11 Magesh  M P
  0 siblings, 0 replies; 14+ messages in thread
From: Magesh  M P @ 2022-05-19  6:11 UTC (permalink / raw)
  To: David Ahern, stephen, netdev

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);			
              }
           }
         }
        

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-05-19  6:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04  6:46 gateway field missing in netlink message Magesh  M P
2022-05-04 22:31 ` David Ahern
2022-05-05  3:43   ` Magesh  M P
2022-05-05  3:49     ` Stephen Hemminger
     [not found]       ` <DM5PR20MB20556090A88575E4F55F1EDAAEC29@DM5PR20MB2055.namprd20.prod.outlook.com>
     [not found]         ` <DM5PR20MB2055F01D55F6F7307B50182EAEC29@DM5PR20MB2055.namprd20.prod.outlook.com>
     [not found]           ` <20220505092851.79d3375a@hermes.local>
     [not found]             ` <DM5PR20MB2055542FB35F8CA770178F9AAEC69@DM5PR20MB2055.namprd20.prod.outlook.com>
2022-05-09  6:59               ` Magesh  M P
2022-05-09 15:32                 ` David Ahern
     [not found]               ` <20220509080511.1893a939@hermes.local>
     [not found]                 ` <DM5PR20MB2055EBCA16DFB527A7E9A32FAEC89@DM5PR20MB2055.namprd20.prod.outlook.com>
2022-05-11  5:35                   ` Magesh  M P
2022-05-11 15:56                     ` Stephen Hemminger
2022-05-11 16:25                       ` David Ahern
2022-05-05  3:50     ` Stephen Hemminger
2022-05-05  4:14       ` Magesh  M P
2022-05-05  4:13     ` David Ahern
2022-05-12  6:33 Magesh  M P
2022-05-19  6:11 Magesh  M P

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).