Date: Mon, 17 Oct 2005 13:01:00 +0300 From: Chris Dionissopoulos <dionch@freemail.gr> To: net@freebsd.org Subject: What's wrong with netgraph NG_FWD_NEW_DATA? Message-ID: <4353765C.4030802@freemail.gr>
next in thread | raw e-mail | index | archive | help
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- <<EOF shutdown xl0: mkpeer xl0: l2split lower downstream name xl0:lower sp0 connect xl0: sp0: upper nomatch EOF ifconfig ngeth0 down ifconfig ngeth0 link 01:02:03:04:05:00 ifconfig ngeth0 192.168.1.2/24 ifconfig ngeth0 up ngctl msg xl0: setautosrc 0 ngctl msg xl0: setpromisc 1 ngctl msg ngeth0: setautosrc 0 ngctl msg ngeth0: setpromisc 1 ngctl connect ngeth0: sp0: lower link0 ngctl msg sp0: addfilter '{ addr=01:02:03:04:05:00 hook="link0" }' gw0# ngctl list There are 8 total nodes: Name: ngctl73383 Type: socket ID: 000000fd Num hooks: 0 Name: sp0 Type: l2split ID: 000000f4 Num hooks: 3 Name: ngeth1 Type: ether ID: 000000d7 Num hooks: 0 Name: ng1 Type: eiface ID: 000000d6 Num hooks: 0 Name: ngeth0 Type: ether ID: 0000000a Num hooks: 0 Name: ng0 Type: eiface ID: 00000009 Num hooks: 1 Name: xl0 Type: ether ID: 00000001 Num hooks: 2 gw0# ngctl show sp0: Name: sp0 Type: l2split ID: 000000f4 Num hooks: 3 Local hook Peer name Peer type Peer ID Peer hook ---------- --------- --------- ------- --------- link0 ng0 eiface 00000009 ether nomatch xl0 ether 00000001 upper downstream xl0 ether 00000001 lower gw0# ngctl msg ng0: getifname Rec'd response "getifname" (1) from "[9]:": Args: "ngeth0" gw0#ifconfig ngeth0 ngeth0: flags=28943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST,PPROMISC> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4353765C.4030802>