It's just a heuristic test to try to guess whether the NLRI information
has path IDs or not. If we run past the end of the packet data, just
stop processing before we try to fetch data past the end, don't return
an error.
This keeps us from showing truncation in non-truncated packets.
Update tests to reflect that change.
/* \summary: Border Gateway Protocol (BGP) printer */
/* \summary: Border Gateway Protocol (BGP) printer */
-/* specification: RFC 4771 */
+/* specification: RFC 4271 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
- /* check if it could be add path */
+ /*
+ * Scan through the NLRI information under the assumpetion that
+ * it doesn't have path IDs.
+ */
for (offset = 0; offset < length;) {
offset += 4;
for (offset = 0; offset < length;) {
offset += 4;
- ND_TCHECK_1(pptr + offset);
+ if (!ND_TTEST_1(pptr + offset)) {
+ /* We ran out of captured data; quit scanning. */
+ break;
+ }
prefix_length = EXTRACT_U_1(pptr + offset);
/*
* Add 4 to cover the path id
prefix_length = EXTRACT_U_1(pptr + offset);
/*
* Add 4 to cover the path id
/* check it's not standard BGP */
for (offset = 0; offset < length; ) {
/* check it's not standard BGP */
for (offset = 0; offset < length; ) {
- ND_TCHECK_1(pptr + offset);
+ if (!ND_TTEST_1(pptr + offset)) {
+ /* We ran out of captured data; quit scanning. */
+ break;
+ }
prefix_length = EXTRACT_U_1(pptr + offset);
/*
* If the prefix_length is zero (0.0.0.0/0)
prefix_length = EXTRACT_U_1(pptr + offset);
/*
* If the prefix_length is zero (0.0.0.0/0)
/* assume not add-path by default */
return 0;
/* assume not add-path by default */
return 0;
}
add_path4 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 32);
}
add_path4 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 32);
- if (add_path4 == -1)
- goto trunc;
add_path6 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 128);
add_path6 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 128);
- if (add_path6 == -1)
- goto trunc;
while (tptr < pptr + len) {
switch (af<<8 | safi) {
while (tptr < pptr + len) {
switch (af<<8 | safi) {
tptr += 3;
add_path4 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 32);
tptr += 3;
add_path4 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 32);
- if (add_path4 == -1)
- goto trunc;
add_path6 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 128);
add_path6 = check_add_path(ndo, tptr, (len-(tptr - pptr)), 128);
- if (add_path6 == -1)
- goto trunc;
while (tptr < pptr + len) {
switch (af<<8 | safi) {
while (tptr < pptr + len) {
switch (af<<8 | safi) {
goto trunc;
ND_PRINT((ndo, "\n\t Withdrawn routes:"));
add_path = check_add_path(ndo, p, withdrawn_routes_len, 32);
goto trunc;
ND_PRINT((ndo, "\n\t Withdrawn routes:"));
add_path = check_add_path(ndo, p, withdrawn_routes_len, 32);
- if (add_path == -1)
- goto trunc;
while (withdrawn_routes_len != 0) {
if (add_path) {
if (withdrawn_routes_len < 4) {
while (withdrawn_routes_len != 0) {
if (add_path) {
if (withdrawn_routes_len < 4) {
if (length) {
add_path = check_add_path(ndo, p, length, 32);
if (length) {
add_path = check_add_path(ndo, p, length, 32);
- if (add_path == -1)
- goto trunc;
ND_PRINT((ndo, "\n\t Updated routes:"));
while (length != 0) {
if (add_path) {
ND_PRINT((ndo, "\n\t Updated routes:"));
while (length != 0) {
if (add_path) {
Cluster List (10), length: 4, Flags [O]: 22.5.5.5
Multi-Protocol Reach NLRI (14), length: 30, Flags [OE]:
AFI: IPv4 (1), SAFI: labeled VPN Unicast (128)
Cluster List (10), length: 4, Flags [O]: 22.5.5.5
Multi-Protocol Reach NLRI (14), length: 30, Flags [OE]:
AFI: IPv4 (1), SAFI: labeled VPN Unicast (128)
- nexthop: RD: 0:0 (= 0.0.0.0), 12.4.4.4, nh-length: 12, no SNPA[|BGP]
+ nexthop: RD: 0:0 (= 0.0.0.0), 12.4.4.4, nh-length: 12, no SNPA
+ RD: 500:500 (= 0.0.1.244), 133.0.0.0/8, label:100208 (bottom)
Origin AS: 0
Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]:
AFI: IPv4 (1), vendor specific SAFI: Route Target Routing Information (132)
Origin AS: 0
Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]:
AFI: IPv4 (1), vendor specific SAFI: Route Target Routing Information (132)
- nexthop: invalid len, nh-length: 1, no SNPA[|BGP]
+ nexthop: invalid len, nh-length: 1, no SNPA
+ origin AS: 0, route target 0:0 (= 0.0.0.0)
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target
+ default route target[|BGP]
Next Hop (3), length: 4, Flags [T]: 0.0.0.0
Multi-Protocol Reach NLRI (14), length: 46, Flags [O]:
AFI: IPv6 (2), SAFI: Unicast (1)
Next Hop (3), length: 4, Flags [T]: 0.0.0.0
Multi-Protocol Reach NLRI (14), length: 46, Flags [O]:
AFI: IPv6 (2), SAFI: Unicast (1)
- nexthop: dead:beef::1, fe80::1ff:fe01:0, nh-length: 32, no SNPA[|BGP]
+ nexthop: dead:beef::1, fe80::1ff:fe01:0, nh-length: 32, no SNPA
+ 4:5::/64