summaryrefslogtreecommitdiff
path: root/net/openbgpd/files/patch-bgpd_rde_rib.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/openbgpd/files/patch-bgpd_rde_rib.c')
-rw-r--r--net/openbgpd/files/patch-bgpd_rde_rib.c134
1 files changed, 114 insertions, 20 deletions
diff --git a/net/openbgpd/files/patch-bgpd_rde_rib.c b/net/openbgpd/files/patch-bgpd_rde_rib.c
index edea241a977e..22d6f0ee0a48 100644
--- a/net/openbgpd/files/patch-bgpd_rde_rib.c
+++ b/net/openbgpd/files/patch-bgpd_rde_rib.c
@@ -2,10 +2,9 @@ Index: bgpd/rde_rib.c
===================================================================
RCS file: /home/cvs/private/hrs/openbgpd/bgpd/rde_rib.c,v
retrieving revision 1.1.1.7
-retrieving revision 1.6
-diff -u -p -r1.1.1.7 -r1.6
+diff -u -p -r1.1.1.7 rde_rib.c
--- bgpd/rde_rib.c 14 Feb 2010 20:19:57 -0000 1.1.1.7
-+++ bgpd/rde_rib.c 10 Apr 2010 12:16:23 -0000 1.6
++++ bgpd/rde_rib.c 3 Jul 2011 04:45:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.116 2009/06/29 14:13:48 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.125 2010/04/07 09:44:11 claudio Exp $ */
@@ -29,7 +28,7 @@ diff -u -p -r1.1.1.7 -r1.6
/* RIB specific functions */
u_int16_t
-rib_new(int id, char *name, u_int16_t flags)
-+rib_new(char *name, u_int16_t flags)
++rib_new(char *name, u_int rtableid, u_int16_t flags)
{
struct rib *xribs;
size_t newsize;
@@ -46,7 +45,7 @@ diff -u -p -r1.1.1.7 -r1.6
}
if (id == RIB_FAILED)
-@@ -78,7 +81,7 @@ rib_new(int id, char *name, u_int16_t fl
+@@ -78,9 +81,10 @@ rib_new(int id, char *name, u_int16_t fl
bzero(&ribs[id], sizeof(struct rib));
strlcpy(ribs[id].name, name, sizeof(ribs[id].name));
RB_INIT(&ribs[id].rib);
@@ -54,8 +53,11 @@ diff -u -p -r1.1.1.7 -r1.6
+ ribs[id].state = RECONF_REINIT;
ribs[id].id = id;
ribs[id].flags = flags;
++ ribs[id].rtableid = rtableid;
-@@ -173,15 +176,16 @@ rib_lookup(struct rib *rib, struct bgpd_
+ return (id);
+ }
+@@ -173,15 +177,16 @@ rib_lookup(struct rib *rib, struct bgpd_
struct rib_entry *re;
int i;
@@ -75,7 +77,15 @@ diff -u -p -r1.1.1.7 -r1.6
for (i = 128; i >= 0; i--) {
re = rib_get(rib, addr, i);
if (re != NULL)
-@@ -254,7 +258,7 @@ rib_empty(struct rib_entry *re)
+@@ -215,6 +220,7 @@ rib_add(struct rib *rib, struct bgpd_add
+
+ if (RB_INSERT(rib_tree, &rib->rib, re) != NULL) {
+ log_warnx("rib_add: insert failed");
++ free(re);
+ return (NULL);
+ }
+
+@@ -254,7 +260,7 @@ rib_empty(struct rib_entry *re)
void
rib_dump(struct rib *rib, void (*upcall)(struct rib_entry *, void *),
@@ -84,7 +94,7 @@ diff -u -p -r1.1.1.7 -r1.6
{
struct rib_context *ctx;
-@@ -263,7 +267,7 @@ rib_dump(struct rib *rib, void (*upcall)
+@@ -263,7 +269,7 @@ rib_dump(struct rib *rib, void (*upcall)
ctx->ctx_rib = rib;
ctx->ctx_upcall = upcall;
ctx->ctx_arg = arg;
@@ -93,7 +103,7 @@ diff -u -p -r1.1.1.7 -r1.6
rib_dump_r(ctx);
}
-@@ -280,7 +284,8 @@ rib_dump_r(struct rib_context *ctx)
+@@ -280,7 +286,8 @@ rib_dump_r(struct rib_context *ctx)
re = rib_restart(ctx);
for (i = 0; re != NULL; re = RB_NEXT(rib_tree, unused, re)) {
@@ -103,7 +113,7 @@ diff -u -p -r1.1.1.7 -r1.6
continue;
if (ctx->ctx_count && i++ >= ctx->ctx_count &&
(re->flags & F_RIB_ENTRYLOCK) == 0) {
-@@ -308,7 +313,7 @@ rib_restart(struct rib_context *ctx)
+@@ -308,7 +315,7 @@ rib_restart(struct rib_context *ctx)
re->flags &= ~F_RIB_ENTRYLOCK;
/* find first non empty element */
@@ -112,7 +122,7 @@ diff -u -p -r1.1.1.7 -r1.6
re = RB_NEXT(rib_tree, unused, re);
/* free the previously locked rib element if empty */
-@@ -632,11 +637,11 @@ prefix_compare(const struct bgpd_addr *a
+@@ -632,11 +639,11 @@ prefix_compare(const struct bgpd_addr *a
int i;
u_int8_t m;
@@ -128,7 +138,7 @@ diff -u -p -r1.1.1.7 -r1.6
if (prefixlen > 32)
fatalx("prefix_cmp: bad IPv4 prefixlen");
mask = htonl(prefixlen2mask(prefixlen));
-@@ -645,7 +650,7 @@ prefix_compare(const struct bgpd_addr *a
+@@ -645,7 +652,7 @@ prefix_compare(const struct bgpd_addr *a
if (aa != ba)
return (aa - ba);
return (0);
@@ -137,7 +147,7 @@ diff -u -p -r1.1.1.7 -r1.6
if (prefixlen > 128)
fatalx("prefix_cmp: bad IPv6 prefixlen");
for (i = 0; i < prefixlen / 8; i++)
-@@ -660,6 +665,24 @@ prefix_compare(const struct bgpd_addr *a
+@@ -660,6 +667,24 @@ prefix_compare(const struct bgpd_addr *a
(b->v6.s6_addr[prefixlen / 8] & m));
}
return (0);
@@ -162,7 +172,7 @@ diff -u -p -r1.1.1.7 -r1.6
default:
fatalx("prefix_cmp: unknown af");
}
-@@ -806,16 +829,33 @@ prefix_write(u_char *buf, int len, struc
+@@ -806,16 +831,33 @@ prefix_write(u_char *buf, int len, struc
{
int totlen;
@@ -203,7 +213,91 @@ diff -u -p -r1.1.1.7 -r1.6
}
/*
-@@ -1070,10 +1110,6 @@ nexthop_update(struct kroute_nexthop *ms
+@@ -861,7 +903,7 @@ prefix_updateall(struct rde_aspath *asp,
+ */
+ if ((p->rib->flags & F_RIB_NOFIB) == 0 &&
+ p == p->rib->active)
+- rde_send_kroute(p, NULL);
++ rde_send_kroute(p, NULL, p->rib->ribid);
+ continue;
+ }
+
+@@ -885,16 +927,12 @@ prefix_updateall(struct rde_aspath *asp,
+ void
+ prefix_destroy(struct prefix *p)
+ {
+- struct rib_entry *re;
+ struct rde_aspath *asp;
+
+- re = p->rib;
+ asp = p->aspath;
+ prefix_unlink(p);
+ prefix_free(p);
+
+- if (rib_empty(re))
+- rib_remove(re);
+ if (path_empty(asp))
+ path_destroy(asp);
+ }
+@@ -907,7 +945,6 @@ prefix_network_clean(struct rde_peer *pe
+ {
+ struct rde_aspath *asp, *xasp;
+ struct prefix *p, *xp;
+- struct pt_entry *pte;
+
+ for (asp = LIST_FIRST(&peer->path_h); asp != NULL; asp = xasp) {
+ xasp = LIST_NEXT(asp, peer_l);
+@@ -916,12 +953,8 @@ prefix_network_clean(struct rde_peer *pe
+ for (p = LIST_FIRST(&asp->prefix_h); p != NULL; p = xp) {
+ xp = LIST_NEXT(p, path_l);
+ if (reloadtime > p->lastchange) {
+- pte = p->prefix;
+ prefix_unlink(p);
+ prefix_free(p);
+-
+- if (pt_empty(pte))
+- pt_remove(pte);
+ }
+ }
+ if (path_empty(asp))
+@@ -954,11 +987,11 @@ prefix_link(struct prefix *pref, struct
+ static void
+ prefix_unlink(struct prefix *pref)
+ {
+- if (pref->rib) {
+- /* make route decision */
+- LIST_REMOVE(pref, rib_l);
+- prefix_evaluate(NULL, pref->rib);
+- }
++ struct rib_entry *re = pref->rib;
++
++ /* make route decision */
++ LIST_REMOVE(pref, rib_l);
++ prefix_evaluate(NULL, re);
+
+ LIST_REMOVE(pref, path_l);
+ PREFIX_COUNT(pref->aspath, -1);
+@@ -966,6 +999,8 @@ prefix_unlink(struct prefix *pref)
+ pt_unref(pref->prefix);
+ if (pt_empty(pref->prefix))
+ pt_remove(pref->prefix);
++ if (rib_empty(re))
++ rib_remove(re);
+
+ /* destroy all references to other objects */
+ pref->aspath = NULL;
+@@ -973,8 +1008,8 @@ prefix_unlink(struct prefix *pref)
+ pref->rib = NULL;
+
+ /*
+- * It's the caller's duty to remove empty aspath respectively pt_entry
+- * structures. Also freeing the unlinked prefix is the caller's duty.
++ * It's the caller's duty to remove empty aspath structures.
++ * Also freeing the unlinked prefix is the caller's duty.
+ */
+ }
+
+@@ -1070,10 +1105,6 @@ nexthop_update(struct kroute_nexthop *ms
return;
}
@@ -214,7 +308,7 @@ diff -u -p -r1.1.1.7 -r1.6
oldstate = nh->state;
if (msg->valid)
nh->state = NEXTHOP_REACH;
-@@ -1088,21 +1124,13 @@ nexthop_update(struct kroute_nexthop *ms
+@@ -1088,21 +1119,13 @@ nexthop_update(struct kroute_nexthop *ms
memcpy(&nh->true_nexthop, &msg->gateway,
sizeof(nh->true_nexthop));
@@ -243,7 +337,7 @@ diff -u -p -r1.1.1.7 -r1.6
if (rde_noevaluate())
/*
-@@ -1118,7 +1146,7 @@ nexthop_update(struct kroute_nexthop *ms
+@@ -1118,7 +1141,7 @@ nexthop_update(struct kroute_nexthop *ms
void
nexthop_modify(struct rde_aspath *asp, struct bgpd_addr *nexthop,
@@ -252,7 +346,7 @@ diff -u -p -r1.1.1.7 -r1.6
{
struct nexthop *nh;
-@@ -1138,7 +1166,7 @@ nexthop_modify(struct rde_aspath *asp, s
+@@ -1138,7 +1161,7 @@ nexthop_modify(struct rde_aspath *asp, s
asp->flags |= F_NEXTHOP_SELF;
return;
}
@@ -261,7 +355,7 @@ diff -u -p -r1.1.1.7 -r1.6
return;
nh = nexthop_get(nexthop);
-@@ -1233,17 +1261,17 @@ nexthop_compare(struct nexthop *na, stru
+@@ -1233,17 +1256,17 @@ nexthop_compare(struct nexthop *na, stru
a = &na->exit_nexthop;
b = &nb->exit_nexthop;
@@ -284,7 +378,7 @@ diff -u -p -r1.1.1.7 -r1.6
return (memcmp(&a->v6, &b->v6, sizeof(struct in6_addr)));
default:
fatalx("nexthop_cmp: unknown af");
-@@ -1269,14 +1297,14 @@ nexthop_hash(struct bgpd_addr *nexthop)
+@@ -1269,14 +1292,14 @@ nexthop_hash(struct bgpd_addr *nexthop)
{
u_int32_t h = 0;