Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
aports
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Müller
aports
Commits
7c8ec269
Commit
7c8ec269
authored
15 years ago
by
Natanael Copa
Browse files
Options
Downloads
Patches
Plain Diff
extra/quagga: upgrade to 0.99.12
parent
75a7aeb5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
extra/quagga/APKBUILD
+4
-8
4 additions, 8 deletions
extra/quagga/APKBUILD
extra/quagga/quagga-0.99.11-checksum.patch
+0
-654
0 additions, 654 deletions
extra/quagga/quagga-0.99.11-checksum.patch
extra/quagga/quagga-CVE-2009-1572.patch
+0
-461
0 additions, 461 deletions
extra/quagga/quagga-CVE-2009-1572.patch
with
4 additions
and
1123 deletions
extra/quagga/APKBUILD
+
4
−
8
View file @
7c8ec269
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname
=
quagga
pkgver
=
0.99.1
1
pkgrel
=
1
0
pkgver
=
0.99.1
2
pkgrel
=
0
pkgdesc
=
"A free routing daemon replacing Zebra supporting RIP, OSPF and BGP."
url
=
"http://quagga.net/"
license
=
"GPL-2"
depends
=
"
uclibc readline ncurses
iproute2"
depends
=
"iproute2"
makedepends
=
"readline-dev ncurses-dev
autoconf automake libtool"
install
=
"
$pkgname
.pre-install
$pkgname
.post-install"
...
...
@@ -13,12 +13,10 @@ subpackages="$pkgname-dev $pkgname-doc"
source
=
"http://www.quagga.net/download/
$pkgname
-
$pkgver
.tar.gz
$pkgname
-0.99.11-link-libcap.patch
$pkgname
-0.99.11-ipv6.patch
$pkgname
-0.99.11-checksum.patch
$pkgname
-0.99.11-ipv6-only.patch
$pkgname
-0.99.11-del-routes.patch
$pkgname
-0.99.11-zombie.patch
$pkgname
-0.99.11-fd-leak.patch
$pkgname
-CVE-2009-1572.patch
bgpd.initd
ospf6d.initd
ospfd.initd
...
...
@@ -65,15 +63,13 @@ build() {
done
install
-Dm644
"
$srcdir
/zebra.confd"
"
$pkgdir
"
/etc/conf.d/zebra
}
md5sums
=
"
903e40c744730ad4d62bee872eeb813b
quagga-0.99.1
1
.tar.gz
md5sums
=
"
d2bb513f4ac113dbb300c15a0bd0a241
quagga-0.99.1
2
.tar.gz
8f99d41a8ed79e51704e8f655d255f29 quagga-0.99.11-link-libcap.patch
d73000d128eaf20a17ffb15b5ca1805a quagga-0.99.11-ipv6.patch
7e1c0152d4733b713613e10df207e3a9 quagga-0.99.11-checksum.patch
44c517e988273e0e5076d24f3959a125 quagga-0.99.11-ipv6-only.patch
1cbcf60a637b2577dee4d6df711e1247 quagga-0.99.11-del-routes.patch
ce345725f2e7240cebe0fd5ac2b2fc48 quagga-0.99.11-zombie.patch
e2391e19b542ec1743776ca9e36ac11a quagga-0.99.11-fd-leak.patch
ab0119615ef8379b523fce30e774f93e quagga-CVE-2009-1572.patch
cc109a746273bc0d6aee9d758e7524ab bgpd.initd
44547b687343ebfed7524cebc5626067 ospf6d.initd
89b0cf4e70172bfcd195b2869cae28da ospfd.initd
...
...
This diff is collapsed.
Click to expand it.
extra/quagga/quagga-0.99.11-checksum.patch
deleted
100644 → 0
+
0
−
654
View file @
75a7aeb5
From: Paul Jakma <paul.jakma@sun.com>
Date: Sun, 16 Nov 2008 18:34:19 +0000 (+0000)
Subject: [lib] Switch Fletcher checksum back to old ospfd version
X-Git-Url: http://code.quagga.net/cgi-bin/gitweb.cgi?p=quagga.git;a=commitdiff_plain;h=5d4b8cf2faba9f5386810a7c70837e5b7fae3572
[lib] Switch Fletcher checksum back to old ospfd version
* lib/checksum.c: (fletcher_checksum) Switch the second phase of the checksum
back to the old ospfd logic.
The isisd-derived version:
a) is very hard to follow
b) had some kind of subtle bug that caused it be wrong when c0=0 and c1=254
(potentially fixable by doing the mods before adjusting x and y)
Additionally:
- explicitely cast expressions using non-internal variables to int, to ensure
the result is signed.
- defensively change the length argument to 'size_t', to ensure the code
works with that argument being unsigned..
Thanks to Joakim Tjernlund for the investigative work into this bug.
* tests/test-checksum.c: new file to exercise the checksum code.
---
diff --git a/lib/checksum.c b/lib/checksum.c
index 88ec72a..f6d74d3 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -52,34 +52,31 @@
in_cksum(void *parg, int nbytes)
/* To be consistent, offset is 0-based index, rather than the 1-based
index required in the specification ISO 8473, Annex C.1 */
u_int16_t
-fletcher_checksum(u_char * buffer, int len, u_int16_t offset)
+fletcher_checksum(u_char * buffer, const size_t len, const uint16_t offset)
{
u_int8_t *p;
- int x;
- int y;
- u_int32_t mul;
- u_int32_t c0;
- u_int32_t c1;
+ int x, y, c0, c1;
u_int16_t checksum;
u_int16_t *csum;
- int i, init_len, partial_len;
-
+ size_t partial_len, i, left = len;
+
checksum = 0;
+ assert (offset < len);
+
/*
* Zero the csum in the packet.
*/
csum = (u_int16_t *) (buffer + offset);
- *(csum) = checksum;
+ *(csum) = 0;
p = buffer;
c0 = 0;
c1 = 0;
- init_len = len;
- while (len != 0)
+ while (left != 0)
{
- partial_len = MIN(len, MODX);
+ partial_len = MIN(left, MODX);
for (i = 0; i < partial_len; i++)
{
@@ -90,27 +87,18 @@
fletcher_checksum(u_char * buffer, int len, u_int16_t offset)
c0 = c0 % 255;
c1 = c1 % 255;
- len -= partial_len;
+ left -= partial_len;
}
-
- mul = (init_len - offset)*(c0);
-
- x = mul - c0 - c1;
- y = c1 - mul - 1;
-
- if (y > 0)
- y++;
- if (x < 0)
- x--;
-
- x %= 255;
- y %= 255;
-
- if (x == 0)
- x = 255;
- if (y == 0)
- y = 1;
-
+
+ /* The cast is important, to ensure the mod is taken as a signed value. */
+ x = ((int)(len - offset - 1) * c0 - c1) % 255;
+
+ if (x <= 0)
+ x += 255;
+ y = 510 - c0 - x;
+ if (y > 255)
+ y -= 255;
+
/*
* Now we write this to the packet.
* We could skip this step too, since the checksum returned would
diff --git a/lib/checksum.h b/lib/checksum.h
index d3ce930..da1d3cb 100644
--- a/lib/checksum.h
+++ b/lib/checksum.h
@@ -1,2 +1,2 @@
extern int in_cksum(void *, int);
-extern u_int16_t fletcher_checksum(u_char * buffer, int len, u_int16_t offset);
+extern u_int16_t fletcher_checksum(u_char *, const size_t len, const uint16_t offset);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c93fa08..4ab507b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,7 +6,7 @@
AM_LDFLAGS = $(PILDFLAGS)
noinst_PROGRAMS = testsig testbuffer testmemory heavy heavywq heavythread \
aspathtest testprivs teststream testbgpcap ecommtest \
- testbgpmpattr
+ testbgpmpattr testchecksum
testsig_SOURCES = test-sig.c
testbuffer_SOURCES = test-buffer.c
@@ -20,6 +20,7 @@
aspathtest_SOURCES = aspath_test.c
testbgpcap_SOURCES = bgp_capability_test.c
ecommtest_SOURCES = ecommunity_test.c
testbgpmpattr_SOURCES = bgp_mp_attr_test.c
+testchecksum_SOURCES = test-checksum.c
testsig_LDADD = ../lib/libzebra.la @LIBCAP@
testbuffer_LDADD = ../lib/libzebra.la @LIBCAP@
@@ -33,3 +34,4 @@
aspathtest_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a
testbgpcap_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a
ecommtest_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a
testbgpmpattr_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a
+testchecksum_LDADD = ../lib/libzebra.la @LIBCAP@
diff --git a/tests/test-checksum.c b/tests/test-checksum.c
new file mode 100644
index 0000000..d218840
--- /dev/null
+++ b/tests/test-checksum.c
@@ -0,0 +1,499 @@
+#include <zebra.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "checksum.h"
+
+struct thread_master *master;
+
+struct acc_vals {
+ int c0;
+ int c1;
+};
+
+struct csum_vals {
+ struct acc_vals a;
+ int x;
+ int y;
+};
+
+static struct csum_vals ospfd_vals, isisd_vals;
+
+typedef size_t testsz_t;
+typedef uint16_t testoff_t;
+
+/* Fletcher Checksum -- Refer to RFC1008. */
+#define MODX 4102
+
+/* Accumulator phase of checksum */
+static
+struct acc_vals
+accumulate (u_char *buffer, testsz_t len, testoff_t off)
+{
+ u_int8_t *p;
+ u_int16_t *csum;
+ int i, init_len, partial_len;
+ struct acc_vals ret;
+
+ csum = (u_int16_t *) (buffer + off);
+ *(csum) = 0;
+
+ p = buffer;
+ ret.c0 = 0;
+ ret.c1 = 0;
+ init_len = len;
+
+ while (len != 0)
+ {
+ partial_len = MIN(len, MODX);
+
+ for (i = 0; i < partial_len; i++)
+ {
+ ret.c0 = ret.c0 + *(p++);
+ ret.c1 += ret.c0;
+ }
+
+ ret.c0 = ret.c0 % 255;
+ ret.c1 = ret.c1 % 255;
+
+ len -= partial_len;
+ }
+ return ret;
+}
+
+/* The final reduction phase.
+ * This one should be the original ospfd version
+ */
+static u_int16_t
+reduce_ospfd (struct csum_vals *vals, testsz_t len, testoff_t off)
+{
+#define x vals->x
+#define y vals->y
+#define c0 vals->a.c0
+#define c1 vals->a.c1
+
+ x = ((len - off - 1) * c0 - c1) % 255;
+
+ if (x <= 0)
+ x += 255;
+ y = 510 - c0 - x;
+ if (y > 255)
+ y -= 255;
+
+ /* take care endian issue. */
+ return htons ((x << 8) + y);
+#undef x
+#undef y
+#undef c0
+#undef c1
+}
+
+/* slightly different concatenation */
+static u_int16_t
+reduce_ospfd1 (struct csum_vals *vals, testsz_t len, testoff_t off)
+{
+#define x vals->x
+#define y vals->y
+#define c0 vals->a.c0
+#define c1 vals->a.c1
+
+ x = ((len - off - 1) * c0 - c1) % 255;
+ if (x <= 0)
+ x += 255;
+ y = 510 - c0 - x;
+ if (y > 255)
+ y -= 255;
+
+ /* take care endian issue. */
+ return htons ((x << 8) | (y & 0xff));
+#undef x
+#undef y
+#undef c0
+#undef c1
+}
+
+/* original isisd version */
+static u_int16_t
+reduce_isisd (struct csum_vals *vals, testsz_t len, testoff_t off)
+{
+#define x vals->x
+#define y vals->y
+#define c0 vals->a.c0
+#define c1 vals->a.c1
+ u_int32_t mul;
+
+ mul = (len - off)*(c0);
+ x = mul - c0 - c1;
+ y = c1 - mul - 1;
+
+ if (y > 0)
+ y++;
+ if (x < 0)
+ x--;
+
+ x %= 255;
+ y %= 255;
+
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 1;
+
+ return htons ((x << 8) | (y & 0xff));
+
+#undef x
+#undef y
+#undef c0
+#undef c1
+}
+
+/* Is the -1 in y wrong perhaps? */
+static u_int16_t
+reduce_isisd_yfix (struct csum_vals *vals, testsz_t len, testoff_t off)
+{
+#define x vals->x
+#define y vals->y
+#define c0 vals->a.c0
+#define c1 vals->a.c1
+ u_int32_t mul;
+
+ mul = (len - off)*(c0);
+ x = mul - c0 - c1;
+ y = c1 - mul;
+
+ if (y > 0)
+ y++;
+ if (x < 0)
+ x--;
+
+ x %= 255;
+ y %= 255;
+
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 1;
+
+ return htons ((x << 8) | (y & 0xff));
+
+#undef x
+#undef y
+#undef c0
+#undef c1
+}
+
+/* Move the mods yp */
+static u_int16_t
+reduce_isisd_mod (struct csum_vals *vals, testsz_t len, testoff_t off)
+{
+#define x vals->x
+#define y vals->y
+#define c0 vals->a.c0
+#define c1 vals->a.c1
+ u_int32_t mul;
+
+ mul = (len - off)*(c0);
+ x = mul - c1 - c0;
+ y = c1 - mul - 1;
+
+ x %= 255;
+ y %= 255;
+
+ if (y > 0)
+ y++;
+ if (x < 0)
+ x--;
+
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 1;
+
+ return htons ((x << 8) | (y & 0xff));
+
+#undef x
+#undef y
+#undef c0
+#undef c1
+}
+
+/* Move the mods up + fix y */
+static u_int16_t
+reduce_isisd_mody (struct csum_vals *vals, testsz_t len, testoff_t off)
+{
+#define x vals->x
+#define y vals->y
+#define c0 vals->a.c0
+#define c1 vals->a.c1
+ u_int32_t mul;
+
+ mul = (len - off)*(c0);
+ x = mul - c0 - c1;
+ y = c1 - mul;
+
+ x %= 255;
+ y %= 255;
+
+ if (y > 0)
+ y++;
+ if (x < 0)
+ x--;
+
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 1;
+
+ return htons ((x << 8) | (y & 0xff));
+
+#undef x
+#undef y
+#undef c0
+#undef c1
+}
+
+struct reductions_t {
+ const char *name;
+ u_int16_t (*f) (struct csum_vals *, testsz_t, testoff_t);
+} reducts[] = {
+ { .name = "ospfd", .f = reduce_ospfd },
+ { .name = "ospfd-1", .f = reduce_ospfd1 },
+ { .name = "isisd", .f = reduce_isisd },
+ { .name = "isisd-yfix", .f = reduce_isisd_yfix },
+ { .name = "isisd-mod", .f = reduce_isisd_mod },
+ { .name = "isisd-mody", .f = reduce_isisd_mody },
+ { NULL, NULL },
+};
+
+/* The original ospfd checksum */
+static u_int16_t
+ospfd_checksum (u_char *buffer, testsz_t len, testoff_t off)
+{
+ u_char *sp, *ep, *p, *q;
+ int c0 = 0, c1 = 0;
+ int x, y;
+ u_int16_t checksum, *csum;
+
+ csum = (u_int16_t *) (buffer + off);
+ *(csum) = 0;
+
+ sp = buffer;
+
+ for (ep = sp + len; sp < ep; sp = q)
+ {
+ q = sp + MODX;
+ if (q > ep)
+ q = ep;
+ for (p = sp; p < q; p++)
+ {
+ c0 += *p;
+ c1 += c0;
+ }
+ c0 %= 255;
+ c1 %= 255;
+ }
+
+ ospfd_vals.a.c0 = c0;
+ ospfd_vals.a.c1 = c1;
+
+ //printf ("%s: len %u, off %u, c0 %d, c1 %d\n",
+ // __func__, len, off, c0, c1);
+
+ x = ((int)(len - off - 1) * (int)c0 - (int)c1) % 255;
+
+ if (x <= 0)
+ x += 255;
+ y = 510 - c0 - x;
+ if (y > 255)
+ y -= 255;
+
+ ospfd_vals.x = x;
+ ospfd_vals.y = y;
+
+ buffer[off] = x;
+ buffer[off + 1] = y;
+
+ /* take care endian issue. */
+ checksum = htons ((x << 8) | (y & 0xff));
+
+ return (checksum);
+}
+
+/* the original, broken isisd checksum */
+static u_int16_t
+iso_csum_create (u_char * buffer, testsz_t len, testoff_t off)
+{
+
+ u_int8_t *p;
+ int x;
+ int y;
+ u_int32_t mul;
+ u_int32_t c0;
+ u_int32_t c1;
+ u_int16_t checksum, *csum;
+ int i, init_len, partial_len;
+
+ checksum = 0;
+
+ csum = (u_int16_t *) (buffer + off);
+ *(csum) = checksum;
+
+ p = buffer;
+ c0 = 0;
+ c1 = 0;
+ init_len = len;
+
+ while (len != 0)
+ {
+ partial_len = MIN(len, MODX);
+
+ for (i = 0; i < partial_len; i++)
+ {
+ c0 = c0 + *(p++);
+ c1 += c0;
+ }
+
+ c0 = c0 % 255;
+ c1 = c1 % 255;
+
+ len -= partial_len;
+ }
+
+ isisd_vals.a.c0 = c0;
+ isisd_vals.a.c1 = c1;
+
+ mul = (init_len - off) * c0;
+
+ x = mul - c1 - c0;
+ y = c1 - mul - 1;
+
+ if (y > 0)
+ y++;
+ if (x < 0)
+ x--;
+
+ x %= 255;
+ y %= 255;
+
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 1;
+
+ isisd_vals.x = x;
+ isisd_vals.y = y;
+
+ checksum = htons((x << 8) | (y & 0xFF));
+
+ *(csum) = checksum;
+
+ /* return the checksum for user usage */
+ return checksum;
+}
+
+static int
+verify (u_char * buffer, testsz_t len)
+{
+ u_int8_t *p;
+ u_int32_t c0;
+ u_int32_t c1;
+ u_int16_t checksum;
+ int i, partial_len;
+
+ p = buffer;
+ checksum = 0;
+
+ c0 = 0;
+ c1 = 0;
+
+ while (len)
+ {
+ partial_len = MIN(len, 5803);
+
+ for (i = 0; i < partial_len; i++)
+ {
+ c0 = c0 + *(p++);
+ c1 += c0;
+ }
+ c0 = c0 % 255;
+ c1 = c1 % 255;
+
+ len -= partial_len;
+ }
+
+ if (c0 == 0 && c1 == 0)
+ return 0;
+
+ return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+/* 60017 65629 702179 */
+#define MAXDATALEN 60017
+#define BUFSIZE MAXDATALEN + sizeof(u_int16_t)
+ u_char buffer[BUFSIZE];
+ int exercise = 0;
+#define EXERCISESTEP 257
+
+ srandom (time (NULL));
+
+ while (1) {
+ u_int16_t ospfd, isisd, lib;
+
+ exercise += EXERCISESTEP;
+ exercise %= MAXDATALEN;
+
+ for (int i = 0; i < exercise; i += sizeof (long int)) {
+ long int rand = random ();
+
+ for (int j = sizeof (long int); j > 0; j--)
+ buffer[i + (sizeof (long int) - j)] = (rand >> (j * 8)) & 0xff;
+ }
+
+ ospfd = ospfd_checksum (buffer, exercise + sizeof(u_int16_t), exercise);
+ if (verify (buffer, exercise + sizeof(u_int16_t)))
+ printf ("verify: ospfd failed\n");
+ isisd = iso_csum_create (buffer, exercise + sizeof(u_int16_t), exercise);
+ if (verify (buffer, exercise + sizeof(u_int16_t)))
+ printf ("verify: isisd failed\n");
+ lib = fletcher_checksum (buffer, exercise + sizeof(u_int16_t), exercise);
+ if (verify (buffer, exercise + sizeof(u_int16_t)))
+ printf ("verify: lib failed\n");
+
+ if (ospfd != lib) {
+ printf ("Mismatch in values at size %u\n"
+ "ospfd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
+ "isisd: 0x%04x\tc0: %d\tc1: %d\tx: %d\ty: %d\n"
+ "lib: 0x%04x\n",
+ exercise,
+ ospfd, ospfd_vals.a.c0, ospfd_vals.a.c1, ospfd_vals.x, ospfd_vals.y,
+ isisd, isisd_vals.a.c0, isisd_vals.a.c1, isisd_vals.x, isisd_vals.y,
+ lib
+ );
+
+ /* Investigate reduction phase discrepencies */
+ if (ospfd_vals.a.c0 == isisd_vals.a.c0
+ && ospfd_vals.a.c1 == isisd_vals.a.c1) {
+ printf ("\n");
+ for (int i = 0; reducts[i].name != NULL; i++) {
+ ospfd = reducts[i].f (&ospfd_vals,
+ exercise + sizeof (u_int16_t),
+ exercise);
+ printf ("%20s: x: %02x, y %02x, checksum 0x%04x\n",
+ reducts[i].name, ospfd_vals.x & 0xff, ospfd_vals.y & 0xff, ospfd);
+ }
+ }
+
+ printf ("\n u_char testdata [] = {\n ");
+ for (int i = 0; i < exercise; i++) {
+ printf ("0x%02x,%s",
+ buffer[i],
+ (i + 1) % 8 ? " " : "\n ");
+ }
+ printf ("\n}\n");
+ exit (1);
+ }
+ }
+}
This diff is collapsed.
Click to expand it.
extra/quagga/quagga-CVE-2009-1572.patch
deleted
100644 → 0
+
0
−
461
View file @
75a7aeb5
* bgpd/bgp_aspath.c: (aspath_make_str_count) "assert (len < str_size)" was
getting hit under certain 4-byte ASN conditions. New realloc strategy.
* bgpd/bgp_aspath.c: (aspath_key_make) const warning fix.
"%d" -> "%u" 4-byte ASN corrections. Prevent negative number when ASN is
above 2^31.:
bgpd/bgp_attr.c
bgpd/bgp_community.c
bgpd/bgp_debug.c
bgpd/bgp_ecommunity.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_packet.c
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgpd.c
---
bgpd/bgp_aspath.c | 85 ++++++++++++++++++-------------------------------
bgpd/bgp_attr.c | 2 +-
bgpd/bgp_community.c | 2 +-
bgpd/bgp_debug.c | 2 +-
bgpd/bgp_ecommunity.c | 4 +-
bgpd/bgp_mplsvpn.c | 6 ++--
bgpd/bgp_packet.c | 8 ++--
bgpd/bgp_route.c | 8 ++--
bgpd/bgp_vty.c | 20 ++++++------
bgpd/bgpd.c | 10 +++---
10 files changed, 62 insertions(+), 85 deletions(-)
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 006fc91..a1e4608 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -393,25 +393,6 @@
aspath_delimiter_char (u_char type, u_char which)
return ' ';
}
-/* countup asns from this segment and index onward */
-static int
-assegment_count_asns (struct assegment *seg, int from)
-{
- int count = 0;
- while (seg)
- {
- if (!from)
- count += seg->length;
- else
- {
- count += (seg->length - from);
- from = 0;
- }
- seg = seg->next;
- }
- return count;
-}
-
unsigned int
aspath_count_confeds (struct aspath *aspath)
{
@@ -521,6 +502,21 @@
aspath_count_numas (struct aspath *aspath)
return num;
}
+static void
+aspath_make_str_big_enough (int len,
+ char **str_buf,
+ int *str_size,
+ int count_to_be_added)
+{
+#define TERMINATOR 1
+ while (len + count_to_be_added + TERMINATOR > *str_size)
+ {
+ *str_size *= 2;
+ *str_buf = XREALLOC (MTYPE_AS_STR, *str_buf, *str_size);
+ }
+#undef TERMINATOR
+}
+
/* Convert aspath structure to string expression. */
static char *
aspath_make_str_count (struct aspath *as)
@@ -540,18 +536,7 @@
aspath_make_str_count (struct aspath *as)
seg = as->segments;
- /* ASN takes 5 chars at least, plus seperator, see below.
- * If there is one differing segment type, we need an additional
- * 2 chars for segment delimiters, and the final '\0'.
- * Hopefully this is large enough to avoid hitting the realloc
- * code below for most common sequences.
- *
- * With 32bit ASNs, this range will increase, but only worth changing
- * once there are significant numbers of ASN >= 100000
- */
-#define ASN_STR_LEN (5 + 1)
- str_size = MAX (assegment_count_asns (seg, 0) * ASN_STR_LEN + 2 + 1,
- ASPATH_STR_DEFAULT_LEN);
+ str_size = ASPATH_STR_DEFAULT_LEN;
str_buf = XMALLOC (MTYPE_AS_STR, str_size);
while (seg)
@@ -575,32 +560,24 @@
aspath_make_str_count (struct aspath *as)
return NULL;
}
- /* We might need to increase str_buf, particularly if path has
- * differing segments types, our initial guesstimate above will
- * have been wrong. need 5 chars for ASN, a seperator each and
- * potentially two segment delimiters, plus a space between each
- * segment and trailing zero.
- *
- * This may need to revised if/when significant numbers of
- * ASNs >= 100000 are assigned and in-use on the internet...
- */
-#define SEGMENT_STR_LEN(X) (((X)->length * ASN_STR_LEN) + 2 + 1 + 1)
- if ( (len + SEGMENT_STR_LEN(seg)) > str_size)
- {
- str_size = len + SEGMENT_STR_LEN(seg);
- str_buf = XREALLOC (MTYPE_AS_STR, str_buf, str_size);
- }
-#undef ASN_STR_LEN
-#undef SEGMENT_STR_LEN
-
if (seg->type != AS_SEQUENCE)
- len += snprintf (str_buf + len, str_size - len,
- "%c",
- aspath_delimiter_char (seg->type, AS_SEG_START));
+ {
+ aspath_make_str_big_enough (len, &str_buf, &str_size, 1); /* %c */
+ len += snprintf (str_buf + len, str_size - len,
+ "%c",
+ aspath_delimiter_char (seg->type, AS_SEG_START));
+ }
/* write out the ASNs, with their seperators, bar the last one*/
for (i = 0; i < seg->length; i++)
{
+#define APPROX_DIG_CNT(x) (x < 100000U ? 5 : 10)
+ /* %u + %c + %c + " " (last two are below loop) */
+ aspath_make_str_big_enough (len,
+ &str_buf,
+ &str_size,
+ APPROX_DIG_CNT(seg->as[i]) + 1 + 1 + 1);
+
len += snprintf (str_buf + len, str_size - len, "%u", seg->as[i]);
if (i < (seg->length - 1))
@@ -1771,8 +1748,8 @@
aspath_key_make (void *p)
static int
aspath_cmp (const void *arg1, const void *arg2)
{
- const struct assegment *seg1 = ((struct aspath *)arg1)->segments;
- const struct assegment *seg2 = ((struct aspath *)arg2)->segments;
+ const struct assegment *seg1 = ((const struct aspath *)arg1)->segments;
+ const struct assegment *seg2 = ((const struct aspath *)arg2)->segments;
while (seg1 || seg2)
{
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index d116c30..f38db41 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -857,7 +857,7 @@
static int bgp_attr_aspath_check( struct peer *peer,
&& ! aspath_firstas_check (attr->aspath, peer->as))
{
zlog (peer->log, LOG_ERR,
- "%s incorrect first AS (must be %d)", peer->host, peer->as);
+ "%s incorrect first AS (must be %u)", peer->host, peer->as);
bgp_notify_send (peer,
BGP_NOTIFY_UPDATE_ERR,
BGP_NOTIFY_UPDATE_MAL_AS_PATH);
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 1cafdb3..a05ea6c 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -282,7 +282,7 @@
community_com2str (struct community *com)
default:
as = (comval >> 16) & 0xFFFF;
val = comval & 0xFFFF;
- sprintf (pnt, "%d:%d", as, val);
+ sprintf (pnt, "%u:%d", as, val);
pnt += strlen (pnt);
break;
}
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 757b9cf..1d5bf6b 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -205,7 +205,7 @@
bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
- snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s",
+ snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %u %s",
attr->extra->aggregator_as,
inet_ntoa (attr->extra->aggregator_addr));
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index c08673c..27c3cd6 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -673,7 +673,7 @@
ecommunity_ecom2str (struct ecommunity *ecom, int format)
eas.val = (*pnt++ << 8);
eas.val |= (*pnt++);
- len = sprintf( str_buf + str_pnt, "%s%d:%d", prefix,
+ len = sprintf( str_buf + str_pnt, "%s%u:%d", prefix,
eas.as, eas.val );
str_pnt += len;
first = 0;
@@ -688,7 +688,7 @@
ecommunity_ecom2str (struct ecommunity *ecom, int format)
eas.val |= (*pnt++ << 8);
eas.val |= (*pnt++);
- len = sprintf (str_buf + str_pnt, "%s%d:%d", prefix,
+ len = sprintf (str_buf + str_pnt, "%s%u:%d", prefix,
eas.as, eas.val);
str_pnt += len;
first = 0;
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index ac90f3c..72ad089 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -265,7 +265,7 @@
prefix_rd2str (struct prefix_rd *prd, char *buf, size_t size)
if (type == RD_TYPE_AS)
{
decode_rd_as (pnt + 2, &rd_as);
- snprintf (buf, size, "%d:%d", rd_as.as, rd_as.val);
+ snprintf (buf, size, "%u:%d", rd_as.as, rd_as.val);
return buf;
}
else if (type == RD_TYPE_IP)
@@ -371,7 +371,7 @@
show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd)
vty_out (vty, "Route Distinguisher: ");
if (type == RD_TYPE_AS)
- vty_out (vty, "%d:%d", rd_as.as, rd_as.val);
+ vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
else if (type == RD_TYPE_IP)
vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
@@ -478,7 +478,7 @@
bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type ty
vty_out (vty, "Route Distinguisher: ");
if (type == RD_TYPE_AS)
- vty_out (vty, "%d:%d", rd_as.as, rd_as.val);
+ vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
else if (type == RD_TYPE_IP)
vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 1422bad..de02bb8 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -813,7 +813,7 @@
bgp_open_send (struct peer *peer)
length = bgp_packet_set_size (s);
if (BGP_DEBUG (normal, NORMAL))
- zlog_debug ("%s sending OPEN, version %d, my as %d, holdtime %d, id %s",
+ zlog_debug ("%s sending OPEN, version %d, my as %u, holdtime %d, id %s",
peer->host, BGP_VERSION_4, local_as,
send_holdtime, inet_ntoa (peer->local_id));
@@ -1184,7 +1184,7 @@
bgp_open_receive (struct peer *peer, bgp_size_t size)
/* Receive OPEN message log */
if (BGP_DEBUG (normal, NORMAL))
- zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %d,"
+ zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %u,"
" holdtime %d, id %s",
peer->host, version, remote_as, holdtime,
inet_ntoa (remote_id));
@@ -1277,7 +1277,7 @@
bgp_open_receive (struct peer *peer, bgp_size_t size)
else
{
if (BGP_DEBUG (normal, NORMAL))
- zlog_debug ("%s bad OPEN, remote AS is %d, expected %d",
+ zlog_debug ("%s bad OPEN, remote AS is %u, expected %u",
peer->host, remote_as, peer->as);
bgp_notify_send_with_data (peer, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_PEER_AS,
@@ -1431,7 +1431,7 @@
bgp_open_receive (struct peer *peer, bgp_size_t size)
if (remote_as != peer->as)
{
if (BGP_DEBUG (normal, NORMAL))
- zlog_debug ("%s bad OPEN, remote AS is %d, expected %d",
+ zlog_debug ("%s bad OPEN, remote AS is %u, expected %u",
peer->host, remote_as, peer->as);
bgp_notify_send_with_data (peer,
BGP_NOTIFY_OPEN_ERR,
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 50407e4..6b7828c 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -834,7 +834,7 @@
bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
{
if (BGP_DEBUG (filter, FILTER))
zlog (peer->log, LOG_DEBUG,
- "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
+ "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
peer->host, peer->as);
return 0;
}
@@ -847,7 +847,7 @@
bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
{
if (BGP_DEBUG (filter, FILTER))
zlog (peer->log, LOG_DEBUG,
- "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
+ "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
peer->host,
bgp->confed_id);
return 0;
@@ -1163,7 +1163,7 @@
bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
{
if (BGP_DEBUG (filter, FILTER))
zlog (rsclient->log, LOG_DEBUG,
- "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
+ "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
rsclient->host, rsclient->as);
return 0;
}
@@ -5956,7 +5956,7 @@
route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
vty_out (vty, ", (stale)");
if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
- vty_out (vty, ", (aggregated by %d %s)",
+ vty_out (vty, ", (aggregated by %u %s)",
attr->extra->aggregator_as,
inet_ntoa (attr->extra->aggregator_addr));
if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index bd94c66..96719a1 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -360,11 +360,11 @@
DEFUN (router_bgp,
VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_AS_MISMATCH:
- vty_out (vty, "BGP is already running; AS is %d%s", as, VTY_NEWLINE);
+ vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_INSTANCE_MISMATCH:
vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
- vty_out (vty, "BGP instance is already running; AS is %d%s",
+ vty_out (vty, "BGP instance is already running; AS is %u%s",
as, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -1306,10 +1306,10 @@
peer_remote_as_vty (struct vty *vty, const char *peer_str,
switch (ret)
{
case BGP_ERR_PEER_GROUP_MEMBER:
- vty_out (vty, "%% Peer-group AS %d. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
+ vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
- vty_out (vty, "%% The AS# can not be changed from %d to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
+ vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
return CMD_WARNING;
}
return bgp_vty_return (vty, ret);
@@ -1647,7 +1647,7 @@
DEFUN (neighbor_set_peer_group,
if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
{
- vty_out (vty, "%% Peer with AS %d cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
+ vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -6912,7 +6912,7 @@
bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
/* Usage summary and header */
vty_out (vty,
- "BGP router identifier %s, local AS number %d%s",
+ "BGP router identifier %s, local AS number %u%s",
inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
ents = bgp_table_count (bgp->rib[afi][safi]);
@@ -6959,7 +6959,7 @@
bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
vty_out (vty, "4 ");
- vty_out (vty, "%5d %7d %7d %8d %4d %4lu ",
+ vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
peer->as,
peer->open_in + peer->update_in + peer->keepalive_in
+ peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
@@ -7469,8 +7469,8 @@
bgp_show_peer (struct vty *vty, struct peer *p)
/* Configured IP address. */
vty_out (vty, "BGP neighbor is %s, ", p->host);
- vty_out (vty, "remote AS %d, ", p->as);
- vty_out (vty, "local AS %d%s, ",
+ vty_out (vty, "remote AS %u, ", p->as);
+ vty_out (vty, "local AS %u%s, ",
p->change_local_as ? p->change_local_as : p->local_as,
CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
" no-prepend" : "");
@@ -8252,7 +8252,7 @@
bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
"Route Server's BGP router identifier %s%s",
inet_ntoa (bgp->router_id), VTY_NEWLINE);
vty_out (vty,
- "Route Server's local AS number %d%s", bgp->as,
+ "Route Server's local AS number %u%s", bgp->as,
VTY_NEWLINE);
vty_out (vty, "%s", VTY_NEWLINE);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 8eb0d2e..cebde0a 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -4512,13 +4512,13 @@
bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
vty_out (vty, " neighbor %s peer-group%s", addr,
VTY_NEWLINE);
if (peer->as)
- vty_out (vty, " neighbor %s remote-as %d%s", addr, peer->as,
+ vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as,
VTY_NEWLINE);
}
else
{
if (! g_peer->as)
- vty_out (vty, " neighbor %s remote-as %d%s", addr, peer->as,
+ vty_out (vty, " neighbor %s remote-as %u%s", addr, peer->as,
VTY_NEWLINE);
if (peer->af_group[AFI_IP][SAFI_UNICAST])
vty_out (vty, " neighbor %s peer-group %s%s", addr,
@@ -4528,7 +4528,7 @@
bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
/* local-as. */
if (peer->change_local_as)
if (! peer_group_active (peer))
- vty_out (vty, " neighbor %s local-as %d%s%s", addr,
+ vty_out (vty, " neighbor %s local-as %u%s%s", addr,
peer->change_local_as,
CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
" no-prepend" : "", VTY_NEWLINE);
@@ -4917,7 +4917,7 @@
bgp_config_write (struct vty *vty)
vty_out (vty, "!%s", VTY_NEWLINE);
/* Router bgp ASN */
- vty_out (vty, "router bgp %d", bgp->as);
+ vty_out (vty, "router bgp %u", bgp->as);
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
{
@@ -4978,7 +4978,7 @@
bgp_config_write (struct vty *vty)
vty_out (vty, " bgp confederation peers");
for (i = 0; i < bgp->confed_peers_cnt; i++)
- vty_out(vty, " %d", bgp->confed_peers[i]);
+ vty_out(vty, " %u", bgp->confed_peers[i]);
vty_out (vty, "%s", VTY_NEWLINE);
}
--
1.6.0.6
_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-dev
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment