From owner-freebsd-net@FreeBSD.ORG Mon Oct 17 10:02:08 2005 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 042F416A41F for ; Mon, 17 Oct 2005 10:02:08 +0000 (GMT) (envelope-from dionch@freemail.gr) Received: from smtp.freemail.gr (smtp.freemail.gr [213.239.180.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7175443D48 for ; Mon, 17 Oct 2005 10:02:07 +0000 (GMT) (envelope-from dionch@freemail.gr) Received: by smtp.freemail.gr (Postfix, from userid 101) id 7AED6BC037; Mon, 17 Oct 2005 13:02:05 +0300 (EEST) Received: from [10.0.0.1] (vdp1003.ath03.dsl.hol.gr [62.38.168.4])by smtp.freemail.gr (Postfix) with ESMTP id 6F280BC020for ; Mon, 17 Oct 2005 13:02:04 +0300 (EEST) Message-ID: <4353765C.4030802@freemail.gr> Date: Mon, 17 Oct 2005 13:01:00 +0300 From: Chris Dionissopoulos User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: What's wrong with netgraph NG_FWD_NEW_DATA? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dionch@freemail.gr List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Oct 2005 10:02:08 -0000 Hi ppl, Trying to split inbound traffic based on layer2 characteristics, i have create a new netgraph module(ng_l2split) using ng_vlan(4) as reference. The design and implementation is pretty simple as ng_vlan : xl0:upper | +---------+ | ng_l2split|-----ng0 (ng_eiface on ngeth0) +---------+ ( --- ng1,2,....) | xl0:lower ng_l2plit has 2 basic hooks as descriped in ng_vlan(4) man page: - downstream hook (attached to physical's "lower" ) - nomatch hook (attached to physical's "upper" ) and for every ng_eiface node you attach you must provide a mac address for filtering (later this will be automated). i.e. #!/bin/sh ngctl -f- < mtu 1500 inet6 fe80::260:8ff:fee8:589e%ngeth0 prefixlen 64 scopeid 0x6 inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255 ether 01:02:03:04:05:00 Traffic initiated localy flows prefectly through ngeth0 and xl0 interfaces, but this is not happen for traffic that comes from outside. It seems that doesn't arrive to ngeth0 upper level protocols. Long story short: o physical interface works fine. o app:stack-->ngeth0--->ng0---->xl0:low--->wire [WORKS] o wire --->xl0:low--->ng0--->ngeth0--->stack:app [FAILED] [works] [failed to reply] Here is my rcvdata function : -------ng_l2split.c part----------- static int ng_l2split_rcvdata(hook_p hook, item_p item) { const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct ether_header *eh; struct ether_addr eaddr; int error; struct mbuf *m; struct filter *f; /* Make sure we have an entire header. */ NGI_GET_M(item, m); if (m->m_len < sizeof(*eh) && (m = m_pullup(m, sizeof(*eh))) == NULL) { NG_FREE_ITEM(item); return (EINVAL); } eh = mtod(m, struct ether_header *); if (hook == priv->downstream_hook) { /* * If from downstream, select between a match hook * or the nomatch hook. */ bcopy(eh->ether_dhost,eaddr.octet, sizeof(eh->ether_dhost)); if ((f = ng_l2split_findentry(priv, &eaddr)) != NULL) { NG_FWD_NEW_DATA(error, item, f->hook, m); printf("send"); } else NG_FWD_NEW_DATA(error, item, priv->nomatch_hook, m); } else NG_FWD_NEW_DATA(error, item, priv->downstream_hook, m); return (error); } ------------------------------------ Any idea what i'm doing wrong? Is NG_FWD_NEW_DATA improperly used? TIA, Chris. p.s. I'm using FreeBSD6-beta5 (Sept-30) ____________________________________________________________________ http://www.freemail.gr - δωρεάν υπηρεσία ηλεκτρονικού ταχυδρομείου. http://www.freemail.gr - free email service for the Greek-speaking.