Skip to contentSkip to conversation

rstpd: Fixed erroneous error message

PATCH In review Vitaly Demyanec 1 participant 3 messages May 25, 2009 – May 26, 2009 Ethernet bridge

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 rstpd: Fixed erroneous error message

This patch is against rstpd v.0.21 (get it here:
https://lists.linux-foundation.org/pipermail/bridge/2009-February/006178.html).

Description:
Error condition was broken. Fixed.

Signed-off-by Vitaly Demyanec <vitas at nppfactor.kiev.ua>

---

ctl_socket.c +2 -2
diff -ur a/ctl_socket.c b/ctl_socket.c
@@ -152,10 +152,10 @@
 	l = sendmsg(p->fd, &msg, MSG_NOSIGNAL);
 	if (l < 0)
 		ERROR("CTL: Couldn't send response: %m");
-	else if (l != sizeof(mhdr) + mhdr.lout) {
+	else if (l != sizeof(mhdr) + mhdr.lout + mhdr.llog) {
 		ERROR
 		    ("CTL: Couldn't send full response, sent %d bytes instead of %zd.",
-		     l, sizeof(mhdr) + mhdr.lout);
+		     l, sizeof(mhdr) + mhdr.lout + mhdr.llog);
 	}
 }
 
Signature · 2 lines
With Best Regards,
Vitaly Demyanec
#1 lore raw

PATCH 2/2 rstpd: Display port role with rstpctl

This patch is against rstpd v.0.21 (get it here:
https://lists.linux-foundation.org/pipermail/bridge/2009-February/006178.html).

Description:
Adds port role (Backup, Alternate, Root etc) to the output of "rstpctl showport" and "rstpctl showportdetail" output.

Signed-off-by Vitaly Demyanec <vitas at nppfactor.kiev.ua>

---

ctl_main.c +33 -1
diff -ur a/ctl_main.c b/ctl_main.c
@@ -173,6 +173,38 @@
 		_str;							\
 	})
 
+#define ROLE_STR(_role)			\
+	({					\
+		int _r = _role;		\
+		char *_str = "Unknown";		\
+		switch ((Role)_r)			\
+		{					     \
+		case RootPort: _str = "Root"; break; \
+		case DesignatedPort:   _str = "Designated"; break; \
+		case AlternatePort: _str = "Alternate"; break; \
+		case BackupPort: _str = "Backup"; break; \
+		case DisabledPort: _str = "Disabled"; break; \
+		default: ; \
+		}							\
+		_str;							\
+	})
+
+#define SHORT_ROLE_STR(_role)			\
+	({					\
+		int _r = _role;		\
+		char *_str = "Unkn";		\
+		switch ((Role)_r)			\
+		{					     \
+		case RootPort: _str = "Root"; break; \
+		case DesignatedPort:   _str = "Desg"; break; \
+		case AlternatePort: _str = "Altn"; break; \
+		case BackupPort: _str = "Back"; break; \
+		case DisabledPort: _str = "Disa"; break; \
+		default: ; \
+		}							\
+		_str;							\
+	})
+
 
 int detail = 0;
 
@@ -193,7 +225,7 @@
 
 	if (detail) {
 		printf("%s (%u)\n", port_name, (s.id & 0xfff));
-		printf(" enabled\t\t%4s\n", BOOL_STR(s.enabled));
+		printf(" enabled\t\t%4s\t\t\trole\t\t%15s\n", BOOL_STR(s.enabled), 

ROLE_STR(s.role_));
printf(" port id\t\t%04x\t\t\tstate\t\t%15s\n",
s.id, STATE_STR(s.state));
printf(" path cost\t%12d\t\t\tadmin path cost\t%12d\n",
@@ -213,7 +245,7 @@
printf("\t\t\tadmin point to point\t%4s\n",
ADMIN_P2P_STR(s.admin_p2p));
} else {
- printf("%c%c %4s %04x %4s " BR_ID_FMT " " BR_ID_FMT " %04x\n",
+ printf("%c%c %4s %04x %4s " BR_ID_FMT " " BR_ID_FMT " %04x %4s\n",
(s.oper_p2p) ? ' ' : '*', (s.oper_edge_port) ? 'E' : ' ', port_name,
@@ -221,7 +253,8 @@
s.enabled?SHORT_STATE_STR(s.state):"down", BR_ID_ARGS(s.designated_root), BR_ID_ARGS(s.designated_bridge),

-		       s.designated_port);
+		       s.designated_port,
+		       SHORT_ROLE_STR(s.role_));

}
return 0;
}
Only in b: ctl_main.c.orig

rstp.c +2 -13
diff -ur a/rstp.c b/rstp.c
@@ -271,19 +271,6 @@
   Disabled
 } InfoType;
 
-// We accomodate the port role encoding in BPDUs as per 9.2.9
-// into this type, defining an extra value of AltBackupPort valid
-// only in a BPDU.
-typedef enum _Role {
-  UnknownPort = 0,
-  AltBackupPort = 1,
-  RootPort = 2,
-  DesignatedPort = 3,
-  AlternatePort,
-  BackupPort,
-  DisabledPort
-} Role;
-
 typedef enum _BPDUType {
   BPDUTypeConfig = 0,
   BPDUTypeRST = 2,
@@ -2947,6 +2934,8 @@
 
   status->admin_p2p = adminPointToPointMAC;
   status->oper_p2p = operPointToPointMAC;
+
+  status->role_ = role;
 }
 
 

Only in b: rstp.c.orig

rstp.h +14 -0
diff -ur a/rstp.h b/rstp.h
@@ -149,6 +149,19 @@
 
 /****** Status ******/
 
