summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2005-11-29 21:11:08 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2005-11-29 21:11:08 +0000
commit9ba6c7b553a591494444e098862acfc939c83b7b (patch)
tree3996b4db9a742db69cf84ac3e8e8d97e08d02169 /usr.sbin/bgpd
parentc7aa2cb78493cd2018b3edc94c4e3686f5f3c4bb (diff)
Add a flags field to struct prefix which will be used shortly. Remove the peer
pointer so that the size does not grow. Adding 4 bytes to struct prefix would result in 64MB more memory usage on one of my systems.
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/mrt.c8
-rw-r--r--usr.sbin/bgpd/rde.c12
-rw-r--r--usr.sbin/bgpd/rde.h4
-rw-r--r--usr.sbin/bgpd/rde_decide.c18
-rw-r--r--usr.sbin/bgpd/rde_rib.c10
-rw-r--r--usr.sbin/bgpd/rde_update.c12
6 files changed, 34 insertions, 30 deletions
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index 446e9aeed30..f06aff60a36 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.47 2004/12/23 16:09:26 henning Exp $ */
+/* $OpenBSD: mrt.c,v 1.48 2005/11/29 21:11:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -508,9 +508,11 @@ mrt_dump_upcall(struct pt_entry *pt, void *ptr)
*/
LIST_FOREACH(p, &pt->prefix_h, prefix_l)
if (mrtbuf->type == MRT_TABLE_DUMP)
- mrt_dump_entry(mrtbuf, p, sequencenum++, p->peer);
+ mrt_dump_entry(mrtbuf, p, sequencenum++,
+ p->aspath->peer);
else
- mrt_dump_entry_mp(mrtbuf, p, sequencenum++, p->peer);
+ mrt_dump_entry_mp(mrtbuf, p, sequencenum++,
+ p->aspath->peer);
}
static int
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 8fec1bf1304..8f981cb0102 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.179 2005/11/29 20:45:21 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.180 2005/11/29 21:11:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1553,7 +1553,7 @@ rde_dump_rib_as(struct prefix *p, pid_t pid)
rib.flags = 0;
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->flags & F_PREFIX_ANNOUNCED)
rib.flags |= F_RIB_ANNOUNCE;
@@ -1801,9 +1801,9 @@ rde_softreconfig_out(struct pt_entry *pt, void *ptr)
nasp = path_copy(p->aspath);
oa = rde_filter(rules_l, peer, oasp, &addr, pt->prefixlen,
- p->peer, DIR_OUT);
+ p->aspath->peer, DIR_OUT);
na = rde_filter(newrules, peer, nasp, &addr, pt->prefixlen,
- p->peer, DIR_OUT);
+ p->aspath->peer, DIR_OUT);
if (oa == ACTION_DENY && na == ACTION_DENY)
/* nothing todo */
@@ -2301,7 +2301,7 @@ network_dump_upcall(struct pt_entry *pt, void *ptr)
pt_getaddr(p->prefix, &addr);
k.prefix.s_addr = addr.v4.s_addr;
k.prefixlen = p->prefix->prefixlen;
- if (p->peer == &peerself)
+ if (p->aspath->peer == &peerself)
k.flags = F_KERNEL;
if (imsg_compose(ibuf_se, IMSG_CTL_SHOW_NETWORK, 0, pid,
-1, &k, sizeof(k)) == -1)
@@ -2313,7 +2313,7 @@ network_dump_upcall(struct pt_entry *pt, void *ptr)
pt_getaddr(p->prefix, &addr);
memcpy(&k6.prefix, &addr.v6, sizeof(k6.prefix));
k6.prefixlen = p->prefix->prefixlen;
- if (p->peer == &peerself)
+ if (p->aspath->peer == &peerself)
k6.flags = F_KERNEL;
if (imsg_compose(ibuf_se, IMSG_CTL_SHOW_NETWORK6, 0,
pid, -1, &k6, sizeof(k6)) == -1)
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index bf5d1c92d9f..bc1c4ed13c8 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.73 2005/11/02 13:19:30 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.74 2005/11/29 21:11:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -232,8 +232,8 @@ struct prefix {
LIST_ENTRY(prefix) prefix_l, path_l;
struct rde_aspath *aspath;
struct pt_entry *prefix;
- struct rde_peer *peer;
time_t lastchange;
+ u_int32_t flags;
};
/* prototypes */
diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c
index 6ee960e78f1..cea94a93fcf 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.42 2005/08/09 20:27:25 claudio Exp $ */
+/* $OpenBSD: rde_decide.c,v 1.43 2005/11/29 21:11:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -176,14 +176,18 @@ prefix_cmp(struct prefix *p1, struct prefix *p2)
return (p2->lastchange - p1->lastchange);
/* 10. lowest BGP Id wins */
- if ((p2->peer->remote_bgpid - p1->peer->remote_bgpid) != 0)
- return (p2->peer->remote_bgpid - p1->peer->remote_bgpid);
+ if ((p2->aspath->peer->remote_bgpid -
+ p1->aspath->peer->remote_bgpid) != 0)
+ return (p2->aspath->peer->remote_bgpid -
+ p1->aspath->peer->remote_bgpid);
/* 11. lowest peer address wins (IPv4 is better than IPv6) */
- if (memcmp(&p1->peer->remote_addr, &p2->peer->remote_addr,
- sizeof(p1->peer->remote_addr)) != 0)
- return (-memcmp(&p1->peer->remote_addr, &p2->peer->remote_addr,
- sizeof(p1->peer->remote_addr)));
+ if (memcmp(&p1->aspath->peer->remote_addr,
+ &p2->aspath->peer->remote_addr,
+ sizeof(p1->aspath->peer->remote_addr)) != 0)
+ return (-memcmp(&p1->aspath->peer->remote_addr,
+ &p2->aspath->peer->remote_addr,
+ sizeof(p1->aspath->peer->remote_addr)));
fatalx("Uh, oh a politician in the decision process");
/* NOTREACHED */
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index 8c30d290e12..aed9953fbef 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.69 2005/07/29 12:38:40 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.70 2005/11/29 21:11:07 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -426,14 +426,13 @@ prefix_move(struct rde_aspath *asp, struct prefix *p)
struct prefix *np;
struct rde_aspath *oasp;
- 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 */
@@ -534,7 +533,7 @@ prefix_bypeer(struct pt_entry *pte, struct rde_peer *peer)
struct prefix *p;
LIST_FOREACH(p, &pte->prefix_h, prefix_l) {
- if (p->peer == peer)
+ if (p->aspath->peer == peer)
return p;
}
return NULL;
@@ -624,7 +623,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 */
@@ -643,7 +641,7 @@ prefix_unlink(struct prefix *pref)
LIST_REMOVE(pref, path_l);
pref->aspath->prefix_cnt--;
- pref->peer->prefix_cnt--;
+ pref->aspath->peer->prefix_cnt--;
/* destroy all references to other objects */
pref->aspath = NULL;
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c
index b602da14c4b..cacaac8e582 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.44 2005/11/29 20:45:21 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.45 2005/11/29 21:11:07 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -266,7 +266,7 @@ up_test_update(struct rde_peer *peer, struct prefix *p)
/* no prefix available */
return (0);
- if (peer == p->peer)
+ if (peer == p->aspath->peer)
/* Do not send routes back to sender */
return (0);
@@ -292,7 +292,7 @@ up_test_update(struct rde_peer *peer, struct prefix *p)
return (0);
}
- if (p->peer->conf.ebgp == 0 && peer->conf.ebgp == 0) {
+ if (p->aspath->peer->conf.ebgp == 0 && peer->conf.ebgp == 0) {
/*
* route reflector redistribution rules:
* 1. if announce is set -> announce
@@ -301,7 +301,7 @@ up_test_update(struct rde_peer *peer, struct prefix *p)
* 4. old non-client, new client -> yes
* 5. old client, new client -> yes
*/
- if (p->peer->conf.reflector_client == 0 &&
+ if (p->aspath->peer->conf.reflector_client == 0 &&
peer->conf.reflector_client == 0 &&
(p->aspath->flags & F_PREFIX_ANNOUNCED) == 0)
/* Do not redistribute updates to ibgp peers */
@@ -413,7 +413,7 @@ up_generate_updates(struct filter_head *rules, struct rde_peer *peer,
pt_getaddr(old->prefix, &addr);
if (rde_filter(rules, peer, fasp, &addr, old->prefix->prefixlen,
- old->peer, DIR_OUT) == ACTION_DENY) {
+ old->aspath->peer, DIR_OUT) == ACTION_DENY) {
path_put(fasp);
return;
}
@@ -437,7 +437,7 @@ up_generate_updates(struct filter_head *rules, struct rde_peer *peer,
pt_getaddr(new->prefix, &addr);
if (rde_filter(rules, peer, fasp, &addr, new->prefix->prefixlen,
- new->peer, DIR_OUT) == ACTION_DENY) {
+ new->aspath->peer, DIR_OUT) == ACTION_DENY) {
path_put(fasp);
up_generate_updates(rules, peer, NULL, old);
return;