diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-02-27 20:53:57 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-02-27 20:53:57 +0000 |
commit | c2cf121f1d2db9820dbc07b7c2936029064e98ae (patch) | |
tree | 79b2de76a41864d290666509107d0faf22309985 /usr.sbin | |
parent | fbea016b8a23b0518ceb0afcad616a711fa34a24 (diff) |
remove unneded peer pointer in struct prefix and change a in_addr_t to
struct in_addr. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/mrt.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 15 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_attr.c | 8 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_decide.c | 24 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_filter.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 32 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_update.c | 12 |
8 files changed, 49 insertions, 58 deletions
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c index d2c3cdf3a1b..183d568efa1 100644 --- a/usr.sbin/bgpd/mrt.c +++ b/usr.sbin/bgpd/mrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mrt.c,v 1.27 2004/02/25 19:48:18 claudio Exp $ */ +/* $OpenBSD: mrt.c,v 1.28 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -303,7 +303,8 @@ mrt_dump_upcall(struct pt_entry *pt, void *ptr) * be dumped p should be set to p = pt->active. */ LIST_FOREACH(p, &pt->prefix_h, prefix_l) - mrt_dump_entry(mrtbuf, p, sequencenum++, &p->peer->conf); + mrt_dump_entry(mrtbuf, p, sequencenum++, + &p->aspath->peer->conf); } static int diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index d51e7c94a35..71383f26387 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.90 2004/02/27 14:46:09 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.91 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -576,15 +576,12 @@ rde_update_log(const char *message, const struct bgpd_addr *prefix, u_int8_t prefixlen) { char *nexthop = NULL; - struct in_addr nh; if (! (conf->log & BGPD_LOG_UPDATES)) return; - if (attr != NULL) { - nh.s_addr = attr->nexthop; - asprintf(&nexthop, " via %s", inet_ntoa(nh)); - } + if (attr != NULL) + asprintf(&nexthop, " via %s", inet_ntoa(attr->nexthop)); log_debug("neighbor %s (AS%u) %s %s/%u %s", log_addr(&peer->conf.remote_addr), peer->conf.remote_as, message, @@ -618,7 +615,7 @@ rde_dump_rib(struct prefix *p, pid_t pid) rib.flags |= F_RIB_ELIGIBLE; if (p->prefix->active == p) rib.flags |= F_RIB_ACTIVE; - if (p->peer->conf.ebgp == 0) + if (p->aspath->peer->conf.ebgp == 0) rib.flags |= F_RIB_INTERNAL; if (p->aspath->nexthop->flags & NEXTHOP_ANNOUNCE) rib.flags |= F_RIB_ANNOUNCE; @@ -654,7 +651,7 @@ rde_dump_prefix(struct prefix *p, pid_t pid) prefix.flags |= F_RIB_ELIGIBLE; if (p->prefix->active == p) prefix.flags |= F_RIB_ACTIVE; - if (p->peer->conf.ebgp == 0) + if (p->aspath->peer->conf.ebgp == 0) prefix.flags |= F_RIB_INTERNAL; if (p->aspath->nexthop->flags & NEXTHOP_ANNOUNCE) prefix.flags |= F_RIB_ANNOUNCE; @@ -1016,7 +1013,7 @@ network_add(struct network_config *nc) bzero(&attrs, sizeof(attrs)); attrs.aspath = aspath_create(NULL, 0); - attrs.nexthop = INADDR_ANY; + attrs.nexthop.s_addr = INADDR_ANY; /* med = 0 */ /* lpref = 0 */ attrs.origin = ORIGIN_IGP; diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 7c2b2f0599f..249eb17515e 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.31 2004/02/26 16:16:41 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.32 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -134,7 +134,7 @@ TAILQ_HEAD(attr_list, attr); struct attr_flags { struct aspath *aspath; - in_addr_t nexthop; /* exit nexthop */ + struct in_addr nexthop; /* exit nexthop */ u_int32_t med; /* multi exit disc */ u_int32_t lpref; /* local pref */ u_int8_t origin; @@ -189,7 +189,7 @@ struct pt_entry { LIST_ENTRY(pt_entry) pt_l; /* currently we are using a hash list for prefixes */ struct bgpd_addr prefix; - int prefixlen; + u_int8_t prefixlen; struct prefix_head prefix_h; struct prefix *active; /* for fast access */ /* diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index cc6bc77f53d..dad22ba3a96 100644 --- a/usr.sbin/bgpd/rde_attr.c +++ b/usr.sbin/bgpd/rde_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_attr.c,v 1.15 2004/02/26 14:00:33 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.16 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -128,7 +128,7 @@ attr_parse(u_char *p, u_int16_t len, struct attr_flags *a, int ebgp, * Check if the nexthop is a valid IP address. We consider * multicast, experimental and loopback addresses as invalid. */ - tmp32 = ntohl(a->nexthop); + tmp32 = ntohl(a->nexthop.s_addr); if (IN_MULTICAST(tmp32) || IN_BADCLASS(tmp32) || (tmp32 & 0x7f000000) == 0x7f000000) return (-1); @@ -335,9 +335,9 @@ attr_compare(struct attr_flags *a, struct attr_flags *b) return (1); if (a->origin < b->origin) return (-1); - if (a->nexthop > b->nexthop) + if (a->nexthop.s_addr > b->nexthop.s_addr) return (1); - if (a->nexthop < b->nexthop) + if (a->nexthop.s_addr < b->nexthop.s_addr) return (-1); if (a->med > b->med) return (1); diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c index f6c76d6255b..4d89e63178d 100644 --- a/usr.sbin/bgpd/rde_decide.c +++ b/usr.sbin/bgpd/rde_decide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_decide.c,v 1.30 2004/02/26 15:46:30 claudio Exp $ */ +/* $OpenBSD: rde_decide.c,v 1.31 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -154,26 +154,26 @@ prefix_cmp(struct prefix *p1, struct prefix *p2) * It is absolutely important that the ebgp value in peer_config.ebgp * is bigger than all other ones (IBGP, confederations) */ - if ((p1->peer->conf.ebgp - p2->peer->conf.ebgp) != 0) { - if (p1->peer->conf.ebgp == 1) /* p1 is EBGP other is lower */ + if ((asp1->peer->conf.ebgp - asp2->peer->conf.ebgp) != 0) { + if (asp1->peer->conf.ebgp == 1) /* p1 is EBGP other is lower */ return 1; - else if (p2->peer->conf.ebgp == 1) /* p2 is EBGP */ + else if (asp2->peer->conf.ebgp == 1) /* p2 is EBGP */ return -1; } /* 7. nexthop costs. NOT YET -> IGNORE */ /* 8. lowest BGP Id wins */ - if ((p2->peer->remote_bgpid - p1->peer->remote_bgpid) != 0) - return (p2->peer->remote_bgpid - p1->peer->remote_bgpid); + if ((asp2->peer->remote_bgpid - asp1->peer->remote_bgpid) != 0) + return (asp2->peer->remote_bgpid - asp1->peer->remote_bgpid); /* 9. lowest peer address wins */ - if (memcmp(&p1->peer->conf.remote_addr, - &p2->peer->conf.remote_addr, - sizeof(p1->peer->conf.remote_addr)) != 0) - return (memcmp(&p1->peer->conf.remote_addr, - &p2->peer->conf.remote_addr, - sizeof(p1->peer->conf.remote_addr))); + if (memcmp(&asp1->peer->conf.remote_addr, + &asp2->peer->conf.remote_addr, + sizeof(asp1->peer->conf.remote_addr)) != 0) + return (memcmp(&asp1->peer->conf.remote_addr, + &asp2->peer->conf.remote_addr, + sizeof(asp1->peer->conf.remote_addr))); fatalx("Uh, oh a politician in the decision process"); diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c index c46fc6ef910..04c4050df07 100644 --- a/usr.sbin/bgpd/rde_filter.c +++ b/usr.sbin/bgpd/rde_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_filter.c,v 1.3 2004/02/24 15:44:33 claudio Exp $ */ +/* $OpenBSD: rde_filter.c,v 1.4 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -64,8 +64,7 @@ rde_apply_set(struct attr_flags *attrs, struct filter_set *set) if (set->flags & SET_MED) attrs->med = set->med; if (set->flags & SET_NEXTHOP) - /* TODO switch attr->nexthop to struct in_addr */ - attrs->nexthop = set->nexthop.s_addr; + attrs->nexthop = set->nexthop; if (set->flags & SET_PREPEND) { /* * The acctual prepending is done afterwards because diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 2b9f07b5ffe..5afd5c85f84 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.38 2004/02/27 14:46:09 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.39 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -349,14 +349,13 @@ prefix_move(struct rde_aspath *asp, struct prefix *p) struct rde_aspath *oasp; RIB_STAT(prefix_move); - ENSURE(asp->peer == p->peer); + ENSURE(asp->peer == p->aspath->peer); /* create new prefix node */ np = prefix_alloc(); np->aspath = asp; /* peer and prefix pointers are still equal */ np->prefix = p->prefix; - np->peer = p->peer; np->lastchange = time(NULL); /* add to new as path */ @@ -391,7 +390,6 @@ prefix_move(struct rde_aspath *asp, struct prefix *p) /* destroy all references to other objects and free the old prefix */ p->aspath = NULL; p->prefix = NULL; - p->peer = NULL; prefix_free(p); /* destroy old path if empty */ @@ -444,7 +442,7 @@ prefix_bypeer(struct pt_entry *pte, struct rde_peer *peer) ENSURE(pte != NULL); LIST_FOREACH(p, &pte->prefix_h, prefix_l) { - if (p->peer == peer) + if (p->aspath->peer == peer) return p; } return NULL; @@ -525,8 +523,7 @@ prefix_link(struct prefix *pref, struct pt_entry *pte, struct rde_aspath *asp) { RIB_STAT(prefix_link); ENSURE(pref->aspath == NULL && - pref->prefix == NULL && - pref->peer == NULL); + pref->prefix == NULL); ENSURE(pref != NULL && pte != NULL && asp != NULL); ENSURE(prefix_bypeer(pte, asp->peer) == NULL); @@ -539,7 +536,6 @@ prefix_link(struct prefix *pref, struct pt_entry *pte, struct rde_aspath *asp) pref->aspath = asp; pref->prefix = pte; - pref->peer = asp->peer; pref->lastchange = time(NULL); /* make route decision */ @@ -569,7 +565,6 @@ prefix_unlink(struct prefix *pref) /* destroy all references to other objects */ pref->aspath = NULL; pref->prefix = NULL; - pref->peer = NULL; /* * It's the caller's duty to remove empty aspath respectively pt_entry @@ -597,8 +592,7 @@ prefix_free(struct prefix *pref) { RIB_STAT(prefix_free); ENSURE(pref->aspath == NULL && - pref->prefix == NULL && - pref->peer == NULL); + pref->prefix == NULL); free(pref); } @@ -614,7 +608,7 @@ prefix_free(struct prefix *pref) * hash table has more benefits and the table walk should not happen too often. */ -static struct nexthop *nexthop_get(in_addr_t); +static struct nexthop *nexthop_get(struct in_addr); static struct nexthop *nexthop_alloc(void); static void nexthop_free(struct nexthop *); @@ -632,8 +626,8 @@ struct nexthop_table { u_int32_t nexthop_hashmask; } nexthoptable; -#define NEXTHOP_HASH(x) \ - &nexthoptable.nexthop_hashtbl[ntohl((x)) & \ +#define NEXTHOP_HASH(x) \ + &nexthoptable.nexthop_hashtbl[ntohl((x.s_addr)) & \ nexthoptable.nexthop_hashmask] void @@ -659,7 +653,7 @@ nexthop_init(u_int32_t hashsize) nh->exit_nexthop.af = AF_INET; nh->exit_nexthop.v4.s_addr = INADDR_ANY; - LIST_INSERT_HEAD(NEXTHOP_HASH(nh->exit_nexthop.v4.s_addr), nh, + LIST_INSERT_HEAD(NEXTHOP_HASH(nh->exit_nexthop.v4), nh, nexthop_l); memcpy(&nh->true_nexthop, &nh->exit_nexthop, @@ -685,7 +679,7 @@ nexthop_add(struct rde_aspath *asp) nh = nexthop_alloc(); nh->state = NEXTHOP_LOOKUP; nh->exit_nexthop.af = AF_INET; - nh->exit_nexthop.v4.s_addr = asp->flags.nexthop; + nh->exit_nexthop.v4 = asp->flags.nexthop; LIST_INSERT_HEAD(NEXTHOP_HASH(asp->flags.nexthop), nh, nexthop_l); rde_send_nexthop(&nh->exit_nexthop, 1); @@ -719,14 +713,14 @@ nexthop_remove(struct rde_aspath *asp) } static struct nexthop * -nexthop_get(in_addr_t nexthop) +nexthop_get(struct in_addr nexthop) { struct nexthop *nh; RIB_STAT(nexthop_get); LIST_FOREACH(nh, NEXTHOP_HASH(nexthop), nexthop_l) { - if (nh->exit_nexthop.v4.s_addr == nexthop) + if (nh->exit_nexthop.v4.s_addr == nexthop.s_addr) return nh; } return NULL; @@ -740,7 +734,7 @@ nexthop_update(struct kroute_nexthop *msg) RIB_STAT(nexthop_update); - nh = nexthop_get(msg->nexthop.v4.s_addr); + nh = nexthop_get(msg->nexthop.v4); if (nh == NULL) { log_warnx("nexthop_update: non-existent nexthop"); return; diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index f5646e71a00..7ce41a66279 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.8 2004/02/25 22:14:31 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.9 2004/02/27 20:53:56 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -213,7 +213,7 @@ up_generate_updates(struct rde_peer *peer, if (new == NULL || new->aspath->nexthop == NULL || new->aspath->nexthop->state != NEXTHOP_REACH) { - if (peer == old->peer) + if (peer == old->aspath->peer) /* Do not send routes back to sender */ return; @@ -226,7 +226,7 @@ up_generate_updates(struct rde_peer *peer, */ return; - if (peer->conf.ebgp == 0 && old->peer->conf.ebgp == 0 && + if (peer->conf.ebgp == 0 && old->aspath->peer->conf.ebgp == 0 && (old->aspath->nexthop->flags & NEXTHOP_ANNOUNCE) == 0) /* Do not redistribute updates to ibgp peers */ return; @@ -269,7 +269,7 @@ up_generate_updates(struct rde_peer *peer, if (up_add(peer, p, NULL) == -1) log_warnx("queuing update failed."); } else { - if (peer == new->peer) + if (peer == new->aspath->peer) /* Do not send routes back to sender */ return; @@ -282,7 +282,7 @@ up_generate_updates(struct rde_peer *peer, */ return; - if (peer->conf.ebgp == 0 && new->peer->conf.ebgp == 0 && + if (peer->conf.ebgp == 0 && new->aspath->peer->conf.ebgp == 0 && (new->aspath->nexthop->flags & NEXTHOP_ANNOUNCE) == 0) /* Do not redistribute updates to ibgp peers */ return; @@ -373,7 +373,7 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa, */ if (nh->flags & NEXTHOP_ANNOUNCE) nexthop = peer->local_addr.v4.s_addr; - else if (a->nexthop == peer->remote_addr.v4.s_addr) + else if (a->nexthop.s_addr == peer->remote_addr.v4.s_addr) /* * per rfc: if remote peer address is equal to * the nexthop set the nexthop to our local address. |