netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: Tommy Christensen <tommy.christensen@tpack.net>
Cc: "'netdev@oss.sgi.com'" <netdev@oss.sgi.com>,
	"Linux 802.1Q VLAN" <vlan@candelatech.com>,
	Francois Romieu <romieu@fr.zoreil.com>,
	"David S. Miller" <davem@redhat.com>
Subject: Re: [PATCH]  802.1Q VLAN
Date: Mon, 01 Nov 2004 10:58:54 -0800	[thread overview]
Message-ID: <4186876E.5040204@candelatech.com> (raw)
In-Reply-To: <4182E0C6.6090205@tpack.net>


How does this look?  I think it should fix the problem with
having a new skb created in the __vlan_put_tag() method.


int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
	struct net_device_stats *stats = vlan_dev_get_stats(dev);
	struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);

	/* Please note, dev_queue_xmit consumes the pkt regardless of the
	 * return value.  So, will copy the skb first and free if successful.
	 */
	struct sk_buff* skb2 = skb_get(skb);

	/* Handle non-VLAN frames if they are sent to us, for example by DHCP.
	 *
	 * NOTE: THIS ASSUMES DIX ETHERNET, SPECIFICALLY NOT SUPPORTING
	 * OTHER THINGS LIKE FDDI/TokenRing/802.3 SNAPs...
	 */

	if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) {
		int orig_headroom = skb_headroom(skb);
		unsigned short veth_TCI;

		/* This is not a VLAN frame...but we can fix that! */
		VLAN_DEV_INFO(dev)->cnt_encap_on_xmit++;

#ifdef VLAN_DEBUG
		printk(VLAN_DBG "%s: proto to encap: 0x%hx (hbo)\n",
			__FUNCTION__, htons(veth->h_vlan_proto));
#endif
		/* Construct the second two bytes. This field looks something
		 * like:
		 * usr_priority: 3 bits	 (high bits)
		 * CFI		 1 bit
		 * VLAN ID	 12 bits (low bits)
		 */
		veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
		veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);

		skb = __vlan_put_tag(skb, veth_TCI);
		if (!skb) {
			stats->tx_dropped++;
			/* Free the extra copy, assuming this is a non-recoverable
			 * issue and we don't want calling code to retry.
			 */
			kfree_skb(skb2);
			return 0;
		}

		if (orig_headroom < VLAN_HLEN) {
			VLAN_DEV_INFO(dev)->cnt_inc_headroom_on_tx++;
		}
	}

#ifdef VLAN_DEBUG
	printk(VLAN_DBG "%s: about to send skb: %p to dev: %s\n",
		__FUNCTION__, skb, skb->dev->name);
	printk(VLAN_DBG "  %2hx.%2hx.%2hx.%2xh.%2hx.%2hx %2hx.%2hx.%2hx.%2hx.%2hx.%2hx %4hx %4hx %4hx\n",
	       veth->h_dest[0], veth->h_dest[1], veth->h_dest[2], veth->h_dest[3], veth->h_dest[4], veth->h_dest[5],
	       veth->h_source[0], veth->h_source[1], veth->h_source[2], veth->h_source[3], veth->h_source[4], veth->h_source[5],
	       veth->h_vlan_proto, veth->h_vlan_TCI, veth->h_vlan_encapsulated_proto);
#endif

	skb->dev = VLAN_DEV_INFO(dev)->real_dev;

	{
		int rv = dev_queue_xmit(skb);
		if (rv == 0) {
			/* Was success, need to free the skb reference since
			 * we bumped up the user count above.  If there was an
			 * error instead, then the skb2 will not be freed, and so
			 * the calling code will be able to re-send it.
			 */

			stats->tx_packets++; /* for statics only */
			stats->tx_bytes += skb2->len;

			kfree_skb(skb2);
		}
		return rv;
	}
}


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

  reply	other threads:[~2004-11-01 18:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-22 21:07 [PATCH] 802.1Q VLAN Ben Greear
2004-10-22 21:46 ` Francois Romieu
2004-10-22 22:09   ` Ben Greear
2004-10-23  0:24     ` Francois Romieu
2004-10-25 20:51     ` Ben Greear
2004-10-25 23:56       ` Ben Greear
2004-10-27  1:02         ` David S. Miller
2004-10-27 23:49         ` David S. Miller
2004-10-28  1:28           ` Ben Greear
2004-10-28  4:42             ` David S. Miller
2004-10-28 23:40       ` Tommy Christensen
2004-10-28 23:35         ` David S. Miller
2004-10-29  0:23         ` Ben Greear
2004-10-29  0:38           ` Krzysztof Halasa
2004-10-29  8:29           ` Tommy Christensen
2004-10-29 17:45             ` Ben Greear
2004-10-29 23:37               ` Tommy Christensen
2004-10-29 23:56                 ` Ben Greear
2004-10-30  0:05                 ` Ben Greear
2004-10-30  0:31                   ` Tommy Christensen
2004-11-01 18:58                     ` Ben Greear [this message]
2004-11-01 23:08                       ` Tommy Christensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4186876E.5040204@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=davem@redhat.com \
    --cc=netdev@oss.sgi.com \
    --cc=romieu@fr.zoreil.com \
    --cc=tommy.christensen@tpack.net \
    --cc=vlan@candelatech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).