netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "kalash nainwal" <kalash.nainwal@gmail.com>
To: netdev@vger.kernel.org
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: inconsistency in dev->hard_header() arguments?
Date: Thu, 26 Jul 2007 15:25:20 +0530	[thread overview]
Message-ID: <416aa1ad0707260255h650468f5m67cef596523f949e@mail.gmail.com> (raw)

The function is called like this- dev->hard_header(skb, dev, ptype,
dest_hw, src_hw, skb->len); where "skb->protocol" is same as "ptype",
but the former is expected to be in network byte order before calling
hard_header, while latter in host byte order (eth_header internally
does its own conversion of ptype). Is this deliberate? or a bug?

We've a driver, which sends pkt over ethernet. Here's the sample send routine-

my_eth_send(struct sk_buff * mp, struct net_device *dev, int linkno)
{
<snip>
        mp->protocol = link->ln_sap;
        mp->nh.raw = mp->data;
        dev->hard_header(mp, mp->dev, ntohs(link->ln_sap),
                dest_node->n_linkinfo[linkno].n_addr,
                src_node->n_linkinfo[linkno].n_addr,
                mp->len);
         dev_queue_xmit(mp);
}

We store the type field (i.e., link->ln_sap) in our driver in network
byte order only (as skb->protocol is expected to be in network byte
order), but as eth_header internally does the conversion again, we've
to un-convert it (for every outgoing pkt!!) unnecessarily. We can get
away with this by using two different variables for ptype- one in n/w
order, other in host order; but unless there's some hidden magic
behind the current behavior, I'd like to send a patch to fix this in
kernel. Or if you think it would touch too many files, might break too
many things...we can let it be.

Regards,
-Kalash

                 reply	other threads:[~2007-07-26  9:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=416aa1ad0707260255h650468f5m67cef596523f949e@mail.gmail.com \
    --to=kalash.nainwal@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).