Diff for /embedaddon/quagga/zebra/zebra_fpm_netlink.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2013/07/21 23:54:41 version 1.1.1.2, 2016/11/02 10:09:10
Line 136  typedef struct netlink_route_info_t_ Line 136  typedef struct netlink_route_info_t_
   int num_nhs;    int num_nhs;
   
   /*    /*
   * Nexthop structures. We keep things simple for now by enforcing a   * Nexthop structures
   * maximum of 64 in case MULTIPATH_NUM is 0; 
    */     */
  netlink_nh_info_t nhs[MAX (MULTIPATH_NUM, 64)];  netlink_nh_info_t nhs[MULTIPATH_NUM];
   union g_addr *pref_src;    union g_addr *pref_src;
 } netlink_route_info_t;  } netlink_route_info_t;
   
Line 152  typedef struct netlink_route_info_t_ Line 151  typedef struct netlink_route_info_t_
  * Returns TRUE if a nexthop was added, FALSE otherwise.   * Returns TRUE if a nexthop was added, FALSE otherwise.
  */   */
 static int  static int
netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop)netlink_route_info_add_nh (netlink_route_info_t *ri, struct nexthop *nexthop,
                            int recursive)
 {  {
   netlink_nh_info_t nhi;    netlink_nh_info_t nhi;
   union g_addr *src;    union g_addr *src;
Line 163  netlink_route_info_add_nh (netlink_route_info_t *ri, s Line 163  netlink_route_info_add_nh (netlink_route_info_t *ri, s
   if (ri->num_nhs >= (int) ZEBRA_NUM_OF (ri->nhs))    if (ri->num_nhs >= (int) ZEBRA_NUM_OF (ri->nhs))
     return 0;      return 0;
   
  if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))  nhi.recursive = recursive;
    { 
      nhi.recursive = 1; 
      nhi.type = nexthop->rtype; 
      nhi.if_index = nexthop->rifindex; 
 
      if (nexthop->rtype == NEXTHOP_TYPE_IPV4 
          || nexthop->rtype == NEXTHOP_TYPE_IPV4_IFINDEX) 
        { 
          nhi.gateway = &nexthop->rgate; 
          if (nexthop->src.ipv4.s_addr) 
            src = &nexthop->src; 
        } 
 
#ifdef HAVE_IPV6 
      if (nexthop->rtype == NEXTHOP_TYPE_IPV6 
          || nexthop->rtype == NEXTHOP_TYPE_IPV6_IFINDEX 
          || nexthop->rtype == NEXTHOP_TYPE_IPV6_IFNAME) 
        { 
          nhi.gateway = &nexthop->rgate; 
        } 
#endif /* HAVE_IPV6 */ 
 
      if (nexthop->rtype == NEXTHOP_TYPE_IFINDEX 
          || nexthop->rtype == NEXTHOP_TYPE_IFNAME) 
        { 
          if (nexthop->src.ipv4.s_addr) 
            src = &nexthop->src; 
        } 
 
      goto done; 
    } 
 
  nhi.recursive = 0; 
   nhi.type = nexthop->type;    nhi.type = nexthop->type;
   nhi.if_index = nexthop->ifindex;    nhi.if_index = nexthop->ifindex;
   
Line 224  netlink_route_info_add_nh (netlink_route_info_t *ri, s Line 191  netlink_route_info_add_nh (netlink_route_info_t *ri, s
         src = &nexthop->src;          src = &nexthop->src;
     }      }
   
   /*  
    * Fall through...  
    */  
   
  done:  
   if (!nhi.gateway && nhi.if_index == 0)    if (!nhi.gateway && nhi.if_index == 0)
     return 0;      return 0;
   
Line 272  static int Line 234  static int
 netlink_route_info_fill (netlink_route_info_t *ri, int cmd,  netlink_route_info_fill (netlink_route_info_t *ri, int cmd,
                          rib_dest_t *dest, struct rib *rib)                           rib_dest_t *dest, struct rib *rib)
 {  {
  struct nexthop *nexthop = NULL;  struct nexthop *nexthop, *tnexthop;
   int recursing;
   int discard;    int discard;
   
   memset (ri, 0, sizeof (*ri));    memset (ri, 0, sizeof (*ri));
Line 281  netlink_route_info_fill (netlink_route_info_t *ri, int Line 244  netlink_route_info_fill (netlink_route_info_t *ri, int
   ri->af = rib_dest_af (dest);    ri->af = rib_dest_af (dest);
   
   ri->nlmsg_type = cmd;    ri->nlmsg_type = cmd;
  ri->rtm_table = rib_dest_vrf (dest)->id;  ri->rtm_table = rib_dest_vrf (dest)->vrf_id;
   ri->rtm_protocol = RTPROT_UNSPEC;    ri->rtm_protocol = RTPROT_UNSPEC;
   
   /*    /*
Line 321  netlink_route_info_fill (netlink_route_info_t *ri, int Line 284  netlink_route_info_fill (netlink_route_info_t *ri, int
       goto skip;        goto skip;
     }      }
   
  /* Multipath case. */  for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
  if (rib->nexthop_active_num == 1 || MULTIPATH_NUM == 1) 
     {      {
      for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)      if (ri->num_nhs >= MULTIPATH_NUM)
        {        break;
   
          if ((cmd == RTM_NEWROUTE      if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
               && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))        continue;
              || (cmd == RTM_DELROUTE
                  && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)))      if ((cmd == RTM_NEWROUTE
            {           && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
              netlink_route_info_add_nh (ri, nexthop);          || (cmd == RTM_DELROUTE
              break;              && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)))
            } 
        } 
    } 
  else 
    { 
      for (nexthop = rib->nexthop; 
           nexthop && (MULTIPATH_NUM == 0 || ri->num_nhs < MULTIPATH_NUM); 
           nexthop = nexthop->next) 
         {          {
          if ((cmd == RTM_NEWROUTE          netlink_route_info_add_nh (ri, nexthop, recursing);
               && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) 
              || (cmd == RTM_DELROUTE 
                  && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))) 
            { 
              netlink_route_info_add_nh (ri, nexthop); 
            } 
         }          }
     }      }
   

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>