ok
Claudio Jeker(cje...@diehard.n-r-g.com) on 2020.11.03 09:07:31 +0100:
> On Wed, Oct 21, 2020 at 06:08:05PM +0200, Claudio Jeker wrote:
> > Bgpd uses many common symbols and the latest compilers are being picky
> > about these common symbols.
> > This removes the global bgpd_process variable and cleans up the filter_set
> > code to not depend on process knowledge (instead use a new type and don't
> > overload another one).
>
> Ping
>
> --
> :wq Claudio
>
> Index: bgpd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.c,v
> retrieving revision 1.229
> diff -u -p -r1.229 bgpd.c
> --- bgpd.c 11 May 2020 16:59:19 -0000 1.229
> +++ bgpd.c 21 Oct 2020 07:18:00 -0000
> @@ -117,10 +117,9 @@ main(int argc, char *argv[])
> int pipe_m2r[2];
>
> conffile = CONFFILE;
> - bgpd_process = PROC_MAIN;
>
> log_init(1, LOG_DAEMON); /* log to stderr until daemonized */
> - log_procinit(log_procnames[bgpd_process]);
> + log_procinit(log_procnames[PROC_MAIN]);
> log_setverbose(1);
>
> saved_argv0 = argv[0];
> Index: bgpd.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
> retrieving revision 1.403
> diff -u -p -r1.403 bgpd.h
> --- bgpd.h 10 May 2020 13:38:46 -0000 1.403
> +++ bgpd.h 21 Oct 2020 07:29:53 -0000
> @@ -120,7 +120,7 @@ enum bgpd_process {
> PROC_MAIN,
> PROC_SE,
> PROC_RDE
> -} bgpd_process;
> +};
>
> enum reconf_action {
> RECONF_NONE,
> @@ -995,6 +995,7 @@ enum action_types {
> ACTION_SET_PREPEND_PEER,
> ACTION_SET_AS_OVERRIDE,
> ACTION_SET_NEXTHOP,
> + ACTION_SET_NEXTHOP_REF,
> ACTION_SET_NEXTHOP_REJECT,
> ACTION_SET_NEXTHOP_BLACKHOLE,
> ACTION_SET_NEXTHOP_NOMODIFY,
> @@ -1017,7 +1018,7 @@ struct filter_set {
> u_int32_t metric;
> int32_t relative;
> struct bgpd_addr nexthop;
> - struct nexthop *nh;
> + struct nexthop *nh_ref;
> struct community community;
> char pftable[PFTABLE_LEN];
> char rtlabel[RTLABEL_LEN];
> Index: printconf.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
> retrieving revision 1.142
> diff -u -p -r1.142 printconf.c
> --- printconf.c 23 Apr 2020 16:13:11 -0000 1.142
> +++ printconf.c 21 Oct 2020 07:32:06 -0000
> @@ -356,6 +356,7 @@ print_set(struct filter_set_head *set)
> break;
> case ACTION_RTLABEL_ID:
> case ACTION_PFTABLE_ID:
> + case ACTION_SET_NEXTHOP_REF:
> /* not possible */
> printf("king bula saiz: config broken");
> break;
> Index: rde.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
> retrieving revision 1.503
> diff -u -p -r1.503 rde.c
> --- rde.c 21 Oct 2020 06:56:32 -0000 1.503
> +++ rde.c 21 Oct 2020 09:39:49 -0000
> @@ -157,8 +157,7 @@ rde_main(int debug, int verbose)
> log_init(debug, LOG_DAEMON);
> log_setverbose(verbose);
>
> - bgpd_process = PROC_RDE;
> - log_procinit(log_procnames[bgpd_process]);
> + log_procinit(log_procnames[PROC_RDE]);
>
> if ((pw = getpwnam(BGPD_USER)) == NULL)
> fatal("getpwnam");
> @@ -509,8 +508,11 @@ badnetdel:
> if ((s = malloc(sizeof(struct filter_set))) == NULL)
> fatal(NULL);
> memcpy(s, imsg.data, sizeof(struct filter_set));
> - if (s->type == ACTION_SET_NEXTHOP)
> - s->action.nh = nexthop_get(&s->action.nexthop);
> + if (s->type == ACTION_SET_NEXTHOP) {
> + s->action.nh_ref =
> + nexthop_get(&s->action.nexthop);
> + s->type = ACTION_SET_NEXTHOP_REF;
> + }
> TAILQ_INSERT_TAIL(&session_set, s, entry);
> break;
> case IMSG_CTL_SHOW_NETWORK:
> @@ -922,8 +924,11 @@ rde_dispatch_imsg_parent(struct imsgbuf
> if ((s = malloc(sizeof(struct filter_set))) == NULL)
> fatal(NULL);
> memcpy(s, imsg.data, sizeof(struct filter_set));
> - if (s->type == ACTION_SET_NEXTHOP)
> - s->action.nh = nexthop_get(&s->action.nexthop);
> + if (s->type == ACTION_SET_NEXTHOP) {
> + s->action.nh_ref =
> + nexthop_get(&s->action.nexthop);
> + s->type = ACTION_SET_NEXTHOP_REF;
> + }
> TAILQ_INSERT_TAIL(&parent_set, s, entry);
> break;
> case IMSG_MRT_OPEN:
> Index: rde_filter.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
> retrieving revision 1.123
> diff -u -p -r1.123 rde_filter.c
> --- rde_filter.c 14 Feb 2020 13:54:31 -0000 1.123
> +++ rde_filter.c 21 Oct 2020 07:35:22 -0000
> @@ -135,11 +135,13 @@ rde_apply_set(struct filter_set_head *sh
> free(np);
> break;
> case ACTION_SET_NEXTHOP:
> + fatalx("unexpected filter action in RDE");
> + case ACTION_SET_NEXTHOP_REF:
> case ACTION_SET_NEXTHOP_REJECT:
> case ACTION_SET_NEXTHOP_BLACKHOLE:
> case ACTION_SET_NEXTHOP_NOMODIFY:
> case ACTION_SET_NEXTHOP_SELF:
> - nexthop_modify(set->action.nh, set->type, aid,
> + nexthop_modify(set->action.nh_ref, set->type, aid,
> &state->nexthop, &state->nhflags);
> break;
> case ACTION_SET_COMMUNITY:
> @@ -462,9 +464,8 @@ filterset_free(struct filter_set_head *s
> rtlabel_unref(s->action.id);
> else if (s->type == ACTION_PFTABLE_ID)
> pftable_unref(s->action.id);
> - else if (s->type == ACTION_SET_NEXTHOP &&
> - bgpd_process == PROC_RDE)
> - nexthop_unref(s->action.nh);
> + else if (s->type == ACTION_SET_NEXTHOP_REF)
> + nexthop_unref(s->action.nh_ref);
> free(s);
> }
> }
> @@ -575,6 +576,11 @@ filterset_equal(struct filter_set_head *
> sizeof(a->action.nexthop)) == 0)
> continue;
> break;
> + case ACTION_SET_NEXTHOP_REF:
> + if (a->type == b->type &&
> + a->action.nh_ref == b->action.nh_ref)
> + continue;
> + break;
> case ACTION_SET_NEXTHOP_BLACKHOLE:
> case ACTION_SET_NEXTHOP_REJECT:
> case ACTION_SET_NEXTHOP_NOMODIFY:
> @@ -657,6 +663,7 @@ filterset_name(enum action_types type)
> case ACTION_SET_AS_OVERRIDE:
> return ("as-override");
> case ACTION_SET_NEXTHOP:
> + case ACTION_SET_NEXTHOP_REF:
> case ACTION_SET_NEXTHOP_REJECT:
> case ACTION_SET_NEXTHOP_BLACKHOLE:
> case ACTION_SET_NEXTHOP_NOMODIFY:
> Index: rde_rib.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v
> retrieving revision 1.215
> diff -u -p -r1.215 rde_rib.c
> --- rde_rib.c 25 Jan 2020 23:54:21 -0000 1.215
> +++ rde_rib.c 21 Oct 2020 07:29:25 -0000
> @@ -1824,7 +1824,7 @@ nexthop_modify(struct nexthop *setnh, en
> case ACTION_SET_NEXTHOP_SELF:
> *flags = NEXTHOP_SELF;
> break;
> - case ACTION_SET_NEXTHOP:
> + case ACTION_SET_NEXTHOP_REF:
> /*
> * it is possible that a prefix matches but has the wrong
> * address family for the set nexthop. In this case ignore it.
> Index: session.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> retrieving revision 1.402
> diff -u -p -r1.402 session.c
> --- session.c 27 Jun 2020 07:24:42 -0000 1.402
> +++ session.c 21 Oct 2020 07:30:23 -0000
> @@ -205,8 +205,7 @@ session_main(int debug, int verbose)
> log_init(debug, LOG_DAEMON);
> log_setverbose(verbose);
>
> - bgpd_process = PROC_SE;
> - log_procinit(log_procnames[bgpd_process]);
> + log_procinit(log_procnames[PROC_SE]);
>
> if ((pw = getpwnam(BGPD_USER)) == NULL)
> fatal(NULL);
>