From: Atzm Watanabe Subject: Re: [PATCH v3 3/3] packet: Deliver VLAN TPID to userspace Date: Tue, 17 Dec 2013 14:51:38 +0900 Message-ID: <87haa86n4l.wl%atzm@stratosphere.co.jp> References: <87mwk16wpy.wl%atzm@stratosphere.co.jp> <20131216092509.1b3d76b3@nehalam.linuxnetplumber.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: netdev@vger.kernel.org, "Ben Hutchings" , "David Miller" , "Daniel Borkmann" , "David Laight" To: Stephen Hemminger Return-path: Received: from mail-yh0-f54.google.com ([209.85.213.54]:52737 "EHLO mail-yh0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878Ab3LQFvm (ORCPT ); Tue, 17 Dec 2013 00:51:42 -0500 Received: by mail-yh0-f54.google.com with SMTP id z12so4667126yhz.27 for ; Mon, 16 Dec 2013 21:51:42 -0800 (PST) In-Reply-To: <20131216092509.1b3d76b3@nehalam.linuxnetplumber.net> Sender: netdev-owner@vger.kernel.org List-ID: At Mon, 16 Dec 2013 09:25:09 -0800, Stephen Hemminger wrote: > > On Mon, 16 Dec 2013 17:12:09 +0900 > Atzm Watanabe wrote: > > > struct tpacket_hdr_variant1 { > > __u32 tp_rxhash; > > __u32 tp_vlan_tci; > > + __u32 tp_vlan_tpid; > > }; > > Is this safe? Won't you break ABI for existing userspace applications. I think we can do it safely without breaking userspace. struct tpacket_hdr_variant1 is an union member of struct tpacket3_hdr, and it is not used for any others in the kernel-userspace ABI. struct tpacket3_hdr is aligned to a multiple of 16 bytes, its size is currently 48 bytes. Against that, the size before aligning is currently 36 bytes, so there is a gap of 12 bytes that is unused. Previous patch 2/3 adds padding members for filling the gap, after the patch 1/3 which adds BUILD_BUG_ON() as sentinel for aligned size. The patch 3/3 adds tp_vlan_tpid by picking area from the padding added in the patch 2/3.