Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jun 2015 15:28:21 GMT
From:      roam@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r287329 - soc2015/roam/ng_ayiya
Message-ID:  <201506191528.t5JFSLWX060864@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: roam
Date: Fri Jun 19 15:28:21 2015
New Revision: 287329
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287329

Log:
  Configure with AYIYA, send a heartbeat packet.
  
  Move the configuration after the AYIYA socket has been connected, and
  as the last part of the configuration, send an AYIYA heartbeat packet.
  
  ObQuote:	"Is there anybody out there?"

Modified:
  soc2015/roam/ng_ayiya/ng_ayiya.c
  soc2015/roam/ng_ayiya/scaffold.pl

Modified: soc2015/roam/ng_ayiya/ng_ayiya.c
==============================================================================
--- soc2015/roam/ng_ayiya/ng_ayiya.c	Fri Jun 19 15:28:18 2015	(r287328)
+++ soc2015/roam/ng_ayiya/ng_ayiya.c	Fri Jun 19 15:28:21 2015	(r287329)
@@ -123,6 +123,8 @@
 };
 typedef struct ng_ayiya_private *priv_p;
 
+static int	send_heartbeat(const node_p node);
+
 static int
 ng_ayiya_constructor(const node_p node)
 {
@@ -279,7 +281,8 @@
 			{
 			const priv_p priv = NG_NODE_PRIVATE(node);
 			if (msg->header.arglen != 0 || priv->configured ||
-			    !priv->hooks[AYIYA_HOOK_INET6])
+			    !priv->hooks[AYIYA_HOOK_INET6] ||
+			    !priv->hooks[AYIYA_HOOK_AYIYA])
 				ERROUT(EINVAL);
 			if (priv->configuring)
 				ERROUT(EINPROGRESS);
@@ -337,7 +340,13 @@
 		}
 		if_rele(ifp);
 
-		configuring_respond(node, found? 0: ENOENT);
+		if (!found) {
+			configuring_respond(node, ENOENT);
+			break;
+		}
+
+		configuring_respond(node, 0);
+		send_heartbeat(node);
 		break;
 		}
 
@@ -393,7 +402,8 @@
 	if (idx == AYIYA_HOOK_LAST)
 		panic("%s", __func__);
 	priv->hooks[idx] = NULL;
-	if (priv->configuring && idx == AYIYA_HOOK_INET6)
+	if (priv->configuring &&
+	    (idx == AYIYA_HOOK_INET6 || idx == AYIYA_HOOK_AYIYA))
 		configuring_respond(node, ECONNABORTED);
 	return (0);
 }
@@ -433,7 +443,21 @@
 {
 	struct mbuf *m = *mb;
 
-	M_PREPEND(m, sizeof(struct ng_ayiya_packet), M_NOWAIT);
+	if (m == NULL) {
+		size_t left = sizeof(struct ng_ayiya_packet);
+		m = m_getm2(NULL, left, M_NOWAIT, MT_DATA, M_PKTHDR);
+		if (m == NULL)
+			return (ENOMEM);
+		for (struct mbuf *mm = m; mm != NULL && left > 0; mm = mm->m_next)
+		{
+			const size_t len = min(M_TRAILINGSPACE(mm), left);
+			mm->m_len = len;
+			m->m_pkthdr.len += len;
+			left -= len;
+		}
+	} else {
+		M_PREPEND(m, sizeof(struct ng_ayiya_packet), M_NOWAIT);
+	}
 	if (m->m_next)
 		m = m_defrag(m, M_NOWAIT);
 	if (m == NULL)
@@ -569,6 +593,20 @@
 }
 
 static int
+send_heartbeat(const node_p node)
+{
+	const priv_p priv = NG_NODE_PRIVATE(node);
+
+	struct mbuf *m = NULL;
+	int error = ayiya_build(&m, 0, IPPROTO_NONE, priv);
+	if (error != 0)
+		return (error);
+
+	NG_SEND_DATA_ONLY(error, priv->hooks[AYIYA_HOOK_AYIYA], m);
+	return (error);
+}
+
+static int
 ng_ayiya_rcvdata(const hook_p hook, const item_p item)
 {
 	const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
@@ -581,7 +619,7 @@
 	switch (hidx) {
 		case AYIYA_HOOK_INET6:
 			{
-			if (!priv->configured || priv->hooks[AYIYA_HOOK_AYIYA] == NULL)
+			if (!priv->configured)
 			{
 				/* FIXME: enqueue the packet? */
 				m_freem(m);

Modified: soc2015/roam/ng_ayiya/scaffold.pl
==============================================================================
--- soc2015/roam/ng_ayiya/scaffold.pl	Fri Jun 19 15:28:18 2015	(r287328)
+++ soc2015/roam/ng_ayiya/scaffold.pl	Fri Jun 19 15:28:21 2015	(r287329)
@@ -420,9 +420,6 @@
 
 	run_command 'ifconfig', $iface, 'inet6', $t->ipv6_local;
 	# FIXME: Add a default route here, too.
-
-	debug "Trying to get the node to configure itself";
-	ngctl 'msg', "$c->{name}:", 'configure';
 }
 
 sub get_tic_tunnel($)
@@ -499,5 +496,7 @@
 		die "Could not query the newly-created ng_ksocket node\n";
 	}
 	ngctl 'msg', "$pname:", 'connect', 'inet/'.$t->ipv4_pop.':5072';
-	...;
+
+	debug "Trying to get the node to configure itself";
+	ngctl 'msg', "$c->{name}:", 'configure';
 }



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