IETF once again fucked up by creating an ivory tower spec while 
ignoring reality. In short the MRT RFC specifies an encoding that is not
even used by the example in the RFC itself. Because of this the MRT parser
code needs to detect the two different encodings. This diff tries to make
this detection better by comparing the prefix lenght byte with the expected
lenght byte for the new encoding (instead of assuming that the high byte of
all AFIs is zero (old format)).

Tested with OpenBGPD mrt dumps (new format) and RIPE dumps (quagga, old
format). I will commit this unless someone screams in the next 24h.
-- 
:wq Claudio

Index: mrtparser.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/mrtparser.c,v
retrieving revision 1.1
diff -u -p -r1.1 mrtparser.c
--- mrtparser.c 21 Sep 2011 10:37:51 -0000      1.1
+++ mrtparser.c 24 Feb 2012 07:32:27 -0000
@@ -829,10 +829,10 @@ mrt_extract_attr(struct mrt_rib_entry *r
                         * implementation. So the abbreviated MP_NLRI hack
                         * in the standard is not used in real life.
                         * Detect the two cases by looking at the first byte
-                        * and if it is 0 it is assumed to be a AFI/SAFI
-                        * encoding.
+                        * and if it is the expected size assume it to be the
+                        * RFC encoding.
                         */
-                       if (*a == 0) {
+                       if (*a != attr_len - 1) {
                                a += 3;
                                alen -= 3;
                                attr_len -= 3;

Reply via email to