Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Aug 2016 10:17:35 GMT
From:      yuanxunzhang@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r308162 - in soc2016/yuanxunzhang/head: sys/net usr.sbin/eaps
Message-ID:  <201608221017.u7MAHZim002130@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yuanxunzhang
Date: Mon Aug 22 10:17:34 2016
New Revision: 308162
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=308162

Log:
  EAPS: set hellotime and failtime interfaces

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
  soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords

Modified: soc2016/yuanxunzhang/head/sys/net/eaps.c
==============================================================================
--- soc2016/yuanxunzhang/head/sys/net/eaps.c	Mon Aug 22 08:00:14 2016	(r308161)
+++ soc2016/yuanxunzhang/head/sys/net/eaps.c	Mon Aug 22 10:17:34 2016	(r308162)
@@ -75,6 +75,8 @@
 void eaps_status(struct eaps_softc *, struct eaps_state *);
 void set_eaps_mode(struct eaps_softc *, struct eaps_state *);
 void set_eaps_priority(struct eaps_softc *, struct eaps_state *);
+void set_eaps_hellotime(struct eaps_softc *, struct eaps_state *);
+void set_eaps_failtime(struct eaps_softc *, struct eaps_state *);
 
 static VNET_DEFINE(struct if_clone *, eaps_cloner);
 #define	V_eaps_cloner	VNET(eaps_cloner)
@@ -217,6 +219,14 @@
 	case SIOCSEAPSPRI:
 		set_eaps_priority(sc, es);
 		break;
+
+	case SIOCSEAPSHELLO:
+		set_eaps_hellotime(sc, es);
+		break;
+
+	case SIOCSEAPSFAIL:
+		set_eaps_failtime(sc, es);
+		break;
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 		break;
@@ -280,6 +290,22 @@
 	EAPS_WUNLOCK(sc);
 }
 
+void
+set_eaps_hellotime(struct eaps_softc *sc, struct eaps_state *es)
+{
+	EAPS_WLOCK(sc);
+	sc->sc_eaps.hellotime = es->hellotime;
+	EAPS_WUNLOCK(sc);
+}
+
+void
+set_eaps_failtime(struct eaps_softc *sc, struct eaps_state *es)
+{
+	EAPS_WLOCK(sc);
+	sc->sc_eaps.failtime = es->failtime;
+	EAPS_WUNLOCK(sc);
+}
+
 void 
 eaps_attach(struct eaps_softc *sc)
 {
@@ -289,6 +315,8 @@
 	sc->sc_eaps.status = EAPS_STATUS_NOT_ACTIVE;
 	sc->sc_eaps.mode = EAPS_MODE_TRANSIT;
 	sc->sc_eaps.priority = EAPS_PRIORITY_NORMAL;
+	sc->sc_eaps.hellotime = EAPS_HELLO_TIME_DEFAULT;
+	sc->sc_eaps.failtime = EAPS_FAIL_TIME_DEFAULT;
 	EAPS_WUNLOCK(sc);
 }
 

Modified: soc2016/yuanxunzhang/head/sys/net/eaps.h
==============================================================================
--- soc2016/yuanxunzhang/head/sys/net/eaps.h	Mon Aug 22 08:00:14 2016	(r308161)
+++ soc2016/yuanxunzhang/head/sys/net/eaps.h	Mon Aug 22 10:17:34 2016	(r308162)
@@ -31,15 +31,18 @@
 #ifndef _NET_EAPS_H
 #define _NET_EAPS_H
 
+
 /* 
 * eaps state information 
 */
 struct eaps_state {
-	char			ifname[IFNAMSIZ];	/* name of the eaps */
-	uint8_t			state;              /* state of eaps */
-	uint8_t         status;             /* enable or disable eaps */
-	uint8_t         mode;               /* switch mode for a node: transit or master, default transit */
-	uint8_t         priority;           /* EAPS domain priority high or normal */
+	char			ifname[IFNAMSIZ];  /* name of the eaps */
+	uint8_t			state;             /* state of eaps */
+	uint8_t         status;            /* enable or disable eaps */
+	uint8_t         mode;              /* switch mode for a node: transit or master, default transit */
+	uint8_t         priority;          /* EAPS domain priority high or normal */
+	uint16_t        hellotime;         /* hello time is set by master node for sending health check message */
+	uint16_t        failtime;          /* fail time is set by master node for waiting before the failtimer expires */
 };
 
 /*
@@ -56,6 +59,9 @@
 #define	SIOCSEAPSDOMAIN		 _IOWR('i', 300, struct eaps_state)
 #define SIOCSEAPSMODE        _IOW('i', 301, struct eaps_state)
 #define SIOCSEAPSPRI         _IOW('i', 302, struct eaps_state)
+#define SIOCSEAPSHELLO       _IOW('i', 303, struct eaps_state)
+#define SIOCSEAPSFAIL        _IOW('i', 304, struct eaps_state)
+
 /*
  * Extreme Active Protection System (EAPS) definitions.
  * Normative reference: draft-shah-extreme-rfc3619bis-02 [Expired I-D]
@@ -163,6 +169,9 @@
 #define EAPS_PRIORITY_NORMAL       0x00    /* EAPS domain priority - normal */
 #define EAPS_PRIORITY_HIGH         0x01    /* EAPS domain priority - high (default) */
 
