diff options
author | David Lamparter <equinox@diac24.net> | 2010-02-05 16:24:01 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-05 17:43:17 +0100 |
commit | 57c7689229764e7a679c36cdec5405ef8544c5bd (patch) | |
tree | 9a037ca43580a0dfd038056e9cfad6742cfb6d0f | |
parent | 1bc5254798593fae60361dfac8b853f6c356895c (diff) | |
download | quagga-57c7689229764e7a679c36cdec5405ef8544c5bd.tar.bz2 quagga-57c7689229764e7a679c36cdec5405ef8544c5bd.tar.xz |
bgpd: fix "bgp: move cleanup fifo code"
a8c48bb76f291c673438d2061753d05a0d9b3276 very hiddenly broke the FIFO
logic by intermixing bgp_advertise's prev/next and bgp_advertise_fifo's
prev/next, causing bgpd to SEGV on establishing a peering.
let's better have bgp_advertise_fifo point to bgp_advertise_fifo again,
thus allowing the compiler to catch intermixtures. this also reduces the
number of casts from 3 to just one.
-rw-r--r-- | bgpd/bgp_advertise.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h index 53427eb3..323239dc 100644 --- a/bgpd/bgp_advertise.h +++ b/bgpd/bgp_advertise.h @@ -24,8 +24,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA /* BGP advertise FIFO. */ struct bgp_advertise_fifo { - struct bgp_advertise *next; - struct bgp_advertise *prev; + struct bgp_advertise_fifo *next; + struct bgp_advertise_fifo *prev; }; /* BGP advertise attribute. */ @@ -104,15 +104,15 @@ struct bgp_synchronize static inline void FIFO_INIT(struct bgp_advertise_fifo *fifo) { - fifo->next = fifo->prev = (struct bgp_advertise *) fifo; + fifo->next = fifo->prev = fifo; } static inline void FIFO_ADD(struct bgp_advertise_fifo *fifo, struct bgp_advertise *node) { - node->fifo.next = (struct bgp_advertise *) fifo; + node->fifo.next = fifo; node->fifo.prev = fifo->prev; - fifo->prev = fifo->prev->next = node; + fifo->prev = fifo->prev->next = &node->fifo; } static inline void FIFO_DEL(struct bgp_advertise *node) @@ -125,12 +125,12 @@ static inline void FIFO_DEL(struct bgp_advertise *node) static inline int FIFO_EMPTY(const struct bgp_advertise_fifo *fifo) { - return (fifo->next == (const struct bgp_advertise *) fifo); + return (fifo->next == fifo); } static inline struct bgp_advertise *FIFO_HEAD(struct bgp_advertise_fifo *fifo) { - return FIFO_EMPTY(fifo) ? NULL : fifo->next; + return FIFO_EMPTY(fifo) ? NULL : (struct bgp_advertise *)fifo->next; } |