From owner-p4-projects@FreeBSD.ORG Tue Jun 9 16:57:53 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EB1C31065672; Tue, 9 Jun 2009 16:57:52 +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 AC9841065670 for ; Tue, 9 Jun 2009 16:57:52 +0000 (UTC) (envelope-from anchie@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 99D048FC1A for ; Tue, 9 Jun 2009 16:57:52 +0000 (UTC) (envelope-from anchie@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n59Gvqo7049503 for ; Tue, 9 Jun 2009 16:57:52 GMT (envelope-from anchie@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n59GvqEY049501 for perforce@freebsd.org; Tue, 9 Jun 2009 16:57:52 GMT (envelope-from anchie@FreeBSD.org) Date: Tue, 9 Jun 2009 16:57:52 GMT Message-Id: <200906091657.n59GvqEY049501@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to anchie@FreeBSD.org using -f From: Ana Kukec To: Perforce Change Reviews Cc: Subject: PERFORCE change 163913 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: Tue, 09 Jun 2009 16:57:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=163913 Change 163913 by anchie@anchie_malimis on 2009/06/09 16:56:51 Initial code for per-interface processing of SEND messages, that used to be received through netgraph. Affected files ... .. //depot/projects/soc2009/anchie_send/send_0.2/sendd/addr.c#2 edit .. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#3 edit .. //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#2 edit .. //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#2 edit Differences ... ==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/addr.c#2 (text+ko) ==== @@ -281,9 +281,14 @@ return (0); } + /* if (os_specific_handle_iface(entry->intf_name, ifidx) < 0) { return (-1); } + */ + if (snd_handle_iface(entry->intf_name, ifidx) < 0) { + return (-1); + } intf_cfg_addr(&entry->intf_addr, ifidx); ==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#3 (text+ko) ==== @@ -69,6 +69,64 @@ return (b); } +/* Per-interface info */ +struct snd_ifinfo { + struct list_head list; + char name[32]; + int ifidx; + int icmps; +} +static DEFINE_LIST_HEAD(ifaces); + +/* Data packet meta data */ +struct input_hook_packet_info { + struct snd_ifinfo *ifinfo; + int in; + int from_kernel; +} + +int +snd_handle_iface(const char *ifname, int ifidx) +{ + struct snd_ifinfo *p; + + if ((p = malloc(sizeof (*p))) == NULL) { + APPLOG_NOMEM(); + return (-1); + } + memset(p, 0, sizeof (*p)); + + snprintf(o->name, sizeof (p->name), "%s", ifname) + p->ifidx = ifidx; + p->icmps = -1; + list_add_tail(&p->list, &ifaces); + + return (0); +} + +void +snd_add_fds(fd_set *fds, int *maxfd) +{ + struct snd_ifinfo *p; + + list_for_each_entry(p, &ifaces, list) { + *maxfd = *maxfd > p->icmps ? *maxfd : p->icmps; + FD_SET(p->icmps, fds); + } +} + +void +snd_dispatch_fds(fd_set *fds) +{ + struct snd_ifinfo *p; + + list_for_each_entry(p, &ifaces, list) { + if (FD_ISSET(p->icmps, fds)) { + /* Reuse the code from + snd_recv_pkt() and snd_icmp_sock_read() + */ + } + void snd_put_buf(struct sbuff *b) { @@ -119,7 +177,7 @@ snd_icmp_sock_read(void) { struct sockaddr_in6 sin[1]; - struct input_hook_packet_info pi; + struct input_hook_packet_info *pi; struct sbuff *b; uint8_t *type; socklen_t slen; @@ -149,7 +207,10 @@ } /* Populate input_hook_packet_info structure! */ - /* Populate ifidx and in integers. */ + /* Determine if the packet was sent to sendd by kernel or other sendd. */ + pi->from_kernel = 1; + + pi->in = 1; type = sbuff_data(b); switch (*type) { @@ -164,8 +225,7 @@ &sin->sin6_addr); break; default: - snd_recv_pkt(sbuff_data(b), ifidx, in, pi); - + DBG(&dbg_snd, "Unhandled ICMP6 type %d", *type); break; } ==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#2 (text+ko) ==== @@ -664,9 +664,6 @@ void *start; struct ip6_hdr *iph; - if (!snd_iface_ok(ifidx)) { - return; - } start = sbuff_data(b); DBG(&dbg, "%s", in ? "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" : @@ -719,11 +716,13 @@ } if (in) { + /* if (snd_is_lcl_cga(pi->cga, ifidx)) { DBG(&dbg, "is local; don't need to check"); drop = 0; goto done; } + */ if (snd_parse_opts(&pi->ndopts, sbuff_data(b), b->len) < 0) { goto drop; } @@ -733,7 +732,7 @@ /* skip all options */ sbuff_advance(b, b->len); b->len = tlen; - + /* if (!snd_is_lcl_cga(pi->cga, ifidx)) { DBG(&dbg_snd, "outgoing: not CGA, dropping"); if (dad && IN6_IS_ADDR_LINKLOCAL(pi->cga)) { @@ -742,6 +741,7 @@ } goto drop; } + */ r = handle_outgoing(pi); } @@ -763,7 +763,8 @@ drop = 1; done: b->data = start; - os_specific_deliver_pkt(pkt, b, drop, changed); + /* ToDo: The packet is here sent through netgraph. Change this! */ + /* os_specific_deliver_pkt(pkt, b, drop, changed); */ } int ==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/sendd.c#2 (text+ko) ==== @@ -92,7 +92,8 @@ if (cfd != -1) FD_SET(cfd, fds); FD_SET(icmps, fds); FD_SET(ctlfd, fds); - os_specific_add_fds(fds, &maxfd); + /* os_specific_add_fds(fds, &maxfd); */ + snd_add_fds(fds, &maxfd); tv = get_next_wait(tvb); if (select(maxfd + 1, fds, NULL, NULL, tv) < 0) { @@ -113,13 +114,14 @@ #endif /* USE_READLINE */ } #endif /* USE_CONSOLE */ - if (FD_ISSET(icmps, fds)) { + if (FD_ISSET(icmps, fds) { snd_icmp_sock_read(); } if (FD_ISSET(ctlfd, fds)) { snd_ctl_read(ctlfd); } - os_specific_dispatch_fds(fds); + snd_dispatch_fds(fds); + /* os_specific_dispatch_fds(fds); */ snd_replace_non_cga_linklocals(); } }