Hello everyone!

So I’ve been working on a small patch to add support for Extended MRT Header 
for BGP messages (MRT dumps) corresponding to MRT type BGP4MP_ET (RFC6396).  
I’ve also developed the same patch for the parsing library bgpdump and the pull 
request is currently under review and should be merged in the upcoming week.

You will find at then end of this email the diff with the changes I’ve made 
(not much, this is not a big patch). I wanted to add support for the MRT types 
ISIS_ET and OSPFv3_ET however I could not find easily the corresponding dump 
processes.

Also, I wanted to get my extra brownie point by updating the ChangeLog but it 
says:

> ChangeLog information for Quagga is now recorded in our source-code
> management system. Please see:
> 
>       http://www.quagga.net/devel.php

Am I missing something or the “devel” page is not up to date?
In anyway, I’ve summed up the changes here:

 - Adding ./configure parameter --enable-et-header that will enable support for 
Extended MRT Header.
 - Adding MSG_PROTOCOL_BGP4MP_ET (value 17) as a MRT type
 - Changing the size of MRT Header to 16 if Extended MRT Header enabled
 - Changing type of MRT dump to MSG_PROTOCOL_BGP4MP_ET and dumping microseconds 
field when Extended MRT Header enabled.

I hope that this patch will match your expectations and let me know if you 
there is anything that I can improve.

Regards,

Alexis Fasquel
Software Engineer @ PCH <http://www.pch.net/>
+1-415-694-0585



diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index a3c9526..34c00b9 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -173,17 +173,25 @@ bgp_dump_interval_add (struct bgp_dump *bgp_dump, int 
interval)
 static void
 bgp_dump_header (struct stream *obuf, int type, int subtype)
 {
-  time_t now;
+  struct timeval clock;
+  long msecs;
+  time_t secs;

-  /* Set header. */
-  time (&now);
+  gettimeofday(&clock, NULL);
+
+  secs = clock.tv_sec;
+  msecs = clock.tv_usec;

   /* Put dump packet header. */
-  stream_putl (obuf, now);
+  stream_putl (obuf, secs);
   stream_putw (obuf, type);
   stream_putw (obuf, subtype);
-
   stream_putl (obuf, 0);       /* len */
+
+#ifdef HAVE_MRT_ET
+  /* Adding microseconds for the MRT Extended Header */
+  stream_putl (obuf, msecs);
+#endif
 }

 static void
@@ -474,7 +482,11 @@ bgp_dump_state (struct peer *peer, int status_old, int 
status_new)
   obuf = bgp_dump_obuf;
   stream_reset (obuf);

+#ifdef HAVE_MRT_ET
+  bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP_ET, BGP4MP_STATE_CHANGE_AS4);
+#else
   bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP, BGP4MP_STATE_CHANGE_AS4);
+#endif
   bgp_dump_common (obuf, peer, 1);/* force this in as4speak*/

   stream_putw (obuf, status_old);
@@ -505,11 +517,19 @@ bgp_dump_packet_func (struct bgp_dump *bgp_dump, struct 
peer *peer,
   /* Dump header and common part. */
   if (CHECK_FLAG (peer->cap, PEER_CAP_AS4_RCV) )
     {
+#ifdef HAVE_MRT_ET
+      bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP_ET, BGP4MP_MESSAGE_AS4);
+#else
       bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE_AS4);
+#endif
     }
   else
     {
+#ifdef HAVE_MRT_ET
+      bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP_ET, BGP4MP_MESSAGE);
+#else
       bgp_dump_header (obuf, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE);
+#endif
     }
   bgp_dump_common (obuf, peer, 0);

diff --git a/bgpd/bgp_dump.h b/bgpd/bgp_dump.h
index e097c78..96a8b26 100644
--- a/bgpd/bgp_dump.h
+++ b/bgpd/bgp_dump.h
@@ -24,6 +24,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, 
Boston, MA
 /* MRT compatible packet dump values.  */
 /* type value */
 #define MSG_PROTOCOL_BGP4MP  16
+#define MSG_PROTOCOL_BGP4MP_ET  17
+
 /* subtype value */
 #define BGP4MP_STATE_CHANGE          0
 #define BGP4MP_MESSAGE               1
@@ -32,7 +34,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, 
Boston, MA
 #define BGP4MP_MESSAGE_AS4           4
 #define BGP4MP_STATE_CHANGE_AS4      5

+#ifdef HAVE_MRT_ET // Extended Timestamp MRT Header enabled
+#define BGP_DUMP_HEADER_SIZE 16
+#else
 #define BGP_DUMP_HEADER_SIZE 12
+#endif
 #define BGP_DUMP_MSG_HEADER  40

 #define TABLE_DUMP_V2_PEER_INDEX_TABLE   1
diff --git a/configure.ac b/configure.ac
index 747a0c6..3923ef4 100755
--- a/configure.ac
+++ b/configure.ac
@@ -248,6 +248,8 @@ AC_ARG_ENABLE(pimd,
   AS_HELP_STRING([--disable-pimd], [do not build pimd]))
 AC_ARG_ENABLE(bgp-announce,
   AS_HELP_STRING([--disable-bgp-announce,], [turn off BGP route announcement]))
+AC_ARG_ENABLE(mrt-et-header,
+  AS_HELP_STRING([--enable-et-header], [turn on MRT Extended Header]))
 AC_ARG_ENABLE(snmp,
   AS_HELP_STRING([--enable-snmp=ARG], [enable SNMP support (smux or agentx)]))
 AC_ARG_WITH(libpam,
@@ -317,6 +319,10 @@ if test x"${enable_time_check}" != x"no" ; then
   fi
 fi

+if test "${enable_et_header}" = "yes"; then
+   AC_DEFINE(HAVE_MRT_ET,,MRT Extended Header support)
+fi
+
 if test "${enable_fpm}" = "yes"; then
    AC_DEFINE(HAVE_FPM,,Forwarding Plane Manager support)
 fi


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to