1
0
mirror of https://github.com/openbsd/src.git synced 2025-12-06 16:23:52 +00:00

This moves the code to lookup and set the pftable_id and rtlabel_id

from rde_apply_set() to filterset_recv(). This was already done in the
nexthop case.
OK tb@
This commit is contained in:
claudio
2025-12-03 14:16:21 +00:00
parent db26abeede
commit cfc59e797c

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: rde_filter.c,v 1.137 2025/12/03 12:20:19 claudio Exp $ */ /* $OpenBSD: rde_filter.c,v 1.138 2025/12/03 14:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -134,8 +134,6 @@ rde_apply_set(struct filter_set_head *sh, struct rde_peer *peer,
state->aspath.aspath = aspath_get(np, nl); state->aspath.aspath = aspath_get(np, nl);
free(np); free(np);
break; break;
case ACTION_SET_NEXTHOP:
fatalx("unexpected filter action in RDE");
case ACTION_SET_NEXTHOP_REF: case ACTION_SET_NEXTHOP_REF:
case ACTION_SET_NEXTHOP_REJECT: case ACTION_SET_NEXTHOP_REJECT:
case ACTION_SET_NEXTHOP_BLACKHOLE: case ACTION_SET_NEXTHOP_BLACKHOLE:
@@ -152,20 +150,10 @@ rde_apply_set(struct filter_set_head *sh, struct rde_peer *peer,
community_delete(&state->communities, community_delete(&state->communities,
&set->action.community, peer); &set->action.community, peer);
break; break;
case ACTION_PFTABLE:
/* convert pftable name to an id */
set->action.id = pftable_name2id(set->action.pftable);
set->type = ACTION_PFTABLE_ID;
/* FALLTHROUGH */
case ACTION_PFTABLE_ID: case ACTION_PFTABLE_ID:
pftable_unref(state->aspath.pftableid); pftable_unref(state->aspath.pftableid);
state->aspath.pftableid = pftable_ref(set->action.id); state->aspath.pftableid = pftable_ref(set->action.id);
break; break;
case ACTION_RTLABEL:
/* convert the route label to an id for faster access */
set->action.id = rtlabel_name2id(set->action.rtlabel);
set->type = ACTION_RTLABEL_ID;
/* FALLTHROUGH */
case ACTION_RTLABEL_ID: case ACTION_RTLABEL_ID:
rtlabel_unref(state->aspath.rtlabelid); rtlabel_unref(state->aspath.rtlabelid);
state->aspath.rtlabelid = rtlabel_ref(set->action.id); state->aspath.rtlabelid = rtlabel_ref(set->action.id);
@@ -173,6 +161,10 @@ rde_apply_set(struct filter_set_head *sh, struct rde_peer *peer,
case ACTION_SET_ORIGIN: case ACTION_SET_ORIGIN:
state->aspath.origin = set->action.origin; state->aspath.origin = set->action.origin;
break; break;
case ACTION_SET_NEXTHOP:
case ACTION_PFTABLE:
case ACTION_RTLABEL:
fatalx("unexpected filter action in RDE");
} }
} }
} }
@@ -767,9 +759,23 @@ filterset_recv(struct imsg *imsg, struct filter_set_head *set)
free(s); free(s);
return; return;
} }
if (s->type == ACTION_SET_NEXTHOP) { switch (s->type) {
case ACTION_SET_NEXTHOP:
s->action.nh_ref = nexthop_get(&s->action.nexthop); s->action.nh_ref = nexthop_get(&s->action.nexthop);
s->type = ACTION_SET_NEXTHOP_REF; s->type = ACTION_SET_NEXTHOP_REF;
break;
case ACTION_RTLABEL:
/* convert the route label to an id for faster access */
s->action.id = rtlabel_name2id(s->action.rtlabel);
s->type = ACTION_RTLABEL_ID;
break;
case ACTION_PFTABLE:
/* convert pftable name to an id */
s->action.id = pftable_name2id(s->action.pftable);
s->type = ACTION_PFTABLE_ID;
break;
default:
break;
} }
TAILQ_INSERT_TAIL(set, s, entry); TAILQ_INSERT_TAIL(set, s, entry);
} }