summaryrefslogtreecommitdiffstats
path: root/tests/bgp_mp_attr_test.c
diff options
context:
space:
mode:
authorChris Hall <GMCH@hestia.halldom.com>2010-01-24 18:46:20 +0000
committerChris Hall <GMCH@hestia.halldom.com>2010-01-24 18:46:20 +0000
commitc21f7fd3e23791cb6ea8a3b0b968af8892c75931 (patch)
tree0a9ee21a4feecec514223bdb7656c8b6ee2a2668 /tests/bgp_mp_attr_test.c
parent0341d5ce47c301b4a4d92b77a83930da4fdc8fb3 (diff)
downloadquagga-c21f7fd3e23791cb6ea8a3b0b968af8892c75931.tar.bz2
quagga-c21f7fd3e23791cb6ea8a3b0b968af8892c75931.tar.xz
Getting BGP Engine to start and removing warnings.
Finish the wiring required to get bgp_msg_read to process OPEN messages into the connection's open_state, and be able to check for correct peer AS, etc. Removed bugs preventing messages from being written. Added BGP Id check to collision detection logic. Removed as many warnings from comilation as possible. Replaced horrible FIFO kludge in the process. (Introduced the even more horrible miyagi kludge.) modified: bgpd/bgp_advertise.c modified: bgpd/bgp_advertise.h modified: bgpd/bgp_connection.c modified: bgpd/bgp_connection.h modified: bgpd/bgp_debug.c modified: bgpd/bgp_fsm.c modified: bgpd/bgp_msg_read.c modified: bgpd/bgp_msg_write.c modified: bgpd/bgp_network.c modified: bgpd/bgp_nexthop.c modified: bgpd/bgp_notification.c modified: bgpd/bgp_open.c modified: bgpd/bgp_packet.c modified: bgpd/bgp_session.c modified: bgpd/bgp_session.h modified: bgpd/bgpd.c modified: lib/Makefile.am modified: lib/distribute.c modified: lib/if_rmap.c new file: lib/miyagi.h modified: lib/prefix.h modified: lib/sockopt.c modified: lib/stream.c modified: lib/thread.c modified: lib/vty.c modified: lib/zebra.h modified: tests/bgp_capability_test.c modified: tests/bgp_mp_attr_test.c modified: tests/ecommunity_test.c modified: tests/heavy-thread.c modified: tests/heavy-wq.c modified: tests/heavy.c modified: tests/main.c modified: tests/test-checksum.c modified: tests/test-sig.c modified: watchquagga/watchquagga.c modified: zebra/if_netlink.c modified: zebra/ioctl.c modified: zebra/rt_netlink.c modified: zebra/rtread_netlink.c
Diffstat (limited to 'tests/bgp_mp_attr_test.c')
-rw-r--r--tests/bgp_mp_attr_test.c139
1 files changed, 70 insertions, 69 deletions
diff --git a/tests/bgp_mp_attr_test.c b/tests/bgp_mp_attr_test.c
index dde0df2f..6a445acf 100644
--- a/tests/bgp_mp_attr_test.c
+++ b/tests/bgp_mp_attr_test.c
@@ -1,4 +1,5 @@
#include <zebra.h>
+#include "miyagi.h"
#include "vty.h"
#include "stream.h"
@@ -36,17 +37,17 @@ static struct test_segment {
#define SHOULD_PARSE 0
#define SHOULD_ERR -1
int parses; /* whether it should parse or not */
-
+
/* AFI/SAFI validation */
afi_t afi;
safi_t safi;
#define VALID_AFI 1
#define INVALID_AFI 0
int afi_valid;
-} mp_reach_segments [] =
+} mp_reach_segments [] =
{
{ "IPv6",
- "IPV6 MP Reach, global nexthop, 1 NLRI",
+ "IPV6 MP Reach, global nexthop, 1 NLRI",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 16,
@@ -57,12 +58,12 @@ static struct test_segment {
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 32, 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
},
- (4 + 16 + 1 + 5),
+ (4 + 16 + 1 + 5),
SHOULD_PARSE,
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-2",
- "IPV6 MP Reach, global nexthop, 2 NLRIs",
+ "IPV6 MP Reach, global nexthop, 2 NLRIs",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 16,
@@ -71,18 +72,18 @@ static struct test_segment {
0x3, 0x4, 0x5, 0x6,
0xa1, 0xa2, 0xa3, 0xa4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
0x0, 0x2, 0x0, 0x3,
},
- (4 + 16 + 1 + 5 + 9),
+ (4 + 16 + 1 + 5 + 9),
SHOULD_PARSE,
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-default",
- "IPV6 MP Reach, global nexthop, 2 NLRIs + default",
+ "IPV6 MP Reach, global nexthop, 2 NLRIs + default",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 16,
@@ -91,7 +92,7 @@ static struct test_segment {
0x3, 0x4, 0x5, 0x6,
0xa1, 0xa2, 0xa3, 0xa4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -103,7 +104,7 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-lnh",
- "IPV6 MP Reach, global+local nexthops, 2 NLRIs + default",
+ "IPV6 MP Reach, global+local nexthops, 2 NLRIs + default",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 32,
@@ -116,7 +117,7 @@ static struct test_segment {
0x2, 0x10, 0x2, 0xff,
0x1, 0x2, 0x3, 0x4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -128,7 +129,7 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-nhlen",
- "IPV6 MP Reach, inappropriate nexthop length",
+ "IPV6 MP Reach, inappropriate nexthop length",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 4,
@@ -141,7 +142,7 @@ static struct test_segment {
0x2, 0x10, 0x2, 0xff,
0x1, 0x2, 0x3, 0x4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -153,7 +154,7 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-nhlen2",
- "IPV6 MP Reach, invalid nexthop length",
+ "IPV6 MP Reach, invalid nexthop length",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 5,
@@ -166,7 +167,7 @@ static struct test_segment {
0x2, 0x10, 0x2, 0xff,
0x1, 0x2, 0x3, 0x4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -178,7 +179,7 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-nhlen3",
- "IPV6 MP Reach, nexthop length overflow",
+ "IPV6 MP Reach, nexthop length overflow",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 32,
@@ -192,7 +193,7 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-nhlen4",
- "IPV6 MP Reach, nexthop length short",
+ "IPV6 MP Reach, nexthop length short",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 16,
@@ -205,7 +206,7 @@ static struct test_segment {
0x2, 0x10, 0x2, 0xff,
0x1, 0x2, 0x3, 0x4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -217,7 +218,7 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-nlri",
- "IPV6 MP Reach, NLRI bitlen overflow",
+ "IPV6 MP Reach, NLRI bitlen overflow",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* nexthop bytes */ 32,
@@ -230,7 +231,7 @@ static struct test_segment {
0x2, 0x10, 0x2, 0xff,
0x1, 0x2, 0x3, 0x4,
/* SNPA (defunct, MBZ) */ 0x0,
- /* NLRI tuples */ 120,
+ /* NLRI tuples */ 120,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -242,11 +243,11 @@ static struct test_segment {
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4",
- "IPv4 MP Reach, 2 NLRIs + default",
+ "IPv4 MP Reach, 2 NLRIs + default",
{
/* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST,
/* nexthop bytes */ 4,
- /* Nexthop */ 192, 168, 0, 1,
+ /* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
17, 10, 2, 3, /* 10.2.3/17 */
@@ -257,11 +258,11 @@ static struct test_segment {
AFI_IP, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4-nhlen",
- "IPv4 MP Reach, nexthop lenth overflow",
+ "IPv4 MP Reach, nexthop lenth overflow",
{
/* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST,
/* nexthop bytes */ 32,
- /* Nexthop */ 192, 168, 0, 1,
+ /* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
17, 10, 2, 3, /* 10.2.3/17 */
@@ -272,14 +273,14 @@ static struct test_segment {
AFI_IP, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4-nlrilen",
- "IPv4 MP Reach, nlri lenth overflow",
+ "IPv4 MP Reach, nlri lenth overflow",
{
/* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST,
/* nexthop bytes */ 4,
- /* Nexthop */ 192, 168, 0, 1,
+ /* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
- 30, 10,
+ 30, 10,
0, /* 0/0 */
},
(4 + 4 + 1 + 3 + 2 + 1),
@@ -287,13 +288,13 @@ static struct test_segment {
AFI_IP, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4-vpnv4",
- "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRIs",
+ "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRIs",
{
/* AFI / SAFI */ 0x0, AFI_IP, BGP_SAFI_VPNV4,
/* nexthop bytes */ 12,
/* RD */ 0, 0, 1, 2,
0, 0xff, 3, 4,
- /* Nexthop */ 192, 168, 0, 1,
+ /* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
17, 10, 2, 3, /* 10.2.3/17 */
@@ -305,17 +306,17 @@ static struct test_segment {
},
/* From bug #385 */
{ "IPv6-bug",
- "IPv6, global nexthop, 1 default NLRI",
+ "IPv6, global nexthop, 1 default NLRI",
{
/* AFI / SAFI */ 0x0, 0x2, 0x1,
/* nexthop bytes */ 0x20,
- /* Nexthop (global) */ 0x20, 0x01, 0x04, 0x70,
+ /* Nexthop (global) */ 0x20, 0x01, 0x04, 0x70,
0x00, 0x01, 0x00, 0x06,
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- /* Nexthop (local) */ 0xfe, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ /* Nexthop (local) */ 0xfe, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
- 0x02, 0x0c, 0xdb, 0xff,
+ 0x02, 0x0c, 0xdb, 0xff,
0xfe, 0xfe, 0xeb, 0x00,
/* SNPA (defunct, MBZ) */ 0,
/* NLRI tuples */ /* Should have 0 here for ::/0, but dont */
@@ -324,7 +325,7 @@ static struct test_segment {
SHOULD_ERR,
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
-
+
{ NULL, NULL, {0}, 0, 0}
};
@@ -332,34 +333,34 @@ static struct test_segment {
static struct test_segment mp_unreach_segments [] =
{
{ "IPv6-unreach",
- "IPV6 MP Unreach, 1 NLRI",
+ "IPV6 MP Unreach, 1 NLRI",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
/* NLRI tuples */ 32, 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
},
- (3 + 5),
+ (3 + 5),
SHOULD_PARSE,
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-unreach2",
- "IPV6 MP Unreach, 2 NLRIs",
+ "IPV6 MP Unreach, 2 NLRIs",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
0x0, 0x2, 0x0, 0x3,
},
- (3 + 5 + 9),
+ (3 + 5 + 9),
SHOULD_PARSE,
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-unreach-default",
- "IPV6 MP Unreach, 2 NLRIs + default",
+ "IPV6 MP Unreach, 2 NLRIs + default",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
- /* NLRI tuples */ 32,
+ /* NLRI tuples */ 32,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -371,10 +372,10 @@ static struct test_segment mp_unreach_segments [] =
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv6-unreach-nlri",
- "IPV6 MP Unreach, NLRI bitlen overflow",
+ "IPV6 MP Unreach, NLRI bitlen overflow",
{
/* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
- /* NLRI tuples */ 120,
+ /* NLRI tuples */ 120,
0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */
64,
0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
@@ -386,7 +387,7 @@ static struct test_segment mp_unreach_segments [] =
AFI_IP6, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4-unreach",
- "IPv4 MP Unreach, 2 NLRIs + default",
+ "IPv4 MP Unreach, 2 NLRIs + default",
{
/* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
@@ -398,11 +399,11 @@ static struct test_segment mp_unreach_segments [] =
AFI_IP, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4-unreach-nlrilen",
- "IPv4 MP Unreach, nlri length overflow",
+ "IPv4 MP Unreach, nlri length overflow",
{
/* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
- 30, 10,
+ 30, 10,
0, /* 0/0 */
},
(3 + 3 + 2 + 1),
@@ -410,13 +411,13 @@ static struct test_segment mp_unreach_segments [] =
AFI_IP, SAFI_UNICAST, VALID_AFI,
},
{ "IPv4-unreach-vpnv4",
- "IPv4/VPNv4 MP Unreach, RD, 3 NLRIs",
+ "IPv4/VPNv4 MP Unreach, RD, 3 NLRIs",
{
/* AFI / SAFI */ 0x0, AFI_IP, BGP_SAFI_VPNV4,
/* nexthop bytes */ 12,
/* RD */ 0, 0, 1, 2,
0, 0xff, 3, 4,
- /* Nexthop */ 192, 168, 0, 1,
+ /* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 16, 10, 1, /* 10.1/16 */
17, 10, 2, 3, /* 10.2.3/17 */
@@ -439,13 +440,13 @@ parse_test (struct peer *peer, struct test_segment *t, int type)
struct attr attr;
struct bgp_nlri nlri;
#define RANDOM_FUZZ 35
-
+
stream_reset (peer->ibuf);
stream_put (peer->ibuf, NULL, RANDOM_FUZZ);
stream_set_getp (peer->ibuf, RANDOM_FUZZ);
-
+
stream_write (peer->ibuf, t->data, t->len);
-
+
printf ("%s: %s\n", t->name, t->desc);
if (type == BGP_ATTR_MP_REACH_NLRI)
@@ -456,30 +457,30 @@ parse_test (struct peer *peer, struct test_segment *t, int type)
if (!ret)
{
safi_t safi = t->safi;
-
+
if (bgp_afi_safi_valid_indices (t->afi, &safi) != t->afi_valid)
failed++;
-
+
printf ("MP: %u/%u (%u): recv %u, nego %u\n",
t->afi, t->safi, safi,
peer->afc_recv[t->afi][safi],
peer->afc_nego[t->afi][safi]);
}
-
+
printf ("parsed?: %s\n", ret ? "no" : "yes");
-
+
if (ret != t->parses)
failed++;
-
+
if (tty)
- printf ("%s", (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET
+ printf ("%s", (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET
: VT100_GREEN "OK" VT100_RESET);
else
printf ("%s", (failed > oldfailed) ? "failed!" : "OK" );
-
+
if (failed)
printf (" (%u)", failed);
-
+
printf ("\n\n");
}
@@ -491,7 +492,7 @@ main (void)
{
struct peer *peer;
int i, j;
-
+
conf_bgp_debug_fsm = -1UL;
conf_bgp_debug_events = -1UL;
conf_bgp_debug_packet = -1UL;
@@ -502,26 +503,26 @@ main (void)
term_bgp_debug_packet = -1UL;
term_bgp_debug_normal = -1UL;
term_bgp_debug_as4 = -1UL;
-
+
master = thread_master_create ();
bgp_master_init ();
-
- if (fileno (stdout) >= 0)
+
+ if (fileno (stdout) >= 0)
tty = isatty (fileno (stdout));
-
+
if (bgp_get (&bgp, &asn, NULL))
return -1;
-
+
peer = peer_create_accept (bgp);
- peer->host = "foo";
-
+ peer->host = miyagi("foo") ;
+
for (i = AFI_IP; i < AFI_MAX; i++)
for (j = SAFI_UNICAST; j < SAFI_MAX; j++)
{
peer->afc[i][j] = 1;
peer->afc_adv[i][j] = 1;
}
-
+
i = 0;
while (mp_reach_segments[i].name)
parse_test (peer, &mp_reach_segments[i++], BGP_ATTR_MP_REACH_NLRI);