bridge(4) RSTP

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bridge(4) RSTP

Stuart Henderson
FreeBSD have early support for rapid STP in bridge(4):

http://lists.freebsd.org/pipermail/freebsd-current/2006-October/066535.html
http://people.freebsd.org/~thompsa/bridge_rstp.20061012.diff

I'll try and look at it sometime, but knowing how far I got last time
I tried porting any kernel code (not very...and they have made quite a
few changes to bridge(4) since importing it via NetBSD last year)
I thought it may be worth drawing attention to here in case anyone
else is interested.

Reply | Threaded
Open this post in threaded view
|

Re: bridge(4) RSTP

Pete Vickers
Hi,

A nice start could be to teach our tcpdump about RSTP. At present it  
just pukes:

20:30:14.196199 802.1d unknown protocol ver(0x2)

/Pete



On 27. okt. 2006, at 13.35, Stuart Henderson wrote:

> FreeBSD have early support for rapid STP in bridge(4):
>
> http://lists.freebsd.org/pipermail/freebsd-current/2006-October/ 
> 066535.html
> http://people.freebsd.org/~thompsa/bridge_rstp.20061012.diff
>
> I'll try and look at it sometime, but knowing how far I got last time
> I tried porting any kernel code (not very...and they have made quite a
> few changes to bridge(4) since importing it via NetBSD last year)
> I thought it may be worth drawing attention to here in case anyone
> else is interested.

Reply | Threaded
Open this post in threaded view
|

Re: bridge(4) RSTP

Stuart Henderson
On 2006/10/27 14:03, Pete Vickers wrote:
> A nice start could be to teach our tcpdump about RSTP. At present it  
> just pukes:

something like this? (coding style probably sucks, but I'm no coder :)

Index: print-stp.c
===================================================================
RCS file: /data/cvsroot/OpenBSD/src/usr.sbin/tcpdump/print-stp.c,v
retrieving revision 1.4
diff -u -r1.4 print-stp.c
--- print-stp.c 20 Dec 2004 08:30:40 -0000 1.4
+++ print-stp.c 29 Oct 2006 13:13:02 -0000
@@ -63,11 +63,22 @@
 #include "llc.h"
 
 #define STP_MSGTYPE_CBPDU 0x00
+#define STP_MSGTYPE_RBPDU 0x02 /* 802.1W RSTP */
 #define STP_MSGTYPE_TBPDU 0x80
 
 #define STP_FLAGS_TC 0x01            /* Topology change */
 #define STP_FLAGS_TCA 0x80            /* Topology change ack */
 
+#define RSTP_FLAGS_PROPOSAL 0x02
+#define RSTP_FLAGS_LEARNING 0x10
+#define RSTP_FLAGS_FORWARDING 0x20
+#define RSTP_FLAGS_AGREEMENT 0x40
+
+#define RSTP_MASK_PORTROLE 0x0C
+#define RSTP_ROLE_ALTERNATE 0x04
+#define RSTP_ROLE_ROOT 0x08
+#define RSTP_ROLE_DESIGNATED 0x0C
+
 static void stp_print_cbpdu(const u_char *, u_int, int);
 static void stp_print_tbpdu(const u_char *, u_int);
 
@@ -102,9 +113,13 @@
  printf(" unknown protocol id(0x%x)", id);
  return;
  }
- if (p[2] != 0) {
- printf(" unknown protocol ver(0x%x)", p[2]);
- return;
+ if (p[2] == 2 ) {
+ printf(" RSTP");
+ } else {
+ if (p[2] != 0) {
+ printf(" unknown protocol ver(0x%x)", p[2]);
+ return;
+ }
  }
  p += 3;
  len -= 3;
@@ -113,6 +128,7 @@
  goto truncated;
  switch (*p) {
  case STP_MSGTYPE_CBPDU:
+ case STP_MSGTYPE_RBPDU:
  stp_print_cbpdu(p, len, cisco_sstp);
  break;
  case STP_MSGTYPE_TBPDU:
@@ -154,6 +170,28 @@
  printf("%stc", (x++ != 0) ? "," : "");
  if ((*p) & STP_FLAGS_TCA)
  printf("%stcack", (x++ != 0) ? "," : "");
+ if ((*p) & RSTP_FLAGS_PROPOSAL)
+ printf("%sproposal", (x++ != 0) ? "," : "");
+ if ((*p) & RSTP_FLAGS_LEARNING)
+ printf("%slearn", (x++ != 0) ? "," : "");
+ if ((*p) & RSTP_FLAGS_FORWARDING)
+ printf("%sfwd", (x++ != 0) ? "," : "");
+ if ((*p) & RSTP_FLAGS_AGREEMENT)
+ printf("%sagree", (x++ != 0) ? "," : "");
+
+ t = ((*p) & RSTP_MASK_PORTROLE);
+
+ switch (t) {
+ case RSTP_ROLE_ALTERNATE:
+ printf("%srole=alt", (x++ != 0) ? "," : "");
+ break;
+ case RSTP_ROLE_ROOT:
+ printf("%srole=root", (x++ != 0) ? "," : "");
+ break;
+ case RSTP_ROLE_DESIGNATED:
+ printf("%srole=desig", (x++ != 0) ? "," : "");
+ break;
+ }
  putchar('>');
  }
  p += 1;

Reply | Threaded
Open this post in threaded view
|

Re: bridge(4) RSTP

Pete Vickers
Hi,

Patch applies cleanly and appears to work great:

root@tug ~> tcpdump -i bge1 stp
tcpdump: listening on bge1, link-type EN10MB
15:25:02.061139 802.1d RSTP config flags=0x3c<learn,fwd,role=desig>  
root=6011.0:18:74:61:e5:40 rootcost=0x0 bridge=6011.0:18:74:61:e5:40  
port=0x8630 age=0/0 max=20/0 hello=2/0 fwdelay=15/0

I'm not coders either so I can't review your patch's quality, but  
would be good to get it verified & in the tree.

thanks.

/Pete




On 29. okt. 2006, at 14.15, Stuart Henderson wrote:

> On 2006/10/27 14:03, Pete Vickers wrote:
>> A nice start could be to teach our tcpdump about RSTP. At present it
>> just pukes:
>
> something like this? (coding style probably sucks, but I'm no coder :)
>
> Index: print-stp.c
> ===================================================================
> RCS file: /data/cvsroot/OpenBSD/src/usr.sbin/tcpdump/print-stp.c,v
> retrieving revision 1.4
> diff -u -r1.4 print-stp.c