From owner-svn-soc-all@freebsd.org Thu Aug 18 21:47:41 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E5ADDBBFE95 for ; Thu, 18 Aug 2016 21:47:41 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D8A241DD4 for ; Thu, 18 Aug 2016 21:47:41 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u7ILlf17019794 for ; Thu, 18 Aug 2016 21:47:41 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u7ILldTs019789 for svn-soc-all@FreeBSD.org; Thu, 18 Aug 2016 21:47:39 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Thu, 18 Aug 2016 21:47:39 GMT Message-Id: <201608182147.u7ILldTs019789@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to yuanxunzhang@FreeBSD.org using -f From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r307973 - in soc2016/yuanxunzhang/head: sys/net usr.sbin/eaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2016 21:47:42 -0000 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)