From owner-svn-soc-all@FreeBSD.ORG Fri Jun 19 15:28:22 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A7DF2480 for ; Fri, 19 Jun 2015 15:28:22 +0000 (UTC) (envelope-from roam@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 964CDC7D for ; Fri, 19 Jun 2015 15:28:22 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5JFSMOt060868 for ; Fri, 19 Jun 2015 15:28:22 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5JFSLWX060864 for svn-soc-all@FreeBSD.org; Fri, 19 Jun 2015 15:28:21 GMT (envelope-from roam@FreeBSD.org) Date: Fri, 19 Jun 2015 15:28:21 GMT Message-Id: <201506191528.t5JFSLWX060864@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r287329 - soc2015/roam/ng_ayiya 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.20 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: Fri, 19 Jun 2015 15:28:22 -0000 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'; }