svn commit: r222257 - head/sys/netgraph
Marko Zec
zec at FreeBSD.org
Tue May 24 14:36:33 UTC 2011
Author: zec
Date: Tue May 24 14:36:32 2011
New Revision: 222257
URL: http://svn.freebsd.org/changeset/base/222257
Log:
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.
MFC after: 3 days
Modified:
head/sys/netgraph/ng_pipe.c
Modified: head/sys/netgraph/ng_pipe.c
==============================================================================
--- head/sys/netgraph/ng_pipe.c Tue May 24 14:12:31 2011 (r222256)
+++ head/sys/netgraph/ng_pipe.c Tue May 24 14:36:32 2011 (r222257)
@@ -298,11 +298,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) {
@@ -403,10 +404,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;
More information about the svn-src-head
mailing list