diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2011-01-12 15:07:47 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2011-01-12 15:07:47 +0000 |
commit | c323393d8ae534b15db718b01dd31daff01ba33b (patch) | |
tree | beb7096494897bec6f540e1683029dfd9a137dcc /usr.sbin | |
parent | c74302a51253b0126e42384c363f9f508c5e6628 (diff) |
Kill struct rroute and move the metric to struct kroute. This
disturbed me for a long time and makes upcomming work a bit easier.
OK sthen@, phessler@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospfd/kroute.c | 32 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 9 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde.c | 36 |
3 files changed, 36 insertions, 41 deletions
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c index 8365bcda42a..5449ea46704 100644 --- a/usr.sbin/ospfd/kroute.c +++ b/usr.sbin/ospfd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.88 2010/10/14 07:35:47 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.89 2011/01/12 15:07:46 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -52,8 +52,8 @@ struct { struct kroute_node { RB_ENTRY(kroute_node) entry; - struct kroute r; struct kroute_node *next; + struct kroute r; int serial; }; @@ -64,7 +64,7 @@ struct kif_node { }; void kr_redist_remove(struct kroute_node *, struct kroute_node *); -int kr_redist_eval(struct kroute *, struct rroute *); +int kr_redist_eval(struct kroute *, struct kroute *); void kr_redistribute(struct kroute_node *); int kroute_compare(struct kroute_node *, struct kroute_node *); int kif_compare(struct kif_node *, struct kif_node *); @@ -375,7 +375,6 @@ kr_fib_reload(void) kn = kr->next; if (kr->serial != kr_state.fib_serial) { - if (kr->r.priority == RTP_OSPF) { kr->serial = kr_state.fib_serial; if (send_rtmsg(kr_state.fd, @@ -461,7 +460,7 @@ kr_ifinfo(char *ifname, pid_t pid) void kr_redist_remove(struct kroute_node *kh, struct kroute_node *kn) { - struct rroute rr; + struct kroute *rr; /* was the route redistributed? */ if ((kn->r.flags & F_REDISTRIBUTED) == 0) @@ -469,8 +468,7 @@ kr_redist_remove(struct kroute_node *kh, struct kroute_node *kn) /* remove redistributed flag */ kn->r.flags &= ~F_REDISTRIBUTED; - rr.kr = kn->r; - rr.metric = DEFAULT_REDIST_METRIC; /* some dummy value */ + rr = &kn->r; /* probably inform the RDE (check if no other path is redistributed) */ for (kn = kh; kn; kn = kn->next) @@ -478,12 +476,12 @@ kr_redist_remove(struct kroute_node *kh, struct kroute_node *kn) break; if (kn == NULL) - main_imsg_compose_rde(IMSG_NETWORK_DEL, 0, &rr, - sizeof(struct rroute)); + main_imsg_compose_rde(IMSG_NETWORK_DEL, 0, rr, + sizeof(struct kroute)); } int -kr_redist_eval(struct kroute *kr, struct rroute *rr) +kr_redist_eval(struct kroute *kr, struct kroute *rr) { u_int32_t a, metric = 0; @@ -526,9 +524,10 @@ kr_redist_eval(struct kroute *kr, struct rroute *rr) * redistribute the best one. */ if (rr->metric > metric) { - rr->kr = *kr; + *rr = *kr; rr->metric = metric; } + return (1); dont_redistribute: @@ -544,7 +543,7 @@ void kr_redistribute(struct kroute_node *kh) { struct kroute_node *kn; - struct rroute rr; + struct kroute rr; int redistribute = 0; /* only the highest prio route can be redistributed */ @@ -560,14 +559,13 @@ kr_redistribute(struct kroute_node *kh) if (!redistribute) return; - if (rr.kr.flags & F_REDISTRIBUTED) { + if (rr.flags & F_REDISTRIBUTED) { main_imsg_compose_rde(IMSG_NETWORK_ADD, 0, &rr, - sizeof(struct rroute)); + sizeof(struct kroute)); } else { - rr.metric = DEFAULT_REDIST_METRIC; /* some dummy value */ - rr.kr = kh->r; + rr = kh->r; main_imsg_compose_rde(IMSG_NETWORK_DEL, 0, &rr, - sizeof(struct rroute)); + sizeof(struct kroute)); } } diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 400b944fa73..6660f2962c5 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.88 2010/09/25 13:28:43 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.89 2011/01/12 15:07:46 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -59,6 +59,7 @@ #define F_REJECT 0x0040 #define F_BLACKHOLE 0x0080 #define F_REDISTRIBUTED 0x0100 +#define F_FORCED_NEXTHOP 0x0200 struct imsgev { struct imsgbuf ibuf; @@ -389,6 +390,7 @@ struct kroute { struct in_addr prefix; struct in_addr nexthop; u_int32_t ext_tag; + u_int32_t metric; u_int16_t flags; u_int16_t rtlabel; u_short ifindex; @@ -396,11 +398,6 @@ struct kroute { u_int8_t priority; }; -struct rroute { - struct kroute kr; - u_int32_t metric; -}; - struct kif_addr { TAILQ_ENTRY(kif_addr) entry; struct in_addr addr; diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index a6429444c72..c8c5c5b8c63 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.88 2010/09/25 13:28:43 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.89 2011/01/12 15:07:46 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -57,10 +57,10 @@ void rde_req_list_del(struct rde_nbr *, struct lsa_hdr *); void rde_req_list_free(struct rde_nbr *); struct iface *rde_asext_lookup(u_int32_t, int); -struct lsa *rde_asext_get(struct rroute *); -struct lsa *rde_asext_put(struct rroute *); +struct lsa *rde_asext_get(struct kroute *); +struct lsa *rde_asext_put(struct kroute *); -struct lsa *orig_asext_lsa(struct rroute *, u_int16_t); +struct lsa *orig_asext_lsa(struct kroute *, u_int16_t); struct lsa *orig_sum_lsa(struct rt_node *, struct area *, u_int8_t, int); struct ospfd_conf *rdeconf = NULL, *nconf = NULL; @@ -591,7 +591,7 @@ rde_dispatch_parent(int fd, short event, void *bula) static struct area *narea; struct iface *niface; struct imsg imsg; - struct rroute rr; + struct kroute rr; struct imsgev *iev = bula; struct imsgbuf *ibuf; struct lsa *lsa; @@ -1065,12 +1065,12 @@ rde_asext_lookup(u_int32_t prefix, int plen) } struct lsa * -rde_asext_get(struct rroute *rr) +rde_asext_get(struct kroute *rr) { - if (rde_asext_lookup(rr->kr.prefix.s_addr, rr->kr.prefixlen)) { + if (rde_asext_lookup(rr->prefix.s_addr, rr->prefixlen)) { /* already announced as (stub) net LSA */ log_debug("rde_asext_get: %s/%d is net LSA", - inet_ntoa(rr->kr.prefix), rr->kr.prefixlen); + inet_ntoa(rr->prefix), rr->prefixlen); return (NULL); } /* update of seqnum is done by lsa_merge */ @@ -1078,7 +1078,7 @@ rde_asext_get(struct rroute *rr) } struct lsa * -rde_asext_put(struct rroute *rr) +rde_asext_put(struct kroute *rr) { /* * just try to remove the LSA. If the prefix is announced as @@ -1157,7 +1157,7 @@ rde_summary_update(struct rt_node *rte, struct area *area) * functions for self-originated LSA */ struct lsa * -orig_asext_lsa(struct rroute *rr, u_int16_t age) +orig_asext_lsa(struct kroute *rr, u_int16_t age) { struct lsa *lsa; struct iface *iface; @@ -1168,7 +1168,7 @@ orig_asext_lsa(struct rroute *rr, u_int16_t age) fatal("orig_asext_lsa"); log_debug("orig_asext_lsa: %s/%d age %d", - inet_ntoa(rr->kr.prefix), rr->kr.prefixlen, age); + inet_ntoa(rr->prefix), rr->prefixlen, age); /* LSA header */ lsa->hdr.age = htons(age); @@ -1184,8 +1184,8 @@ orig_asext_lsa(struct rroute *rr, u_int16_t age) * not be true. In this case a hack needs to be done to * make the ls_id unique. */ - lsa->hdr.ls_id = rr->kr.prefix.s_addr; - lsa->data.asext.mask = prefixlen2mask(rr->kr.prefixlen); + lsa->hdr.ls_id = rr->prefix.s_addr; + lsa->data.asext.mask = prefixlen2mask(rr->prefixlen); if (age == MAX_AGE) { /* inherit metric and ext_tag from the current LSA, @@ -1197,7 +1197,7 @@ orig_asext_lsa(struct rroute *rr, u_int16_t age) lsa->hdr.adv_rtr); if (v != NULL) { rr->metric = ntohl(v->lsa->data.asext.metric); - rr->kr.ext_tag = ntohl(v->lsa->data.asext.ext_tag); + rr->ext_tag = ntohl(v->lsa->data.asext.ext_tag); } } @@ -1211,17 +1211,17 @@ orig_asext_lsa(struct rroute *rr, u_int16_t age) * Some implementations actually check that there are multiple * neighbors on the particular segment, we skip that check. */ - iface = rde_asext_lookup(rr->kr.nexthop.s_addr, -1); - if (rr->kr.flags & F_CONNECTED) + iface = rde_asext_lookup(rr->nexthop.s_addr, -1); + if (rr->flags & F_CONNECTED) lsa->data.asext.fw_addr = 0; else if (iface && (iface->type == IF_TYPE_BROADCAST || iface->type == IF_TYPE_NBMA)) - lsa->data.asext.fw_addr = rr->kr.nexthop.s_addr; + lsa->data.asext.fw_addr = rr->nexthop.s_addr; else lsa->data.asext.fw_addr = 0; lsa->data.asext.metric = htonl(rr->metric); - lsa->data.asext.ext_tag = htonl(rr->kr.ext_tag); + lsa->data.asext.ext_tag = htonl(rr->ext_tag); lsa->hdr.ls_chksum = 0; lsa->hdr.ls_chksum = |