socsvn commit: r307973 - in soc2016/yuanxunzhang/head: sys/net usr.sbin/eaps

yuanxunzhang at FreeBSD.org yuanxunzhang at FreeBSD.org
Thu Aug 18 21:47:42 UTC 2016


Author: yuanxunzhang
Date: Thu Aug 18 21:47:39 2016
New Revision: 307973
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307973

Log:
  EAPS: query eaps domian status

Modified:
  soc2016/yuanxunzhang/head/sys/net/eaps.c
  soc2016/yuanxunzhang/head/sys/net/eaps.h
  soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c
  soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h

Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c
==============================================================================
--- soc2016/yuanxunzhang/head/sys/net/eaps.c	Thu Aug 18 19:18:40 2016	(r307972)
+++ soc2016/yuanxunzhang/head/sys/net/eaps.c	Thu Aug 18 21:47:39 2016	(r307973)
@@ -245,7 +245,8 @@
 	struct rm_priotracker tracker;
 	EAPS_RLOCK(sc, &tracker);
 	es->state = sc->sc_eaps.state;
-	es->active = sc->sc_eaps.active;
+	es->status = sc->sc_eaps.status;
+	es->ifname = sc->sc_ifp->if_xname;
 	printf("EAPS status: interface: %s, state: %d\n.", sc->sc_ifp->if_xname, es->state);
 	EAPS_RUNLOCK(sc, &tracker);
 }
@@ -256,7 +257,7 @@
 	//set eaps domain protocol state to default value
 	EAPS_WLOCK(sc);
 	sc->sc_eaps.state = EAPS_S_IDLE;
-	sc->sc_eaps.active = EAPS_ACTIVE_DISABLE;
+	sc->sc_eaps.status = EAPS_ACTIVE_DISABLE;
 	EAPS_WUNLOCK(sc);
 }
 

Modified: soc2016/yuanxunzhang/head/sys/net/eaps.h
==============================================================================
--- soc2016/yuanxunzhang/head/sys/net/eaps.h	Thu Aug 18 19:18:40 2016	(r307972)
+++ soc2016/yuanxunzhang/head/sys/net/eaps.h	Thu Aug 18 21:47:39 2016	(r307973)
@@ -151,10 +151,10 @@
 #define	EAPS_S_INIT		0x06	/* Master node in INIT state */
 
 /*
- * EAPS ring active states
+ * EAPS ring status states (active or not active)
  */
-#define EAPS_ACTIVE_DISABLE   0x00    /* Disable the eaps domain */
-#define EAPS_ACTIVE_ENABLE    0x01    /* Enable the eaps domain */
+#define EAPS_STATUS_ACTIVE       0x00    /* Eaps is active */
+#define EAPS_STATUS_NOT_ACTIVE   0x01    /* Eaps is not active */
 
 #define	EAPS_LOCK_INIT(_sc)	rm_init(&(_sc)->sc_mtx, "eaps rmlock")
 #define	EAPS_LOCK_DESTROY(_sc)	rm_destroy(&(_sc)->sc_mtx)

Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c	Thu Aug 18 19:18:40 2016	(r307972)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c	Thu Aug 18 21:47:39 2016	(r307973)
@@ -59,6 +59,22 @@
 
 static const char eaps_ifname[] = "eaps";
 
+/* Must be same order with define */
+static const char *eaps_status_message[] = {
+	"active",		/* EAPS_STATUS_ACTIVE */
+	"not active",   /* EAPS_STATUS_NOT_ACTIVE */
+};
+
+static const char *eaps_state_message[] = {
+	"idle",      /* EAPS_S_IDLE */
+	"complete"   /* EAPS_S_COMPLETE */
+	"failed"     /* EAPS_S_FAILED */
+	"link up"    /* EAPS_S_LINKS_UP */
+	"link down"  /* EAPS_S_LINK_DOWN */
+	"preforward" /* EAPS_S_PREFORWARD */
+	"init"       /* EAPS_S_INIT */ 
+}
+
 static struct keytab {
 	const char	*kt_cp;
 	int	kt_i;
@@ -183,8 +199,14 @@
 	} 
 
 	strlcpy(es.ifname, domain_name, sizeof(es.ifname));
-	if (ioctl(s, SIOCSEAPSDOMAIN, &es) < 0)
+	if (ioctl(s, SIOCSEAPSDOMAIN, &es) == 0) {
+		printf("%s: ", domain_name);
+		printf("status: %s, ", eaps_status_message[es->status]);
+		printf("state: %s, ", eaps_state_message[es->state]);
+		putchar('\n');
+	} else {
 		err(1, "SIOCSEAPSDOMAIN");
+	}
 
 	exit(error);
 }

Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h	Thu Aug 18 19:18:40 2016	(r307972)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h	Thu Aug 18 21:47:39 2016	(r307973)
@@ -47,5 +47,21 @@
 	uint8_t         active;             /* enable or disable eaps */
 };
 
+/*
+ * EAPS ring node states
+ */
+#define	EAPS_S_IDLE		0x00	/* EAPS Domain (Master/Transit) not running */
+#define	EAPS_S_COMPLETE		0x01	/* Master node in COMPLETE state */
+#define	EAPS_S_FAILED		0x02	/* Master node in FAILED state */
+#define	EAPS_S_LINKS_UP		0x03	/* Transit UP: Pri & Sec ring ports are up */
+#define	EAPS_S_LINK_DOWN	0x04 	/* Transit DOWN: Pri and/or Sec ports down */
+#define	EAPS_S_PREFORWARD	0x05	/* Transit in PREFORWARDING State */
+#define	EAPS_S_INIT		0x06	/* Master node in INIT state */
+
+/*
+ * EAPS ring status states (active or not active)
+ */
+#define EAPS_STATUS_ACTIVE       0x00    /* Eaps is active */
+#define EAPS_STATUS_NOT_ACTIVE   0x01    /* Eaps is not active */
 
 #define	SIOCSEAPSDOMAIN		 _IOWR('i', 300, struct eaps_state)


More information about the svn-soc-all mailing list