Paul Jakma | 010ebbb | 2014-09-16 11:53:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Sun Microsystems, Inc. |
| 3 | * |
| 4 | * This file is part of Quagga. |
| 5 | * |
| 6 | * Quagga is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * Quagga is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with Quagga; see the file COPYING. If not, write to the Free |
| 18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | * 02111-1307, USA. |
| 20 | */ |
| 21 | |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "vty.h" |
| 25 | #include "stream.h" |
| 26 | #include "privs.h" |
| 27 | #include "memory.h" |
Donald Sharp | 0490729 | 2016-01-07 10:03:01 -0500 | [diff] [blame] | 28 | #include "filter.h" |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 29 | |
| 30 | #include "bgpd/bgpd.h" |
| 31 | #include "bgpd/bgp_attr.h" |
| 32 | #include "bgpd/bgp_open.h" |
| 33 | #include "bgpd/bgp_debug.h" |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 34 | #include "bgpd/bgp_route.h" |
| 35 | #include "bgpd/bgp_mplsvpn.h" |
| 36 | #include "bgpd/bgp_nexthop.h" |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 37 | |
| 38 | #define VT100_RESET "\x1b[0m" |
| 39 | #define VT100_RED "\x1b[31m" |
| 40 | #define VT100_GREEN "\x1b[32m" |
| 41 | #define VT100_YELLOW "\x1b[33m" |
| 42 | |
| 43 | |
| 44 | #define CAPABILITY 0 |
| 45 | #define DYNCAP 1 |
| 46 | #define OPT_PARAM 2 |
| 47 | |
| 48 | /* need these to link in libbgp */ |
| 49 | struct zebra_privs_t *bgpd_privs = NULL; |
| 50 | struct thread_master *master = NULL; |
| 51 | |
| 52 | static int failed = 0; |
| 53 | static int tty = 0; |
| 54 | |
| 55 | /* test segments to parse and validate, and use for other tests */ |
| 56 | static struct test_segment { |
| 57 | const char *name; |
| 58 | const char *desc; |
| 59 | const u_char data[1024]; |
| 60 | int len; |
| 61 | #define SHOULD_PARSE 0 |
| 62 | #define SHOULD_ERR -1 |
| 63 | int parses; /* whether it should parse or not */ |
| 64 | |
| 65 | /* AFI/SAFI validation */ |
| 66 | afi_t afi; |
| 67 | safi_t safi; |
| 68 | #define VALID_AFI 1 |
| 69 | #define INVALID_AFI 0 |
| 70 | int afi_valid; |
| 71 | } mp_reach_segments [] = |
| 72 | { |
| 73 | { "IPv6", |
| 74 | "IPV6 MP Reach, global nexthop, 1 NLRI", |
| 75 | { |
| 76 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 77 | /* nexthop bytes */ 16, |
| 78 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, |
| 79 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 80 | 0x3, 0x4, 0x5, 0x6, |
| 81 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 82 | /* SNPA (defunct, MBZ) */ 0x0, |
| 83 | /* NLRI tuples */ 32, 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 84 | }, |
| 85 | (4 + 16 + 1 + 5), |
| 86 | SHOULD_PARSE, |
| 87 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 88 | }, |
| 89 | { "IPv6-2", |
| 90 | "IPV6 MP Reach, global nexthop, 2 NLRIs", |
| 91 | { |
| 92 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 93 | /* nexthop bytes */ 16, |
| 94 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* ffee:102:... */ |
| 95 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 96 | 0x3, 0x4, 0x5, 0x6, |
| 97 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 98 | /* SNPA (defunct, MBZ) */ 0x0, |
| 99 | /* NLRI tuples */ 32, |
| 100 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 101 | 64, |
| 102 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 103 | 0x0, 0x2, 0x0, 0x3, |
| 104 | }, |
| 105 | (4 + 16 + 1 + 5 + 9), |
| 106 | SHOULD_PARSE, |
| 107 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 108 | }, |
| 109 | { "IPv6-default", |
| 110 | "IPV6 MP Reach, global nexthop, 2 NLRIs + default", |
| 111 | { |
| 112 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 113 | /* nexthop bytes */ 16, |
| 114 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, |
| 115 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 116 | 0x3, 0x4, 0x5, 0x6, |
| 117 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 118 | /* SNPA (defunct, MBZ) */ 0x0, |
| 119 | /* NLRI tuples */ 32, |
| 120 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 121 | 64, |
| 122 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 123 | 0x0, 0x2, 0x0, 0x3, |
| 124 | 0x0, /* ::/0 */ |
| 125 | }, |
| 126 | (4 + 16 + 1 + 5 + 9 + 1), |
| 127 | SHOULD_PARSE, |
| 128 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 129 | }, |
| 130 | { "IPv6-lnh", |
| 131 | "IPV6 MP Reach, global+local nexthops, 2 NLRIs + default", |
| 132 | { |
| 133 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 134 | /* nexthop bytes */ 32, |
| 135 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ |
| 136 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 137 | 0x3, 0x4, 0x5, 0x6, |
| 138 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 139 | /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ |
| 140 | 0x0, 0x0, 0x0, 0x0, |
| 141 | 0x2, 0x10, 0x2, 0xff, |
| 142 | 0x1, 0x2, 0x3, 0x4, |
| 143 | /* SNPA (defunct, MBZ) */ 0x0, |
| 144 | /* NLRI tuples */ 32, |
| 145 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 146 | 64, |
| 147 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 148 | 0x0, 0x2, 0x0, 0x3, |
| 149 | 0x0, /* ::/0 */ |
| 150 | }, |
| 151 | (4 + 32 + 1 + 5 + 9 + 1), |
| 152 | SHOULD_PARSE, |
| 153 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 154 | }, |
| 155 | { "IPv6-nhlen", |
| 156 | "IPV6 MP Reach, inappropriate nexthop length", |
| 157 | { |
| 158 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 159 | /* nexthop bytes */ 4, |
| 160 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ |
| 161 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 162 | 0x3, 0x4, 0x5, 0x6, |
| 163 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 164 | /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ |
| 165 | 0x0, 0x0, 0x0, 0x0, |
| 166 | 0x2, 0x10, 0x2, 0xff, |
| 167 | 0x1, 0x2, 0x3, 0x4, |
| 168 | /* SNPA (defunct, MBZ) */ 0x0, |
| 169 | /* NLRI tuples */ 32, |
| 170 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 171 | 64, |
| 172 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 173 | 0x0, 0x2, 0x0, 0x3, |
| 174 | 0x0, /* ::/0 */ |
| 175 | }, |
| 176 | (4 + 32 + 1 + 5 + 9 + 1), |
| 177 | SHOULD_ERR, |
| 178 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 179 | }, |
| 180 | { "IPv6-nhlen2", |
| 181 | "IPV6 MP Reach, invalid nexthop length", |
| 182 | { |
| 183 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 184 | /* nexthop bytes */ 5, |
| 185 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ |
| 186 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 187 | 0x3, 0x4, 0x5, 0x6, |
| 188 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 189 | /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ |
| 190 | 0x0, 0x0, 0x0, 0x0, |
| 191 | 0x2, 0x10, 0x2, 0xff, |
| 192 | 0x1, 0x2, 0x3, 0x4, |
| 193 | /* SNPA (defunct, MBZ) */ 0x0, |
| 194 | /* NLRI tuples */ 32, |
| 195 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 196 | 64, |
| 197 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 198 | 0x0, 0x2, 0x0, 0x3, |
| 199 | 0x0, /* ::/0 */ |
| 200 | }, |
| 201 | (4 + 32 + 1 + 5 + 9 + 1), |
| 202 | SHOULD_ERR, |
| 203 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 204 | }, |
| 205 | { "IPv6-nhlen3", |
| 206 | "IPV6 MP Reach, nexthop length overflow", |
| 207 | { |
| 208 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 209 | /* nexthop bytes */ 32, |
| 210 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ |
| 211 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 212 | 0x3, 0x4, 0x5, 0x6, |
| 213 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 214 | }, |
| 215 | (4 + 16), |
| 216 | SHOULD_ERR, |
| 217 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 218 | }, |
| 219 | { "IPv6-nhlen4", |
| 220 | "IPV6 MP Reach, nexthop length short", |
| 221 | { |
| 222 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 223 | /* nexthop bytes */ 16, |
| 224 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ |
| 225 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 226 | 0x3, 0x4, 0x5, 0x6, |
| 227 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 228 | /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ |
| 229 | 0x0, 0x0, 0x0, 0x0, |
| 230 | 0x2, 0x10, 0x2, 0xff, |
| 231 | 0x1, 0x2, 0x3, 0x4, |
| 232 | /* SNPA (defunct, MBZ) */ 0x0, |
| 233 | /* NLRI tuples */ 32, |
| 234 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 235 | 64, |
| 236 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 237 | 0x0, 0x2, 0x0, 0x3, |
| 238 | 0x0, /* ::/0 */ |
| 239 | }, |
| 240 | (4 + 32 + 1 + 5 + 9 + 1), |
| 241 | SHOULD_ERR, |
| 242 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 243 | }, |
| 244 | { "IPv6-nlri", |
| 245 | "IPV6 MP Reach, NLRI bitlen overflow", |
| 246 | { |
| 247 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 248 | /* nexthop bytes */ 32, |
| 249 | /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ |
| 250 | 0xaa, 0xbb, 0xcc, 0xdd, |
| 251 | 0x3, 0x4, 0x5, 0x6, |
| 252 | 0xa1, 0xa2, 0xa3, 0xa4, |
| 253 | /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ |
| 254 | 0x0, 0x0, 0x0, 0x0, |
| 255 | 0x2, 0x10, 0x2, 0xff, |
| 256 | 0x1, 0x2, 0x3, 0x4, |
| 257 | /* SNPA (defunct, MBZ) */ 0x0, |
| 258 | /* NLRI tuples */ 120, |
| 259 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 260 | 64, |
| 261 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 262 | 0x0, 0x2, 0x0, 0x3, |
| 263 | 0, /* ::/0 */ |
| 264 | }, |
| 265 | (4 + 32 + 1 + 5 + 9 + 1), |
| 266 | SHOULD_ERR, |
| 267 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 268 | }, |
| 269 | { "IPv4", |
| 270 | "IPv4 MP Reach, 2 NLRIs + default", |
| 271 | { |
| 272 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, |
| 273 | /* nexthop bytes */ 4, |
| 274 | /* Nexthop */ 192, 168, 0, 1, |
| 275 | /* SNPA (defunct, MBZ) */ 0x0, |
| 276 | /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ |
| 277 | 17, 10, 2, 3, /* 10.2.3/17 */ |
| 278 | 0, /* 0/0 */ |
| 279 | }, |
| 280 | (4 + 4 + 1 + 3 + 4 + 1), |
| 281 | SHOULD_PARSE, |
| 282 | AFI_IP, SAFI_UNICAST, VALID_AFI, |
| 283 | }, |
| 284 | { "IPv4-nhlen", |
| 285 | "IPv4 MP Reach, nexthop lenth overflow", |
| 286 | { |
| 287 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, |
| 288 | /* nexthop bytes */ 32, |
| 289 | /* Nexthop */ 192, 168, 0, 1, |
| 290 | /* SNPA (defunct, MBZ) */ 0x0, |
| 291 | /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ |
| 292 | 17, 10, 2, 3, /* 10.2.3/17 */ |
| 293 | 0, /* 0/0 */ |
| 294 | }, |
| 295 | (4 + 4 + 1 + 3 + 4 + 1), |
| 296 | SHOULD_ERR, |
| 297 | AFI_IP, SAFI_UNICAST, VALID_AFI, |
| 298 | }, |
| 299 | { "IPv4-nlrilen", |
| 300 | "IPv4 MP Reach, nlri lenth overflow", |
| 301 | { |
| 302 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, |
| 303 | /* nexthop bytes */ 4, |
| 304 | /* Nexthop */ 192, 168, 0, 1, |
| 305 | /* SNPA (defunct, MBZ) */ 0x0, |
| 306 | /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ |
| 307 | 30, 10, |
| 308 | 0, /* 0/0 */ |
| 309 | }, |
| 310 | (4 + 4 + 1 + 3 + 2 + 1), |
| 311 | SHOULD_ERR, |
| 312 | AFI_IP, SAFI_UNICAST, VALID_AFI, |
| 313 | }, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 314 | { "IPv4-VPNv4", |
| 315 | "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs", |
| 316 | { |
| 317 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 318 | /* nexthop bytes */ 12, |
| 319 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 320 | 0, 0, 0, 0, |
| 321 | /* Nexthop */ 192, 168, 0, 1, |
| 322 | /* SNPA (defunct, MBZ) */ 0x0, |
| 323 | /* NLRI tuples */ 88 + 16, |
| 324 | 0, 1, 2, /* tag */ |
| 325 | /* rd, 8 octets */ |
| 326 | 0, 0, /* RD_TYPE_AS */ |
| 327 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 328 | 10, 1, /* 10.1/16 */ |
| 329 | 88 + 17, |
| 330 | 0xff, 0, 0, /* tag */ |
| 331 | /* rd, 8 octets */ |
| 332 | 0, 0, /* RD_TYPE_IP */ |
| 333 | 192, 168, 0, 1, /* IPv4 */ |
| 334 | 10, 2, 3, /* 10.2.3/17 */ |
| 335 | }, |
| 336 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), |
| 337 | SHOULD_PARSE, |
| 338 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 339 | }, |
| 340 | { "IPv4-VPNv4-bogus-plen", |
| 341 | "IPv4/MPLS-labeled VPN MP Reach, RD, Nexthop, NLRI / bogus p'len", |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 342 | { |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 343 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 344 | /* nexthop bytes */ 12, |
| 345 | /* RD */ 0, 0, 1, 2, |
| 346 | 0, 0xff, 3, 4, |
| 347 | /* Nexthop */ 192, 168, 0, 1, |
| 348 | /* SNPA (defunct, MBZ) */ 0x0, |
| 349 | /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ |
| 350 | 17, 10, 2, 3, /* 10.2.3/17 */ |
| 351 | 0, /* 0/0 */ |
| 352 | }, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 353 | (3 + 1 + 3*4 + 1 + 3 + 4 + 1), |
| 354 | SHOULD_ERR, |
| 355 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 356 | }, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 357 | { "IPv4-VPNv4-plen1-short", |
| 358 | "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, 1st plen short", |
| 359 | { |
| 360 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 361 | /* nexthop bytes */ 12, |
| 362 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 363 | 0, 0, 0, 0, |
| 364 | /* Nexthop */ 192, 168, 0, 1, |
| 365 | /* SNPA (defunct, MBZ) */ 0x0, |
| 366 | /* NLRI tuples */ 88 + 1, |
| 367 | 0, 1, 2, /* tag */ |
| 368 | /* rd, 8 octets */ |
| 369 | 0, 0, /* RD_TYPE_AS */ |
| 370 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 371 | 10, 1, /* 10.1/16 */ |
| 372 | 88 + 17, |
| 373 | 0xff, 0, 0, /* tag */ |
| 374 | /* rd, 8 octets */ |
| 375 | 0, 0, /* RD_TYPE_IP */ |
| 376 | 192, 168, 0, 1, /* IPv4 */ |
| 377 | 10, 2, 3, /* 10.2.3/17 */ |
| 378 | }, |
| 379 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), |
| 380 | SHOULD_ERR, |
| 381 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 382 | }, |
| 383 | { "IPv4-VPNv4-plen1-long", |
| 384 | "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, 1st plen long", |
| 385 | { |
| 386 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 387 | /* nexthop bytes */ 12, |
| 388 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 389 | 0, 0, 0, 0, |
| 390 | /* Nexthop */ 192, 168, 0, 1, |
| 391 | /* SNPA (defunct, MBZ) */ 0x0, |
| 392 | /* NLRI tuples */ 88 + 32, |
| 393 | 0, 1, 2, /* tag */ |
| 394 | /* rd, 8 octets */ |
| 395 | 0, 0, /* RD_TYPE_AS */ |
| 396 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 397 | 10, 1, /* 10.1/16 */ |
| 398 | 88 + 17, |
| 399 | 0xff, 0, 0, /* tag */ |
| 400 | /* rd, 8 octets */ |
| 401 | 0, 0, /* RD_TYPE_IP */ |
| 402 | 192, 168, 0, 1, /* IPv4 */ |
| 403 | 10, 2, 3, /* 10.2.3/17 */ |
| 404 | }, |
| 405 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), |
| 406 | SHOULD_ERR, |
| 407 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 408 | }, |
| 409 | { "IPv4-VPNv4-plenn-long", |
| 410 | "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRIs, last plen long", |
| 411 | { |
| 412 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 413 | /* nexthop bytes */ 12, |
| 414 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 415 | 0, 0, 0, 0, |
| 416 | /* Nexthop */ 192, 168, 0, 1, |
| 417 | /* SNPA (defunct, MBZ) */ 0x0, |
| 418 | /* NLRI tuples */ 88 + 16, |
| 419 | 0, 1, 2, /* tag */ |
| 420 | /* rd, 8 octets */ |
| 421 | 0, 0, /* RD_TYPE_AS */ |
| 422 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 423 | 10, 1, /* 10.1/16 */ |
| 424 | 88 + 17, |
| 425 | 0xff, 0, 0, /* tag */ |
| 426 | /* rd, 8 octets */ |
| 427 | 0, 0, /* RD_TYPE_IP */ |
| 428 | 192, 168, 0, 1, /* IPv4 */ |
| 429 | 10, 2, 3, /* 10.2.3/17 */ |
| 430 | 88 + 1, /* bogus */ |
| 431 | }, |
| 432 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3) + 1), |
| 433 | SHOULD_ERR, |
| 434 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 435 | }, |
| 436 | { "IPv4-VPNv4-plenn-short", |
| 437 | "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, last plen short", |
| 438 | { |
| 439 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 440 | /* nexthop bytes */ 12, |
| 441 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 442 | 0, 0, 0, 0, |
| 443 | /* Nexthop */ 192, 168, 0, 1, |
| 444 | /* SNPA (defunct, MBZ) */ 0x0, |
| 445 | /* NLRI tuples */ 88 + 16, |
| 446 | 0, 1, 2, /* tag */ |
| 447 | /* rd, 8 octets */ |
| 448 | 0, 0, /* RD_TYPE_AS */ |
| 449 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 450 | 10, 1, /* 10.1/16 */ |
| 451 | 88 + 2, |
| 452 | 0xff, 0, 0, /* tag */ |
| 453 | /* rd, 8 octets */ |
| 454 | 0, 0, /* RD_TYPE_IP */ |
| 455 | 192, 168, 0, 1, /* IPv4 */ |
| 456 | 10, 2, 3, /* 10.2.3/17 */ |
| 457 | }, |
| 458 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), |
| 459 | SHOULD_ERR, |
| 460 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 461 | }, |
| 462 | { "IPv4-VPNv4-bogus-rd-type", |
| 463 | "IPv4/VPNv4 MP Reach, RD, NH, 2 NLRI, unknown RD in 1st (log, but parse)", |
| 464 | { |
| 465 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 466 | /* nexthop bytes */ 12, |
| 467 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 468 | 0, 0, 0, 0, |
| 469 | /* Nexthop */ 192, 168, 0, 1, |
| 470 | /* SNPA (defunct, MBZ) */ 0x0, |
| 471 | /* NLRI tuples */ 88 + 16, |
| 472 | 0, 1, 2, /* tag */ |
| 473 | /* rd, 8 octets */ |
| 474 | 0xff, 0, /* Bogus RD */ |
| 475 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 476 | 10, 1, /* 10.1/16 */ |
| 477 | 88 + 17, |
| 478 | 0xff, 0, 0, /* tag */ |
| 479 | /* rd, 8 octets */ |
| 480 | 0, 0, /* RD_TYPE_IP */ |
| 481 | 192, 168, 0, 1, /* IPv4 */ |
| 482 | 10, 2, 3, /* 10.2.3/17 */ |
| 483 | }, |
| 484 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), |
| 485 | SHOULD_PARSE, |
| 486 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 487 | }, |
| 488 | { "IPv4-VPNv4-0-nlri", |
| 489 | "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRI, 3rd 0 bogus", |
| 490 | { |
| 491 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
| 492 | /* nexthop bytes */ 12, |
| 493 | /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ |
| 494 | 0, 0, 0, 0, |
| 495 | /* Nexthop */ 192, 168, 0, 1, |
| 496 | /* SNPA (defunct, MBZ) */ 0x0, |
| 497 | /* NLRI tuples */ 88 + 16, |
| 498 | 0, 1, 2, /* tag */ |
| 499 | /* rd, 8 octets */ |
| 500 | 0, 0, /* RD_TYPE_AS */ |
| 501 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 502 | 10, 1, /* 10.1/16 */ |
| 503 | 88 + 17, |
| 504 | 0xff, 0, 0, /* tag */ |
| 505 | /* rd, 8 octets */ |
| 506 | 0, 0, /* RD_TYPE_IP */ |
| 507 | 192, 168, 0, 1, /* IPv4 */ |
| 508 | 10, 2, 3, /* 10.2.3/17 */ |
| 509 | 0 /* 0/0, bogus for vpnv4 ?? */ |
| 510 | }, |
| 511 | (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3) + 1), |
| 512 | SHOULD_ERR, |
| 513 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
| 514 | }, |
| 515 | |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 516 | /* From bug #385 */ |
| 517 | { "IPv6-bug", |
| 518 | "IPv6, global nexthop, 1 default NLRI", |
| 519 | { |
| 520 | /* AFI / SAFI */ 0x0, 0x2, 0x1, |
| 521 | /* nexthop bytes */ 0x20, |
| 522 | /* Nexthop (global) */ 0x20, 0x01, 0x04, 0x70, |
| 523 | 0x00, 0x01, 0x00, 0x06, |
| 524 | 0x00, 0x00, 0x00, 0x00, |
| 525 | 0x00, 0x00, 0x00, 0x01, |
| 526 | /* Nexthop (local) */ 0xfe, 0x80, 0x00, 0x00, |
| 527 | 0x00, 0x00, 0x00, 0x00, |
| 528 | 0x02, 0x0c, 0xdb, 0xff, |
| 529 | 0xfe, 0xfe, 0xeb, 0x00, |
| 530 | /* SNPA (defunct, MBZ) */ 0, |
| 531 | /* NLRI tuples */ /* Should have 0 here for ::/0, but dont */ |
| 532 | }, |
| 533 | 37, |
| 534 | SHOULD_ERR, |
| 535 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 536 | }, |
| 537 | |
| 538 | { NULL, NULL, {0}, 0, 0} |
| 539 | }; |
| 540 | |
| 541 | /* MP_UNREACH_NLRI tests */ |
| 542 | static struct test_segment mp_unreach_segments [] = |
| 543 | { |
| 544 | { "IPv6-unreach", |
| 545 | "IPV6 MP Unreach, 1 NLRI", |
| 546 | { |
| 547 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 548 | /* NLRI tuples */ 32, 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 549 | }, |
| 550 | (3 + 5), |
| 551 | SHOULD_PARSE, |
| 552 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 553 | }, |
| 554 | { "IPv6-unreach2", |
| 555 | "IPV6 MP Unreach, 2 NLRIs", |
| 556 | { |
| 557 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 558 | /* NLRI tuples */ 32, |
| 559 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 560 | 64, |
| 561 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 562 | 0x0, 0x2, 0x0, 0x3, |
| 563 | }, |
| 564 | (3 + 5 + 9), |
| 565 | SHOULD_PARSE, |
| 566 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 567 | }, |
| 568 | { "IPv6-unreach-default", |
| 569 | "IPV6 MP Unreach, 2 NLRIs + default", |
| 570 | { |
| 571 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 572 | /* NLRI tuples */ 32, |
| 573 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 574 | 64, |
| 575 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 576 | 0x0, 0x2, 0x0, 0x3, |
| 577 | 0x0, /* ::/0 */ |
| 578 | }, |
| 579 | (3 + 5 + 9 + 1), |
| 580 | SHOULD_PARSE, |
| 581 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 582 | }, |
| 583 | { "IPv6-unreach-nlri", |
| 584 | "IPV6 MP Unreach, NLRI bitlen overflow", |
| 585 | { |
| 586 | /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, |
| 587 | /* NLRI tuples */ 120, |
| 588 | 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ |
| 589 | 64, |
| 590 | 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ |
| 591 | 0x0, 0x2, 0x0, 0x3, |
| 592 | 0, /* ::/0 */ |
| 593 | }, |
| 594 | (3 + 5 + 9 + 1), |
| 595 | SHOULD_ERR, |
| 596 | AFI_IP6, SAFI_UNICAST, VALID_AFI, |
| 597 | }, |
| 598 | { "IPv4-unreach", |
| 599 | "IPv4 MP Unreach, 2 NLRIs + default", |
| 600 | { |
| 601 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, |
| 602 | /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ |
| 603 | 17, 10, 2, 3, /* 10.2.3/17 */ |
| 604 | 0, /* 0/0 */ |
| 605 | }, |
| 606 | (3 + 3 + 4 + 1), |
| 607 | SHOULD_PARSE, |
| 608 | AFI_IP, SAFI_UNICAST, VALID_AFI, |
| 609 | }, |
| 610 | { "IPv4-unreach-nlrilen", |
| 611 | "IPv4 MP Unreach, nlri length overflow", |
| 612 | { |
| 613 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, |
| 614 | /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ |
| 615 | 30, 10, |
| 616 | 0, /* 0/0 */ |
| 617 | }, |
| 618 | (3 + 3 + 2 + 1), |
| 619 | SHOULD_ERR, |
| 620 | AFI_IP, SAFI_UNICAST, VALID_AFI, |
| 621 | }, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 622 | { "IPv4-unreach-VPNv4", |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 623 | "IPv4/MPLS-labeled VPN MP Unreach, RD, 3 NLRIs", |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 624 | { |
Denis Ovsienko | 42e6d74 | 2011-07-14 12:36:19 +0400 | [diff] [blame] | 625 | /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 626 | /* NLRI tuples */ 88 + 16, |
| 627 | 0, 1, 2, /* tag */ |
| 628 | /* rd, 8 octets */ |
| 629 | 0, 0, /* RD_TYPE_AS */ |
| 630 | 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */ |
| 631 | 10, 1, /* 10.1/16 */ |
| 632 | 88 + 17, |
| 633 | 0xff, 0, 0, /* tag */ |
| 634 | /* rd, 8 octets */ |
| 635 | 0, 0, /* RD_TYPE_IP */ |
| 636 | 192, 168, 0, 1, /* IPv4 */ |
| 637 | 10, 2, 3, /* 10.2.3/17 */ |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 638 | }, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 639 | (3 + (1+3+8+2) + (1+3+8+3)), |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 640 | SHOULD_PARSE, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 641 | AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 642 | }, |
| 643 | { NULL, NULL, {0}, 0, 0} |
| 644 | }; |
| 645 | |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 646 | /* nlri_parse indicates 0 on successful parse, and -1 otherwise. |
| 647 | * attr_parse indicates BGP_ATTR_PARSE_PROCEED/0 on success, |
| 648 | * and BGP_ATTR_PARSE_ERROR/-1 or lower negative ret on err. |
| 649 | */ |
| 650 | static void |
| 651 | handle_result (struct peer *peer, struct test_segment *t, |
| 652 | int parse_ret, int nlri_ret) |
| 653 | { |
| 654 | int oldfailed = failed; |
| 655 | |
| 656 | if (!parse_ret) |
| 657 | { |
| 658 | safi_t safi = t->safi; |
| 659 | |
| 660 | if (bgp_afi_safi_valid_indices (t->afi, &safi) != t->afi_valid) |
| 661 | failed++; |
| 662 | |
| 663 | printf ("MP: %u/%u (%u): recv %u, nego %u\n", |
| 664 | t->afi, t->safi, safi, |
| 665 | peer->afc_recv[t->afi][safi], |
| 666 | peer->afc_nego[t->afi][safi]); |
| 667 | } |
| 668 | |
| 669 | printf ("mp attr parsed?: %s\n", parse_ret ? "no" : "yes"); |
| 670 | if (!parse_ret) |
| 671 | printf ("nrli parsed?: %s\n", nlri_ret ? "no" : "yes"); |
| 672 | printf ("should parse?: %s\n", t->parses ? "no" : "yes"); |
| 673 | |
| 674 | if ((parse_ret != 0 || nlri_ret != 0) != (t->parses != 0)) |
| 675 | failed++; |
| 676 | |
| 677 | |
| 678 | if (tty) |
| 679 | printf ("%s", (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET |
| 680 | : VT100_GREEN "OK" VT100_RESET); |
| 681 | else |
| 682 | printf ("%s", (failed > oldfailed) ? "failed!" : "OK" ); |
| 683 | |
| 684 | if (failed) |
| 685 | printf (" (%u)", failed); |
| 686 | |
| 687 | printf ("\n\n"); |
| 688 | } |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 689 | |
| 690 | /* basic parsing test */ |
| 691 | static void |
| 692 | parse_test (struct peer *peer, struct test_segment *t, int type) |
| 693 | { |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 694 | int parse_ret = 0, nlri_ret = 0; |
David Lamparter | aeef13b | 2013-01-23 04:20:37 +0100 | [diff] [blame] | 695 | struct attr attr = { }; |
| 696 | struct bgp_nlri nlri = { }; |
Paul Jakma | 1dba254 | 2012-05-01 16:20:33 +0100 | [diff] [blame] | 697 | struct bgp_attr_parser_args attr_args = { |
| 698 | .peer = peer, |
| 699 | .length = t->len, |
| 700 | .total = 1, |
| 701 | .attr = &attr, |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 702 | .type = type, |
Paul Jakma | 1dba254 | 2012-05-01 16:20:33 +0100 | [diff] [blame] | 703 | .flags = BGP_ATTR_FLAG_OPTIONAL, |
| 704 | .startp = BGP_INPUT_PNT (peer), |
| 705 | }; |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 706 | #define RANDOM_FUZZ 35 |
| 707 | |
| 708 | stream_reset (peer->ibuf); |
| 709 | stream_put (peer->ibuf, NULL, RANDOM_FUZZ); |
| 710 | stream_set_getp (peer->ibuf, RANDOM_FUZZ); |
| 711 | |
| 712 | stream_write (peer->ibuf, t->data, t->len); |
| 713 | |
| 714 | printf ("%s: %s\n", t->name, t->desc); |
Paul Jakma | 1dba254 | 2012-05-01 16:20:33 +0100 | [diff] [blame] | 715 | |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 716 | if (type == BGP_ATTR_MP_REACH_NLRI) |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 717 | parse_ret = bgp_mp_reach_parse (&attr_args, &nlri); |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 718 | else |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 719 | parse_ret = bgp_mp_unreach_parse (&attr_args, &nlri); |
| 720 | |
| 721 | if (parse_ret == 0 && t->afi_valid == VALID_AFI) |
| 722 | assert (nlri.afi == t->afi && nlri.safi == t->safi); |
| 723 | |
| 724 | if (!parse_ret) |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 725 | { |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 726 | int (*f) (struct peer *, struct attr *, struct bgp_nlri *) |
| 727 | = bgp_nlri_parse; |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 728 | |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 729 | if (t->safi == SAFI_MPLS_LABELED_VPN) |
| 730 | f = bgp_nlri_parse_vpn; |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 731 | |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 732 | if (type == BGP_ATTR_MP_REACH_NLRI) |
| 733 | nlri_ret = f (peer, &attr, &nlri); |
| 734 | else |
| 735 | nlri_ret = f (peer, NULL, &nlri); |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 736 | } |
| 737 | |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 738 | handle_result (peer, t, parse_ret, nlri_ret); |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | static struct bgp *bgp; |
| 742 | static as_t asn = 100; |
| 743 | |
| 744 | int |
| 745 | main (void) |
| 746 | { |
| 747 | struct peer *peer; |
| 748 | int i, j; |
| 749 | |
| 750 | conf_bgp_debug_fsm = -1UL; |
| 751 | conf_bgp_debug_events = -1UL; |
| 752 | conf_bgp_debug_packet = -1UL; |
| 753 | conf_bgp_debug_normal = -1UL; |
| 754 | conf_bgp_debug_as4 = -1UL; |
| 755 | term_bgp_debug_fsm = -1UL; |
| 756 | term_bgp_debug_events = -1UL; |
| 757 | term_bgp_debug_packet = -1UL; |
| 758 | term_bgp_debug_normal = -1UL; |
| 759 | term_bgp_debug_as4 = -1UL; |
| 760 | |
| 761 | master = thread_master_create (); |
| 762 | bgp_master_init (); |
Paul Jakma | c9e4f86 | 2012-06-14 10:42:39 +0100 | [diff] [blame] | 763 | bgp_option_set (BGP_OPT_NO_LISTEN); |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 764 | bgp_attr_init (); |
| 765 | bgp_address_init (); |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 766 | |
| 767 | if (fileno (stdout) >= 0) |
| 768 | tty = isatty (fileno (stdout)); |
| 769 | |
| 770 | if (bgp_get (&bgp, &asn, NULL)) |
| 771 | return -1; |
| 772 | |
| 773 | peer = peer_create_accept (bgp); |
David Lamparter | c313895 | 2015-04-21 10:02:23 +0200 | [diff] [blame] | 774 | peer->host = (char *)"foo"; |
Paul Jakma | 18ab08b | 2016-01-27 16:37:33 +0000 | [diff] [blame^] | 775 | peer->status = Established; |
Paul Jakma | 1eab26b | 2008-06-07 20:44:30 +0000 | [diff] [blame] | 776 | |
| 777 | for (i = AFI_IP; i < AFI_MAX; i++) |
| 778 | for (j = SAFI_UNICAST; j < SAFI_MAX; j++) |
| 779 | { |
| 780 | peer->afc[i][j] = 1; |
| 781 | peer->afc_adv[i][j] = 1; |
| 782 | } |
| 783 | |
| 784 | i = 0; |
| 785 | while (mp_reach_segments[i].name) |
| 786 | parse_test (peer, &mp_reach_segments[i++], BGP_ATTR_MP_REACH_NLRI); |
| 787 | |
| 788 | i = 0; |
| 789 | while (mp_unreach_segments[i].name) |
| 790 | parse_test (peer, &mp_unreach_segments[i++], BGP_ATTR_MP_UNREACH_NLRI); |
| 791 | |
| 792 | printf ("failures: %d\n", failed); |
| 793 | return failed; |
| 794 | } |