Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 May 2011 08:43:59 +0000 (UTC)
From:      Marko Zec <zec@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r222347 - stable/8/sys/netgraph
Message-ID:  <201105270843.p4R8hxUY009021@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zec
Date: Fri May 27 08:43:59 2011
New Revision: 222347
URL: http://svn.freebsd.org/changeset/base/222347

Log:
  MFC r222257:
    Assume the link to be dead if bit error rate (BER) parameter is set to 1.
    When a transition from link alive to link dead configuration or vice
    versa occurs, notify any upstream and / or downstream peers using
    NGM_FLOW messagges.
  
    Link state notification using NGM_FLOW messages is modelled around
    around already existing code in ng_ether.c.

Modified:
  stable/8/sys/netgraph/ng_pipe.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/netgraph/ng_pipe.c
==============================================================================
--- stable/8/sys/netgraph/ng_pipe.c	Fri May 27 08:43:03 2011	(r222346)
+++ stable/8/sys/netgraph/ng_pipe.c	Fri May 27 08:43:59 2011	(r222347)
@@ -300,11 +300,12 @@ ngp_rcvmsg(node_p node, item_p item, hoo
 {
 	const priv_p priv = NG_NODE_PRIVATE(node);
 	struct ng_mesg *resp = NULL;
-	struct ng_mesg *msg;
+	struct ng_mesg *msg, *flow_msg;
 	struct ng_pipe_stats *stats;
 	struct ng_pipe_run *run;
 	struct ng_pipe_cfg *cfg;
 	int error = 0;
+	int prev_down, now_down, cmd;
 
 	NGI_GET_MSG(item, msg);
 	switch (msg->header.typecookie) {
@@ -405,10 +406,38 @@ ngp_rcvmsg(node_p node, item_p item, hoo
 			    cfg->header_offset < 64)
 				priv->header_offset = cfg->header_offset;
 
+			prev_down = priv->upper.cfg.ber == 1 ||
+			    priv->lower.cfg.ber == 1;
 			parse_cfg(&priv->upper.cfg, &cfg->downstream,
 			    &priv->upper, priv);
 			parse_cfg(&priv->lower.cfg, &cfg->upstream,
 			    &priv->lower, priv);
+			now_down = priv->upper.cfg.ber == 1 ||
+			    priv->lower.cfg.ber == 1;
+
+			if (prev_down != now_down) {
+				if (now_down)
+					cmd = NGM_LINK_IS_DOWN;
+				else
+					cmd = NGM_LINK_IS_UP;
+
+				if (priv->lower.hook != NULL) {
+					NG_MKMESSAGE(flow_msg, NGM_FLOW_COOKIE,
+					    cmd, 0, M_NOWAIT);
+					if (flow_msg != NULL)
+						NG_SEND_MSG_HOOK(error, node,
+						    flow_msg, priv->lower.hook,
+						    0);
+				}
+				if (priv->upper.hook != NULL) {
+					NG_MKMESSAGE(flow_msg, NGM_FLOW_COOKIE,
+					    cmd, 0, M_NOWAIT);
+					if (flow_msg != NULL)
+						NG_SEND_MSG_HOOK(error, node,
+						    flow_msg, priv->upper.hook,
+						    0);
+				}
+			}
 			break;
 		default:
 			error = EINVAL;



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