From owner-p4-projects@FreeBSD.ORG Sun Aug 16 19:46:44 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1474D106568F; Sun, 16 Aug 2009 19:46:44 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B48AC106568D for ; Sun, 16 Aug 2009 19:46:43 +0000 (UTC) (envelope-from bz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A36788FC41 for ; Sun, 16 Aug 2009 19:46:43 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7GJkhuQ012833 for ; Sun, 16 Aug 2009 19:46:43 GMT (envelope-from bz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7GJkhZJ012831 for perforce@freebsd.org; Sun, 16 Aug 2009 19:46:43 GMT (envelope-from bz@freebsd.org) Date: Sun, 16 Aug 2009 19:46:43 GMT Message-Id: <200908161946.n7GJkhZJ012831@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bz@freebsd.org using -f From: "Bjoern A. Zeeb" To: Perforce Change Reviews Cc: Subject: PERFORCE change 167414 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Aug 2009 19:46:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=167414 Change 167414 by bz@bz_zoo on 2009/08/16 19:46:39 - sort includes - make sre functions are defined before use to make the quieten compiler warnings. - save rtm_version, rtm_type and rtm_seq (direction) from the ifan to be able to send it back with the rtm. - remove a bit of dead code and polish debugging messages. Affected files ... .. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#24 edit Differences ... ==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#24 (text+ko) ==== @@ -30,28 +30,35 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." */ -#include -#include -#include +#include #include +#include #include -#include -#include + #include -#include + +#include #include -#include + #include + #include + +#include +#include +#include +#include + #include "config.h" -#include -#include #include "sendd_local.h" #include "os_specific.h" #include "snd_proto.h" #include "dbg.h" +#include +#include + static int icmp6sock = -1; static int sndsock = -1; @@ -63,6 +70,25 @@ static char abuf[INET6_ADDRSTRLEN]; #endif +/* Per-interface info */ +struct snd_ifinfo { + struct list_head list; + char name[32]; + int ifidx; + int snds; +}; +static DEFINE_LIST_HEAD(ifaces); + +/* Data packet meta data */ +struct snd_packet_info { + struct snd_ifinfo *ifinfo; + u_char rtm_version; + u_char rtm_type; + int rtm_seq; +}; + +void snd_sock_read(struct snd_ifinfo *p); + /* TODO: dynamically size according to MTU */ struct sbuff * snd_get_buf(void) @@ -77,21 +103,6 @@ return (b); } -/* Per-interface info */ -struct snd_ifinfo { - struct list_head list; - char name[32]; - int ifidx; - int snds; -}; -static DEFINE_LIST_HEAD(ifaces); - -/* Data packet meta data */ -struct snd_packet_info { - struct snd_ifinfo *ifinfo; - int in; -}; - void snd_dispatch_fds(fd_set *fds) { @@ -131,14 +142,13 @@ { struct snd_packet_info *pi; struct rt_msghdr *rtm; - struct ip6_hdr *ip6; if (drop) { snd_put_buf(b); return; } pi = (struct snd_packet_info *)(b->head); - DBG(&dbg_snd, "Direction, in = %d", pi->in); + DBG(&dbg_snd, "Direction, %s", (pi->rtm_seq == RTM_SND_OUT) ? "SND_OUT" : "SND_IN"); DBG(&dbg_snd, "rt_msghdr = %d, if_announcemsghdr = %d\n", sizeof (struct rt_msghdr), sizeof (struct if_announcemsghdr)); @@ -156,8 +166,12 @@ /* reusing RTM header received from kernel */ rtm->rtm_msglen = b->len; + rtm->rtm_version = pi->rtm_version; + rtm->rtm_type = pi->rtm_type; + rtm->rtm_index = pi->ifinfo->ifidx; + rtm->rtm_seq = pi->rtm_seq; + rtm->rtm_pid = getpid(); rtm->rtm_addrs = 0; - rtm->rtm_index = pi->ifinfo->ifidx; if (rtm->rtm_flags & M_MCAST) DBG(&dbg_snd, "M_MCAST!"); @@ -279,39 +293,33 @@ DBG(&dbg_snd, "RTM_IFANNOUNCE"); break; case RTM_SND: -#if 0 - ifan = sbuff_data(b); + ifan = (struct if_announcemsghdr *)rtm; + pi->rtm_version = ifan->ifan_version; + pi->rtm_type = ifan->ifan_type; + pi->rtm_seq = ifan->ifan_what; + switch (ifan->ifan_what) { -#endif - switch (rtm->rtm_seq) { case RTM_SND_IN: applog(LOG_ERR, "RTM_SND_IN"); /* n = RTM hdr + SEND message */ - if (sbuff_pull(b, sizeof (struct rt_msghdr)) == NULL) { -#if 0 if (sbuff_pull(b, sizeof (struct if_announcemsghdr)) == NULL) { -#endif - DBG(&dbg_snd, "invalid pkt (not enough for rtm hedaer"); goto done; + DBG(&dbg_snd, "invalid pkt (not enough for rtm hedaer"); + goto done; } pi->ifinfo = p; - pi->in = SND_IN; snd_recv_pkt(b, p->ifidx, SND_IN); break; case RTM_SND_OUT: applog(LOG_ERR, "RTM_SND_OUT"); /* n = RTM hdr + ip6_hdr + icmp6len */ - if (sbuff_pull(b, sizeof (struct rt_msghdr)) == NULL) { -#if 0 if (sbuff_pull(b, sizeof (struct if_announcemsghdr)) == NULL) { -#endif DBG(&dbg_snd, "invalid pkt (not enough for rtm header"); goto done; } pi->ifinfo = p; - pi->in = SND_OUT; snd_recv_pkt(b, p->ifidx, SND_OUT); break;