From owner-freebsd-current@FreeBSD.ORG Mon Nov 26 08:10:56 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A21A5BD3 for ; Mon, 26 Nov 2012 08:10:56 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6DCD38FC1F for ; Mon, 26 Nov 2012 08:10:56 +0000 (UTC) Received: by mail-pa0-f54.google.com with SMTP id bi5so2150373pad.13 for ; Mon, 26 Nov 2012 00:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=7JLTCB9OoQGPrgG1CWvyaL8+SrVPUBfM5Rr+i5XPnJM=; b=wSKYY+/vJAcpHhSu1zpR8/Mu2xrzs1SQCFYydno8Axzszw5x7c6TiaeilIfcxOTwSL 8EAFsmteyF1QA1PzYElNdx+myJTdZ+JF5TLbL7tn6TbZ683sZBU7/7W6IffoHJEE1DIp 2FhDnzRY3CXFIsRrSrC12h1IGxjYzaOXnl1rvcVeo1DW43X0rJ5BCLxwqLgQ2dzgvQbN h9J97MnCCanltJ4c0rFH0vDHtFSIu1U4ElfBjrfVWx25G/R36vfNeQqJUe6iwr8k1Fba kgIi5UlcvUIyMpo5ijNwnR1lCkGksGGlCEu8+pdRi3s6ZZMNvFh86XjV2Wkc234oTDrc JjkA== Received: by 10.68.136.135 with SMTP id qa7mr35074936pbb.157.1353917455102; Mon, 26 Nov 2012 00:10:55 -0800 (PST) Received: from pyunyh@gmail.com (lpe4.p59-icn.cdngp.net. [114.111.62.249]) by mx.google.com with ESMTPS id vs3sm8375285pbc.61.2012.11.26.00.10.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 00:10:53 -0800 (PST) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Mon, 26 Nov 2012 17:10:40 +0900 From: YongHyeon PYUN Date: Mon, 26 Nov 2012 17:10:40 +0900 To: Kohji Okuno Subject: Re: About 802.1Q tag Message-ID: <20121126081040.GA4076@michelle.cdnetworks.com> References: <20121126.095414.2127926346996476541.okuno.kohji@jp.panasonic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121126.095414.2127926346996476541.okuno.kohji@jp.panasonic.com> User-Agent: Mutt/1.4.2.3i Cc: freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Nov 2012 08:10:56 -0000 On Mon, Nov 26, 2012 at 09:54:14AM +0900, Kohji Okuno wrote: > Hi, > > Would someone check the following code? > > If the hardware do not process an 802.1Q tag, the kernel repacks mbuf > in line 578-580. But, `struct ether_header *eh' was assigned at line 484. > > And, in line 611-637, because of the kernel refers old eh pointer, the > kernel will misjudges its ether packet. > > I think that `eh = mtod(m, struct ether_header *);' is needed after > line 580. Yes, your analysis looks correct. > > Thanks, > Kohji Okuno > > sys/net/if_ethersubr.c: > 448 static void > 449 ether_input_internal(struct ifnet *ifp, struct mbuf *m) > 450 { > 451 struct ether_header *eh; > > 484 eh = mtod(m, struct ether_header *); > > 554 /* > 555 * If the hardware did not process an 802.1Q tag, do this now, > 556 * to allow 802.1P priority frames to be passed to the main input > 557 * path correctly. > 558 * TODO: Deal with Q-in-Q frames, but not arbitrary nesting levels. > 559 */ > 560 if ((m->m_flags & M_VLANTAG) == 0 && etype == ETHERTYPE_VLAN) { > > 578 bcopy((char *)evl, (char *)evl + ETHER_VLAN_ENCAP_LEN, > 579 ETHER_HDR_LEN - ETHER_TYPE_LEN); > 580 m_adj(m, ETHER_VLAN_ENCAP_LEN); > 581 } > > 610 > 611 #if defined(INET) || defined(INET6) > 612 /* > 613 * Clear M_PROMISC on frame so that carp(4) will see it when the > 614 * mbuf flows up to Layer 3. > 615 * FreeBSD's implementation of carp(4) uses the inprotosw > 616 * to dispatch IPPROTO_CARP. carp(4) also allocates its own > 617 * Ethernet addresses of the form 00:00:5e:00:01:xx, which > 618 * is outside the scope of the M_PROMISC test below. > 619 * TODO: Maintain a hash table of ethernet addresses other than > 620 * ether_dhost which may be active on this ifp. > 621 */ > 622 if (ifp->if_carp && (*carp_forus_p)(ifp, eh->ether_dhost)) { > 623 m->m_flags &= ~M_PROMISC; > 624 } else > 625 #endif > 626 { > 627 /* > 628 * If the frame received was not for our MAC address, set the > 629 * M_PROMISC flag on the mbuf chain. The frame may need to > 630 * be seen by the rest of the Ethernet input path in case of > 631 * re-entry (e.g. bridge, vlan, netgraph) but should not be > 632 * seen by upper protocol layers. > 633 */ > 634 if (!ETHER_IS_MULTICAST(eh->ether_dhost) && > 635 bcmp(IF_LLADDR(ifp), eh->ether_dhost, ETHER_ADDR_LEN) != 0) > 636 m->m_flags |= M_PROMISC; > 637 }