+/* We accomodate the port role encoding in BPDUs as per 9.2.9
+  into this type, defining an extra value of AltBackupPort valid
+  only in a BPDU. */
+typedef enum _Role {
+    UnknownPort = 0,
+    AltBackupPort = 1,
+    RootPort = 2,
+    DesignatedPort = 3,
+    AlternatePort,
+    BackupPort,
+    DisabledPort
+} Role;
+
 typedef struct STP_BridgeStatus_
 {
   unsigned char bridge_id[8];
@@ -197,6 +210,7 @@
                         */
   unsigned int admin_p2p;
   unsigned int oper_p2p;
+  unsigned int role_;
 } STP_PortStatus;
 
 void STP_IN_get_port_status(STP_Port *, STP_PortStatus *);
Signature · 2 lines
With Best Regards,
Vitaly Demyanec
#2 lore raw

Re: [Bridge] [PATCH 2/2] rstpd: Display port role with rstpctl

Oh, sorry, my mailer has deformed inlined patch, so send it again, now as attachment.

BTW, what about that .depend file in repository? It is not used in Makefile, and anyway its content is out-of-date. Maybe it should be removed from repository?

Signature · 2 lines
With Best Regards,
Vitaly Demyanec
ctl_main.c +36 -3
diff -ur a/ctl_main.c b/ctl_main.c
@@ -173,6 +173,38 @@
 		_str;							\
 	})
 
+#define ROLE_STR(_role)			\
+	({					\
+		int _r = _role;		\
+		char *_str = "Unknown";		\
+		switch ((Role)_r)			\
+		{					     \
+		case RootPort: _str = "Root"; break; \
+		case DesignatedPort:   _str = "Designated"; break; \
+		case AlternatePort: _str = "Alternate"; break; \
+		case BackupPort: _str = "Backup"; break; \
+		case DisabledPort: _str = "Disabled"; break; \
+		default: ; \
+		}							\
+		_str;							\
+	})
+
+#define SHORT_ROLE_STR(_role)			\
+	({					\
+		int _r = _role;		\
+		char *_str = "Unkn";		\
+		switch ((Role)_r)			\
+		{					     \
+		case RootPort: _str = "Root"; break; \
+		case DesignatedPort:   _str = "Desg"; break; \
+		case AlternatePort: _str = "Altn"; break; \
+		case BackupPort: _str = "Back"; break; \
+		case DisabledPort: _str = "Disa"; break; \
+		default: ; \
+		}							\
+		_str;							\
+	})
+
 
 int detail = 0;
 
@@ -193,7 +225,7 @@
 
 	if (detail) {
 		printf("%s (%u)\n", port_name, (s.id & 0xfff));
-		printf(" enabled\t\t%4s\n", BOOL_STR(s.enabled));
+		printf(" enabled\t\t%4s\t\t\trole\t\t%15s\n", BOOL_STR(s.enabled), ROLE_STR(s.role_));
 		printf(" port id\t\t%04x\t\t\tstate\t\t%15s\n",
 		       s.id, STATE_STR(s.state));
 		printf(" path cost\t%12d\t\t\tadmin path cost\t%12d\n", 
@@ -213,7 +245,7 @@
 		printf("\t\t\tadmin point to point\t%4s\n",
 		       ADMIN_P2P_STR(s.admin_p2p));
 	} else {
-		printf("%c%c %4s %04x %4s " BR_ID_FMT " " BR_ID_FMT " %04x\n",
+		printf("%c%c %4s %04x %4s " BR_ID_FMT " " BR_ID_FMT " %04x %4s\n",
 		       (s.oper_p2p) ? ' ' : '*',
 		       (s.oper_edge_port) ? 'E' : ' ',
 		       port_name,
@@ -221,7 +253,8 @@
 		       s.enabled?SHORT_STATE_STR(s.state):"down",
 		       BR_ID_ARGS(s.designated_root),
 		       BR_ID_ARGS(s.designated_bridge),
-		       s.designated_port);
+		       s.designated_port,
+		       SHORT_ROLE_STR(s.role_));
 	}
 	return 0;
 }
rstp.c +2 -13
diff -ur a/rstp.c b/rstp.c
@@ -271,19 +271,6 @@
   Disabled
 } InfoType;
 
-// We accomodate the port role encoding in BPDUs as per 9.2.9
-// into this type, defining an extra value of AltBackupPort valid
-// only in a BPDU.
-typedef enum _Role {
-  UnknownPort = 0,
-  AltBackupPort = 1,
-  RootPort = 2,
-  DesignatedPort = 3,
-  AlternatePort,
-  BackupPort,
-  DisabledPort
-} Role;
-
 typedef enum _BPDUType {
   BPDUTypeConfig = 0,
   BPDUTypeRST = 2,
@@ -2947,6 +2934,8 @@
 
   status->admin_p2p = adminPointToPointMAC;
   status->oper_p2p = operPointToPointMAC;
+
+  status->role_ = role;
 }
 
 
rstp.h +14 -0
diff -ur a/rstp.h b/rstp.h
@@ -149,6 +149,19 @@
 
 /****** Status ******/
 
+/* We accomodate the port role encoding in BPDUs as per 9.2.9
+  into this type, defining an extra value of AltBackupPort valid
+  only in a BPDU. */
+typedef enum _Role {
+    UnknownPort = 0,
+    AltBackupPort = 1,
+    RootPort = 2,
+    DesignatedPort = 3,
+    AlternatePort,
+    BackupPort,
+    DisabledPort
+} Role;
+
 typedef struct STP_BridgeStatus_
 {
   unsigned char bridge_id[8];
@@ -197,6 +210,7 @@
                         */
   unsigned int admin_p2p;
   unsigned int oper_p2p;
+  unsigned int role_;
 } STP_PortStatus;
 
 void STP_IN_get_port_status(STP_Port *, STP_PortStatus *);