+#define EAPS_HELLO_TIME_DEFAULT    1000    /* EAPS hello time default value 1000 milliseconds */
+#define EAPS_FAIL_TIME_DEFAULT     3000    /* EAPS fail time default value 3000 milliseconds */
+
 #define	EAPS_LOCK_INIT(_sc)	rm_init(&(_sc)->sc_mtx, "eaps rmlock")
 #define	EAPS_LOCK_DESTROY(_sc)	rm_destroy(&(_sc)->sc_mtx)
 #define	EAPS_RLOCK(_sc, _p)	rm_rlock(&(_sc)->sc_mtx, (_p))

Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c	Mon Aug 22 08:00:14 2016	(r308161)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c	Mon Aug 22 10:17:34 2016	(r308162)
@@ -99,6 +99,8 @@
 static void show_eaps_status(int, char **, int);
 static void set_eaps_mode(int, char **, int);
 static void set_eaps_priority(int, char **, int);
+static void set_eaps_hellotime(int, char **, int);
+static void set_eaps_failtime(int, char **, int);
 static void usage(const char *);
 void load_module(const char *);
 
@@ -130,6 +132,8 @@
 		case K_PRIORITY:
 			set_eaps_priority(argc, argv, s);
 			break;
+		case K_HELLOTIME:
+			set_eaps_hellotime(argc, argv, s);
 		}
 	usage(*argv);
 	return retval;
@@ -223,6 +227,8 @@
 		printf("state: %s\n", eaps_state_message[es.state]);
 		printf("\tswitch mode: %s\n", eaps_mode_message[es.mode]);
 		printf("\tpriority: %s\n", eaps_priority_message[es.priority]);
+		printf("\thellotime: %s\n", es.hellotime);
+		printf("\tfailtime: %s\n", es.failtime);
 	} else {
 		printf("Debug print: ioctl failed!\n");
 		err(1, "SIOCSEAPSDOMAIN");
@@ -299,6 +305,74 @@
 	exit(error);
 }
 
+static void 
+set_eaps_hellotime(int argc, char **argv, int s)
+{
+	int error = 0;
+
+	struct eaps_state es;
+	bzero(&es, sizeof(es));
+
+	char *domain_name = *(++argv);
+
+	// check eaps domain name
+	if (domain_name == NULL) {
+		err(1, "EAPS domain name is NULL!");
+	} 
+
+	uint16_t hellotime = atio(*(++argv));
+	printf("Debug print: set_eaps_failtime %d!\n", hellotime);
+
+	// hellotime must be greater than 0
+	if (hellotime <= 0)
+	{
+		err(1, "invalid hellotime, hellotime must be greater than 0");
+	}
+
+	es.hellotime = hellotime;
+	strlcpy(es.ifname, domain_name, sizeof(es.ifname));
+	if (ioctl(s, SIOCSEAPSHELLO, &es) != 0)
+		err(1, "SIOCSEAPSHELLO");
+	
+	exit(error);
+}
+
+static void
+set_eaps_failtime(int argc, char **argv, int s)
+{
+	int error = 0;
+
+	struct eaps_state es;
+	bzero(&es, sizeof(es));
+
+	char *domain_name = *(++argv);
+
+	// check eaps domain name
+	if (domain_name == NULL) {
+		err(1, "EAPS domain name is NULL!");
+	} 
+
+	uint16_t failtime = atio(*(++argv));
+	printf("Debug print: set_eaps_failtime %d!\n", failtime);
+
+	// get current value of hellotime, because failtime must be greater than hellotime
+	if (ioctl(s, SIOCSEAPSDOMAIN, &es) == 0) {
+		if (failtime <= es.hellotime) {
+			err(1, "invalid failtime, failtime must be greater than hellotime");
+		}
+	}else {
+		printf("Debug print: ioctl failed!\n");
+		err(1, "SIOCSEAPSDOMAIN");
+	}
+
+	es.failtime = failtime;
+	strlcpy(es.ifname, domain_name, sizeof(es.ifname));
+	if (ioctl(s, SIOCSEAPSFAIL, &es) != 0)
+		err(1, "SIOCSEAPSFAIL");
+
+	exit(error);
+}
+
 static void
 usage(const char *cp)
 {

Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h	Mon Aug 22 08:00:14 2016	(r308161)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.h	Mon Aug 22 10:17:34 2016	(r308162)
@@ -42,13 +42,14 @@
 * eaps state information 
 */
 struct eaps_state {
-	char			ifname[IFNAMSIZ];	/* name of the eaps */
-	uint8_t			state;              /* state of eaps */
-	uint8_t         status;             /* enable or disable eaps */
-	uint8_t         mode;               /* switch mode for a node: transit or master, default transit */
-	uint8_t         priority;           /* EAPS domain priority high or normal */
+	char			ifname[IFNAMSIZ];  /* name of the eaps */
+	uint8_t			state;             /* state of eaps */
+	uint8_t         status;            /* enable or disable eaps */
+	uint8_t         mode;              /* switch mode for a node: transit or master, default transit */
+	uint8_t         priority;          /* EAPS domain priority high or normal */
+	uint16_t        hellotime;         /* hello time is set by master node for sending health check message */
+	uint16_t        failtime;          /* fail time is set by master node for waiting before the failtimer expires */
 };
-
 /*
  * EAPS ring status states (active or not active)
  */
@@ -64,4 +65,6 @@
 #define	SIOCSEAPSDOMAIN		 _IOWR('i', 300, struct eaps_state)
 #define SIOCSEAPSMODE        _IOW('i', 301, struct eaps_state)
 #define SIOCSEAPSPRI         _IOW('i', 302, struct eaps_state)
+#define SIOCSEAPSHELLO       _IOW('i', 303, struct eaps_state)
+#define SIOCSEAPSFAIL        _IOW('i', 304, struct eaps_state)
  

Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords
==============================================================================
--- soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords	Mon Aug 22 08:00:14 2016	(r308161)
+++ soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords	Mon Aug 22 10:17:34 2016	(r308162)
@@ -6,4 +6,5 @@
 show
 mode
 priority
-
+hellotime
+failtime



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608221017.u7MAHZim002130>