On Fri, Jul 13, 2018 at 11:25:56AM +0200, Sebastian Benoit wrote:
> get rid of two more implicit ktable_get with rdomain 0
> ie. ktable_get(/* XXX */ 0)
> 
> should not change anything when run in rdomain 0.
> 
> ok?

OK claudio@
 
> (benno_more_rdomain_instead_of_0.diff)
> 
> diff --git usr.sbin/bgpd/bgpd.c usr.sbin/bgpd/bgpd.c
> index 03dec715288..8299102340b 100644
> --- usr.sbin/bgpd/bgpd.c
> +++ usr.sbin/bgpd/bgpd.c
> @@ -296,7 +296,7 @@ BROKEN    if (pledge("stdio rpath wpath cpath fattr unix 
> route recvfd sendfd",
>               }
>  
>               if (pfd[PFD_SOCK_ROUTE].revents & POLLIN) {
> -                     if (kr_dispatch_msg() == -1)
> +                     if (kr_dispatch_msg(conf->default_tableid) == -1)
>                               quit = 1;
>               }
>  
> @@ -351,7 +351,7 @@ BROKEN    if (pledge("stdio rpath wpath cpath fattr unix 
> route recvfd sendfd",
>       control_cleanup(conf->csock);
>       control_cleanup(conf->rcsock);
>       carp_demote_shutdown();
> -     kr_shutdown(conf->fib_priority);
> +     kr_shutdown(conf->fib_priority, conf->default_tableid);
>       pftable_clear_all();
>  
>       free_config(conf);
> diff --git usr.sbin/bgpd/bgpd.h usr.sbin/bgpd/bgpd.h
> index 5e6a4eaae26..0c55d2a8645 100644
> --- usr.sbin/bgpd/bgpd.h
> +++ usr.sbin/bgpd/bgpd.h
> @@ -1079,13 +1079,13 @@ void           ktable_postload(u_int8_t);
>  int           ktable_exists(u_int, u_int *);
>  int           kr_change(u_int, struct kroute_full *,  u_int8_t);
>  int           kr_delete(u_int, struct kroute_full *, u_int8_t);
> -void          kr_shutdown(u_int8_t);
> +void          kr_shutdown(u_int8_t, u_int);
>  void          kr_fib_couple(u_int, u_int8_t);
>  void          kr_fib_couple_all(u_int8_t);
>  void          kr_fib_decouple(u_int, u_int8_t);
>  void          kr_fib_decouple_all(u_int8_t);
>  void          kr_fib_update_prio_all(u_int8_t);
> -int           kr_dispatch_msg(void);
> +int           kr_dispatch_msg(u_int rdomain);
>  int           kr_nexthop_add(u_int32_t, struct bgpd_addr *,
>                   struct bgpd_config *);
>  void          kr_nexthop_delete(u_int32_t, struct bgpd_addr *,
> diff --git usr.sbin/bgpd/kroute.c usr.sbin/bgpd/kroute.c
> index 5907f0cef67..1f1b7a3cfdc 100644
> --- usr.sbin/bgpd/kroute.c
> +++ usr.sbin/bgpd/kroute.c
> @@ -135,8 +135,8 @@ void                       knexthop_clear(struct ktable 
> *);
>  
>  struct kif_node              *kif_find(int);
>  int                   kif_insert(struct kif_node *);
> -int                   kif_remove(struct kif_node *);
> -void                  kif_clear(void);
> +int                   kif_remove(struct kif_node *, u_int);
> +void                  kif_clear(u_int);
>  
>  int                   kif_kr_insert(struct kroute_node *);
>  int                   kif_kr_remove(struct kroute_node *);
> @@ -161,14 +161,14 @@ u_int8_t        prefixlen_classful(in_addr_t);
>  u_int8_t     mask2prefixlen(in_addr_t);
>  u_int8_t     mask2prefixlen6(struct sockaddr_in6 *);
>  void         get_rtaddrs(int, struct sockaddr *, struct sockaddr **);
> -void         if_change(u_short, int, struct if_data *);
> -void         if_announce(void *);
> +void         if_change(u_short, int, struct if_data *, u_int rdomain);
> +void         if_announce(void *, u_int);
>  
>  int          send_rtmsg(int, int, struct ktable *, struct kroute *,
>                   u_int8_t);
>  int          send_rt6msg(int, int, struct ktable *, struct kroute6 *,
>                   u_int8_t);
> -int          dispatch_rtmsg(void);
> +int          dispatch_rtmsg(u_int rdomain);
>  int          fetchtable(struct ktable *, u_int8_t);
>  int          fetchifs(int);
>  int          dispatch_rtmsg_addr(struct rt_msghdr *,
> @@ -759,13 +759,13 @@ krVPN4_delete(struct ktable *kt, struct kroute_full 
> *kl, u_int8_t fib_prio)
>  }
>  
>  void
> -kr_shutdown(u_int8_t fib_prio)
> +kr_shutdown(u_int8_t fib_prio, u_int rdomain)
>  {
>       u_int   i;
>  
>       for (i = krt_size; i > 0; i--)
>               ktable_free(i - 1, fib_prio);
> -     kif_clear();
> +     kif_clear(rdomain);
>  }
>  
>  void
> @@ -870,9 +870,9 @@ kr_fib_update_prio_all(u_int8_t fib_prio)
>  }
>  
>  int
> -kr_dispatch_msg(void)
> +kr_dispatch_msg(u_int rdomain)
>  {
> -     return (dispatch_rtmsg());
> +     return (dispatch_rtmsg(rdomain));
>  }
>  
>  int
> @@ -1923,7 +1923,7 @@ kif_insert(struct kif_node *kif)
>  }
>  
>  int
> -kif_remove(struct kif_node *kif)
> +kif_remove(struct kif_node *kif, u_int rdomain)
>  {
>       struct ktable   *kt;
>       struct kif_kr   *kkr;
> @@ -1934,7 +1934,7 @@ kif_remove(struct kif_node *kif)
>               return (-1);
>       }
>  
> -     if ((kt = ktable_get(/* XXX */ 0)) == NULL)
> +     if ((kt = ktable_get(rdomain)) == NULL)
>               goto done;
>  
>       while ((kkr = LIST_FIRST(&kif->kroute_l)) != NULL) {
> @@ -1956,12 +1956,12 @@ done:
>  }
>  
>  void
> -kif_clear(void)
> +kif_clear(u_int rdomain)
>  {
>       struct kif_node *kif;
>  
>       while ((kif = RB_MIN(kif_tree, &kit)) != NULL)
> -             kif_remove(kif);
> +             kif_remove(kif, rdomain);
>  }
>  
>  int
> @@ -2474,7 +2474,8 @@ get_rtaddrs(int addrs, struct sockaddr *sa, struct 
> sockaddr **rti_info)
>  }
>  
>  void
> -if_change(u_short ifindex, int flags, struct if_data *ifd)
> +if_change(u_short ifindex, int flags, struct if_data *ifd,
> +    u_int rdomain)
>  {
>       struct ktable           *kt;
>       struct kif_node         *kif;
> @@ -2488,6 +2489,9 @@ if_change(u_short ifindex, int flags, struct if_data 
> *ifd)
>               return;
>       }
>  
> +     log_info("%s: ifindex %u, ifi_rdomain %u", __func__, ifindex,
> +         ifd->ifi_rdomain);
> +
>       kif->k.flags = flags;
>       kif->k.link_state = ifd->ifi_link_state;
>       kif->k.if_type = ifd->ifi_type;
> @@ -2501,7 +2505,7 @@ if_change(u_short ifindex, int flags, struct if_data 
> *ifd)
>  
>       kif->k.nh_reachable = reachable;
>  
> -     kt = ktable_get(/* XXX */ 0);
> +     kt = ktable_get(rdomain);
>  
>       LIST_FOREACH(kkr, &kif->kroute_l, entry) {
>               if (reachable)
> @@ -2528,7 +2532,7 @@ if_change(u_short ifindex, int flags, struct if_data 
> *ifd)
>  }
>  
>  void
> -if_announce(void *msg)
> +if_announce(void *msg, u_int rdomain)
>  {
>       struct if_announcemsghdr        *ifan;
>       struct kif_node                 *kif;
> @@ -2548,7 +2552,7 @@ if_announce(void *msg)
>               break;
>       case IFAN_DEPARTURE:
>               kif = kif_find(ifan->ifan_index);
> -             kif_remove(kif);
> +             kif_remove(kif, rdomain);
>               break;
>       }
>  }
> @@ -3081,7 +3085,7 @@ fetchifs(int ifindex)
>  }
>  
>  int
> -dispatch_rtmsg(void)
> +dispatch_rtmsg(u_int rdomain)
>  {
>       char                     buf[RT_BUF_SIZE];
>       ssize_t                  n;
> @@ -3108,7 +3112,7 @@ dispatch_rtmsg(void)
>               rtm = (struct rt_msghdr *)next;
>               if (lim < next + sizeof(u_short) ||
>                   lim < next + rtm->rtm_msglen)
> -                     fatalx("dispatch_rtmsg: partial rtm in buffer");
> +                     fatalx("%s: partial rtm in buffer", __func__);
>               if (rtm->rtm_version != RTM_VERSION)
>                       continue;
>  
> @@ -3137,10 +3141,10 @@ dispatch_rtmsg(void)
>               case RTM_IFINFO:
>                       memcpy(&ifm, next, sizeof(ifm));
>                       if_change(ifm.ifm_index, ifm.ifm_flags,
> -                         &ifm.ifm_data);
> +                         &ifm.ifm_data, rdomain);
>                       break;
>               case RTM_IFANNOUNCE:
> -                     if_announce(next);
> +                     if_announce(next, rdomain);
>                       break;
>               default:
>                       /* ignore for now */
> 

-- 
:wq Claudio

Reply via email to